I have set up a Google Cloud Platform kubernetes cluster (and Container Registry) with source code on GitHub. Source code is divided into folders with separate Dockerfiles for each microservice.
I want to set up CI/CD using GitHub actions.
As far as I understand, the default GKE workflow will connect to gcloud using secrets, build the images and push them to Container Registry. And then perform an update.
My questions
- How is the deployment performed?
- What is kustomize for?
- Do I have to configure on gcloud anything else than GKE key / token
- Suppose I want to update multiple docker images. Will it suffice to build multiple images and push them? Like below (a little bit simplified for clarity), or do I have to also modify the Deploy job:
- name: Build
run: |-
docker build -t "gcr.io/$PROJECT_ID/$IMAGE_1:$GITHUB_SHA" service1/.
docker build -t "gcr.io/$PROJECT_ID/$IMAGE_2:$GITHUB_SHA" service2/.
docker build -t "gcr.io/$PROJECT_ID/$IMAGE_3:$GITHUB_SHA" service3/.
- name: Publish
run: |-
docker push "gcr.io/$PROJECT_ID/$IMAGE_1:$GITHUB_SHA"
docker push "gcr.io/$PROJECT_ID/$IMAGE_2:$GITHUB_SHA"
docker push "gcr.io/$PROJECT_ID/$IMAGE_3:$GITHUB_SHA"
This is the deploy fragment from the GKE workflow:
# Deploy the Docker image to the GKE cluster
- name: Deploy
run: |-
./kustomize edit set image gcr.io/PROJECT_ID/IMAGE:TAG=gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA
./kustomize build . | kubectl apply -f -
kubectl rollout status deployment/$DEPLOYMENT_NAME
kubectl get services -o wide