Kubernetes lets you manage containerized applications on a cluster of nodes. The solution is perfect if you need to deploy and scale your application on the fly without consuming more resources that required.

Buddy lets you easily streamline the whole process down to a simple push to Git and brings a series of extra benefits to the table:

  • you don't have to enter the commands manually every time
  • you get precise feedback in case there's an error in .yml files
  • you don't need a DevOps specialist around to update your application
  • you can expand your delivery pipeline with builds and tests before the deployment

This article will tell you how to do that in a series of a few simple steps.

Set up a project with Buddy

For the purpose of this guide we'll use a Git repository with a sample WordPress project and config files for K8s volumes, WordPress, and MySQL: https://github.com/buddy-works/wordpress-kubernetes.git

  1. Sign up to Buddy with your GitHub/Bitbucket account or email
  2. Create a new project, select your Git provider, and choose your WP project:

Configure Pipeline #1: Apply K8s deployment

The first pipeline will automatically apply configuration changes to your K8s volumes and WordPress instance on a push to branch:

  1. Click Add a new pipeline
  2. Set the trigger mode to 'On every push'
  3. Select the branch that will trigger the execution
  4. Click Add a new pipeline when ready

Define the delivery actions

  1. Add Apply K8s deployment configuration action and configure the details:

    • enter the details to the server with your K8s cluster
    • select the volumes.yml config file from your repository

  2. Add two more actions for mysql.yml and wordpress.yml.

    You can also add a notification that will let you know of finished deployments.

In the end, your pipeline should look like this:

Configure Pipeline #2: Build & Replace Docker image

The second pipeline will automatically update the image on your K8s cluster if you make any changes to your WordPress project:

  1. Click Add a new pipeline
  2. Set the trigger mode to 'On every push'
  3. Select the branch that will trigger the execution
  4. Click Add a new pipeline when ready

Define the delivery actions

  1. Add Docker build action and configure the details:

    • select the Dockerfile from the repository
    • select the registry to which Buddy will push your image (eg. Docker Hub)
    • in the Tag field, use the parameter ${execution.to_revision.short_revision}

    You can view the whole list of Buddy parameters here.

  2. Add Set image in K8s deployment action and configure the details:

    • enter the details to the server with your K8s cluster
    • select the container to update (wordpress)
    • in the Tag field, use the parameter ${execution.to_revision.short_revision}

    You can add a build action that will eg. compile your assets before the deployment (Gulp/Grunt etc.).

This is what your pipeline should look like when you're done (Gulp is optional):

Run the pipeline

With both pipelines in place, make a push to the assigned branch and watch Buddy perform all tasks for you:

Congratulations! You have successfully automated your Kubernetes deployments. Feel free to further optimize your workflow by adding more actions to your pipelines.

Make sure to check out our guides for inspiration, or reach out on our live-chat or directly at support@buddy.works for use-cases on pipeline configuration.

Cheers!