Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Listing available pods

Info
titleshell command
kubectl get pods

To view the contents of a pod

Info
titleshell command
kubectl describe pods
This command will display what containers are in a pod and what image was used to create the container


Retrieve a POD name

Info
titleLinux shell command
export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')

echo $POD_NAME
curl 

curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy/


Info
titleWindows shell command
export
$Env:POD_NAME=$(kubectl get pods -o go-template --template '{{range .
items
item}}{{.metadata.name
}}{{"\n"
}}{{end}}')

echo $Env:POD_NAME

curl http://localhost:8001/api/v1/namespaces/default/pods/$Env:POD_NAME/proxy/


Viewing container logs

Info
titleshell command

kubectl logs $POD_NAME

Anything that the application would normally send to STDOUT becomes logs for the container within the Pod. We can retrieve these logs using the kubectl logs command:


Executing  command on the container

Info
titleshell command

kubectl exec $POD_NAME env