Przeglądaj źródła

Arreglos para mostrar entorno de trabajo

Celestino Rey 1 rok temu
rodzic
commit
7c6b7420e6

+ 0 - 1
Dockerfile.k8s

@@ -58,7 +58,6 @@ RUN pip install --no-cache /wheels/*
 # copy entrypoint.sh
 COPY ./entrypoint.sh .
 
-
 # copy project
 COPY . $APP_HOME
 

+ 1 - 1
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

+ 5 - 5
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

+ 3 - 3
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

+ 0 - 46
K8S/nginx-deployment-limpio.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: 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

+ 0 - 139
K8S/reymota-deployment-limpio.yaml

@@ -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: {}

+ 2 - 0
K8S/reymota-deployment.yaml

@@ -41,6 +41,8 @@ spec:
         env:
         - name: VERSION
           value: "$IMG_VERSION"
+        - name: OPENSHIFT
+          value: "False"
         - name: ENVIRONMENT
           valueFrom:
             configMapKeyRef:

+ 1 - 1
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
 

+ 6 - 0
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
+    }

+ 1 - 0
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"]
 

+ 8 - 0
src/templates/index.html

@@ -1,5 +1,7 @@
 {% extends 'base.html' %}
 
+{% load filtros_de_entorno %}
+
 {% block content %}
 
 <div class="container-xl">
@@ -9,7 +11,13 @@
     <div class="app-card alert alert-dismissible shadow-sm mb-4 border-left-decoration" role="alert">
         <div class="inner">
             <div class="app-card-body p-3 p-lg-4">
+
+             {% if 'OPENSHIFT'|muestra_version == 'True' %}
                 <h3 class="mb-3">¡Bienvenido a sitio REYMOTA.ES en Openshift!</h3>
+             {% else %}
+                <h3 class="mb-3">¡Bienvenido a sitio REYMOTA.ES en K8S!</h3>
+             {% endif %}
+
                 <div class="row gx-5 gy-3">
                     <!--
                     <div class="col-12 col-lg-9">