CI/CD with Kubernetes: Tools and Practices
Setting up a CI/CD pipeline on top of Kubernetes will speed up your release lifecycle — enabling you to release multiple times a day — and enable nimble teams to iterate quickly. Kubernetes has many features that make it ideal for CI/CD. With Kubernetes, builds become a lot faster. Instead of spinning up entirely new servers, your build process is quick, lightweight and straightforward.
Development speeds up when you don’t have to worry about building and deploying a monolith in order to update everything. By splitting a monolith into microservices, you can instead update pieces — this service or that. Part of a good CI/CD workflow should also include a strong test suite. While not unique to Kubernetes, a containerized approach can make tests more straightforward to run. If your application tests depend on other services, you can run your tests against those containers, simplifying the testing process. A one-line command is usually all you need to update a Kubernetes deployment.
Kubernetes Simplifies CI/CD
In a CI/CD workflow, ideally, you run many tests. If those tests fail, your image will never be built, and you’ll never deploy that container. However, if testing fails to uncover issues, Kubernetes offers better protection because Kubernetes simplifies zero-downtime deployment. For a long time, deployments meant downtime. Operations teams used to handle deployment efforts manually or via scripting, a live process that could take hours, if not all night. Accordingly, one of the fears of CI/CD is that a deployment will break and a site will go down.
Kubernetes’ zero-downtime deployment capability relieves anxieties about maintenance windows, making schedule delays and downtime a thing of the past — and saving money in the process. It also keeps everyone in the loop while meeting the needs of development, operations and business teams. The revolutionary Kubernetes deployment object has built-in features that automate this operations effort.
In particular, the aforementioned tests and health checks can prevent bad code from reaching production. As part of a rolling update, Kubernetes spins up separate new pods running your application while the old ones are still running. When the new pods are healthy, Kubernetes gets rid of the old ones. It’s a smart, simple concept, and it’s one less thing you have to worry about for each application and in your CI/CD workflow.
As part of the incredible momentum Kubernetes has seen, a number of DevOps tools have emerged that are particularly helpful in developing CI/CD workflows with Kubernetes. Bear in mind that CI/CD tools and practices are still evolving with the advent of cloud-native deployments on Kubernetes. No single tool yet offers the perfect solution for managing cloud-native applications from build through deployment and continuous delivery. Although there are far too many to mention here, it’s worth highlighting a few DevOps tools that were purpose-built for cloud-native applications:
- Draft: This tool from Microsoft targets developer workflows. With a few simple commands, Draft can containerize and deploy an application to Kubernetes. The automated containerization of applications here can be quite powerful. Draft uses best practices for popular frameworks and languages to build images and Kubernetes configuration that will work in most cases.
- Helm: Known as the Kubernetes package manager, this framework simplifies deploying applications to Kubernetes. Deployment configuration for many popular projects is available in well maintained “Charts.” This means that helm install Prometheus is all that’s needed to get a project like Prometheus running in your cluster. Helm can also provide the same kind of conveniences when deploying your own custom applications.
- Skaffold: Similar to Draft, this is a new tool from Google that enables exciting new development workflows. In addition to supporting more standard CI/CD workflows, this has an option to build and deploy code to a Kubernetes development environment each time the code changes locally. This tool is highly configurable, and even supports using Helm for deployments.
- Spinnaker: This open source continuous delivery platform was developed by Netflix to handle CD operations at high scale over its cloud network. It is a cloud-native pipeline management tool that supports integrations into all the major cloud providers: AWS, Azure, Google Cloud Platform and OpenStack. It natively supports Kubernetes deployments, but its scope extends much farther beyond Kubernetes.
Today, organizations are increasingly choosing to use Kubernetes instead of other orchestration tools. More and more, organizations are recognizing that containers offer a better solution than the more traditional tooling they had been using, and that Kubernetes is the best container deployment and management solution available. The next articles in this series will examine CI/CD with Kubernetes in more detail.