5-Step Kubernetes CI/CD Process using Artifactory & Helm
Last updated Oct 10, 2023
35
Stars
61
Forks
0
Issues
0
Stars/day
Attention Score
27
Language breakdown
Groovy 62.3%
Java 20.9%
HTML 8.3%
Dockerfile 4.8%
Smarty 2.8%
Shell 0.9%
▸ Files
click to expand
README
5 Step CI/CD In Kubernetes using Artifactory, Jenkins & Helm
Contents
- Setup Kubernetes Cluster on EKS
- Setup Kubernetes Cluster on GKE
- Setup Kubernetes Cluster on AKS
- Install Artifactory on kubernetes
- Install Jenkins on kubernetes
- Configure Continuous Integration/Continuous Deployment
Prerequisites
- Basic knowledge of Docker, Jenkins, Kubernetes and Artifactory
Setup Kubernetes Cluster on EKS
Follow this to setup kubernetes cluster on EKS. https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.htmlSetup Kubernetes Cluster on GKE
Follow this to setup kubernetes cluster on GKE. https://cloud.google.com/container-engine/docs/quickstartSetup Kubernetes Cluster on AKS
Follow this to setup kubernetes cluster on AKS. https://docs.microsoft.com/en-us/azure/aks/tutorial-kubernetes-deploy-clusterInstall Artifactory on kubernetes
Here is documentation to install JFrog Artifactory on kubernetes artifactory-docker-examplesHere is link to official helm chart for Artifactory https://github.com/kubernetes/charts/tree/master/stable/artifactory
Note If you are using Artifactory SaaS you can skip this step.
Configure docker insecure registry in each node of kubernetes cluster if you are using self-signed certificate.
- Get cluster ip of nginx services by running following command:
kubectl get services nginx-kubernetes-service
- Ssh into each node of cluster and configure insecure registry using steps provided here
$CLUSTER_IP as insecure registry.
- Add following entry in
/etc/hostsfile:
$CLUSTER_IP docker.artifactory docker-remote.artifactory docker-local.artifactory
- Pull
nodedocker image from artifactory by running following command:
docker pull docker.artifactory/node
Install Jenkins on kubernetes
Use Helm Chart to install jenkins in kubernetes.
Note: Make sure to increase resources for Jenkins deployment in values.yaml file. Jenkins comes with the Kubernetes plugin..
Cache docker images of jenkins master and agent in Artifactory by changing value of Master.Image to docker.artifactory/jenkinsci/jenkins and Agent.Image to docker.artifactory/jenkinsci/jnlp-slave in values.yaml file.
Configuring Jenkins to build docker images:
- From Jenkins home click on Manage Jenkins -> Configure System.
- You will see section Cloud -> Kubernetes -> Images -> Volumes.
- Click on Add Volume and add Host Path Volume with following mount path:
- ssh into each kubernetes node of your cluster and perform following:
jenkins user.
2. Add jenkins user to docker group.
3. Make sure jenkins user can access /var/run/docker.sock and /usr/bin/docker in each kubernetes node.
4. Create test job in Jenkins and run docker version command from test job.
5 Step CI/CD
Step 1. Create an application war file
- Creates a sample application called ‘webservice-1.1.2.war’
- Pushes it to a local repository in Artifactory
- gradle-example
Step 2. Create a template Docker image
- Creates a base Docker image called ‘docker-framework’ using Ubuntu + Java + Tomcat
- Pushes it to a local repository in Artifactory
- docker-framework
Step 3. Create a product Docker image
- Downloads, from Artifactory, the ‘webservice-1.1.2.war’ file and the ‘docker-framework’ Docker image, that were created in the previous two pipelines
- Creates a ‘docker-app’ production Docker image
- Pushes it to Artifactory
- Promotes it to a production repository in Artifactory
- docker-app
Step 4. Create Helm chart of product Docker image
- Create helm chart of
docker-app - Push helm chart in local helm repository in Artifactory
- chart
Step 5. Deploy docker-app in Kubernetes cluster using helm chart
- Pull helm chart from Virtual helm repository of Artifactory
- Deploy
docker-appin Kubernetes using downloaded helm chart - deploy
🔗 More in this category