From d6adeeba2bb3f939eef6ddf68a01a683d86dfe16 Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Sun, 15 Jan 2023 21:14:35 +0100 Subject: [PATCH] Correccioes en Gogs para hacerlo persistente --- Gogs/creaTodo.sh | 1 + Gogs/entra.sh | 1 + Gogs/gogs-deployment.yaml | 69 +++++++++++++++++++++++++++++++++++ Gogs/gogs-statefulset.yaml | 11 ++++++ Gogs/paraTodo.sh | 1 + Gogs/pv-local-gogs.yaml | 11 ++++++ Gogs/pv-local-mysql-gogs.yaml | 4 +- Gogs/pvc-gogs.yaml | 14 +++++++ 8 files changed, 110 insertions(+), 2 deletions(-) create mode 100755 Gogs/entra.sh create mode 100644 Gogs/gogs-deployment.yaml create mode 100644 Gogs/pv-local-gogs.yaml create mode 100644 Gogs/pvc-gogs.yaml diff --git a/Gogs/creaTodo.sh b/Gogs/creaTodo.sh index e00bf4bf..e708baa2 100755 --- a/Gogs/creaTodo.sh +++ b/Gogs/creaTodo.sh @@ -1,4 +1,5 @@ kubectl create namespace gogs kubectl create -f pv-local-mysql-gogs.yaml +kubectl create -f pv-local-gogs.yaml kubectl create -k ./ watch kubectl get all -n gogs diff --git a/Gogs/entra.sh b/Gogs/entra.sh new file mode 100755 index 00000000..b65306a3 --- /dev/null +++ b/Gogs/entra.sh @@ -0,0 +1 @@ +kubectl exec -ti deployment.apps/gogs -n gogs -- /bin/bash diff --git a/Gogs/gogs-deployment.yaml b/Gogs/gogs-deployment.yaml new file mode 100644 index 00000000..38850d04 --- /dev/null +++ b/Gogs/gogs-deployment.yaml @@ -0,0 +1,69 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: gogs-pv-claim + namespace: gogs + labels: + app: gogs-app +spec: + accessModes: + - ReadWriteOnce + storageClassName: "" + resources: + requests: + storage: 10Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: gogs + namespace: gogs + labels: + app: gogs-app +spec: + selector: + matchLabels: + app: gogs-app + tier: frontend + strategy: + type: Recreate + template: + metadata: + labels: + app: gogs-app + tier: frontend + spec: + containers: + - image: gogs/gogs:latest + name: gogs + env: + - name: DB_TYPE + value: mysql + - name: DB_NAME + value: gogs + - name: DB_HOST + value: gogs-mysql + - name: DB_PASS + valueFrom: + secretKeyRef: + name: mysqlgogs-pass + key: password + - name: DB_USER + valueFrom: + secretKeyRef: + name: mysqlgogs-pass + key: db_user + ports: + - containerPort: 3000 + name: http + protocol: TCP + - containerPort: 22 + name: ssh + protocol: TCP + volumeMounts: + - name: gogs-persistent-storage + mountPath: /data + volumes: + - name: gogs-persistent-storage + persistentVolumeClaim: + claimName: gogs-pv-claim diff --git a/Gogs/gogs-statefulset.yaml b/Gogs/gogs-statefulset.yaml index afec62db..bcdc3c34 100644 --- a/Gogs/gogs-statefulset.yaml +++ b/Gogs/gogs-statefulset.yaml @@ -28,6 +28,17 @@ spec: - containerPort: 22 name: ssh protocol: TCP + volumeMounts: + - name: gogs-pv + mountPath: /data dnsPolicy: ClusterFirst restartPolicy: Always terminationGracePeriodSeconds: 30 + volumeClaimTemplates: + - metadata: + name: gogs-pv + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 10Gi diff --git a/Gogs/paraTodo.sh b/Gogs/paraTodo.sh index 02956e82..a140ce42 100755 --- a/Gogs/paraTodo.sh +++ b/Gogs/paraTodo.sh @@ -1,3 +1,4 @@ kubectl delete -k ./ kubectl delete -f pv-local-mysql-gogs.yaml +kubectl delete -f pv-local-gogs.yaml kubectl delete namespace gogs diff --git a/Gogs/pv-local-gogs.yaml b/Gogs/pv-local-gogs.yaml new file mode 100644 index 00000000..95f62ede --- /dev/null +++ b/Gogs/pv-local-gogs.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: gogs-data +spec: + capacity: + storage: 10Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/cluster/gogs/gogs_data" diff --git a/Gogs/pv-local-mysql-gogs.yaml b/Gogs/pv-local-mysql-gogs.yaml index 4566a520..0dc28822 100644 --- a/Gogs/pv-local-mysql-gogs.yaml +++ b/Gogs/pv-local-mysql-gogs.yaml @@ -1,11 +1,11 @@ apiVersion: v1 kind: PersistentVolume metadata: - name: gogs-data + name: gogs-db spec: capacity: storage: 20Gi accessModes: - ReadWriteOnce hostPath: - path: "/mnt/cluster/gogs" + path: "/mnt/cluster/gogs/gogs_db" diff --git a/Gogs/pvc-gogs.yaml b/Gogs/pvc-gogs.yaml new file mode 100644 index 00000000..f35797e8 --- /dev/null +++ b/Gogs/pvc-gogs.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: gogs-pv-claim + namespace: gogs + labels: + app: gogs-app +spec: + accessModes: + - ReadWriteOnce + storageClassName: "" + resources: + requests: + storage: 10Gi