I am trying to make a GitHub Actions file that will build my app, dockerize it, and then apply it to my GKE cluster. I seem to have managed to connect to GCP, but as soon as I try to run a kubectl command (kubectl get pods
) it doesn't recognize the command.
I have tried a lot of actions in use:
, and none of them seem to work.
Here is what I have so far.
It is self hosted because I have test ran it a lot (100+ times), but I would eventually like to have it be a GitHub runner.
name: Deploy to GKE and AKS
on:
push:
branches:
- main
jobs:
deploy:
runs-on: self-hosted
env:
PROJECT_ID: project_id
APPLICATION_CREDENTIALS: ${{ secrets.GKE_SA_JSON_KEY }}
CLUSTER_NAME: cluster_name
ZONE_NAME: us-central1-a
path: docker_images/
yaml: yaml_files/
KUBE_CONFIG: ${{ secrets.GLCOU_KUBE_SETUP }}
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/project_id'
service_account: 'service_account'
project_id: project_id
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
- id: 'get-credentials'
uses: 'google-github-actions/get-gke-credentials@v1'
with:
cluster_name: name
location: us-central1
project_id: id
- name: test
run: |
gcloud config set account ACCOUNT
kubectl get deployments
kubectl get pods
- name: 'Use gcloud CLI'
run: 'kubectl get pods'