Browse Source

local-path-storage creado

main
Celestino Rey 6 months ago
parent
commit
75b914f76d
7 changed files with 169 additions and 25 deletions
  1. +4
    -4
      Makefile
  2. +3
    -18
      README.md
  3. +1
    -1
      jenkins-20-storage-class.yaml
  4. +2
    -2
      jenkins-30-deployment.yaml
  5. +130
    -0
      lpp/local-path-storage.yaml
  6. +18
    -0
      lpp/pod.yaml
  7. +11
    -0
      lpp/pvc.yaml

+ 4
- 4
Makefile View File

@ -13,9 +13,9 @@ install:
-kubectl create -f reg-secret.yaml -kubectl create -f reg-secret.yaml
-kubectl create -f jenkins-10-serviceAccount.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-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 - -envsubst < jenkins-30-deployment.yaml |kubectl create -f -
-kubectl create -f jenkins-40-service.yaml -kubectl create -f jenkins-40-service.yaml
-kubectl create -f jenkins-50-ingress.yaml -kubectl create -f jenkins-50-ingress.yaml
@ -24,9 +24,9 @@ clean:
-kubectl delete -f jenkins-50-ingress.yaml -kubectl delete -f jenkins-50-ingress.yaml
-kubectl delete -f jenkins-40-service.yaml -kubectl delete -f jenkins-40-service.yaml
-envsubst < jenkins-30-deployment.yaml |kubectl delete -f - -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-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 jenkins-10-serviceAccount.yaml
-kubectl delete -f reg-secret.yaml -kubectl delete -f reg-secret.yaml
-kubectl delete -f jenkins-05-namespace.yaml -kubectl delete -f jenkins-05-namespace.yaml

+ 3
- 18
README.md View File

@ -2,27 +2,12 @@
Refer https://devopscube.com/setup-jenkins-on-kubernetes-cluster/ for step by step process to use these manifests. 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 ## Rancher Desktop
para que Ingress funcione en Rancher Desktop, hay que quitar Traefik e instalar Nginx. para que Ingress funcione en Rancher Desktop, hay que quitar Traefik e instalar Nginx.


+ 1
- 1
jenkins-20-storage-class.yaml View File

@ -2,5 +2,5 @@ kind: StorageClass
apiVersion: storage.k8s.io/v1 apiVersion: storage.k8s.io/v1
metadata: metadata:
name: local-path name: local-path
provisioner: kubernetes.io/no-provisioner
provisioner: kubernetes.io/storage-provisioner
volumeBindingMode: WaitForFirstConsumer volumeBindingMode: WaitForFirstConsumer

+ 2
- 2
jenkins-30-deployment.yaml View File

@ -19,8 +19,8 @@ spec:
serviceAccountName: jenkins-admin serviceAccountName: jenkins-admin
containers: containers:
- name: jenkins - 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: # OPTIONAL: check for new floating-tag LTS releases whenever the pod is restarted:
imagePullPolicy: Always imagePullPolicy: Always
resources: resources:


+ 130
- 0
lpp/local-path-storage.yaml View File

@ -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

+ 18
- 0
lpp/pod.yaml View File

@ -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

+ 11
- 0
lpp/pvc.yaml View File

@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: local-path-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-path
resources:
requests:
storage: 128Mi

Loading…
Cancel
Save