Reputation: 47
I have a workflow on Github action that builds, tests, and pushes a container to GKE. I followed the steps outlined in https://docs.github.com/en/actions/guides/deploying-to-google-kubernetes-engine but my build keeps on failing. The failure comes from the Kustomization stage of the build process.
This is what the error looks like:
Run ./kustomize edit set image gcr.io/PROJECT_ID/IMAGE:TAG=gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA
./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
shell: /usr/bin/bash -e ***0***
env:
PROJECT_ID: ***
GKE_CLUSTER: codematictest
GKE_ZONE: us-east1-b
DEPLOYMENT_NAME: codematictest
IMAGE: codematictest
CLOUDSDK_METRICS_ENVIRONMENT: github-actions-setup-gcloud
KUBECONFIG: /home/runner/work/codematic-test/codematic-test/fb7d2ebb-4c82-4d43-af10-5b0b62bab1fd
Error: Missing kustomization file 'kustomization.yaml'.
Usage:
kustomize edit set image [flags]
Examples:
The command
set image postgres=eu.gcr.io/my-project/postgres:latest my-app=my-registry/my-app@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
will add
images:
- name: postgres
newName: eu.gcr.io/my-project/postgres
newTag: latest
- digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
name: my-app
newName: my-registry/my-app
to the kustomization file if it doesn't exist,
and overwrite the previous ones if the image name exists.
The command
set image node:8.15.0 mysql=mariadb alpine@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
will add
images:
- name: node
newTag: 8.15.0
- name: mysql
newName: mariadb
- digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
name: alpine
to the kustomization file if it doesn't exist,
and overwrite the previous ones if the image name exists.
Flags:
-h, --help help for image
Error: Process completed with exit code 1.
My GitHub workflow file looks like this:
name: gke
on: push
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: codematictest
GKE_ZONE: us-east1-b
DEPLOYMENT_NAME: codematictest
IMAGE: codematictest
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
defaults:
run:
working-directory: api
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout
uses: actions/checkout@v2
# Setup gcloud CLI
- uses: google-github-actions/[email protected]
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
gcloud --quiet auth configure-docker
# Get the GKE credentials so we can deploy to the cluster
- uses: google-github-actions/[email protected]
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
# Build the Docker image
- name: Build
run: |-
docker build \
--tag "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA" \
--build-arg GITHUB_SHA="$GITHUB_SHA" \
--build-arg GITHUB_REF="$GITHUB_REF" \
.
# Push the Docker image to Google Container Registry
- name: Publish
run: |-
docker push "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA"
# Set up kustomize
- name: Set up Kustomize
run: |-
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
chmod u+x ./kustomize
# 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
Upvotes: 2
Views: 2422
Reputation: 816
The kustomization file, as explained in it's repository, should be in the next file structure:
~/someApp
├── deployment.yaml
├── kustomization.yaml
└── service.yaml
Upvotes: 1