How to jumpstart your CI/CD process with Kubernetes
Many organizations have embraced continuous integration (CI) and continuous deployment (CD) methods. These organizations often have multiple tools on different platforms to manage their CI/CD processes, which means they work with various user interfaces (UIs), users, permissions, and so forth.
Kubernetes adoption has also increased over the last few years, and many Red Hat customers are using the Red Hat OpenShift Container Platform for their production environments. We have put a lot of effort into making the CI/CD experience on OpenShift as seamless as possible. This article (and our talk at Red Hat Summit 2022) explains how to get started with CI/CD on OpenShift Container Platform for an already deployed application.
[ Want more on this topic? Watch the full session, Jumpstart your CI/CD process, on-demand from Red Hat Summit. ]
This method uses three tools: GitOps Primer, OpenShift GitOps (Argo CD), and GitHub Actions.
There are several ways to deploy applications on OpenShift clusters. Some use technologies in the Kubernetes ecosystem, such as Helm, to deploy applications, while others use manual processes or tools outside the ecosystem, like Ansible.
GitOps Primer helps those trying to move from non-kube-native deployment processes to Kubernetes-native deployment approaches like GitOps. The tool's goal is simple: Get every object that an application has deployed on Kubernetes, package it, and provide a download link for the package for you to push to your Git repository.
GitOps Primer handles the first part of the GitOps process: Getting your application's manifest to Git with the click of a button.
GitOps Primer helps get your application's manifest to Git, but you still need a tool that takes manifests from Git and deploys them on OpenShift.
OpenShift GitOps is based on Argo CD, one of the most popular GitOps tools in the Kubernetes ecosystem, and one that Red Hat fully supports with an OpenShift subscription.
OpenShift GitOps and Argo CD's primary goal is simple: Monitor a Git repository and, upon changes, make sure the cluster's state matches the described state in Git.
[ You might also be interested in reading How to use Argo CD to set up a CD pipeline with OpenShift Pipelines. ]
In our Red Hat Summit session, we configured OpenShift GitOps to monitor our Git repository where the GitOps Primer manifests were uploaded. As a result, OpenShift GitOps not only deployed the application in our cluster but also avoided configuration drift between the application's configuration in the cluster and the application's configuration in the Git repository.
GitHub Actions allows you to automate your entire software development workflow. The community around the tool is huge; you can find actions for almost anything you have in mind.
By configuring GitHub Actions to run the CI for our application, we automated all required steps for building and testing our application using two workflows.
The first workflow in our pipeline:
- Runs a linter to perform static code analysis for our code.
- Runs the unit tests.
- Builds the application and publishes the binary in the repo releases.
The second workflow builds our container image and makes sure it's stable before changing the application configuration in Git. The workflow:
- Builds the application container image.
- Deploys the image to a Kind temporary cluster.
- Pushes the image to the container registry (Quay.io) after image testing in Kind.
- Changes the application configuration in the Git repository and updates the application's deployment file to use the new image.
Once the pipelines finish, Argo CD watches the deployment change and configures the application in OpenShift to use the new image.
This closes the circle and fully automates the application's CI and CD. Now, developers can focus on coding the app rather than deploying it and updating its configuration.
GitHub Actions has a wide variety of actions created by the community that may help improve your CI process in multiple ways. For example, you could look at some activities to secure your end-to-end supply chain.
The above process covers the very basics of OpenShift GitOps. If you'd like to take it a step further, you could start looking at other features, including waves and PGP verification, to improve your application's CD processes. And for a complete overview, please view our talk at Red Hat Summit 2022.
Navigate the shifting technology landscape. Read An architect's guide to multicloud infrastructure.