diff --git a/Makefile b/Makefile index 116024e..c599486 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,9 @@ install: -kubectl create -f reg-secret.yaml -kubectl create -f jenkins-10-serviceAccount.yaml - -kubectl create -f jenkins-20-storage-class.yaml +# -kubectl create -f jenkins-20-storage-class.yaml -kubectl create -f jenkins-21-pvc.yaml - -kubectl create -f jenkins-25-volume.yaml +# -kubectl create -f jenkins-25-volume.yaml -envsubst < jenkins-30-deployment.yaml |kubectl create -f - -kubectl create -f jenkins-40-service.yaml -kubectl create -f jenkins-50-ingress.yaml @@ -24,9 +24,9 @@ clean: -kubectl delete -f jenkins-50-ingress.yaml -kubectl delete -f jenkins-40-service.yaml -envsubst < jenkins-30-deployment.yaml |kubectl delete -f - - -kubectl delete -f jenkins-25-volume.yaml +# -kubectl delete -f jenkins-25-volume.yaml -kubectl delete -f jenkins-21-pvc.yaml - -kubectl delete -f jenkins-20-storage-class.yaml +# -kubectl delete -f jenkins-20-storage-class.yaml -kubectl delete -f jenkins-10-serviceAccount.yaml -kubectl delete -f reg-secret.yaml -kubectl delete -f jenkins-05-namespace.yaml diff --git a/README.md b/README.md index 726ec6e..942a336 100644 --- a/README.md +++ b/README.md @@ -2,27 +2,12 @@ Refer https://devopscube.com/setup-jenkins-on-kubernetes-cluster/ for step by step process to use these manifests. -## Node Afinity +## local-path -En el fichero +https://weng-albert.medium.com/storageclass-local-path-provider-en-961eca8699d4 - jenkins-02-volume.yaml +el local-path-storage se ha de crear después de instalar el cluster. Crea la storageclass también. -hay que ajustar el nombre del nodo - - nodeAffinity: - required: - nodeSelectorTerms: - - matchExpressions: - - key: kubernetes.io/hostname - operator: In - values: - - imac - -El nombre del nodo se obtiene con - - kubectl get nodes - ## Rancher Desktop para que Ingress funcione en Rancher Desktop, hay que quitar Traefik e instalar Nginx. diff --git a/jenkins-20-storage-class.yaml b/jenkins-20-storage-class.yaml index 75615c3..7d75fb2 100644 --- a/jenkins-20-storage-class.yaml +++ b/jenkins-20-storage-class.yaml @@ -2,5 +2,5 @@ kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: local-path -provisioner: kubernetes.io/no-provisioner +provisioner: kubernetes.io/storage-provisioner volumeBindingMode: WaitForFirstConsumer diff --git a/jenkins-30-deployment.yaml b/jenkins-30-deployment.yaml index f200769..9a62124 100644 --- a/jenkins-30-deployment.yaml +++ b/jenkins-30-deployment.yaml @@ -19,8 +19,8 @@ spec: serviceAccountName: jenkins-admin containers: - name: jenkins - # image: jenkins/jenkins:lts - image: $REGISTRY/jenkins-docker:$IMG_VERSION + image: jenkins/jenkins:lts + # image: $REGISTRY/jenkins-docker:$IMG_VERSION # OPTIONAL: check for new floating-tag LTS releases whenever the pod is restarted: imagePullPolicy: Always resources: diff --git a/lpp/local-path-storage.yaml b/lpp/local-path-storage.yaml new file mode 100644 index 0000000..b7c8f06 --- /dev/null +++ b/lpp/local-path-storage.yaml @@ -0,0 +1,130 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: local-path-storage + +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: local-path-provisioner-service-account + namespace: local-path-storage + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: local-path-provisioner-role +rules: + - apiGroups: [ "" ] + resources: [ "nodes", "persistentvolumeclaims", "configmaps" ] + verbs: [ "get", "list", "watch" ] + - apiGroups: [ "" ] + resources: [ "endpoints", "persistentvolumes", "pods" ] + verbs: [ "*" ] + - apiGroups: [ "" ] + resources: [ "events" ] + verbs: [ "create", "patch" ] + - apiGroups: [ "storage.k8s.io" ] + resources: [ "storageclasses" ] + verbs: [ "get", "list", "watch" ] + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: local-path-provisioner-bind +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: local-path-provisioner-role +subjects: + - kind: ServiceAccount + name: local-path-provisioner-service-account + namespace: local-path-storage + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: local-path-provisioner + namespace: local-path-storage +spec: + replicas: 1 + selector: + matchLabels: + app: local-path-provisioner + template: + metadata: + labels: + app: local-path-provisioner + spec: + serviceAccountName: local-path-provisioner-service-account + containers: + - name: local-path-provisioner + image: rancher/local-path-provisioner:v0.0.24 + imagePullPolicy: IfNotPresent + command: + - local-path-provisioner + - --debug + - start + - --config + - /etc/config/config.json + volumeMounts: + - name: config-volume + mountPath: /etc/config/ + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + volumes: + - name: config-volume + configMap: + name: local-path-config + +--- +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: local-path +provisioner: rancher.io/local-path +volumeBindingMode: WaitForFirstConsumer +reclaimPolicy: Delete + +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: local-path-config + namespace: local-path-storage +data: + config.json: |- + { + "nodePathMap":[ + { + "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES", + "paths":["/opt/local-path-provisioner"] + } + ] + } + setup: |- + #!/bin/sh + set -eu + mkdir -m 0777 -p "$VOL_DIR" + teardown: |- + #!/bin/sh + set -eu + rm -rf "$VOL_DIR" + helperPod.yaml: |- + apiVersion: v1 + kind: Pod + metadata: + name: helper-pod + spec: + containers: + - name: helper-pod + image: busybox + imagePullPolicy: IfNotPresent + + diff --git a/lpp/pod.yaml b/lpp/pod.yaml new file mode 100644 index 0000000..2ca8ca9 --- /dev/null +++ b/lpp/pod.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Pod +metadata: + name: volume-test +spec: + containers: + - name: volume-test + image: nginx:stable-alpine + imagePullPolicy: IfNotPresent + volumeMounts: + - name: volv + mountPath: /data + ports: + - containerPort: 80 + volumes: + - name: volv + persistentVolumeClaim: + claimName: local-path-pvc diff --git a/lpp/pvc.yaml b/lpp/pvc.yaml new file mode 100644 index 0000000..b38d2c3 --- /dev/null +++ b/lpp/pvc.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: local-path-pvc +spec: + accessModes: + - ReadWriteOnce + storageClassName: local-path + resources: + requests: + storage: 128Mi