diff --git a/jenkins-k8s b/jenkins-k8s deleted file mode 160000 index 0c3fba1..0000000 --- a/jenkins-k8s +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0c3fba187adbc96c78d9c1dc60e11cdd176ca45b diff --git a/jenkins-k8s/deployment.yaml b/jenkins-k8s/deployment.yaml new file mode 100644 index 0000000..6cd7b9c --- /dev/null +++ b/jenkins-k8s/deployment.yaml @@ -0,0 +1,123 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: jenkins + namespace: common +spec: + replicas: 1 + selector: + matchLabels: + app: jenkins + template: + metadata: + labels: + app: jenkins + 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-pvc-local + +--- +apiVersion: v1 +kind: Service +metadata: + name: jenkins + namespace: common + annotations: + prometheus.io/scrape: 'true' + prometheus.io/path: / + prometheus.io/port: '8080' +spec: + selector: + app: jenkins + type: NodePort + ports: + - port: 8080 + targetPort: 8080 + nodePort: 30080 +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-local + labels: + type: local +spec: + storageClassName: local-storage + claimRef: + name: jenkins-pvc-local + namespace: common + capacity: + storage: 20Gi + accessModes: + - ReadWriteOnce + local: + path: /data/jenkins + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - bfs-k8snode-10-2-0-10.hetzner.base.beaconfireinc.com + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: jenkins-pvc-local + namespace: common +spec: + storageClassName: local-storage + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 3Gi diff --git a/jenkins-k8s/serviceAccount.yaml b/jenkins-k8s/serviceAccount.yaml new file mode 100644 index 0000000..1747d74 --- /dev/null +++ b/jenkins-k8s/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: common + +--- +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: common