Kubernetes Deep Dive

Sign Up Free or Log In to participate!

How did you access a pod using the kubectl exec command without ‘Authenticating’ to the pod?

@3:52.. How did you access a pod using the kubectl exec command without ‘Authenticating’ to the pod? Sorry for this Dumb question but absolute beginner here.

rajramo

When you use kops, kubemini or any other utility to create the kubernetes cluster, it creates and downloads the whole config along with token for communication to kubernetes API server. kubectl taks to API server and API server talks to the rest of system within the cluster. Once you delete the cluster, your token is also vanished. You can find the cluster context details directory ~/.kube/config

2 Answers

When you use kops, kubemini or any other utility to create the kubernetes cluster, it creates and downloads the whole config along with token for communication to kubernetes API server. kubectl taks to API server and API server talks to the rest of system within the cluster. Once you delete the cluster, your token is also vanished. You can find the cluster context details directory ~/.kube/config

kubectl exec -ti $POD_NAME bash         

You can extract your pod name via environment variables such this 

export POD_NAME=$(kubectl get pods -o go-template –template ‘{{range .items}}{{.metadata.name}}{{"n"}}{{end}}’)

echo Name of the Pod: $POD_NAME

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?