Set Up GitOps for the Redpanda Helm Chart
GitOps is a modern approach to managing and automating the deployment and provisioning process using Git as the single source of truth. It involves storing configuration files and deployment scripts in a Git repository, and then using automation tools to continuously monitor the repository for changes.
This example uses Flux to deploy the Redpanda Helm chart on a local Kubernetes cluster. Flux is a toolkit for GitOps with Kubernetes clusters that supports the following:
-
Version control for configurations: You can track changes, collaborate, and revert to previous configurations if needed.
-
Drift detection and remediation: Flux continuously monitors the Redpanda cluster’s state. If discrepancies are detected, Flux automatically remediates them to bring the Redpanda cluster back to the desired state.
-
Collaboration and auditing: Multiple team members can propose changes to Redpanda configurations through Git pull requests, enabling code reviews and discussions before changes are applied.
Prerequisites
You must have the following:
-
An understanding of the core concepts of Flux.
-
At least version 1.24 of the kubectl CLI.
kubectl version --client
-
At least version 3.6.0 of Helm.
helm version
Create a local Kubernetes cluster
Create one master and three worker nodes (one worker node for each Redpanda broker).
-
Define a cluster in the
kind.yaml
configuration file:cat <<EOF >kind.yaml --- apiVersion: kind.x-k8s.io/v1alpha4 kind: Cluster nodes: - role: control-plane - role: worker - role: worker - role: worker EOF
-
Create the Kubernetes cluster from the configuration file:
kind create cluster --config kind.yaml
Run the lab
Fork this repository, and configure Flux to connect to your fork and deploy the Redpanda Helm chart.
-
Fork the
redpanda-data/redpanda-labs
repository on GitHub. -
Bootstrap Flux for your forked repository.
Make sure to do the following:
-
Provide Flux with your GitHub personal access token (PAT).
-
Configure the
path
flag with the valuekubernetes/gitops-helm
. This is the path where the example manifests are stored in the repository.
Here is an example of the bootstrap command:
flux bootstrap github \ --token-auth \ --owner=<github-username> \ --repository=redpanda-labs \ --branch=main \ --path=./kubernetes/gitops-helm \ --personal
Replace
<github-username>
with your GitHub username. -
The bootstrap script does the following:
-
Creates a deploy token and saves it as a Kubernetes Secret
-
Creates an empty GitHub project, if the project specified by
--repository
doesn’t exist -
Generates Flux definition files for your project
-
Commits the definition files to the specified branch
-
Applies the definition files to your cluster
-
Applies the manifests in
kubernetes/gitops-helm
which deploy Redpanda and cert-manager
After you run the script, Flux is ready to manage itself and any other resources you add to the GitHub project at the specified path.
Verify the deployment
To verify that the deployment was successful, check the status of the HelmRelease resource:
kubectl get helmrelease redpanda --namespace redpanda --watch
In a few minutes, you should see that the Helm install succeeded:
NAME AGE READY STATUS redpanda 3m23s True Helm install succeeded for release redpanda/redpanda.v1 with chart redpanda@5.7.5
Manage updates
To update Redpanda, modify the redpanda-helm-release.yaml
manifest in your Git repository. You can configure the Helm chart in the spec.values
field. For a description of all available configurations, see the Redpanda Helm Chart Specification.
When you push changes to GitHub, Flux automatically applies the updates to your Kubernetes cluster.
Delete the cluster
To delete the Kubernetes cluster as well as all the Docker resources that kind created, run:
kind delete cluster
Suggested reading
See the interactive examples for setting up GitOps with the Redpanda Operator.