Bläddra i källkod

Cloudnative y alpine

Celestino Rey 6 månader sedan
förälder
incheckning
06a037d8a9

+ 17 - 26
Dockerfile

@@ -1,40 +1,31 @@
 # yup, python 3.11!
-FROM python:3.11-slim
+FROM python:3.11-alpine 
 
 # install nginx y otras cosas
-RUN apt-get update && apt-get install nginx netcat-openbsd curl vim jq rsync libpango-1.0-0 libpangocairo-1.0-0 libcairo2 postgresql-client -y
+RUN apk add nginx netcat-openbsd curl vim jq rsync pango pango-dev cairo postgresql-client bash glib fontconfig font-noto
+
+COPY ./src/requirements.txt requirements.txt
+RUN pip install --user --no-cache-dir -r requirements.txt
+
+COPY ./nginx/default.conf /etc/nginx/http.d/nginx.conf
 
-# 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
+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
+
+ENV PATH="/root/.local/bin:$PATH"
 
 # copy the django code
 COPY ./src ./app
 
-RUN chgrp -R 0 ./app && chmod -R g=u ./app
-RUN chgrp -R 0 /var/lib/nginx && chmod -R g=u /var/lib/nginx
+RUN chgrp -R 0 ./app && \
+    chmod -R g=u ./app
 
 # change our working directory to the django projcet roo
 WORKDIR /app
 
-# 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
-
-# Añade path a .bashrc
-
-RUN echo "export PATH=/opt/venv/bin/:$PATH" >> /root/.bashrc
-
-# make our entrypoint.sh executable
-RUN chmod +x config/entrypoint.sh
-
-#EXPOSE 8080
-
 # execute our entrypoint.sh file
-CMD ["./config/entrypoint.sh"]
+CMD ["/app/config/entrypoint.sh"]
+

+ 74 - 30
Jenkinsfile

@@ -23,6 +23,7 @@ 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: 'helm', description: 'Instala helm', defaultValue: false)
   }
   
   stages {
@@ -34,9 +35,13 @@ pipeline {
         echo "Creando las PVC..." 
         container('kubectl') {
           withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
-            sh 'kubectl create -f K8S/pvc-${NOMBRE_APP}.yaml'
-            sh 'kubectl create -f K8S/pvc-static.yaml'
-            sh 'kubectl create -f K8S/pvc-postgresql.yaml'
+          sh """#!/bin/bash
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/pvc-${NOMBRE_APP}.yaml
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/pvc-static.yaml
+
+            kubectl create -f K8S/pvc-${NOMBRE_APP}.yaml
+            kubectl create -f K8S/pvc-static.yaml
+            """
           }
         }
       }      
@@ -50,10 +55,15 @@ pipeline {
         echo "Borrando las PVC..." 
         container('kubectl') {
           withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
-            sh 'sh K8S/patchPVC.sh||true'
-            sh 'kubectl delete -f K8S/pvc-${NOMBRE_APP}.yaml||true'
-            sh 'kubectl delete -f K8S/pvc-static.yaml||true'
-            sh 'kubectl delete -f K8S/pvc-postgresql.yaml||true'
+          sh """#!/bin/bash
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/pvc-${NOMBRE_APP}.yaml
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/pvc-static.yaml
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/patchPVC.sh
+
+            sh K8S/patchPVC.sh||true
+            kubectl delete -f K8S/pvc-${NOMBRE_APP}.yaml
+            kubectl delete -f K8S/pvc-static.yaml
+            """
           }
         }
       }     
@@ -67,16 +77,18 @@ pipeline {
         echo "Borrando todo..." 
         container('kubectl') {
           withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
-            sh 'kubectl delete -f K8S/db-deployment.yaml||true'
-            sh 'kubectl delete -f K8S/db-service.yaml||true'
-
-            sh 'kubectl delete -f K8S/${NOMBRE_APP}-deployment.yaml||true'
-            sh 'kubectl delete -f K8S/${NOMBRE_APP}-ingress.yaml||true'
+          sh """#!/bin/bash
+            sed -i 's|<NS>|"${NAMESPACE}"|' 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/env-prod-configmap.yaml
 
-            sh 'kubectl delete -f K8S/reg-secret.yaml||true'
-            sh 'kubectl delete -f K8S/env-prod-configmap.yaml||true' 
-            sh 'kubectl 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/reg-secret.yaml||true
+            kubectl delete -f K8S/env-prod-configmap.yaml||true 
+          """
           }
         }
       }      
@@ -104,7 +116,10 @@ pipeline {
         echo "Creando namespace..." 
         container('kubectl') {
           withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
-            sh 'kubectl apply -f K8S/namespace.yaml'
+          sh """#!/bin/bash
+            sed -i 's|<NS>|"${NAMESPACE}"|' K8S/namespace.yaml
+            kubectl create -f K8S/namespace.yaml
+            """
           }
         }
       }      
@@ -141,16 +156,19 @@ pipeline {
         echo "Creando todo..." 
         container('kubectl') {
           withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {           
-            sh 'kubectl create -f K8S/reg-secret.yaml'
-            sh 'kubectl create -f K8S/env-prod-configmap.yaml' 
-            sh 'kubectl create -f K8S/env-prod-db-configmap.yaml' 
+          sh """#!/bin/bash
+            sed -i 's|<NS>|"${NAMESPACE}"|' 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/env-prod-configmap.yaml
 
-            sh 'kubectl create -f K8S/db-deployment.yaml'
-            sh 'kubectl create -f K8S/db-service.yaml'
+            kubectl create -f K8S/reg-secret.yaml||true
+            kubectl apply -f K8S/env-prod-configmap.yaml
 
-            sh 'sed -i "s/<TAG>/${BUILD_NUMBER}/" K8S/${NOMBRE_APP}-deployment.yaml'
-            sh 'kubectl apply -f K8S/${NOMBRE_APP}-deployment.yaml'
-            sh 'kubectl 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
+            """
           }
         }
       }
@@ -171,16 +189,42 @@ pipeline {
         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 delete -f K8S/${NOMBRE_APP}-deployment.yaml || true'          
-            sh 'kubectl apply -f K8S/${NOMBRE_APP}-deployment.yaml'
+          sh """#!/bin/bash
+            sed -i 's|<NS>|"${NAMESPACE}"|' 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
+            """
           }
         }
       }
     }   
-  }
 
-  /*  
+    stage('Instala Helm Chart') {
+      when {
+        allOf {
+          expression { !params.clean }
+          expression { !params.namespace }
+          expression { !params.borranamespace } 
+          expression { !params.claims }
+          expression { !params.borraclaims }
+          expression { !params.install }
+          expression { params.helm }
+        }
+      }
+      steps {
+        echo "Instalando el helm chart" 
+        container('kubectl') {
+          withCredentials([file(credentialsId: env.Destino, variable: 'KUBECONFIG')]) {
+          sh """#!/bin/bash
+            helm upgrade finanzas finanzas --namespace finanzas --set=image.tag=${BUILD_NUMBER}
+            """
+          }
+        }
+      }
+    }
+  }
+  
   post {
     always {
       mail to: 'creylopez@yahoo.es',
@@ -210,5 +254,5 @@ pipeline {
            mimeType: 'text/html'
     }
   }
-  */
 }
+

+ 24 - 36
K8S/Makefile

@@ -1,7 +1,6 @@
-export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':')
 export REGISTRY=registry.reymota.es
-export IMG_VERSION = 0.76
-export IMG_NGINX_VERSION = 2.0
+export IMG_VERSION = alpine-3
+export NAMESPACE = rmdev
 
 # limpia todo
 all: imagen clean install
@@ -9,48 +8,37 @@ all: imagen clean install
 imagen:
 	cd ../; make
 
+ns:
+	-cat namespace.yaml | sed -e "s/<NS>/${NAMESPACE}/" |kubectl create -f -
+
 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 
+	-cat reg-secret.yaml| sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
+	-cat env-prod-configmap.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
 
-	-kubectl create -f pv-local-reymota.yaml
-	-kubectl create -f reymota-prod-persistentvolumeclaim.yaml
-	-kubectl create -f static-volume-persistentvolumeclaim.yaml
-	-kubectl create -f postgres-data-persistentvolumeclaim.yaml
+	-cat reymota-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${IMG_VERSION}/" | kubectl create -f -
+	-cat reymota-ingress.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
 
-	-kubectl create -f db-deployment.yaml
-	-kubectl create -f db-service.yaml
 
-	-envsubst < reymota-deployment.yaml |kubectl create -f -
-	-envsubst < nginx-deployment.yaml |kubectl create -f -
-	-kubectl create -f nginx-service.yaml
-	-kubectl create -f reymota-ingress.yaml
+clean:
 
 clean:
-	-envsubst < nginx-deployment.yaml |kubectl delete -f -
-	-kubectl delete -f nginx-service.yaml
-	-envsubst < reymota-deployment.yaml |kubectl delete -f -
+	-cat reymota-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${IMG_VERSION}/" | kubectl delete -f -
+
+	-cat env-prod-configmap.yaml  | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
 
-	-kubectl delete -f db-deployment.yaml
-	-kubectl delete -f db-service.yaml
+	-cat reg-secret.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
+	-cat reymota-ingress.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
 
-	-kubectl delete -f env-prod-configmap.yaml 
-	-kubectl delete -f env-prod-db-configmap.yaml 
 
-	-kubectl delete -f postgres-data-persistentvolumeclaim.yaml
-	-kubectl delete -f static-volume-persistentvolumeclaim.yaml
-	-kubectl delete -f reymota-prod-persistentvolumeclaim.yaml
-	-kubectl delete -f pv-local-reymota.yaml
-	-kubectl delete -f reg-secret.yaml
-	-kubectl delete -f namespace.yaml
+borraclaims:
+	-cat pvc-reymota.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
+	-cat pvc-static.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
 
-nginx:
-	cd ../nginx; make
+claims:
+	-cat pvc-reymota.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
+	-cat pvc-static.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
 
-backup:
-	kubectl --kubeconfig /home/creylopez/.kube/config -n reymota exec -ti deployment.apps/db -- /usr/lib/postgresql/15/bin/pg_dump --username=creylopez --dbname=reymota > reymota-$(IMG_VERSION).sql
+app:
+	-cat reymota-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${IMG_VERSION}/" | kubectl delete -f -
+	-cat reymota-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${IMG_VERSION}/" | kubectl create -f -
 
-muestra:
-	-envsubst < reymota-deployment.yaml > /tmp/deployment.yaml

+ 7 - 3
K8S/env-prod-configmap.yaml

@@ -2,14 +2,18 @@ apiVersion: v1
 data:
   DEBUG: "False"
   ENTORNO: "Producción"
-  APP_VERSION: 15.0.3
+  APP_VERSION: 16.0.0
   SECRET_KEY: change_me
-  SQL_HOST: postgresql
+  SQL_HOST: postgres-cluster-rw.reymota-pg-cluster.svc.cluster.local
   SQL_PORT: "5432"
   DATABASE: postgres
+  DJANGO_LOG_LEVEL: "WARNING"
+  FINANZAS_LOG_LEVEL: "INFO"
+  REYMOTAUSERS_LOG_LEVEL: "INFO"
 kind: ConfigMap
 metadata:
   labels:
     io.kompose.service: web-env-prod
   name: env-prod
-  namespace: reymota
+  namespace: <NS>
+

BIN
K8S/media.tar.gz


+ 1 - 1
K8S/namespace.yaml

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

+ 0 - 89
K8S/pv-local-reymota.yaml

@@ -1,89 +0,0 @@
-apiVersion: v1
-kind: PersistentVolume
-metadata:
-  name: reymota-media-folder
-  namespace: reymota
-  labels:
-    app: reymota
-spec:
-  capacity:
-    storage: 100Mi
-  accessModes:
-    - ReadWriteOnce
-  hostPath:
-    path: "/mnt/Externo/reymota/media"
----
-apiVersion: v1
-kind: PersistentVolume
-metadata:
-  name: reymota-lyrics-migrations-folder
-  namespace: reymota
-  labels:
-    app: reymota
-spec:
-  capacity:
-    storage: 50Mi
-  accessModes:
-    - ReadWriteOnce
-  hostPath:
-    path: "/mnt/Externo/reymota/migrations/lyrics"
----
-apiVersion: v1
-kind: PersistentVolume
-metadata:
-  name: reymota-repostajes-migrations-folder
-  namespace: reymota
-  labels:
-    app: reymota
-spec:
-  capacity:
-    storage: 52Mi
-  accessModes:
-    - ReadWriteOnce
-  hostPath:
-    path: "/mnt/Externo/reymota/migrations/repostajes"
----
-apiVersion: v1
-kind: PersistentVolume
-metadata:
-  name: reymota-reymotausers-migrations-folder
-  namespace: reymota
-  labels:
-    app: reymota
-spec:
-  capacity:
-    storage: 53Mi
-  accessModes:
-    - ReadWriteOnce
-  hostPath:
-    path: "/mnt/Externo/reymota/migrations/reymotausers"
----
-apiVersion: v1
-kind: PersistentVolume
-metadata:
-  name: reymota-static-folder
-  namespace: reymota
-  labels:
-    app: reymota
-spec:
-  capacity:
-    storage: 70Mi
-  accessModes:
-    - ReadWriteOnce
-  hostPath:
-    path: "/mnt/Externo/reymota/static"
----
-apiVersion: v1
-kind: PersistentVolume
-metadata:
-  name: reymota-pg-folder
-  namespace: reymota
-  labels:
-    app: reymota
-spec:
-  capacity:
-    storage: 200Mi
-  accessModes:
-    - ReadWriteOnce
-  hostPath:
-    path: "/mnt/Externo/reymota/pg"

+ 0 - 13
K8S/pvc-postgresql.yaml

@@ -1,13 +0,0 @@
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
-  labels:
-    io.kompose.service: postgres-data
-  name: postgres-data
-  namespace: reymota
-spec:
-  accessModes:
-    - ReadWriteOnce
-  resources:
-    requests:
-      storage: 100Mi

+ 6 - 6
K8S/pvc-reymota.yaml

@@ -5,7 +5,7 @@ metadata:
   labels:
     io.kompose.service: reymota-media
   name: reymota-media
-  namespace: reymota
+  namespace: <NS>
 spec:
   accessModes:
     - ReadWriteOnce
@@ -21,7 +21,7 @@ metadata:
   labels:
     io.kompose.service: reymota-lyrics-migrations
   name: reymota-lyrics-migrations
-  namespace: reymota
+  namespace: <NS>
 spec:
   accessModes:
     - ReadWriteOnce
@@ -37,13 +37,13 @@ metadata:
   labels:
     io.kompose.service: reymota-repostajes-migrations
   name: reymota-repostajes-migrations
-  namespace: reymota
+  namespace: <NS>
 spec:
   accessModes:
     - ReadWriteOnce
   resources:
     requests:
-      storage: 52Mi
+      storage: 50Mi
 status: {}
 ---
 apiVersion: v1
@@ -53,11 +53,11 @@ metadata:
   labels:
     io.kompose.service: reymota-reymotausers-migrations
   name: reymota-reymotausers-migrations
-  namespace: reymota
+  namespace: <NS>
 spec:
   accessModes:
     - ReadWriteOnce
   resources:
     requests:
-      storage: 53Mi
+      storage: 50Mi
 status: {}

+ 1 - 1
K8S/pvc-static.yaml

@@ -4,7 +4,7 @@ metadata:
   labels:
     io.kompose.service: static-volume
   name: static-volume
-  namespace: reymota
+  namespace: <NS>
 spec:
   accessModes:
     - ReadWriteOnce

+ 1 - 1
K8S/reg-secret.yaml

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

+ 3 - 3
K8S/reymota-deployment.yaml

@@ -2,13 +2,13 @@ apiVersion: v1
 kind: Service
 metadata:
   name: reymota
-  namespace: reymota
+  namespace: <NS>
 spec:
   type: NodePort
   ports:
     - name: "8080"
       port: 8080
-      nodePort: 30347
+      nodePort: 30350
       targetPort: 8080
   selector:
     app: reymota
@@ -17,7 +17,7 @@ apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: reymota
-  namespace: reymota
+  namespace: <NS>
   labels:
     app: reymota
 spec:

+ 1 - 1
K8S/reymota-ingress.yaml

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

+ 3 - 3
Makefile

@@ -1,8 +1,8 @@
 install:
 
-	echo "Creando imagen con version '${IMG_VERSION}' para la arquitectura '${ARQUITECTURA}' en el registry '${REGISTRY}'"
+	echo "Creando imagen con version '${IMG_VERSION}' en el registry '${REGISTRY}'"
 
-	docker build --no-cache -t ${REGISTRY}/reymota-${ARQUITECTURA}:${IMG_VERSION} -f Dockerfile.k8s .
-	docker push ${REGISTRY}/reymota-${ARQUITECTURA}:${IMG_VERSION}
+	docker build --no-cache -t ${REGISTRY}/reymota:${IMG_VERSION} -f Dockerfile .
+	docker push ${REGISTRY}/reymota:${IMG_VERSION}
 
 

+ 1 - 0
nginx/default.conf

@@ -30,3 +30,4 @@ server {
         root   /usr/share/nginx/html;
     }
 }
+

+ 4 - 7
src/config/entrypoint.sh

@@ -1,8 +1,6 @@
 #!/bin/bash
 RUN_PORT="8000"
 
-export PATH=/opt/venv/bin:$PATH
-
 if [ "$DATABASE" = "postgres" ]
 then
     echo "Esperando a postgres..."
@@ -13,10 +11,8 @@ then
 
     echo "PostgreSQL ha arrancado"
 
-	/opt/venv/bin/python manage.py migrate --no-input
-	/opt/venv/bin/python manage.py collectstatic --no-input
-
-	#/opt/venv/bin/gunicorn cartera_acciones.wsgi:application --bind "0.0.0.0:${RUN_PORT}" --daemon
+	python manage.py migrate --no-input
+	python manage.py collectstatic --no-input
 
   # Start nginx as a daemon so it doesn't block, then run gunicorn in
   # foreground (PID 1) so logs go to stdout/stderr and are visible to kubectl logs
@@ -31,7 +27,7 @@ then
 
   echo "Lanzando gunicorn con log level: $LOG_LEVEL"
 
-  exec /opt/venv/bin/gunicorn reymota.wsgi:application \
+  exec gunicorn reymota.wsgi:application \
     --bind "0.0.0.0:${RUN_PORT}" \
     --access-logfile - \
     --error-logfile - \
@@ -39,3 +35,4 @@ then
 else
     echo "la base de datos no es postgres: '$DATABASE'"
 fi
+

+ 7 - 4
src/reymota/settings.py

@@ -35,9 +35,9 @@ SECRET_KEY = 'django-insecure-vu#zk4g8pj-qoov#8^i$&s8n_ipp2r3h+o$z1w(1%d=6+i@erm
 DEBUG = os.environ["DEBUG"] == 'True'
 OPENSHIFT = os.environ["OPENSHIFT"] == 'True'
 
-ALLOWED_HOSTS = [".ocp-cluster.reymota.lab", "reymota.es", ".reymota.lab"]
+ALLOWED_HOSTS = [".ocp-cluster.reymota.lab", "reymota.es", ".reymota.lab",".vmcluster.lab"]
 
-CSRF_TRUSTED_ORIGINS = ["https://*.ocp-cluster.reymota.lab", "https://reymota.es", "http://reymota.rancher.reymota.lab"]
+CSRF_TRUSTED_ORIGINS = ["https://*.ocp-cluster.reymota.lab", "https://reymota.es", "http://reymota.rancher.reymota.lab","http://*.vmcluster.lab"]
 
 # Application definition
 
@@ -98,11 +98,14 @@ WSGI_APPLICATION = 'reymota.wsgi.application'
 DATABASES = {
     "default": {
         "ENGINE": "django.db.backends.postgresql",
-        "NAME": "reymota",
+        "NAME": "reymotadb",
         "USER": "creylopez",
         "PASSWORD": "Dsa-0213",
-        "HOST": "postgresql",
+        "HOST": "postgres-cluster-rw.reymota-pg-cluster.svc.cluster.local",
         "PORT": "5432",
+        "OPTIONS": {
+            "options": "-c search_path=reymota,public"
+        }
     }
 }