From fcbf741ed79408e07e60510f8eb921fc260e3bef Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Fri, 30 May 2025 12:48:03 +0200 Subject: [PATCH] Preparo para fleet --- JugarAlPadel/Fleet/db-deployment.yaml | 52 ++++++++++++ JugarAlPadel/Fleet/db-service.yaml | 17 ++++ JugarAlPadel/Fleet/env-prod-configmap.yaml | 11 +++ JugarAlPadel/Fleet/env-prod-db-configmap.yaml | 11 +++ .../Fleet/jugaralpadel-deployment.yaml | 84 +++++++++++++++++++ JugarAlPadel/Fleet/jugaralpadel-ingress.yaml | 31 +++++++ JugarAlPadel/Fleet/namespace.yaml | 7 ++ JugarAlPadel/Fleet/nginx-deployment.yaml | 46 ++++++++++ JugarAlPadel/Fleet/nginx-service.yaml | 20 +++++ JugarAlPadel/Fleet/pv-local-jugaralpadel.yaml | 74 ++++++++++++++++ JugarAlPadel/Fleet/pvc-jugaralpadel.yaml | 47 +++++++++++ JugarAlPadel/Fleet/pvc-postgresql.yaml | 13 +++ JugarAlPadel/Fleet/pvc-static.yaml | 13 +++ JugarAlPadel/Fleet/reg-secret.yaml | 8 ++ JugarAlPadel/K8S/Makefile | 20 +++-- 15 files changed, 449 insertions(+), 5 deletions(-) create mode 100644 JugarAlPadel/Fleet/db-deployment.yaml create mode 100644 JugarAlPadel/Fleet/db-service.yaml create mode 100644 JugarAlPadel/Fleet/env-prod-configmap.yaml create mode 100644 JugarAlPadel/Fleet/env-prod-db-configmap.yaml create mode 100644 JugarAlPadel/Fleet/jugaralpadel-deployment.yaml create mode 100644 JugarAlPadel/Fleet/jugaralpadel-ingress.yaml create mode 100644 JugarAlPadel/Fleet/namespace.yaml create mode 100644 JugarAlPadel/Fleet/nginx-deployment.yaml create mode 100644 JugarAlPadel/Fleet/nginx-service.yaml create mode 100644 JugarAlPadel/Fleet/pv-local-jugaralpadel.yaml create mode 100644 JugarAlPadel/Fleet/pvc-jugaralpadel.yaml create mode 100644 JugarAlPadel/Fleet/pvc-postgresql.yaml create mode 100644 JugarAlPadel/Fleet/pvc-static.yaml create mode 100644 JugarAlPadel/Fleet/reg-secret.yaml diff --git a/JugarAlPadel/Fleet/db-deployment.yaml b/JugarAlPadel/Fleet/db-deployment.yaml new file mode 100644 index 0000000..140946a --- /dev/null +++ b/JugarAlPadel/Fleet/db-deployment.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.34.0 (cbf2835db) + labels: + io.kompose.service: postgresql + name: postgresql + namespace: jugaralpadel +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: postgresql + strategy: + type: Recreate + template: + metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.34.0 (cbf2835db) + labels: + io.kompose.service: postgresql + spec: + containers: + - env: + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + key: POSTGRES_DB + name: env-prod-db + - name: POSTGRES_PASSWORD + valueFrom: + configMapKeyRef: + key: POSTGRES_PASSWORD + name: env-prod-db + - name: POSTGRES_USER + valueFrom: + configMapKeyRef: + key: POSTGRES_USER + name: env-prod-db + image: postgres:15 + name: postgresql + volumeMounts: + - mountPath: /var/lib/postgresql/data + name: postgres-data + restartPolicy: Always + volumes: + - name: postgres-data + persistentVolumeClaim: + claimName: postgres-data diff --git a/JugarAlPadel/Fleet/db-service.yaml b/JugarAlPadel/Fleet/db-service.yaml new file mode 100644 index 0000000..01920b1 --- /dev/null +++ b/JugarAlPadel/Fleet/db-service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.34.0 (cbf2835db) + labels: + io.kompose.service: postgresql + name: postgresql + namespace: jugaralpadel +spec: + ports: + - name: "5432" + port: 5432 + targetPort: 5432 + selector: + io.kompose.service: postgresql diff --git a/JugarAlPadel/Fleet/env-prod-configmap.yaml b/JugarAlPadel/Fleet/env-prod-configmap.yaml new file mode 100644 index 0000000..67e2f1d --- /dev/null +++ b/JugarAlPadel/Fleet/env-prod-configmap.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +data: + DEBUG: "False" + APP_VERSION: 14.0.1 + DATABASE: postgres +kind: ConfigMap +metadata: + labels: + io.kompose.service: web-env-prod + name: env-prod + namespace: jugaralpadel diff --git a/JugarAlPadel/Fleet/env-prod-db-configmap.yaml b/JugarAlPadel/Fleet/env-prod-db-configmap.yaml new file mode 100644 index 0000000..9fab4a9 --- /dev/null +++ b/JugarAlPadel/Fleet/env-prod-db-configmap.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +data: + POSTGRES_DB: jugaralpadel + POSTGRES_PASSWORD: Dsa-0213 + POSTGRES_USER: creylopez +kind: ConfigMap +metadata: + labels: + io.kompose.service: db-env-prod-db + name: env-prod-db + namespace: jugaralpadel diff --git a/JugarAlPadel/Fleet/jugaralpadel-deployment.yaml b/JugarAlPadel/Fleet/jugaralpadel-deployment.yaml new file mode 100644 index 0000000..e8e9d5d --- /dev/null +++ b/JugarAlPadel/Fleet/jugaralpadel-deployment.yaml @@ -0,0 +1,84 @@ +apiVersion: v1 +kind: Service +metadata: + name: jugaralpadel + namespace: jugaralpadel +spec: + ports: + - name: "8000" + port: 8000 + targetPort: 8000 + selector: + app: jugaralpadel +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: jugaralpadel + namespace: jugaralpadel + labels: + app: jugaralpadel +spec: + replicas: 1 + selector: + matchLabels: + app: jugaralpadel + strategy: + type: Recreate + template: + metadata: + labels: + app: jugaralpadel + spec: + containers: + - args: + - gunicorn + - gestion_reservas.wsgi:application + - --bind + - 0.0.0.0:8000 + name: jugaralpadel + image: registry.reymota.es/jugaralpadel-x86_64:0.70.37 + env: + - name: IMG_VERSION + value: "0.70.37" + - name: DEBUG + valueFrom: + configMapKeyRef: + key: DEBUG + name: env-prod + - name: APP_VERSION + valueFrom: + configMapKeyRef: + key: APP_VERSION + name: env-prod + ports: + - containerPort: 8000 + protocol: TCP + volumeMounts: + - mountPath: /app/gestion_reservas/mediafiles + name: jugaralpadel-media + + - mountPath: /app/gestion_reservas/eventos/migrations + name: jugaralpadel-eventos-migrations + - mountPath: /app/gestion_reservas/reymotausers/migrations + name: jugaralpadel-reymotausers-migrations + + - mountPath: /app/gestion_reservas/staticfiles + name: static-volume + imagePullSecrets: + - name: myregistrykey + restartPolicy: Always + volumes: + - name: jugaralpadel-media + persistentVolumeClaim: + claimName: jugaralpadel-media + - name: jugaralpadel-eventos-migrations + persistentVolumeClaim: + claimName: jugaralpadel-eventos-migrations + - name: jugaralpadel-reymotausers-migrations + persistentVolumeClaim: + claimName: jugaralpadel-reymotausers-migrations + - name: static-volume + persistentVolumeClaim: + claimName: static-volume +status: {} diff --git a/JugarAlPadel/Fleet/jugaralpadel-ingress.yaml b/JugarAlPadel/Fleet/jugaralpadel-ingress.yaml new file mode 100644 index 0000000..de00442 --- /dev/null +++ b/JugarAlPadel/Fleet/jugaralpadel-ingress.yaml @@ -0,0 +1,31 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + generation: 1 + managedFields: + - apiVersion: networking.k8s.io/v1 + fieldsType: FieldsV1 + fieldsV1: + f:spec: + f:defaultBackend: + .: {} + f:service: + .: {} + f:name: {} + f:port: {} + f:rules: {} + manager: rancher + operation: Update + name: jugaralpadel + namespace: jugaralpadel +spec: + defaultBackend: + service: + name: nginx + port: + number: 1337 + ingressClassName: nginx + rules: + - host: jugaralpadel.rancher.reymota.lab +status: + loadBalancer: {} diff --git a/JugarAlPadel/Fleet/namespace.yaml b/JugarAlPadel/Fleet/namespace.yaml new file mode 100644 index 0000000..edba458 --- /dev/null +++ b/JugarAlPadel/Fleet/namespace.yaml @@ -0,0 +1,7 @@ +################################################### +# Namespace jugaralpadel +################################################### +apiVersion: v1 +kind: Namespace +metadata: + name: jugaralpadel diff --git a/JugarAlPadel/Fleet/nginx-deployment.yaml b/JugarAlPadel/Fleet/nginx-deployment.yaml new file mode 100644 index 0000000..a91d259 --- /dev/null +++ b/JugarAlPadel/Fleet/nginx-deployment.yaml @@ -0,0 +1,46 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.34.0 (cbf2835db) + labels: + io.kompose.service: nginx + name: nginx + namespace: jugaralpadel +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: nginx + strategy: + type: Recreate + template: + metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.34.0 (cbf2835db) + labels: + io.kompose.service: nginx + spec: + containers: + - image: registry.reymota.es/nginx-jugaralpadel-x86_64:2.3 + name: nginx + ports: + - containerPort: 80 + protocol: TCP + volumeMounts: + - mountPath: /app/gestion_reservas/staticfiles + name: static-volume + - mountPath: /app/gestion_reservas/mediafiles + name: jugaralpadel-media + imagePullSecrets: + - name: myregistrykey + restartPolicy: Always + volumes: + - name: static-volume + persistentVolumeClaim: + claimName: static-volume + - name: jugaralpadel-media + persistentVolumeClaim: + claimName: jugaralpadel-media diff --git a/JugarAlPadel/Fleet/nginx-service.yaml b/JugarAlPadel/Fleet/nginx-service.yaml new file mode 100644 index 0000000..1acf4a8 --- /dev/null +++ b/JugarAlPadel/Fleet/nginx-service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.34.0 (cbf2835db) + labels: + io.kompose.service: nginx + name: nginx + namespace: jugaralpadel +spec: + type: NodePort + ports: + - name: "1337" + port: 1337 + nodePort: 30345 + targetPort: 80 + selector: + io.kompose.service: nginx + diff --git a/JugarAlPadel/Fleet/pv-local-jugaralpadel.yaml b/JugarAlPadel/Fleet/pv-local-jugaralpadel.yaml new file mode 100644 index 0000000..5b4aa9d --- /dev/null +++ b/JugarAlPadel/Fleet/pv-local-jugaralpadel.yaml @@ -0,0 +1,74 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: jugaralpadel-media-folder + namespace: jugaralpadel + labels: + app: jugaralpadel +spec: + capacity: + storage: 100Mi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/Externo/jugaralpadel/media" +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: jugaralpadel-eventos-migrations-folder + namespace: jugaralpadel + labels: + app: jugaralpadel +spec: + capacity: + storage: 50Mi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/Externo/jugaralpadel/migrations/eventos" +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: jugaralpadel-reymotausers-migrations-folder + namespace: jugaralpadel + labels: + app: jugaralpadel +spec: + capacity: + storage: 53Mi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/Externo/jugaralpadel/migrations/reymotausers" +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: jugaralpadel-static-folder + namespace: jugaralpadel + labels: + app: jugaralpadel +spec: + capacity: + storage: 70Mi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/Externo/jugaralpadel/static" +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: jugaralpadel-pg-folder + namespace: jugaralpadel + labels: + app: jugaralpadel +spec: + capacity: + storage: 200Mi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/Externo/jugaralpadel/pg" diff --git a/JugarAlPadel/Fleet/pvc-jugaralpadel.yaml b/JugarAlPadel/Fleet/pvc-jugaralpadel.yaml new file mode 100644 index 0000000..d8c2c1a --- /dev/null +++ b/JugarAlPadel/Fleet/pvc-jugaralpadel.yaml @@ -0,0 +1,47 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: jugaralpadel-media + name: jugaralpadel-media + namespace: jugaralpadel +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi +status: {} +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: jugaralpadel-eventos-migrations + name: jugaralpadel-eventos-migrations + namespace: jugaralpadel +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 50Mi +status: {} +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: jugaralpadel-reymotausers-migrations + name: jugaralpadel-reymotausers-migrations + namespace: jugaralpadel +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 53Mi +status: {} diff --git a/JugarAlPadel/Fleet/pvc-postgresql.yaml b/JugarAlPadel/Fleet/pvc-postgresql.yaml new file mode 100644 index 0000000..c1576e0 --- /dev/null +++ b/JugarAlPadel/Fleet/pvc-postgresql.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + labels: + io.kompose.service: postgres-data + name: postgres-data + namespace: jugaralpadel +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi diff --git a/JugarAlPadel/Fleet/pvc-static.yaml b/JugarAlPadel/Fleet/pvc-static.yaml new file mode 100644 index 0000000..85c1fb7 --- /dev/null +++ b/JugarAlPadel/Fleet/pvc-static.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + labels: + io.kompose.service: static-volume + name: static-volume + namespace: jugaralpadel +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 70Mi diff --git a/JugarAlPadel/Fleet/reg-secret.yaml b/JugarAlPadel/Fleet/reg-secret.yaml new file mode 100644 index 0000000..b3c9082 --- /dev/null +++ b/JugarAlPadel/Fleet/reg-secret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: myregistrykey + namespace: jugaralpadel +data: + .dockerconfigjson: ewoJImF1dGhzIjogewoJCSJyZWdpc3RyeS5yZXltb3RhLmVzIjogewoJCQkiYXV0aCI6ICJZM0psZVd4dmNHVjZPbEpsZVMweE1UYzIiCgkJfQoJfQp9 +type: kubernetes.io/dockerconfigjson diff --git a/JugarAlPadel/K8S/Makefile b/JugarAlPadel/K8S/Makefile index f90d3cc..e6ee5f5 100644 --- a/JugarAlPadel/K8S/Makefile +++ b/JugarAlPadel/K8S/Makefile @@ -57,8 +57,18 @@ verimg: backup: kubectl --kubeconfig /home/creylopez/.kube/config -n jugaralpadel exec -ti deployment.apps/db -- /usr/lib/postgresql/15/bin/pg_dump --username=creylopez --dbname=jugaralpadel > jugaralpadel-$(IMG_VERSION).sql -muestra: - -envsubst < jugaralpadel-deployment.yaml > /tmp/deployment.yaml - - - +fleet: + -envsubst < jugaralpadel-deployment.yaml > ../Fleet/jugaralpadel-deployment.yaml + -envsubst < nginx-deployment.yaml > ../Fleet/nginx-deployment.yaml + -cp namespace.yaml ../Fleet + -cp reg-secret.yaml ../Fleet + -cp env-prod-configmap.yaml ../Fleet + -cp env-prod-db-configmap.yaml ../Fleet + -cp pv-local-jugaralpadel.yaml ../Fleet + -cp pvc-jugaralpadel.yaml ../Fleet + -cp pvc-static.yaml ../Fleet + -cp pvc-postgresql.yaml ../Fleet + -cp db-deployment.yaml ../Fleet + -cp db-service.yaml ../Fleet + -cp nginx-service.yaml ../Fleet + -cp jugaralpadel-ingress.yaml ../Fleet