Simple Kubernetes deployment with Jenkins! And my first experience with Jenkins.
$ minikube start --cpus 5 --memory 10240MB --driver docker
you can use other cni(flannel, calico) and drivers(kvm2, vmware)
For setup proxy for docker:
--docker-env http_proxy=http://proxy.example.org:3128 --docker-env https_proxy=http://proxy.example.org:3128 --docker-env no_proxy=*.test.example.com,.example2.com,localhost,127.0.0.1,10.96.0.0/12,192.168.59.0/24,192.168.39.0/24,registry,local,registry.local
I need proxy for downloading images and tools
minikube addons:
Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster. Traffic routing is controlled by rules defined on the Ingress resource. We use ingress-nginx.
$ minikube addons enable ingress
Registry stores and lets you distribute Docker images.
- tightly control where your images are being stored
- fully own your images distribution pipeline
- integrate image storage and distribution tightly into your in-house development workflow
$ minikube addons enable registry
Metrics Server collects resource metrics from Kubelets and exposes them in Kubernetes apiserver through Metrics API for use by Horizontal Pod Autoscaler and Vertical Pod Autoscaler. we need it on one of the scale solutions.
$ minikube addons enable metrics-server
Jenkins is an open source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery. We can find jenkins Helm Value in jenkins subdirectory. and deploy it on kubernetes. for more information see here.
kubectl create namespace jenkins
Configure Helm Once Helm is installed and set up properly, add the Jenkins repo as follows:
$ helm repo add jenkinsci https://charts.jenkins.io
$ helm repo update
Apply some raw manifests:
kubectl apply -f jenkins/jenkins-volume.yaml
kubectl apply -f jenkins/jenkins-sa.yaml
Now you can install Jenkins by running the helm install command and passing it the following arguments:
helm upgrade --install jenkins -n jenkins -f jenkins/values.yaml jenkinsci/jenkins
You can find Jenkins configuration in jenkins/values.yaml
. I use Jcasc for persist configuration and for Infrastructure as code aproche. below I explain why we have a pipeline for each project in the Jcasc. see here.
To access your Jenkins server, you must retrieve the password. You can retrieve your password using either of the two options below.
kubectl get secret -n jenkins jenkins -o jsonpath={.data.jenkins-admin-username} | base64 --decode
kubectl get secret -n jenkins jenkins -o jsonpath={.data.jenkins-admin-password} | base64 --decode
To make Jenkins accessible outside the Kubernetes cluster for test you can use port-forwarding. for production you can enable ingress and set domain and etc.
kubectl port-forward svc/jenkins 8080:8080 --address 0.0.0.0 -n jenkins
Made by Arman Absalan (@armanaxh)