Skip to main content

Steps to run kubectl on your machine

Install google-cloud-cli. For staging <PROJECT_ID> is powr-staging and for production it's powr-prod.

Run command:

 gcloud config set project <PROJECT_ID>
gcloud config set compute/region us-east1
gcloud components update
gcloud components install kubectl
gcloud components install gke-gcloud-auth-plugin
gcloud container clusters get-credentials main --region us-east1 --project powr-staging

This will create the configuration for kubectl and allow you to check current cluster status with kubectl get all -n main, where -n main stays for namespace. Result will look like:

NAME                                READY   STATUS      RESTARTS   AGE
pod/sidekiq-10min-27494820-bzqqj 0/3 Error 0 16h
pod/sidekiq-10min-27494820-mdp9x 0/3 Error 0 16h
pod/sidekiq-10min-27494820-pg6jf 0/3 Error 0 16h
pod/sidekiq-10min-27494820-rgslh 0/3 Error 0 16h
pod/sidekiq-10min-27494820-s57nc 0/3 Error 0 16h
pod/sidekiq-10min-27494820-x6gvq 0/3 Error 0 16h
pod/sidekiq-10min-27494820-zp6m7 0/3 Error 0 16h
pod/sidekiq-10min-27495790-nhpnq 0/3 Completed 0 28m
pod/sidekiq-10min-27495800-lfz4q 0/3 Completed 0 18m
pod/sidekiq-56f665b47b-m2k7m 1/1 Running 0 11m
pod/sidekiq-daily-27495620-6gcq6 0/1 Completed 0 3h18m
pod/sidekiq-hourly-27495678-vw82x 0/1 Completed 0 140m
pod/sidekiq-hourly-27495738-525rg 0/1 Completed 0 80m
pod/sidekiq-hourly-27495798-g7l8w 0/1 Completed 0 20m
pod/web-58d4567469-svqtg 0/1 Pending 0 10s
pod/web-5ff9c96f88-zvg9g 1/1 Running 0 11m

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/web ClusterIP 10.55.2.116 <none> 80/TCP 25h

NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/sidekiq 1/1 1 1 25h
deployment.apps/web 1/1 1 1 25h

NAME DESIRED CURRENT READY AGE
replicaset.apps/sidekiq-56f665b47b 1 1 1 20h
replicaset.apps/sidekiq-6975f65548 0 0 0 25h
replicaset.apps/web-575787f679 0 0 0 17h
replicaset.apps/web-586b4dd6f9 0 0 0 86m
replicaset.apps/web-58d4567469 1 1 0 12s
replicaset.apps/web-595c79cbd8 0 0 0 17h
replicaset.apps/web-5cc98c4ff9 0 0 0 11h
replicaset.apps/web-5ff9c96f88 1 1 1 20h
replicaset.apps/web-65d87f44bd 0 0 0 14h
replicaset.apps/web-6c6f8cfb75 0 0 0 44m
replicaset.apps/web-6d867f6d5 0 0 0 98m
replicaset.apps/web-7f6464b84 0 0 0 18h
replicaset.apps/web-b556595c8 0 0 0 13h
replicaset.apps/web-b78f55fbb 0 0 0 12h

NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
horizontalpodautoscaler.autoscaling/sidekiq Deployment/sidekiq 9%/90%, 0%/90% 1 1 1 25h
horizontalpodautoscaler.autoscaling/web Deployment/web 11%/90%, 0%/80% 1 1 1 25h

NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
cronjob.batch/sidekiq-10min */10 * * * * False 0 8m38s 25h
cronjob.batch/sidekiq-daily 20 04 * * * False 0 3h18m 25h
cronjob.batch/sidekiq-hourly 18 * * * * False 0 20m 25h

NAME COMPLETIONS DURATION AGE
job.batch/sidekiq-10min-27494820 0/1 16h 16h
job.batch/sidekiq-10min-27495790 1/1 34s 28m
job.batch/sidekiq-10min-27495800 1/1 32s 18m
job.batch/sidekiq-10min-27495810 1/1 2m46s 8m39s
job.batch/sidekiq-daily-27495620 1/1 32s 3h18m
job.batch/sidekiq-hourly-27495678 1/1 33s 140m
job.batch/sidekiq-hourly-27495738 1/1 35s 80m
job.batch/sidekiq-hourly-27495798 1/1 29s 20m

Where web is rails application, sidekiq is a queue manager with async jobs and

sidekiq-10min/hourly/daily are cronjobs (same as schedulers on heroku). We also have service/web that is responsible for routing traffic from pods to ingress. Two types of autoscalers that are manager through helm and set of cronjobs (schedulers).

If you want to set main as your default namespace then run:

 kubectl config get-contexts $(kubectl config current-context)
kubectl config set-context [NAME] [--cluster=cluster_nickname] [--namespace=namespace]
kubectl config use-context [NAME]

$Set [NAME] to whatever you want.

Additional info could be found here.