From fb0f8d7b507eba228bfca80384189da8421c54da Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 6 Mar 2025 12:03:57 +0100 Subject: [PATCH 1/4] Rename YAML manifests so they are numbered in order of application Signed-off-by: Jim Klimov --- namespace.yaml => jenkins-00-namespace.yaml | 0 serviceAccount.yaml => jenkins-01-serviceAccount.yaml | 0 volume.yaml => jenkins-02-volume.yaml | 0 deployment.yaml => jenkins-03-deployment.yaml | 0 service.yaml => jenkins-04-service.yaml | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename namespace.yaml => jenkins-00-namespace.yaml (100%) rename serviceAccount.yaml => jenkins-01-serviceAccount.yaml (100%) rename volume.yaml => jenkins-02-volume.yaml (100%) rename deployment.yaml => jenkins-03-deployment.yaml (100%) rename service.yaml => jenkins-04-service.yaml (100%) diff --git a/namespace.yaml b/jenkins-00-namespace.yaml similarity index 100% rename from namespace.yaml rename to jenkins-00-namespace.yaml diff --git a/serviceAccount.yaml b/jenkins-01-serviceAccount.yaml similarity index 100% rename from serviceAccount.yaml rename to jenkins-01-serviceAccount.yaml diff --git a/volume.yaml b/jenkins-02-volume.yaml similarity index 100% rename from volume.yaml rename to jenkins-02-volume.yaml diff --git a/deployment.yaml b/jenkins-03-deployment.yaml similarity index 100% rename from deployment.yaml rename to jenkins-03-deployment.yaml diff --git a/service.yaml b/jenkins-04-service.yaml similarity index 100% rename from service.yaml rename to jenkins-04-service.yaml From b474749515372bb2bd0d76167d6263fa18459af6 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 6 Mar 2025 12:04:35 +0100 Subject: [PATCH 2/4] README.md: reference upstream Jenkins variant of the instructions Signed-off-by: Jim Klimov --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 26ab198..630bc6f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # Kubernetes Manifests for Jenkins Deployment -Refer https://devopscube.com/setup-jenkins-on-kubernetes-cluster/ for step by step process to use these manifests. \ No newline at end of file +Refer to https://devopscube.com/setup-jenkins-on-kubernetes-cluster/ for step-by-step process to use these manifests. + +A variant is maintained as https://www.jenkins.io/doc/book/installing/kubernetes/ instructions. From 414e3f9782731035d357a2a8797d77eadf28a8ad Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 6 Mar 2025 12:06:53 +0100 Subject: [PATCH 3/4] Provide symlinks from numbered-ordered YAML file names to ones used in older documentation revisions Signed-off-by: Jim Klimov --- deployment.yaml | 57 +++++++++++++++++++++++++++++++++++++++++++++ namespace.yaml | 4 ++++ service.yaml | 17 ++++++++++++++ serviceAccount.yaml | 30 ++++++++++++++++++++++++ volume.yaml | 47 +++++++++++++++++++++++++++++++++++++ 5 files changed, 155 insertions(+) create mode 100644 deployment.yaml create mode 100644 namespace.yaml create mode 100644 service.yaml create mode 100644 serviceAccount.yaml create mode 100644 volume.yaml diff --git a/deployment.yaml b/deployment.yaml new file mode 100644 index 0000000..0efa08d --- /dev/null +++ b/deployment.yaml @@ -0,0 +1,57 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: jenkins + namespace: devops-tools +spec: + replicas: 1 + selector: + matchLabels: + app: jenkins-server + template: + metadata: + labels: + app: jenkins-server + spec: + securityContext: + fsGroup: 1000 + runAsUser: 1000 + serviceAccountName: jenkins-admin + containers: + - name: jenkins + image: jenkins/jenkins:lts + resources: + limits: + memory: "2Gi" + cpu: "1000m" + requests: + memory: "500Mi" + cpu: "500m" + ports: + - name: httpport + containerPort: 8080 + - name: jnlpport + containerPort: 50000 + livenessProbe: + httpGet: + path: "/login" + port: 8080 + initialDelaySeconds: 90 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 5 + readinessProbe: + httpGet: + path: "/login" + port: 8080 + initialDelaySeconds: 60 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 + volumeMounts: + - name: jenkins-data + mountPath: /var/jenkins_home + volumes: + - name: jenkins-data + persistentVolumeClaim: + claimName: jenkins-pv-claim \ No newline at end of file diff --git a/namespace.yaml b/namespace.yaml new file mode 100644 index 0000000..b16f0c3 --- /dev/null +++ b/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: devops-tools diff --git a/service.yaml b/service.yaml new file mode 100644 index 0000000..8a37798 --- /dev/null +++ b/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: jenkins-service + namespace: devops-tools + annotations: + prometheus.io/scrape: 'true' + prometheus.io/path: / + prometheus.io/port: '8080' +spec: + selector: + app: jenkins-server + type: NodePort + ports: + - port: 8080 + targetPort: 8080 + nodePort: 32000 \ No newline at end of file diff --git a/serviceAccount.yaml b/serviceAccount.yaml new file mode 100644 index 0000000..75245c1 --- /dev/null +++ b/serviceAccount.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: jenkins-admin +rules: + - apiGroups: [""] + resources: ["*"] + verbs: ["*"] + +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: jenkins-admin + namespace: devops-tools + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: jenkins-admin +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: jenkins-admin +subjects: +- kind: ServiceAccount + name: jenkins-admin + namespace: devops-tools \ No newline at end of file diff --git a/volume.yaml b/volume.yaml new file mode 100644 index 0000000..edbaf33 --- /dev/null +++ b/volume.yaml @@ -0,0 +1,47 @@ +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: local-storage +provisioner: kubernetes.io/no-provisioner +volumeBindingMode: WaitForFirstConsumer + +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: jenkins-pv-volume + labels: + type: local +spec: + storageClassName: local-storage + claimRef: + name: jenkins-pv-claim + namespace: devops-tools + capacity: + storage: 10Gi + accessModes: + - ReadWriteOnce + local: + path: /mnt + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - worker-node01 + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: jenkins-pv-claim + namespace: devops-tools +spec: + storageClassName: local-storage + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 3Gi \ No newline at end of file From f95530742d74f9ce59793c082c3960e7658cda32 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 6 Mar 2025 12:25:16 +0100 Subject: [PATCH 4/4] jenkins-03-deployment.yaml: suggest "imagePullPolicy: Always" to optionally check for new floating-tag LTS releases whenever the pod is restarted Signed-off-by: Jim Klimov --- jenkins-03-deployment.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jenkins-03-deployment.yaml b/jenkins-03-deployment.yaml index 0efa08d..e2cdf8b 100644 --- a/jenkins-03-deployment.yaml +++ b/jenkins-03-deployment.yaml @@ -20,6 +20,8 @@ spec: containers: - name: jenkins image: jenkins/jenkins:lts + # OPTIONAL: check for new floating-tag LTS releases whenever the pod is restarted: + imagePullPolicy: Always resources: limits: memory: "2Gi"