Install Jenkins by Helm to Kubernetes on Azure

Here you can find instructions for installing Jenkins on Kubernetes running on Microsoft Azure. The main advantage of deployment Jenkins on Kubernetes is the automatic scaling of agents.

How to do it?

First of all, you’ll need an account at portal.azure.com. Microsoft provides credit for new registration. If you have MSDN subscription you’ll get some credit which is available at portal my.visualstudio.com.

Software prerequisites:

  • Install Docker Desktop (not Desktop Enterprise). The installation also contains kubectl command from Kubernetes.
  • Install Helm.
  • Install Azure CLI.

Create Kubernetes infrastructure.

az aks create -n kube-jenkins --resource-group kube-jenkins-group \
  --node-count 1 --node-vm-size Standard_B2ms

Retrieve credentials for working with Kubernetes cluster on Azure.

az aks get-credentials -g kube-jenkins-group -n kube-jenkins

Switch to newly created Kubernetes.

kubectl config use-context kube-jenkins

Install Jenkins on Kubernetes by Helm.

helm install jenkins stable/jenkins

Retrieve password for admin user to login to Kubernetes.

printf $(kubectl get secret --namespace default jenkins \
  -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode);echo

Create a tunnel from your computer to Kubernetes cluster. It will allow you to access port 8080 on localhost and the request will be forwarded to Jenkins on Kubernetes. With this command you do not need to install Ingress controller, so the setup is a little bit more secure than exposing Jenkins to internet.

export POD_NAME=$(kubectl get pods --namespace default \
  -l "app.kubernetes.io/component=jenkins-master" \
  -l "app.kubernetes.io/instance=jenkins" -o jsonpath="{.items[0].metadata.name}")
  echo http://127.0.0.1:8080
  kubectl --namespace default port-forward $POD_NAME 8080:8080

Go to web browser and type URL http://localhost:8080

Login is admin and password was retrieved by the command above.

If you’d like to remove Jenkins installation just type:

helm uninstall jenkins
Facebook Comments
Rating: 5.0/5. From 1 vote.
Please wait...

19. December 2019 at 22:41 - Development (Tags: , , , ). Both comments and pings are currently closed.

Comments are closed.