continuous-integrationknativecontainer-image

Knative: update image of a service in a CI autodeploy pipeline


I recently converted my kubernetes deployment service to a knative serverless application. I am looking for a way how to update the image of a container the the knative app from a CI/CD pipeline without using yml file (CI pipeline doesn't have access to the yaml config used to deploy the file). Previously, I was using kubectl set image command to update the image from CI to the latest version for a deployment but it does not appear to work for a knative service, e.g. the command I tried is: kubectl set image ksvc/hello-world hello-world=some-new-image --record

Is there a way to update the image of a knative app using a kubectl command without having access to the original yaml config?


Solution

  • You can use kn CLI:

    https://github.com/knative/client/blob/master/docs/cmd/kn_service_update.md

      kn service update hello-world --image some-new-image
    

    This would create a new revision for the Knative service though. You can clean up old revisions with kn.

    Get kn here: https://knative.dev/docs/install/install-kn/