Quellcode durchsuchen

Cambiando a cloudnative y a harbor

Celestino Rey vor 6 Monaten
Ursprung
Commit
4a2913c526

+ 20 - 29
Dockerfile

@@ -1,39 +1,30 @@
-# yup, python 3.11!
-FROM python:3.11-slim
-
-# install nginx
-RUN apt-get update && apt-get install nginx netcat-openbsd curl vim jq rsync postgresql-client -y
-# copy our nginx configuration to overwrite nginx defaults
-RUN rm /etc/nginx/sites-enabled/default
-RUN rm /etc/nginx/sites-available/default
-COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
-# link nginx logs to container stdout
-RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log
+FROM python:3.14.2-alpine3.23
 
-# copy the django code
-COPY ./src ./app
+# install nginx y otras cosas
+RUN apk add nginx netcat-openbsd curl vim jq rsync pango pango-dev cairo postgresql-client bash glib fontconfig font-noto
 
-RUN chgrp -R 0 ./app && chmod -R g=u ./app
-RUN chgrp -R 0 /var/lib/nginx && chmod -R g=u /var/lib/nginx
+COPY ./src/requirements.txt requirements.txt
+RUN python3 -m pip install --upgrade pip
+RUN pip install --user --no-cache-dir -r requirements.txt
 
-# change our working directory to the django projcet roo
-WORKDIR /app
+COPY ./nginx/default.conf /etc/nginx/http.d/nginx.conf
 
-# create virtual env (notice the location?)
-# update pip
-# install requirements
-RUN python -m venv /opt/venv && \
-    /opt/venv/bin/python -m pip install pip --upgrade && \
-    /opt/venv/bin/python -m pip install -r requirements.txt
+# link nginx logs to container stdout
+RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
+    ln -sf /dev/stderr /var/log/nginx/error.log && \
+    chgrp -R 0 /var/lib/nginx && \
+    chmod -R g=u /var/lib/nginx
 
-# Añade path a .bashrc
+ENV PATH="/root/.local/bin:$PATH"
 
-RUN echo "export PATH=/opt/venv/bin/:$PATH" >> /root/.bashrc
+# copy the django code
+COPY ./src ./app
 
-# make our entrypoint.sh executable
-RUN chmod +x config/entrypoint.sh
+RUN chgrp -R 0 ./app && \
+    chmod -R g=u ./app
 
-#EXPOSE 8080
+# change our working directory to the django projcet roo
+WORKDIR /app
 
 # execute our entrypoint.sh file
-CMD ["./config/entrypoint.sh"]
+CMD ["/app/config/entrypoint.sh"]

+ 86 - 33
Jenkinsfile

@@ -13,6 +13,7 @@ pipeline {
   // Definición de variables de entorno
   environment {
     NOMBRE_APP = 'jugaralpadel'
+    REGISTRO = 'harbor.reymota.es/jugaralpadel'
   }
 
   // Definición de parámetros
@@ -23,6 +24,8 @@ pipeline {
     booleanParam(name: 'borraclaims', description: 'Borra PVC', defaultValue: false)
     booleanParam(name: 'namespace', description: 'Crea namespace', defaultValue: false)
     booleanParam(name: 'borranamespace', description: 'Borra namespace', defaultValue: false)
+    booleanParam(name: 'creadb', description: 'Crea el objeto para crear la DB en el cúster', defaultValue: false)
+    booleanParam(name: 'borradb', description: 'Borra el objeto que creó la DB, no la DB', defaultValue: false)
   }
   
   stages {
@@ -34,9 +37,10 @@ pipeline {
         echo "Creando las PVC..." 
         container('kubectl') {
           withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
-            sh 'kubectl --insecure-skip-tls-verify create -f K8S/pvc-${NOMBRE_APP}.yaml'
-            sh 'kubectl --insecure-skip-tls-verify create -f K8S/pvc-static.yaml'
-            sh 'kubectl --insecure-skip-tls-verify create -f K8S/pvc-postgresql.yaml'
+	  sh """#!/bin/bash
+	    cat K8S/pvc-${NOMBRE_APP}.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
+	    cat K8S/pvc-static.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
+            """
           }
         }
       }      
@@ -50,15 +54,47 @@ pipeline {
         echo "Borrando las PVC..." 
         container('kubectl') {
           withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
-            sh 'sh K8S/patchPVC.sh||true'
-            sh 'kubectl --insecure-skip-tls-verify delete -f K8S/pvc-${NOMBRE_APP}.yaml||true'
-            sh 'kubectl --insecure-skip-tls-verify delete -f K8S/pvc-static.yaml||true'
-            sh 'kubectl --insecure-skip-tls-verify delete -f K8S/pvc-postgresql.yaml||true'
+	  sh """#!/bin/bash
+	    cat K8S/pvc-${NOMBRE_APP}.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
+	    cat K8S/pvc-static.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
+            """
           }
         }
       }     
     }
 
+    stage('Crea el objeto para crear la DB') {
+      when {
+        expression { params.creadb}
+      }
+      steps {
+        echo "Creando el objeto que crea la DB..." 
+        container('kubectl') {
+          withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
+	  sh """#!/bin/bash
+	    kubectl create -f K8S/${NOMBRE_APP}-db.yaml 
+            """
+          }
+        }
+      }      
+    }
+
+    stage('Borra el objeto que creó la DB, no la DB') {
+      when {
+        expression { params.borradb}
+      }
+      steps {
+        echo "Borrando el objeto que creó la DB..." 
+        container('kubectl') {
+          withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
+	  sh """#!/bin/bash
+	    kubectl delete -f K8S/${NOMBRE_APP}-db.yaml 
+            """
+          }
+        }
+      }      
+    }
+
     stage('Borra todo') {
       when {
         expression { params.clean }
@@ -67,16 +103,21 @@ pipeline {
         echo "Borrando todo..." 
         container('kubectl') {
           withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
-            sh 'kubectl --insecure-skip-tls-verify delete -f K8S/db-deployment.yaml||true'
-            sh 'kubectl --insecure-skip-tls-verify delete -f K8S/db-service.yaml||true'
-
-            sh 'kubectl --insecure-skip-tls-verify delete -f K8S/${NOMBRE_APP}-deployment.yaml||true'
-            sh 'kubectl --insecure-skip-tls-verify delete -f K8S/${NOMBRE_APP}-ingress.yaml||true'
+          sh """#!/bin/bash
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/${NOMBRE_APP}-deployment.yaml
+            sed -i 's|<REGISTRO>|${REGISTRO}|' K8S/${NOMBRE_APP}-deployment.yaml
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/${NOMBRE_APP}-ingress.yaml
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/reg-secret.yaml
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/secreto-db.yaml
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/env-prod-configmap.yaml
 
-            sh 'kubectl --insecure-skip-tls-verify delete -f K8S/reg-secret.yaml||true'
-            sh 'kubectl --insecure-skip-tls-verify delete -f K8S/env-prod-configmap.yaml||true' 
-            sh 'kubectl --insecure-skip-tls-verify delete -f K8S/env-prod-db-configmap.yaml||true' 
+            kubectl delete -f K8S/${NOMBRE_APP}-deployment.yaml||true
+            kubectl delete -f K8S/${NOMBRE_APP}-ingress.yaml||true
 
+            kubectl delete -f K8S/secreto-db.yaml||true
+            kubectl delete -f K8S/reg-secret.yaml||true
+            kubectl delete -f K8S/env-prod-configmap.yaml||true 
+          """
           }
         }
       }      
@@ -90,7 +131,9 @@ pipeline {
         echo "Borrando namespace..." 
         container('kubectl') {
           withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
-            sh 'kubectl --insecure-skip-tls-verify delete -f K8S/namespace.yaml||true'
+	  sh """#!/bin/bash
+	    cat K8S/namespace.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
+            """
           }
         }
       }      
@@ -104,7 +147,9 @@ pipeline {
         echo "Creando namespace..." 
         container('kubectl') {
           withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
-            sh 'kubectl --insecure-skip-tls-verify apply -f K8S/namespace.yaml'
+	  sh """#!/bin/bash
+	    cat K8S/namespace.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
+            """
           }
         }
       }      
@@ -126,7 +171,7 @@ pipeline {
             sh '''
             /kaniko/executor --dockerfile `pwd`/Dockerfile \
                              --context `pwd` \
-                             --destination=registry.reymota.es/${NOMBRE_APP}:${BUILD_NUMBER}
+                             --destination=${REGISTRO}/${NOMBRE_APP}:${BUILD_NUMBER}
             '''
           }
         }
@@ -140,17 +185,23 @@ pipeline {
       steps {
         echo "Creando todo..." 
         container('kubectl') {
-          withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {           
-            sh 'kubectl --insecure-skip-tls-verify create -f K8S/reg-secret.yaml'
-            sh 'kubectl --insecure-skip-tls-verify create -f K8S/env-prod-configmap.yaml' 
-            sh 'kubectl --insecure-skip-tls-verify create -f K8S/env-prod-db-configmap.yaml' 
+          withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
+          sh """#!/bin/bash
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/${NOMBRE_APP}-deployment.yaml
+            sed -i 's|<REGISTRO>|${REGISTRO}|' K8S/${NOMBRE_APP}-deployment.yaml
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/${NOMBRE_APP}-ingress.yaml
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/reg-secret.yaml
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/secreto-db.yaml
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/env-prod-configmap.yaml
 
-            sh 'kubectl --insecure-skip-tls-verify create -f K8S/db-deployment.yaml'
-            sh 'kubectl --insecure-skip-tls-verify create -f K8S/db-service.yaml'
+            kubectl create -f K8S/reg-secret.yaml||true
+            kubectl create -f K8S/secreto-db.yaml||true
+            kubectl apply -f K8S/env-prod-configmap.yaml
 
-            sh 'sed -i "s/<TAG>/${BUILD_NUMBER}/" K8S/${NOMBRE_APP}-deployment.yaml'
-            sh 'kubectl --insecure-skip-tls-verify apply -f K8S/${NOMBRE_APP}-deployment.yaml'
-            sh 'kubectl --insecure-skip-tls-verify create -f K8S/${NOMBRE_APP}-ingress.yaml'
+            sed -i "s/<TAG>/${BUILD_NUMBER}/" K8S/${NOMBRE_APP}-deployment.yaml
+            kubectl apply -f K8S/${NOMBRE_APP}-deployment.yaml
+            kubectl create -f K8S/${NOMBRE_APP}-ingress.yaml||true
+            """
           }
         }
       }
@@ -164,22 +215,25 @@ pipeline {
           expression { !params.borranamespace } 
           expression { !params.claims }
           expression { !params.borraclaims }
-          expression { !params.install }
         }
       }
       steps {
         echo "Desplegando la aplicación" 
         container('kubectl') {
           withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
-            sh 'sed -i "s/<TAG>/${BUILD_NUMBER}/" K8S/${NOMBRE_APP}-deployment.yaml'
-            sh 'kubectl --insecure-skip-tls-verify delete -f K8S/${NOMBRE_APP}-deployment.yaml || true'          
-            sh 'kubectl --insecure-skip-tls-verify apply -f K8S/${NOMBRE_APP}-deployment.yaml'
+          sh """#!/bin/bash
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/${NOMBRE_APP}-deployment.yaml
+            sed -i 's|<REGISTRO>|${REGISTRO}|' K8S/${NOMBRE_APP}-deployment.yaml
+            sed -i "s/<TAG>/${BUILD_NUMBER}/" K8S/${NOMBRE_APP}-deployment.yaml
+            kubectl delete -f K8S/${NOMBRE_APP}-deployment.yaml || true
+            kubectl apply -f K8S/${NOMBRE_APP}-deployment.yaml
+            """
           }
         }
       }
     }   
   }
-  /*
+  
   post {
     always {
       mail to: 'creylopez@yahoo.es',
@@ -209,5 +263,4 @@ pipeline {
            mimeType: 'text/html'
     }
   }
-  */
 }

+ 0 - 77
K8S/Makefile.K8S

@@ -1,77 +0,0 @@
-export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':')
-export REGISTRY=registry.reymota.es
-
-export IMG_VERSION = 0.70.42
-export IMG_NGINX_VERSION = 2.3
-
-# limpia todo
-all: imagen clean install
-
-imagen:
-	cd ../; make
-
-install:
-	-kubectl create -f namespace.yaml
-	-kubectl create -f reg-secret.yaml
-	-kubectl create -f env-prod-configmap.yaml 
-	-kubectl create -f env-prod-db-configmap.yaml 
-
-	#-kubectl create -f pv-local-jugaralpadel.yaml
-	#-kubectl create -f pv-postgres.yaml
-	-kubectl create -f pvc-jugaralpadel.yaml
-	-kubectl create -f pvc-static.yaml
-	-kubectl create -f pvc-postgresql.yaml
-
-	-kubectl create -f db-deployment.yaml
-	-kubectl create -f db-service.yaml
-
-	-envsubst < jugaralpadel-deployment.yaml |kubectl create -f -
-	-envsubst < nginx-deployment.yaml |kubectl create -f -
-	-kubectl create -f nginx-service.yaml
-	-kubectl create -f jugaralpadel-ingress.yaml
-
-
-clean:
-	-envsubst < nginx-deployment.yaml |kubectl delete -f -
-	-kubectl delete -f nginx-service.yaml
-	-envsubst < jugaralpadel-deployment.yaml |kubectl delete -f -
-
-	-kubectl delete -f db-deployment.yaml
-	-kubectl delete -f db-service.yaml
-
-	-kubectl delete -f env-prod-configmap.yaml 
-	-kubectl delete -f env-prod-db-configmap.yaml 
-
-	-kubectl delete -f pvc-jugaralpadel.yaml
-	-kubectl delete -f pvc-static.yaml
-	-kubectl delete -f pvc-postgresql.yaml
-	#-kubectl delete -f pv-local-jugaralpadel.yaml
-	#-kubectl delete -f pv-postgres.yaml
-	-kubectl delete -f reg-secret.yaml
-	-kubectl delete -f namespace.yaml
-
-nginx:
-	cd ../nginx; make
-
-verimg:
-	docker run -it  ${REGISTRY}/jugaralpadel-${ARQUITECTURA}:${IMG_VERSION} bash
-
-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
-   
-fleet:
-	-cp namespace.yaml ../Fleet/15-namespace.yaml
-	-cp reg-secret.yaml ../Fleet/20-reg-secret.yaml
-	-cp env-prod-configmap.yaml  ../Fleet/25-env-prod-configmap.yaml
-	-cp env-prod-db-configmap.yaml  ../Fleet/30-env-prod-db-configmap.yaml
-	-cp pv-postgres.yaml ../Fleet/35-pv-postgres.yaml
-	-cp pv-local-jugaralpadel.yaml ../Fleet/37-pv-local-jugaralpadel.yaml
-	-cp pvc-postgresql.yaml ../Fleet/40-pvc-postgresql.yaml
-	-cp pvc-jugaralpadel.yaml ../Fleet/45-pvc-jugaralpadel.yaml
-	-cp pvc-static.yaml ../Fleet/50-pvc-static.yaml
-	-cp db-deployment.yaml ../Fleet/55-db-deployment.yaml
-	-cp db-service.yaml ../Fleet/60-db-service.yaml
-	-cp nginx-service.yaml ../Fleet/65-nginx-service.yaml
-	-envsubst < jugaralpadel-deployment.yaml > ../Fleet/70-jugaralpadel-deployment.yaml
-	-envsubst < nginx-deployment.yaml > ../Fleet/75-nginx-deployment.yaml
-	-cp jugaralpadel-ingress.yaml ../Fleet/80-jugaralpadel-ingress.yaml

+ 0 - 92
K8S/Makefile.OC

@@ -1,92 +0,0 @@
-export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':')
-export REGISTRY=registry.reymota.es
-
-export IMG_VERSION = 11
-
-# limpia todo
-all: ayuda
-
-todo: imagen clean install
-
-ayuda:
-	@echo  "make imagen -> crea la imagen del contenedor con la aplicación y la sube al registry"
-	@echo  "make ns -> crea el namespace"
-	@echo  "make app -> crea el deployment de la aplicación"
-	@echo  "make borraapp -> borra el deployment de la aplicación"
-	@echo  "make claims -> crea las pvc"
-	@echo  "make borraclaims -> crea las pvc ¡ojo! lo que haya en los volumenes se pierde"
-	@echo  "make volumes -> crea los pv en entornos donde no hay creación dinámica de los volumenes"
-	@echo  "make borravolumes -> borra los pv en entornos donde no hay creación dinámica de los volumenes"
-	@echo  "make install -> crea los confimaps, servicios y deployments de todo"
-	@echo  "make clean -> borra los confimaps, servicios y deployments de todo"
-	@echo  "make todo -> crea todo"
-
-imagen:
-	cd ../; make
-
-ns:
-	-oc create -f namespace.yaml
-
-app:
-	-envsubst < jugaralpadel-deployment.yaml |oc create -f -
-
-borraapp:
-	-envsubst < jugaralpadel-deployment.yaml |oc delete -f -
-
-install:
-	-oc create -f reg-secret.yaml
-	-oc create -f env-prod-configmap.yaml 
-	-oc create -f env-prod-db-configmap.yaml 
-
-	-oc create -f db-deployment.yaml
-	-oc create -f db-service.yaml
-
-	-envsubst < jugaralpadel-deployment.yaml |oc create -f -
-	-oc expose service/jugaralpadel
-
-claims:
-	-oc create -f pvc-jugaralpadel.yaml
-	-oc create -f pvc-static.yaml
-	-oc create -f pvc-postgresql.yaml
-
-borraclaims:
-	-oc delete -f pvc-jugaralpadel.yaml
-	-oc delete -f pvc-static.yaml
-	-oc delete -f pvc-postgresql.yaml
-
-volumes:
-	-oc create -f pv-local-jugaralpadel.yaml
-
-borravolumes:
-	-oc delete -f pv-local-jugaralpadel.yaml
-
-clean:
-	-envsubst < jugaralpadel-deployment.yaml |oc delete -f -
-
-	-oc delete -f db-deployment.yaml
-	-oc delete -f db-service.yaml
-
-	-oc delete -f env-prod-configmap.yaml 
-	-oc delete -f env-prod-db-configmap.yaml 
-
-	-oc delete -f reg-secret.yaml
-
-verimg:
-	docker run -it  ${REGISTRY}/jugaralpadel-${ARQUITECTURA}:${IMG_VERSION} bash
-
-backup:
-	oc --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
-   
-fleet:
-	-cp namespace.yaml ../Fleet/15-namespace.yaml
-	-cp reg-secret.yaml ../Fleet/20-reg-secret.yaml
-	-cp env-prod-configmap.yaml  ../Fleet/25-env-prod-configmap.yaml
-	-cp env-prod-db-configmap.yaml  ../Fleet/30-env-prod-db-configmap.yaml
-	-cp pvc-jugaralpadel.yaml ../Fleet/40-pvc-jugaralpadel.yaml
-	-cp pvc-static.yaml ../Fleet/45-pvc-static.yaml
-	-cp pvc-postgresql.yaml ../Fleet/50-pvc-postgresql.yaml
-	-cp db-deployment.yaml ../Fleet/55-db-deployment.yaml
-	-cp db-service.yaml ../Fleet/60-db-service.yaml
-	-envsubst < jugaralpadel-deployment.yaml > ../Fleet/70-jugaralpadel-deployment.yaml
-	-cp jugaralpadel-ingress.yaml ../Fleet/80-jugaralpadel-ingress.yaml
-

+ 0 - 55
K8S/db-deployment.yaml

@@ -1,55 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
-  annotations:
-    kompose.cmd: kompose convert
-    kompose.version: 1.34.0 (cbf2835db)
-  labels:
-    io.kompose.service: postgresql
-    app.kubernetes.io/part-of: jugaralpadel
-  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
-            - name: PGDATA
-              value: /var/lib/postgresql/data/pgdata
-          image: postgres:15
-          name: postgresql
-          volumeMounts:
-            - mountPath: /var/lib/postgresql/data
-              name: postgres-data
-      restartPolicy: Always
-      volumes:
-        - name: postgres-data
-          persistentVolumeClaim:
-            claimName: postgres-data

+ 0 - 17
K8S/db-service.yaml

@@ -1,17 +0,0 @@
-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

+ 2 - 2
K8S/env-prod-configmap.yaml

@@ -4,7 +4,7 @@ data:
   APP_VERSION: 16.0.6
   SQL_DATABASE: reymota
   SQL_ENGINE: django.db.backends.postgresql
-  SQL_HOST: postgresql
+  SQL_HOST: postgres-cluster-rw.reymota-pg-cluster.svc.cluster.local
   SQL_PASSWORD: Dsa-0213
   SQL_PORT: "5432"
   SQL_USER: creylopez
@@ -15,4 +15,4 @@ metadata:
   labels:
     io.kompose.service: web-env-prod
   name: env-prod
-  namespace: jugaralpadel
+  namespace: <NS>

+ 0 - 11
K8S/env-prod-db-configmap.yaml

@@ -1,11 +0,0 @@
-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

+ 10 - 0
K8S/jugaralpadel-db.yaml

@@ -0,0 +1,10 @@
+apiVersion: postgresql.cnpg.io/v1
+kind: Database
+metadata:
+  name: jugaralpadel-db
+  namespace: reymota-pg-cluster
+spec:
+  name: jugaralpadel
+  owner: creylopez
+  cluster:
+    name: postgres-cluster

+ 4 - 4
K8S/jugaralpadel-deployment.yaml

@@ -2,7 +2,7 @@ apiVersion: v1
 kind: Service
 metadata:
   name: jugaralpadel
-  namespace: jugaralpadel
+  namespace: <NS>
 spec:
   type: NodePort
   ports:
@@ -17,7 +17,7 @@ apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: jugaralpadel
-  namespace: jugaralpadel
+  namespace: <NS>
   labels:
     app: jugaralpadel
     app.kubernetes.io/part-of: jugaralpadel
@@ -35,10 +35,10 @@ spec:
     spec:
       containers:
       - name: jugaralpadel
-        image: registry.reymota.es/jugaralpadel:<TAG>
+        image: <REGISTRO>/jugaralpadel:<TAG>
         env:
         - name: IMG_VERSION
-          value: "$IMG_VERSION"
+          value: <TAG>
         - name: DEBUG
           valueFrom:
             configMapKeyRef:

+ 1 - 1
K8S/jugaralpadel-ingress.yaml

@@ -17,7 +17,7 @@ metadata:
       manager: rancher
       operation: Update
   name: jugaralpadel
-  namespace: jugaralpadel
+  namespace: <NS>
 spec:
   defaultBackend:
     service:

+ 0 - 50
K8S/jugaralpadel-topolvm-pvc.yaml

@@ -1,50 +0,0 @@
-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
-  storageClassName: topolvm-provisioner
-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
-  storageClassName: topolvm-provisioner
-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
-  storageClassName: topolvm-provisioner
-status: {}

+ 1 - 1
K8S/namespace.yaml

@@ -4,4 +4,4 @@
 apiVersion: v1
 kind: Namespace
 metadata:
-  name: jugaralpadel
+  name: <NS>

+ 0 - 46
K8S/nginx-deployment.yaml

@@ -1,46 +0,0 @@
-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/nginx-jugaralpadel-$ARQUITECTURA:$IMG_NGINX_VERSION
-          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

+ 0 - 20
K8S/nginx-service.yaml

@@ -1,20 +0,0 @@
-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
-

+ 0 - 59
K8S/pv-local-jugaralpadel.yaml

@@ -1,59 +0,0 @@
-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"

+ 0 - 15
K8S/pv-postgres.yaml

@@ -1,15 +0,0 @@
----
-apiVersion: v1
-kind: PersistentVolume
-metadata:
-  name: jugaralpadel-pg-folder
-  namespace: jugaralpadel
-  labels:
-    app: jugaralpadel
-spec:
-  capacity:
-    storage: 150Mi
-  accessModes:
-    - ReadWriteOnce
-  hostPath:
-    path: "/mnt/Externo/jugaralpadel/pg"

+ 6 - 10
K8S/pvc-jugaralpadel.yaml

@@ -5,14 +5,13 @@ metadata:
   labels:
     io.kompose.service: jugaralpadel-media
   name: jugaralpadel-media
-  namespace: jugaralpadel
+  namespace: <NS>
 spec:
   accessModes:
     - ReadWriteOnce
   resources:
     requests:
-      storage: 100Mi
-  #storageClassName: lvms-vg1
+      storage: 10Mi
 status: {}
 ---
 apiVersion: v1
@@ -22,14 +21,13 @@ metadata:
   labels:
     io.kompose.service: jugaralpadel-eventos-migrations
   name: jugaralpadel-eventos-migrations
-  namespace: jugaralpadel
+  namespace: <NS>
 spec:
   accessModes:
     - ReadWriteOnce
   resources:
     requests:
       storage: 50Mi
-  #storageClassName: lvms-vg1
 status: {}
 ---
 apiVersion: v1
@@ -39,14 +37,13 @@ metadata:
   labels:
     io.kompose.service: jugaralpadel-gestionreservas-migrations
   name: jugaralpadel-gestionreservas-migrations
-  namespace: jugaralpadel
+  namespace: <NS>
 spec:
   accessModes:
     - ReadWriteOnce
   resources:
     requests:
       storage: 50Mi
-  #storageClassName: lvms-vg1
 status: {}
 ---
 apiVersion: v1
@@ -56,12 +53,11 @@ metadata:
   labels:
     io.kompose.service: jugaralpadel-reymotausers-migrations
   name: jugaralpadel-reymotausers-migrations
-  namespace: jugaralpadel
+  namespace: <NS>
 spec:
   accessModes:
     - ReadWriteOnce
   resources:
     requests:
-      storage: 53Mi
-  #storageClassName: lvms-vg1
+      storage: 50Mi
 status: {}

+ 0 - 14
K8S/pvc-postgresql.yaml

@@ -1,14 +0,0 @@
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
-  labels:
-    io.kompose.service: postgres-data
-  name: postgres-data
-  namespace: jugaralpadel
-spec:
-  accessModes:
-    - ReadWriteOnce
-  resources:
-    requests:
-      storage: 150Mi
-  #storageClassName: lvms-vg1

+ 1 - 2
K8S/pvc-static.yaml

@@ -4,11 +4,10 @@ metadata:
   labels:
     io.kompose.service: static-volume
   name: static-volume
-  namespace: jugaralpadel
+  namespace: <NS>
 spec:
   accessModes:
     - ReadWriteOnce
   resources:
     requests:
       storage: 70Mi
-  #storageClassName: lvms-vg1

+ 2 - 2
K8S/reg-secret.yaml

@@ -2,7 +2,7 @@ apiVersion: v1
 kind: Secret
 metadata:
   name: myregistrykey
-  namespace: jugaralpadel
+  namespace: <NS>
 data:
-  .dockerconfigjson: ewoJImF1dGhzIjogewoJCSJyZWdpc3RyeS5yZXltb3RhLmVzIjogewoJCQkiYXV0aCI6ICJZM0psZVd4dmNHVjZPbEpsZVMweE1UYzIiCgkJfQoJfQp9
+  .dockerconfigjson: ewoJImF1dGhzIjogewoJCSJnaXRzZXJ2ZXIucmV5bW90YS5lcyI6IHsKCQkJImF1dGgiOiAiWTNKbGVXeHZjR1Y2T2xKbGVTMHhNVGMyIgoJCX0sCgkJImhhcmJvci5yZXltb3RhLmVzIjogewoJCQkiYXV0aCI6ICJZM0psZVd4dmNHVjZPbmhsZG5wdmJpMTRkWEJvYjNvdE1WSjFkM052IgoJCX0sCgkJInJlZ2lzdHJ5LnJleW1vdGEuZXMiOiB7CgkJCSJhdXRoIjogIlkzSmxlV3h2Y0dWNk9sSmxlUzB4TVRjMiIKCQl9Cgl9Cn0=
 type: kubernetes.io/dockerconfigjson

+ 0 - 1
K8S/verImg.sh

@@ -1 +0,0 @@
-docker run -it registry.jugaralpadel.es/jugaralpadel-x86_64:0.1 bash

+ 3 - 5
Makefile

@@ -1,8 +1,6 @@
 install:
 
-	echo "Creando imagen con version '${IMG_VERSION}' en el registry '${REGISTRY}'"
-
-	docker build --no-cache -t ${REGISTRY}/jugaralpadel:${IMG_VERSION} -f Dockerfile.oc .
-	docker push ${REGISTRY}/jugaralpadel:${IMG_VERSION}
-
+	echo "Creando imagen con version '${IMG_VERSION}' en el registry '${REGISTRO}'"
 
+	docker build --no-cache -t ${REGISTRO}/jugaralpadel:${IMG_VERSION} -f Dockerfile .
+	docker push ${REGISTRO}/jugaralpadel:${IMG_VERSION}

+ 0 - 4
para.sh

@@ -1,4 +0,0 @@
-oc delete deployment.apps/jugaralpadel
-oc delete svc jugaralpadel
-oc get all
-oc delete route.route.openshift.io/jugaralpadel