Kubernetes GCP commands

  • Set your project: gcloud config set project my-project.
  • gcloud container clusters list
  • To configure kubectl for your cluster: gcloud container clusters get-credentials cluster-1.
  • Deploy and run an app: kubectl run hello-server --image gcr.io/google-samples/hello-app:1.0 --port 8080. To undo the run command: kubectl delete deployment hello-server.
  • Scaling your deployment: kubectl scale deployment --replicas=2 hello-server.
  • Create a service to make your app accessible to the world: kubectl expose deployment hello-server --type LoadBalancer --port 80 --target-port 8080.
  • To update an deployment with a new image version: kubectl set image deployment/hello-server hello-server=gcr.io/google-samples/hello-app:1.1.
  • To get the LB's external IP: kubectl get service hello-server.
  • To list all services running: kubectl get services.
  • Clean up: kubectl delete service hello-server and gcloud container clusters delete cluster-1.
  • To resize the cluster itself: gcloud container clusters resize --node-pool=default-pool --num-nodes=4 cluster-1.

Source: https://cloud.google.com/kubernetes-engine/docs/quickstart


  • To SSH login to a POD: kubectl exec -it <pod-name> -- /bin/bash.

Connecting to the API

  • Getting the master node information: kubectl cluster-info.
  • Create a reverse proxy: kubectl proxy --port=8080 &. Access the API.
Posted on May 21, 2020 11:03 AM by Subhash Chandran
cloud kubernetes gcp k8s docker