فهرست منبع

Jenkins is working; Some dns work on monkeybox

Fred Damstra (k8s1) 2 سال پیش
والد
کامیت
df797bf209

+ 30 - 0
Workloads/jenkins/1.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: default
+
+---
+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: default

+ 35 - 0
Workloads/jenkins/2.volume.yaml

@@ -0,0 +1,35 @@
+---
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+  name: jenkins-pv-volume
+spec:
+  capacity:
+    storage: 10Ti
+  volumeMode: Filesystem
+  accessModes:
+    - ReadWriteMany
+  persistentVolumeReclaimPolicy: Retain # Keep 4eva
+  storageClassName: default
+  mountOptions:
+    - hard
+    - nfsvers=3
+  nfs:
+    path: /mnt/DroboFS/Shares/Kubernetes/volumes/static/jenkins-pv-volume
+    server: 10.42.42.10
+  claimRef:
+    name: jenkins-pv-volume
+    namespace: default
+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: jenkins-pv-claim
+spec:
+  storageClassName: default
+  accessModes:
+    - ReadWriteMany
+  resources:
+    requests:
+      storage: 10Ti
+status: {}

+ 71 - 0
Workloads/jenkins/3.deployment.yaml

@@ -0,0 +1,71 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: jenkins
+  namespace: default
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      run: jenkins
+  template:
+    metadata:
+      labels:
+        run: 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: http
+              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         
+# Initially installed without dnsConfig. We'll see if it's needed.
+#          dnsConfig:
+#           nameservers:
+#             - 10.42.42.239
+#             - 10.42.42.1
+#            searches:
+#              - default.svc.cluster.local
+#              - svc.cluster.local
+#              - cluster.local
+#           options:
+#             - name: ndots
+#               value: "2"
+#             - name: edns0
+#             - name: trust-ad
+      volumes:
+        - name: jenkins-data
+          persistentVolumeClaim:
+              claimName: jenkins-pv-claim

+ 52 - 0
Workloads/jenkins/4.service.yaml

@@ -0,0 +1,52 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: jenkins
+  labels:
+    run: jenkins
+  namespace: default
+  annotations:
+      prometheus.io/scrape: 'true'
+      prometheus.io/path:   /
+      prometheus.io/port:   '8080'
+spec:
+  selector: 
+    run: jenkins
+#    app: jenkins-server
+#  type: NodePort  
+  ports:
+    - name: http
+      port: 80
+      targetPort: 8080
+#      nodePort: 32000
+---
+# Hosting
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  name: jenkins
+  annotations:
+    cert-manager.io/cluster-issuer: "letsencrypt-stage"
+    ## No basic auth for smokeping
+    ## type of authentication
+    #nginx.ingress.kubernetes.io/auth-type: basic
+    ## name of the secret that contains the user/password definitions
+    #nginx.ingress.kubernetes.io/auth-secret: basic-auth
+    ## message to display with an appropriate context why the authentication is required
+    #nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - Octoprint'
+spec:
+  tls:
+  - hosts:
+    - jenkins.monkeybox.org
+    secretName: jenkins-tls
+  rules:
+  - host: jenkins.monkeybox.org
+    http:
+      paths:
+      - path: /
+        pathType: Prefix
+        backend:
+          service:
+            name: jenkins
+            port:
+              number: 80

+ 17 - 0
Workloads/jenkins/4b.service.yaml

@@ -0,0 +1,17 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: jenkins-service
+  namespace: default
+  annotations:
+      prometheus.io/scrape: 'true'
+      prometheus.io/path:   /
+      prometheus.io/port:   '8080'
+spec:
+  selector: 
+    run: jenkins
+  type: NodePort  
+  ports:
+    - port: 8080
+      targetPort: 8080
+      nodePort: 32000

+ 35 - 0
Workloads/jenkins/README.md

@@ -0,0 +1,35 @@
+#
+
+Following directions from https://www.jenkins.io/doc/book/installing/kubernetes/
+
+```
+git clone https://github.com/scriptcamp/kubernetes-jenkins
+cp kubernetes-jenkins/serviceAccount.yaml ./1.serviceAccount.yaml
+vim 1.serviceAccount.yaml
+# Changed namespace to 'default'
+
+kubectl apply -f 1.serviceAccount.yaml
+
+
+cp kubernetes-jenkins/volume.yaml ./2.volume.yaml
+vim 2.volume.yaml
+# More or less changed the whole thing
+
+mkdir /mnt/kubernetes/volumes/static/jenkins-pv-volume
+kubectl apply -f 2.volume.yaml
+
+cp kubernetes-jenkins/deployment.yaml ./3.deployment.yaml
+vim 3.deployment.yaml
+# Change namespace to default
+
+kubectl apply -f 3.deployment.yaml
+# check on status
+
+cp kubernetes-jenkins/service.yaml ./4.service.yaml
+vim 4.service.yaml
+# Change namespace
+# disable NodePort (both lines)
+# Add the Ingress section
+
+### ... much debugging later
+```

+ 8 - 8
Workloads/monkeybox.org/monkeybox.yaml

@@ -102,18 +102,18 @@ spec:
           persistentVolumeClaim:
             claimName: monkeybox
       dnsConfig:
-        nameservers:
-          - 10.42.42.239
-          - 10.42.42.1
+#        nameservers:
+#          - 10.42.42.239
+#          - 10.42.42.1
         searches:
           - default.svc.cluster.local
           - svc.cluster.local 
           - cluster.local
-        options:
-          - name: ndots
-            value: "2"
-          - name: edns0
-          - name: trust-ad
+#        options:
+#          - name: ndots
+#            value: "2"
+#          - name: edns0
+#          - name: trust-ad
 status: {}
 ---
 # Hosting