This guide walks you through installing Jenkins in a Kubernetes cluster using Helm, with:
- A pre-created PersistentVolumeClaim (PVC)
- TLS certificate issued by cert-manager
- Custom admin credentials
- Traefik Ingress for public access
- Persistent data even after reinstallation
Prerequisites
- A running Kubernetes cluster (self-managed or on AWS EC2)
helm
andkubectl
installed- Traefik as your Ingress controller
- A
StorageClass
configured (e.g.,ebs-sc
for AWS) - DNS record pointing
jenkins.maksonlee.com
to your cluster’s public IP - Namespace
jenkins
not yet used
- Create a PersistentVolumeClaim
Save this as jenkins-pvc.yaml
:
# jenkins-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: jenkins-pvc
namespace: jenkins
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
storageClassName: ebs-sc
Apply it:
kubectl create namespace jenkins
kubectl apply -f jenkins-pvc.yaml
- Create a TLS Certificate using Cert-Manager
Make sure cert-manager
is installed in your cluster.
# jenkins-cert.yaml
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: jenkins-cert
namespace: jenkins
spec:
secretName: jenkins-tls
commonName: jenkins.maksonlee.com
dnsNames:
- jenkins.maksonlee.com
issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
Ensure that the ClusterIssuer letsencrypt-prod
already exists. If not, you’ll need to create it before applying this certificate.
Apply it:
kubectl apply -f jenkins-cert.yaml
This will create the TLS secret jenkins-tls
, which Jenkins will use for HTTPS access.
- Prepare Helm
values.yaml
Save this as jenkins-values.yaml
:
controller:
initializeOnce: true
additionalPlugins:
- credentials-binding
- cloudbees-folder
- matrix-auth
ingress:
enabled: true
hostName: jenkins.maksonlee.com
tls:
- secretName: jenkins-tls
hosts:
- jenkins.maksonlee.com
persistence:
existingClaim: jenkins-pvc
- Install Jenkins via Helm
Add the Jenkins chart repo:
helm repo add jenkins https://charts.jenkins.io
helm repo update
Install:
helm install jenkins jenkins/jenkins \
-n jenkins \
-f jenkins-values.yaml
Get your ‘admin’ user password by running:
kubectl exec --namespace jenkins -it svc/jenkins -c jenkins -- /bin/cat /run/secrets/additional/chart-admin-password && echo
- Access Jenkins
Once deployed, visit: https://jenkins.maksonlee.com
- Reinstall Without Data Loss
If you uninstall Jenkins:
helm uninstall jenkins -n jenkins
Your PVC (jenkins-pvc
) will still remain. Reinstall using the same steps to retain all your data.