diff --git a/Dockerfile.k8s b/Dockerfile.k8s index 5a6158b..faa147b 100644 --- a/Dockerfile.k8s +++ b/Dockerfile.k8s @@ -58,7 +58,6 @@ RUN pip install --no-cache /wheels/* # copy entrypoint.sh COPY ./entrypoint.sh . - # copy project COPY . $APP_HOME diff --git a/K8S/Makefile b/K8S/Makefile index bea44c6..ae582bf 100644 --- a/K8S/Makefile +++ b/K8S/Makefile @@ -1,6 +1,6 @@ export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':') export REGISTRY=registry.reymota.es -export IMG_VERSION = 0.56 +export IMG_VERSION = 0.60 export IMG_NGINX_VERSION = 1.0 # limpia todo diff --git a/K8S/db-deployment.yaml b/K8S/db-deployment.yaml index e80c2bd..640aa39 100644 --- a/K8S/db-deployment.yaml +++ b/K8S/db-deployment.yaml @@ -5,14 +5,14 @@ metadata: kompose.cmd: kompose convert kompose.version: 1.34.0 (cbf2835db) labels: - io.kompose.service: db - name: db + io.kompose.service: postgresql + name: postgresql namespace: reymota spec: replicas: 1 selector: matchLabels: - io.kompose.service: db + io.kompose.service: postgresql strategy: type: Recreate template: @@ -21,7 +21,7 @@ spec: kompose.cmd: kompose convert kompose.version: 1.34.0 (cbf2835db) labels: - io.kompose.service: db + io.kompose.service: postgresql spec: containers: - env: @@ -41,7 +41,7 @@ spec: key: POSTGRES_USER name: env-prod-db image: postgres:15 - name: db + name: postgresql volumeMounts: - mountPath: /var/lib/postgresql/data name: postgres-data diff --git a/K8S/db-service.yaml b/K8S/db-service.yaml index 98e237d..f7fc05d 100644 --- a/K8S/db-service.yaml +++ b/K8S/db-service.yaml @@ -5,8 +5,8 @@ metadata: kompose.cmd: kompose convert kompose.version: 1.34.0 (cbf2835db) labels: - io.kompose.service: db - name: db + io.kompose.service: postgresql + name: postgresql namespace: reymota spec: ports: @@ -14,4 +14,4 @@ spec: port: 5432 targetPort: 5432 selector: - io.kompose.service: db + io.kompose.service: postgresql diff --git a/K8S/nginx-deployment-limpio.yaml b/K8S/nginx-deployment-limpio.yaml deleted file mode 100644 index 2d781dd..0000000 --- a/K8S/nginx-deployment-limpio.yaml +++ /dev/null @@ -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: reymota -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-reymota-x86_64:1.0 - name: nginx - ports: - - containerPort: 80 - protocol: TCP - volumeMounts: - - mountPath: /app/reymota/staticfiles - name: static-volume - - mountPath: /app/reymota/mediafiles - name: reymota-media - imagePullSecrets: - - name: myregistrykey - restartPolicy: Always - volumes: - - name: static-volume - persistentVolumeClaim: - claimName: static-volume - - name: reymota-media - persistentVolumeClaim: - claimName: reymota-media diff --git a/K8S/reymota-deployment-limpio.yaml b/K8S/reymota-deployment-limpio.yaml deleted file mode 100644 index 1ae94d0..0000000 --- a/K8S/reymota-deployment-limpio.yaml +++ /dev/null @@ -1,139 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: reymota - namespace: reymota -spec: - ports: - - name: "8000" - port: 8000 - targetPort: 8000 - selector: - app: reymota ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: reymota - namespace: reymota - labels: - app: reymota -spec: - replicas: 1 - selector: - matchLabels: - app: reymota - strategy: - type: Recreate - template: - metadata: - labels: - app: reymota - spec: - containers: - - args: - - gunicorn - - reymota.wsgi:application - - --bind - - 0.0.0.0:8000 - name: reymota - image: registry.reymota.es/reymota-x86_64:0.24 - env: - - name: VERSION - value: "0.24" - - name: ENVIRONMENT - valueFrom: - configMapKeyRef: - key: ENTORNO - name: env-prod - - name: DEBUG - valueFrom: - configMapKeyRef: - key: DEBUG - name: env-prod - - name: DJANGO_ALLOWED_HOSTS - valueFrom: - configMapKeyRef: - key: DJANGO_ALLOWED_HOSTS - name: env-prod - - name: CSRF_TRUSTED_ORIGINS - valueFrom: - configMapKeyRef: - key: CSRF_TRUSTED_ORIGINS - name: env-prod - - name: SECRET_KEY - valueFrom: - configMapKeyRef: - key: SECRET_KEY - name: env-prod - - name: DATABASE - valueFrom: - configMapKeyRef: - key: DATABASE - name: env-prod - - name: SQL_HOST - valueFrom: - configMapKeyRef: - key: SQL_HOST - name: env-prod - - name: SQL_PORT - valueFrom: - configMapKeyRef: - key: SQL_PORT - name: env-prod - - name: SQL_ENGINE - valueFrom: - configMapKeyRef: - key: SQL_ENGINE - name: env-prod - - name: SQL_DATABASE - valueFrom: - configMapKeyRef: - key: SQL_DATABASE - name: env-prod - - name: SQL_USER - valueFrom: - configMapKeyRef: - key: SQL_USER - name: env-prod - - name: SQL_PASSWORD - valueFrom: - configMapKeyRef: - key: SQL_PASSWORD - name: env-prod - ports: - - containerPort: 8000 - protocol: TCP - volumeMounts: - - mountPath: /app/reymota/mediafiles - name: reymota-media - - - mountPath: /app/reymota/lyrics/migrations - name: reymota-lyrics-migrations - - mountPath: /app/reymota/repostajes/migrations - name: reymota-repostajes-migrations - - mountPath: /app/reymota/reymotausers/migrations - name: reymota-reymotausers-migrations - - - mountPath: /app/reymota/staticfiles - name: static-volume - imagePullSecrets: - - name: myregistrykey - restartPolicy: Always - volumes: - - name: reymota-media - persistentVolumeClaim: - claimName: reymota-media - - name: reymota-lyrics-migrations - persistentVolumeClaim: - claimName: reymota-lyrics-migrations - - name: reymota-repostajes-migrations - persistentVolumeClaim: - claimName: reymota-repostajes-migrations - - name: reymota-reymotausers-migrations - persistentVolumeClaim: - claimName: reymota-reymotausers-migrations - - name: static-volume - persistentVolumeClaim: - claimName: static-volume -status: {} diff --git a/K8S/reymota-deployment.yaml b/K8S/reymota-deployment.yaml index fdabea3..04b65e7 100644 --- a/K8S/reymota-deployment.yaml +++ b/K8S/reymota-deployment.yaml @@ -41,6 +41,8 @@ spec: env: - name: VERSION value: "$IMG_VERSION" + - name: OPENSHIFT + value: "False" - name: ENVIRONMENT valueFrom: configMapKeyRef: diff --git a/README.md b/README.md index 7aa6e49..5afbf15 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Crear un proyecto. A continuación añadir una app desde Agregar, importar desde git. - oc new-app http://gitea.reymota.es/creylopez/ReyMotaAppsOC.git -e DEBUG="False" --name='reymota' + oc new-app http://gitea.reymota.es/creylopez/ReyMotaAppsOC.git -e DEBUG="False" -e OPENSHIFT="True" --name='reymota' Tal y como está la estructura de directorios, deberia detectar automáticamente una compilación Python diff --git a/src/reymota/context_processors.py b/src/reymota/context_processors.py index eece58c..4a78c47 100644 --- a/src/reymota/context_processors.py +++ b/src/reymota/context_processors.py @@ -5,3 +5,9 @@ def app_version(request): return { 'APP_VERSION': settings.APP_VERSION } + + +def isopenshift(request): + return { + 'OPENSHIFT': settings.OPENSHIFT + } diff --git a/src/reymota/settings.py b/src/reymota/settings.py index 5af120e..1ff6170 100644 --- a/src/reymota/settings.py +++ b/src/reymota/settings.py @@ -29,6 +29,7 @@ SECRET_KEY = 'django-insecure-vu#zk4g8pj-qoov#8^i$&s8n_ipp2r3h+o$z1w(1%d=6+i@erm # SECURITY WARNING: don't run with debug turned on in production! # DEBUG = True DEBUG = os.environ["DEBUG"] == 'True' +OPENSHIFT = os.environ["OPENSHIFT"] == 'True' ALLOWED_HOSTS = [".ocp-cluster.reymota.lab", "reymota.es", ".reymota.lab"] diff --git a/src/templates/index.html b/src/templates/index.html index e0d35ee..5f699bb 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -1,5 +1,7 @@ {% extends 'base.html' %} +{% load filtros_de_entorno %} + {% block content %}