3

I'm wanting to create a basic 'on new commits to master, rebuild the images and deploy to kubernetes' pipeline.

Docker Hub has its concept of automated builds on new commits, but I'd still need to use Travis CI to do the kubernetes deployment.

Is there a way to synchronise these - so that Travis doesn't start its scripts until Docker Hub has built the image?

Alternatively - I could just do all of the building on Travis CI. But Docker Hub doesn't seem to provide service accounts - or have I got that wrong? It seems like the only way to create a service account is to actually manually create a new username/password for service account. Is that the case?

What are the generally established ways of doing this?

1
  • I may not have a clear understanding of the question, but why not just use a deployment script to build the images, push them and apply them to kubernetes? And via a .travis.yml file you can tell Travis not to run the deployment script unless you are pushing it to master. – Daniel Jun 26 '19 at 4:00
1

If you're married to Docker Hub, you could use a webhook to notify Travis of the need to start it's job.

However, I solve this problem using Quay.io - it has the robot account (you refer to "service account") you need. It also has a richer set of notifications.

You could maintain your current workflow using webhooks to

  1. create the repository on Quay or Docker Hub, have the image built on git events.
  2. Create a webhook in the repository to send data to your Travis job when builds succeed

Or, you could build your images in the Travis job.

  1. Push the initial image to a repository on Quay
  2. Add a robot account to your repository in Quay
  3. Add the necessary secrets to your Travis build (token and robot user name)
  4. Configure Travis to build the image, run whatever tests you need and then push on green.
  5. Add an after_success task to redeploy your app in k8s after the push.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.