Tutorials  /  Container & Cloud

From Setup to Deployment: Automated CI/CD Pipelines with Jenkins X and Kubernetes

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

Managing applications in a Kubernetes environment can be complex, especially when it comes to package management and CI/CD. In this blog post, we’ll explore two essential tools specifically designed for Kubernetes to address these challenges: Helm and Jenkins X.

Step 1: Helm - Kubernetes Package Management

Helm is a package manager specifically designed for Kubernetes and maintained by the Cloud Native Computing Foundation (CNCF) in collaboration with Microsoft, Google, Bitnami, and the Helm community. Much like Linux package managers like APT or YUM, Helm hides the complexity of application installations and their dependencies behind the scenes, making application sharing and management significantly easier. Helm uses "Charts" to package applications into predefined resources that can be managed with simple commands.

# Example Helm Chart for a simple application

apiVersion: v1

appVersion: "1.0"

description: A simple nginx application

name: my-nginx

version: 1.0.0

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: Jenkins X - CI/CD for Kubernetes

Jenkins X is a CI/CD tool built specifically for Kubernetes, aimed at automating production pipelines and environments. Using Docker images, Helm charts, and the Jenkins Pipeline engine, Jenkins X can automatically manage releases and versions and promote applications across environments on GitHub.

pipeline {

agent any

stages {

stage('Build') {

steps {

// Steps to build the application

}

}

stage('Test') {

steps {

// Steps to test the application

}

}

stage('Deploy') {

steps {

// Steps to deploy the application

}

}

}

}

Step 3: Practical Implementation

To demonstrate the functionality of Helm and Jenkins X, we’ll conduct a practical exercise. First, we’ll set up a local Kubernetes cluster environment with Minikube, then install Helm on the cluster and create a sample chart to deploy an application. Afterward, we’ll use Jenkins X to set up a CI/CD pipeline and automate our application.

# Sample commands to set up a Minikube environment and install Helm

minikube start

helm install myapp ./mychart

Step 4: Setting Up Jenkins X

First, install the jx CLI tool and configure Docker to use insecure registries for the local IP range. Then, create your Minikube Kubernetes cluster with CI/CD capabilities:

curl -L https://github.com/jenkins-x/jx/releases/download/v1.3.781/jx-linux-amd64.tar.gz | tar xzv

mv jx /usr/local/bin

echo '{ "insecure-registries" : ["0.0.0.0/0"] }' | sudo tee /etc/docker/daemon.json

sudo systemctl restart docker

jx create cluster minikube --cpu=5 --default-admin-password=admin --vm-driver=none --memory=13314

Step 5: Creating a Test Application

Clone a sample application and import it into Jenkins X:

git clone https://github.com/do-community/rsvpapp.git

cd rsvpapp

rm -r .git/

jx import

Adjust the application configuration, push it to your GitHub repository, and monitor the pipeline status:

sed -i 's/servicePort: 5000/servicePort: 8080/' values.yaml

git add .

git commit -m "Change servicePort to 8080"

git push origin main

jx get build logs

Open your application in the browser:

minikube service rsvpapp

Step 6: Promoting the Application to Production

Use the `jx promote` command to move the application to the production environment:

jx promote rsvpapp --version=0.0.2 --env=production

Open the application in your browser to verify that it has been successfully promoted to production:

minikube service rsvpapp --namespace=jx-production

With these 6 steps, you have successfully set up a Jenkins X environment and moved a test application to production using a Jenkins X pipeline

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