kubernetes CI/CD: automate docker build, tag and push tasks on a CI/CD infrastructure

8/10/2018

We're setting a CI/CD infrastructure in order to deploy our applications on openshift/kubernetes.

We're deploying applications using jenkins, fabric8 and helm.

Nevertheless, we're creating some other kind of artifacts: init and sidecar images. So, our applications need that those images are available on kubernetes/openshift registry before main containers start.

Currently, we're building, tagging and pushing them on openshift/kubernetes registry, manually.

$ docker build .
$ docker tag image <registry>/image
$ docker push <registry>/image

We want to automate this process, I mean, we'd really like to avoid performing these three steps and we want to avoid to configure a docker client on a jenkins slave in order to push them.

I don't know if I've explained so well.

-- Jordi
jenkins
kubernetes
openshift

1 Answer

8/10/2018

Well you would need a seperate machine installed with docker that is used just to build and push your docker image, with a software that is triggered by jenkins to do the task. But I don't know about any software doing that.

Our solution was to install docker on a jenkins node. The build itself is written as pipeline and is commited to our scm as Jenkinsfile with the steps being:

  • build/test app
  • build docker image
  • push docker image
  • delete image on jenkins node
  • deploy

If you dont want to use docker on jenkins and you use java something like jib could do the trick. But I'm not sure anything like that exists for other languages.

Update:

Thanks to Grahams suggestion you could also checkout:

-- BeWu
Source: StackOverflow