Understanding Kubernetes CI/CD Pipelines vs Conventional CI/CD Pipelines

Listen to this Post

Not a joke, many DevOps engineers don’t fully understand the difference between a conventional CI/CD pipeline and a Kubernetes CI/CD pipeline. Here, I’ve made this to help you better understand.

What we cover:

  • DevOps
  • Cloud
  • Kubernetes
  • Infrastructure as Code (IaC)
  • GitOps
  • MLOps

URL: TechOps Examples Newsletter

Practice Verified Codes and Commands

Conventional CI/CD Pipeline

1. Jenkins Pipeline Example:

pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'mvn clean package'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
}
stage('Deploy') {
steps {
sh 'scp target/*.war user@server:/var/lib/tomcat/webapps/'
}
}
}
}

2. GitLab CI/CD Example:

stages:
- build
- test
- deploy

build_job:
stage: build
script:
- echo "Building the application..."
- mvn clean package

test_job:
stage: test
script:
- echo "Running tests..."
- mvn test

deploy_job:
stage: deploy
script:
- echo "Deploying to server..."
- scp target/*.war user@server:/var/lib/tomcat/webapps/

Kubernetes CI/CD Pipeline

1. Kubernetes Deployment YAML:

apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: my-registry/my-app:latest
ports:
- containerPort: 8080

2. Helm Chart Example:

apiVersion: v2
name: my-app
description: A Helm chart for Kubernetes
version: 0.1.0
appVersion: "1.0"

dependencies:
- name: nginx
version: "1.0.0"
repository: "https://charts.bitnami.com/bitnami"

values:
replicaCount: 3
image:
repository: my-registry/my-app
tag: latest
pullPolicy: IfNotPresent

3. ArgoCD Application YAML:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/my-org/my-repo.git
targetRevision: HEAD
path: k8s
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
prune: true
selfHeal: true

Linux and Windows Commands for CI/CD

Linux Commands:

1. Docker Commands:


<h1>Build Docker image</h1>

docker build -t my-app:latest .

<h1>Run Docker container</h1>

docker run -d -p 8080:8080 my-app:latest

<h1>Push Docker image to registry</h1>

docker push my-registry/my-app:latest

2. Kubectl Commands:


<h1>Apply Kubernetes deployment</h1>

kubectl apply -f deployment.yaml

<h1>Check pod status</h1>

kubectl get pods

<h1>View logs of a pod</h1>

kubectl logs <pod-name>

<h1>Delete a deployment</h1>

kubectl delete -f deployment.yaml

3. Helm Commands:


<h1>Add Helm repository</h1>

helm repo add bitnami https://charts.bitnami.com/bitnami

<h1>Install Helm chart</h1>

helm install my-app bitnami/nginx

<h1>Upgrade Helm release</h1>

helm upgrade my-app bitnami/nginx

<h1>Uninstall Helm release</h1>

helm uninstall my-app

Windows Commands:

1. PowerShell Commands:


<h1>Build Docker image</h1>

docker build -t my-app:latest .

<h1>Run Docker container</h1>

docker run -d -p 8080:8080 my-app:latest

<h1>Push Docker image to registry</h1>

docker push my-registry/my-app:latest

2. Kubectl Commands:


<h1>Apply Kubernetes deployment</h1>

kubectl apply -f deployment.yaml

<h1>Check pod status</h1>

kubectl get pods

<h1>View logs of a pod</h1>

kubectl logs <pod-name>

<h1>Delete a deployment</h1>

kubectl delete -f deployment.yaml

What Undercode Say

Understanding the difference between conventional CI/CD pipelines and Kubernetes CI/CD pipelines is crucial for modern DevOps practices. While conventional pipelines focus on automating build, test, and deployment processes, Kubernetes pipelines integrate container orchestration, providing scalable and automated infrastructure management. Tools like Jenkins, GitLab, Helm, and ArgoCD are essential for implementing these pipelines effectively. Mastering these tools and commands will significantly enhance your DevOps capabilities, ensuring efficient and reliable software delivery in cloud-native environments.

References:

Reported By: Govardhana Miriyala – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification ✅Featured Image