Tutorials  /  Container & Cloud

GitOps-based CI/CD on Kubernetes: A Guide

Ccentron Redaktion · November 2024 ·3 min read ·Container & Cloud, Tutorial

Automating Continuous Integration (CI) and Continuous Deployment (CD) on Kubernetes with a GitOps approach provides an efficient way to develop, test, and deploy applications. In this blog post, we demonstrate using CircleCI for continuous integration and Argo CD for continuous deployment on a Kubernetes cluster.

Step 1: Setting up CircleCI

CircleCI automates builds and tests in Kubernetes. By configuring a workflow in a YAML file, we define the steps for CircleCI, including running tests, building Docker images, and pushing these images to a container repository like Docker Hub.

version: 2

jobs:

test:

docker:

- image: circleci/python:3.8

steps:

- checkout

- run: pytest

build:

docker:

- image: docker:19.03.12

steps:

- checkout

- setup_remote_docker

- run: docker build -t myapp:latest .

push:

docker:

- image: docker:19.03.12

steps:

- setup_remote_docker

- run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

- run: docker push myapp:latest

workflows:

version: 2

build-deploy:

jobs:

- test

- build:

requires:

- test

- push:

requires:

- build

K8

Matching infrastructure at centron

From container to cluster: managed Kubernetes with cStack starts at €29.99 per month – control plane, autoscaler and traffic included. Explore managed Kubernetes →

Step 2: Installing and Configuring Argo CD

Argo CD manages continuous deployment on Kubernetes. After installation, we connect Argo CD with GitHub and configure the application for deployment. This involves setting up access permissions, adding clusters, and configuring applications for automatic synchronization.

# Installing Argo CD

kubectl create namespace argocd

kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.1.4/manifests/install.yaml

# Connecting with GitHub

argocd login localhost:8080

argocd account update-password

argocd cluster add minikube

Step 3: Linking Argo CD with GitHub and Manual Deployment

Argo CD synchronizes deployments with a GitHub repository. By linking with GitHub and configuring the application, we can automate deployments. We also introduce the option to manually trigger synchronization of the application with the repository, offering flexibility and control over the deployment process.

Step 4: Testing the Continuous Deployment Setup

Once configuration is complete, we test the Continuous Deployment system by making a change in the project and triggering a new build of the application. We observe how Argo CD detects the changes and automatically updates the application on the Kubernetes cluster.

Conclusion

With CircleCI for continuous integration and Argo CD for continuous deployment, we have a powerful toolkit for automating Kubernetes workflows. Using a GitOps approach organizes our CI/CD processes around Git, enabling efficient and consistent development.

Through this tutorial, you’ve created a basic pipeline for developing, testing, and deploying applications on Kubernetes. You can use these tools to develop and further customize your own GitOps CI/CD system. For more information on Git and DevOps tools, we recommend our other tutorials and resources.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Container & Cloud
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren