Kubernetes config editing

5/22/2018

Is there any CLI tools or libraries that allow to update container images (and other parameters) in K8S YAML/JSON configuration files?

For example, I have this YAML:

apiVersion: apps/v1
kind: Deployment
<...>
spec:
  template:
    spec:
      containers:
        - name: dmp-reports
          image: example.com/my-image:v1
<...>

And I want to automatically update the image for this deployment in this file (basically, this is necessary for the CI/CD system).

-- Yanislav Kornev
kubernetes
yaml

2 Answers

5/22/2018

You can use sed in your CI/CD pipeline to update the file and deploy. In jenkins its sh sed ......

You can also use Helm - create templates and you can specify the new image names (etc.) when deploying the release.

-- Amrit Bera
Source: StackOverflow

5/22/2018

We have the same issue on the Jenkins X project where we have many git repositories and as we change things like libraries or base docker images we need to change lots of versions in pom.xml, package.json, Dockerfiles, helm charts etc.

We use a simple CLI tool called UpdateBot which automates the generation of Pull Requests on all downstream repositories. We tend to think of this as Continuous Delivery for libraries and base images ;). e.g. here's the current Pull Requests that UpdateBot has generated on the Jenkins X organisation repositories

Then here's how we update Dockerfiles / helm charts as we release, say, new base images: https://github.com/jenkins-x/builder-base/blob/master/jx/scripts/release.sh#L28-L29

-- James Strachan
Source: StackOverflow