This example will show you the CI/CD integration with Jenkins, Kubernetes and NetApp on a simple Web Application.

Pre-requisits

Before start this demo there are some requirements:

  • Docker Hub Account for publishing the docker image
  • a GIT repository (Github, Gitlab, Bitbucket, etc.)
  • Kubernetes Cluster
  • NetApp Storage System (FAS/AFF/CVO)
  • Trident must be configured in K8s cluster – Link: Trident Docs
  • helm charts must be configured in K8s cluster – Link: Helm Chart Docs

Preparation environment

Cloning Git repository

Goto my GitHub repository: github-repo

cd /opt
git clone https://github.com/fabian-born/jenkins-k8s-netapp.git .
cd jenkins-k8s-netapp

NodeJS and Redis Webapp

Implementing WebApp

The first step is to modify the app files for your environment:

  • in helm/webapp/templates/webapp-redis.yaml (line 5)
volume.beta.kubernetes.io/storage-class: <your storage class name> 

Now you can install the helm chart

helm install -n prod ./helm/webapp

Now the connection to the WebApp could be tested. For testing open the browser and add the URL of your WebApp: http://NODE_IP:30000 or if a loadbalancer available: http://LOADBALANCER_IP

Jenkins

Installing jenkins pod with special values

There are some changes in jenkins-helm.yaml

Persistence:
...
  Enabled: true
... 
  StorageClass: <your storage class name>
...

and

rbac:
  install: true

After modifying the file the jenkins container can be created:

helm install -n jenkins -f jenkins-helm.yaml stable/jenkins

After installing jenkins you have to find out your admin password:

  1. Get your ‘admin’ user password by running:
printf $(kubectl get secret --namespace default jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode);echo
  1. Get the Jenkins URL to visit by running these commands in the same shell:

NOTE: It may take a few minutes for the LoadBalancer IP to be available. You can watch the status of by running: (remove the “space” charackter between the Curly Brackets!)

kubectl get svc --namespace default -w jenkins
export SERVICE_IP=$(kubectl get svc --namespace default jenkins --template "'{ { range (index .status.loadBalancer.ingress 0) } }{ { . } }{ { end } }'")
echo http://$SERVICE_IP:8080/login

If there is no Loadbalancer IP available you can use the address http://NODE_IP:8080/login

  1. Login with the password from step 1 and the username: admin

–> read the next article: Part 2