Browse Source

Arreglos para mostrar entorno de trabajo

main
Celestino Rey 8 months ago
parent
commit
7c6b7420e6
11 changed files with 27 additions and 196 deletions
  1. +0
    -1
      Dockerfile.k8s
  2. +1
    -1
      K8S/Makefile
  3. +5
    -5
      K8S/db-deployment.yaml
  4. +3
    -3
      K8S/db-service.yaml
  5. +0
    -46
      K8S/nginx-deployment-limpio.yaml
  6. +0
    -139
      K8S/reymota-deployment-limpio.yaml
  7. +2
    -0
      K8S/reymota-deployment.yaml
  8. +1
    -1
      README.md
  9. +6
    -0
      src/reymota/context_processors.py
  10. +1
    -0
      src/reymota/settings.py
  11. +8
    -0
      src/templates/index.html

+ 0
- 1
Dockerfile.k8s View File

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


+ 1
- 1
K8S/Makefile View File

@ -1,6 +1,6 @@
export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':') export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':')
export REGISTRY=registry.reymota.es export REGISTRY=registry.reymota.es
export IMG_VERSION = 0.56
export IMG_VERSION = 0.60
export IMG_NGINX_VERSION = 1.0 export IMG_NGINX_VERSION = 1.0
# limpia todo # limpia todo


+ 5
- 5
K8S/db-deployment.yaml View File

@ -5,14 +5,14 @@ metadata:
kompose.cmd: kompose convert kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db) kompose.version: 1.34.0 (cbf2835db)
labels: labels:
io.kompose.service: db
name: db
io.kompose.service: postgresql
name: postgresql
namespace: reymota namespace: reymota
spec: spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
io.kompose.service: db
io.kompose.service: postgresql
strategy: strategy:
type: Recreate type: Recreate
template: template:
@ -21,7 +21,7 @@ spec:
kompose.cmd: kompose convert kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db) kompose.version: 1.34.0 (cbf2835db)
labels: labels:
io.kompose.service: db
io.kompose.service: postgresql
spec: spec:
containers: containers:
- env: - env:
@ -41,7 +41,7 @@ spec:
key: POSTGRES_USER key: POSTGRES_USER
name: env-prod-db name: env-prod-db
image: postgres:15 image: postgres:15
name: db
name: postgresql
volumeMounts: volumeMounts:
- mountPath: /var/lib/postgresql/data - mountPath: /var/lib/postgresql/data
name: postgres-data name: postgres-data


+ 3
- 3
K8S/db-service.yaml View File

@ -5,8 +5,8 @@ metadata:
kompose.cmd: kompose convert kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db) kompose.version: 1.34.0 (cbf2835db)
labels: labels:
io.kompose.service: db
name: db
io.kompose.service: postgresql
name: postgresql
namespace: reymota namespace: reymota
spec: spec:
ports: ports:
@ -14,4 +14,4 @@ spec:
port: 5432 port: 5432
targetPort: 5432 targetPort: 5432
selector: selector:
io.kompose.service: db
io.kompose.service: postgresql

+ 0
- 46
K8S/nginx-deployment-limpio.yaml View File

@ -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 View File

@ -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 View File

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


+ 1
- 1
README.md View File

@ -12,7 +12,7 @@ Crear un proyecto.
A continuación añadir una app desde Agregar, importar desde git. 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 Tal y como está la estructura de directorios, deberia detectar automáticamente una compilación Python


+ 6
- 0
src/reymota/context_processors.py View File

@ -5,3 +5,9 @@ def app_version(request):
return { return {
'APP_VERSION': settings.APP_VERSION 'APP_VERSION': settings.APP_VERSION
} }
def isopenshift(request):
return {
'OPENSHIFT': settings.OPENSHIFT
}

+ 1
- 0
src/reymota/settings.py View File

@ -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! # SECURITY WARNING: don't run with debug turned on in production!
# DEBUG = True # DEBUG = True
DEBUG = os.environ["DEBUG"] == 'True' 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"]


+ 8
- 0
src/templates/index.html View File

@ -1,5 +1,7 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load filtros_de_entorno %}
{% block content %} {% block content %}
<div class="container-xl"> <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="app-card alert alert-dismissible shadow-sm mb-4 border-left-decoration" role="alert">
<div class="inner"> <div class="inner">
<div class="app-card-body p-3 p-lg-4"> <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> <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="row gx-5 gy-3">
<!-- <!--
<div class="col-12 col-lg-9"> <div class="col-12 col-lg-9">


Loading…
Cancel
Save