Top Tags

Install Jenkins Helm on Microk8s Metallb

Install Jenkins Helm on Microk8s Metallb

Overview

This guide walks through deploying Jenkins CI/CD on MicroK8s using Helm charts with MetalLB as the load balancer. This setup provides a production-ready Jenkins environment on bare-metal Kubernetes clusters without requiring cloud provider load balancers.

Architecture Components

ComponentPurposeVersion Info
MicroK8sLightweight Kubernetes distributionSingle-node or multi-node cluster
MetalLBBare-metal load balancer implementationLayer 2 or BGP mode
HelmKubernetes package managerv3.x recommended
JenkinsCI/CD automation serverLatest LTS via Helm chart

Prerequisites

Before proceeding, ensure you have:

  • MicroK8s installed and running (microk8s status --wait-ready)
  • User added to microk8s group for non-root access
  • Sufficient resources: minimum 2 CPU cores, 4GB RAM recommended
  • Network access to the IP range you'll assign to MetalLB

Enable MetalLB

MetalLB is a load-balancer implementation for bare-metal Kubernetes clusters. It provides LoadBalancer-type services that would otherwise only work in cloud environments like AWS, GCP, or Azure.

bash
1microk8s enable metallb

During enablement, you'll be prompted to specify an IP address range. Choose IPs from your local network that are not used by DHCP to avoid conflicts.

Full installation with modules go here -> MicroK8s install with Helm and OneDev

Understanding MetalLB Modes

MetalLB supports two announcement modes:

Layer 2 Mode (Default for MicroK8s)

  • Uses ARP/NDP to announce IPs on the local network
  • Simpler setup, no router configuration required
  • Single node handles all traffic for a given IP (failover available)
  • Best for home labs and small deployments

BGP Mode

  • Announces IPs via BGP to network routers
  • True load distribution across nodes
  • Requires BGP-capable router configuration
  • Better for production environments

MetalLB Configuration Resources

After enabling MetalLB, you can customize the IP allocation using Custom Resources:

yaml
1# IPAddressPool defines the range of IPs MetalLB can allocate
2apiVersion: metallb.io/v1beta1
3kind: IPAddressPool
4metadata:
5 name: default-pool
6 namespace: metallb-system
7spec:
8 addresses:
9 - 192.168.1.200-192.168.1.220 # Adjust to your network
10 autoAssign: true
11 avoidBuggyIPs: true # Avoid .0 and .255 addresses
yaml
1# L2Advertisement enables Layer 2 mode for the pool
2apiVersion: metallb.io/v1beta1
3kind: L2Advertisement
4metadata:
5 name: default-l2
6 namespace: metallb-system
7spec:
8 ipAddressPools:
9 - default-pool

Install Helm

Helm is the package manager for Kubernetes, enabling you to define, install, and upgrade complex Kubernetes applications.

bash
1sudo snap install helm --classic

Verify Helm Installation

bash
1helm version

Configure Helm with MicroK8s

If you're using MicroK8s built-in Helm, you can use microk8s helm3 instead. For standalone Helm, ensure kubectl is configured:

bash
1# Export kubeconfig for standalone helm
2mkdir -p ~/.kube
3microk8s config > ~/.kube/config

Install Jenkins

Add the official Jenkins Helm repository and update the local cache:

bash
1helm repo add jenkins https://charts.jenkins.io
2helm repo update

Explore Available Versions

bash
1# List available Jenkins chart versions
2helm search repo jenkins/jenkins --versions | head -20

Deploy Jenkins

bash
1helm install jenkins jenkins/jenkins --namespace jenkins --create-namespace --set controller.serviceType=LoadBalancer

Understanding Deployment Parameters

ParameterValueDescription
jenkins (1st)Release nameHelm release identifier
jenkins/jenkinsChart referenceRepository/chart name
--namespace jenkinsNamespaceKubernetes namespace for isolation
--create-namespaceFlagCreates namespace if not exists
--set controller.serviceType=LoadBalancerOverrideExposes Jenkins via MetalLB

Advanced Deployment with Custom Values

For production deployments, create a values.yaml file for customization:

yaml
1# jenkins-values.yaml - Production configuration example
2controller:
3 # Image configuration
4 image:
5 tag: "lts-jdk17" # Use LTS with JDK 17
6
7 # Resource allocation
8 resources:
9 requests:
10 cpu: "500m"
11 memory: "1Gi"
12 limits:
13 cpu: "2000m"
14 memory: "4Gi"
15
16 # Service configuration for MetalLB
17 serviceType: LoadBalancer
18 servicePort: 8080
19
20 # Admin configuration
21 admin:
22 username: admin
23 # Password will be auto-generated if not specified
24
25 # Install essential plugins
26 installPlugins:
27 - kubernetes:latest
28 - workflow-aggregator:latest
29 - git:latest
30 - configuration-as-code:latest
31 - job-dsl:latest
32 - blueocean:latest
33
34 # JCasC - Jenkins Configuration as Code
35 JCasC:
36 defaultConfig: true
37 configScripts:
38 welcome-message: |
39 jenkins:
40 systemMessage: "Jenkins configured via Helm on MicroK8s"
41
42# Persistence configuration
43persistence:
44 enabled: true
45 size: 10Gi
46 storageClass: "microk8s-hostpath" # Use MicroK8s storage
47
48# Agent configuration for Kubernetes
49agent:
50 enabled: true
51 image:
52 repository: jenkins/inbound-agent
53 tag: "latest"
54 resources:
55 requests:
56 cpu: "256m"
57 memory: "256Mi"
58 limits:
59 cpu: "512m"
60 memory: "512Mi"

Deploy with custom values:

bash
1helm install jenkins jenkins/jenkins \
2 --namespace jenkins \
3 --create-namespace \
4 -f jenkins-values.yaml

Enable Required MicroK8s Addons

For full Jenkins functionality, enable these addons:

bash
1# Enable persistent storage for Jenkins data
2microk8s enable hostpath-storage
3
4# Enable DNS for service discovery
5microk8s enable dns
6
7# Enable RBAC for security (usually enabled by default)
8microk8s enable rbac

Get IP

bash
1kubectl get services -n jenkins

Expected Output

plaintext
1NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
2jenkins LoadBalancer 10.152.183.45 192.168.1.200 8080:32000/TCP 2m
3jenkins-agent ClusterIP 10.152.183.89 <none> 50000/TCP 2m

The EXTERNAL-IP is provided by MetalLB and is accessible from your local network.

Verify MetalLB IP Assignment

bash
1# Check MetalLB speaker logs for IP announcement
2kubectl logs -n metallb-system -l app=metallb,component=speaker --tail=50

Get password

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

Access Jenkins

  1. Open your browser and navigate to: http://<EXTERNAL-IP>:8080
  2. Login with:
    • Username: admin
    • Password: The output from the command above

Post-Installation Configuration

Verify Jenkins Pod Health

bash
1# Check pod status
2kubectl get pods -n jenkins -w
3
4# View Jenkins startup logs
5kubectl logs -n jenkins -l app.kubernetes.io/name=jenkins -f

Configure Jenkins Kubernetes Plugin

Jenkins automatically configures the Kubernetes plugin when deployed via Helm. Verify the cloud configuration:

  1. Navigate to Manage JenkinsClouds
  2. Verify Kubernetes cloud is configured
  3. Test connection to the cluster

Backup and Recovery

Jenkins data is stored in a PersistentVolume. To backup:

bash
1# Get PVC information
2kubectl get pvc -n jenkins
3
4# Create a backup job (example using kubectl cp)
5kubectl cp jenkins/jenkins-0:/var/jenkins_home ./jenkins-backup

Troubleshooting

MetalLB Not Assigning IP

bash
1# Check MetalLB controller status
2kubectl get pods -n metallb-system
3
4# Verify IPAddressPool configuration
5kubectl get ipaddresspools -n metallb-system -o yaml
6
7# Check for conflicts in IP range
8kubectl describe service jenkins -n jenkins

Jenkins Pod Not Starting

bash
1# Check pod events
2kubectl describe pod -n jenkins -l app.kubernetes.io/name=jenkins
3
4# Check for resource constraints
5kubectl top nodes
6
7# View init container logs
8kubectl logs -n jenkins jenkins-0 -c init

Helm Release Issues

bash
1# List Helm releases
2helm list -n jenkins
3
4# View release history
5helm history jenkins -n jenkins
6
7# Rollback if needed
8helm rollback jenkins <revision> -n jenkins

Cleanup

To completely remove Jenkins and associated resources:

bash
1# Uninstall Helm release
2helm uninstall jenkins -n jenkins
3
4# Delete namespace (removes PVC and all resources)
5kubectl delete namespace jenkins
6
7# Optional: Disable MetalLB if no longer needed
8microk8s disable metallb