Authenticate with cluster if using gcloud CLI,
gcloud container clusters get-credentials CLUSTER_NAME --region=COMPUTE_REGION
Run again with different value to set a new default cluster
List pods in cluster,
kubectl get pods
Search for a specific pod with grep,
kubectl get pods | grep POD
List public IPs, and URLs,
kubectl get ingress
Copy to pod,
kubectl cp /path/to/file POD:/path/to/destination
Copying from pod is same command in reverse,
kubectl cp POD:/path/to/file /path/to/destination
Copy with only partial match on pod name,
kubectl cp /path/to/file $(kubectl get pods | grep POD | awk '{print $1}'):/path/to/destination
Useful for cases where pods are regularly destroyed and re-deployed with extrenuous names.
i.e.
mypod-prod-1987y671-2io87
Would just have to remember mypod-prod
.
Connect to pods,
kubectl exec -it POD -- /bin/bash
Can also match with partials like cp command,
kubectl exec -it $(kubectl get pods | grep POD | awk '{print $1}') -- /bin/bash