Select Page

These are just my quick notes for my everyday job…

install kube control:

  • install gcloud
  • gcloud components install kubectl

get config from existing cluster:

  • gcloud config set container/cluster cluster-name
  • gcloud container clusters get-credentials cluster-name
  • test it:
    gcloud container node-pools list

gcloud overview:

  • get basic info about gcloud configuration: (account, zone,…)
    • gcloud config list
  • install kubectl:
    • gcloud components install kubectl
  • update gcloud:
    • gcloud components update

Pods:

  • get list of pods:
    • kubectl get pods
  • login into pod with bash:
    • kubectl exec -it <pod_name> — bash
    • you may need to set following ENV variable to see output of some commands (like “top”):
      • export TERM=linux
  • check problems with pod:
    • kubectl describe pod
  • get pod config file:
    • kubectl get pod …. -o yaml > filename.yaml

Deployments:

  • get deployments list:
    • kubectl get deployments
  • get config of existing deployment:
    • kubectl get deployment depl-name -o yaml
  • put it into file:
    • kubectl get deployment depl-name -o yaml > depl-name.yaml

Nodes:

  • check nodes:
    • kubectl top nodes
    • kubectl describe node node-name
    • kubectl describe nodes

Service:

  • expose deployment as a service with public IP address:
    • k expose deployment depl-name –type=”LoadBalancer” –load-balancer-ip=”xxx.xxx.xxx.xxx” –port=80 –target-port=80
  • expose deployment as a service without public IP:
    • k expose deployment depl-name –type=”ClusterIP”
  • kubectl describe service svc-name

Secrets:

  • Create secret from files in current directory:
    • kubectl create secret generic your-secret-v1 –from-file=.
  • Get and decode existing secret:
    • kubectl get secret mysecret -o yaml
    • echo “…secretdata…”|base64 -d