Listing available pods
To view the contents of a pod
Info |
---|
|
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 |
---|
|
export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
echo $POD_NAME
curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy/ |
Info |
---|
title | Windows shell command |
---|
|
export $Env:POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.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 |
---|
|
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 |
---|
|
kubectl exec $POD_NAME env |
Listing PODs within a deployment
Info |
---|
|
kubectl get pods -l app=nginx --show-labels |
Error message indicating missing config file when running kubectl
You might see the following message
# kubectl version
W0404 15:19:07.071657 17635 loader.go:223] Config not found: /root/.kube/config
error: Missing or incomplete configuration info. Please point to an existing, complete config file:
1. Via the command-line flag --kubeconfig
2. Via the KUBECONFIG environment variable
3. In your home directory as ~/.kube/config
To view or setup config directly use the 'config' command.
Simply run kubectl --client=true once only and the problem should be fixed