Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 1
Message 1 of 2

kubectl in GCP

If I'm interested in using GitHub Actions that requires using kubectl for a GCP environment, how do I get started? The closest I can get to when I search is the actions/aws repo but I'm not using AWS.

1 Reply
Highlighted
Copilot Lvl 3
Message 2 of 2

Re: kubectl in GCP

What exactly are you trying to do/achieve? I am running the Google Cloud SDK in my workflows without any problems. I haven't had the need to use kubectl yet, but it is included in the default environment. So given you've authenticated against your cluster (which you should be able to do using the gcloud utility) you should be able to query it with kubectl in a run step just fine. For example, setting up/logging in the gcloud SDK looks like this in a workflow step:

 

- name: gcloud-auth
  env:
    GCLOUD_AUTH: ${{ secrets.GCLOUD_AUTH }}
  run: |
    echo "$GCLOUD_AUTH" | base64 --decode > ${HOME}/gcloud.json
    gcloud auth activate-service-account --key-file=${HOME}/gcloud.json
    gcloud auth configure-docker

The GCLOUD_AUTH secret is a base64 encoded keyfile of a service account with the proper permissions that my workflow needs. This step logs it in just fine and it configures Docker so I can pull/push from/to my GCR repositories (so the last command is optional, you only need it if you want Docker to access stuff on private GCR repositories).