Azure / k8s-deploy

GitHub Action for deploying to Kubernetes clusters
MIT License
252 stars 103 forks source link

Bug: Image is not being replaced in the manifest #286

Closed andresguisado closed 1 year ago

andresguisado commented 1 year ago

Context:

Configured k8s-deploy@v4 gitub action as follow:

https://github.com/aquasaemea/insecure-bank-app-andres/blob/main/.github/workflows/aquasec.yml#L151

IMAGE_TAG is an env var defined at the beginning of the pipeline and it is getting the value from the "github run number id":

https://github.com/aquasaemea/insecure-bank-app-andres/blob/main/.github/workflows/aquasec.yml#L14

Github action pipeline:

https://github.com/aquasaemea/insecure-bank-app-andres/actions/runs/4961516330/jobs/8878467758

Current problem:

The image defined in k8s-deploy@v4 job should be replaced the image in the following k8s manifest changing the tag latest to "github run id" but it doesn't work and it always deploys with the "latest" tag as it is in the manifest:

https://github.com/aquasaemea/insecure-bank-app-andres/blob/main/manifests/dev/deployment.yaml#L26

Expected behaviour:

The Image defined in the manifest is replaced by the image tag defined in the k8s-deploy@v4 github action job at the deployment time

Version

Runner

Github runners

Relevant log output

I didn't find in the documentation how to run this in debug mode:

https://github.com/marketplace/actions/deploy-to-kubernetes-cluster

OliverMKing commented 1 year ago

Hello @andresguisado. I don't believe supported by GitHub Workflows in general (not k8s-deploy specific).

Here's a related thread.

Try this

      - name: Deploying to Dev
        uses: azure/k8s-deploy@v4 
        with:
           namespace: ag-dev
           images: 'docker.io/${{ env.DOCKER_REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG}'
           manifests: |
              manifests/dev/deployment.yaml
              manifests/dev/service.yaml
andresguisado commented 1 year ago

Hi @OliverMKing.

${{ github.run_number }} is supported in Github actions: https://docs.github.com/en/actions/learn-github-actions/contexts#github-context

I have hardcoded the image name apart from the tag - https://github.com/aquasaemea/nodejs-app/blob/main/.github/workflows/aquasec.yml#L155

However, it is still not find and match it in order to replace the tag as the documentation is saying and it deploys the tag 73 which is the one in the deployment manifest so no tag replacement is happening- https://github.com/aquasaemea/nodejs-app/blob/main/manifests/dev/deployment.yaml#L26

As you can see in actions, the tag deployed should be the 76- https://github.com/aquasaemea/nodejs-app/actions which is in the docker hub - https://hub.docker.com/layers/aquasaemea/nodejs-app/76/images/sha256-20fa1909d77fe47f24554c984300c4df6e25869febb6dc7883a7b03170fc3a93?context=explore

OliverMKing commented 1 year ago

@andresguisado it doesn't look like the image names are the same.

Your action workflow defines images as

images: 'docker.io/aquasaemea/nodejs:${{ github.run_number }}'

Your deployment.yaml has the image as image: docker.io/aquasaemea/nodejs-app:73.

nodejs vs nodejs-app

OliverMKing commented 1 year ago

Going to go ahead and close this. Feel free to open if you are still having issues.