Browse Source

Funcionando desde reymota.es

politica
Celestino Rey 1 year ago
parent
commit
d90dec2dbb
17 changed files with 51 additions and 8 deletions
  1. +5
    -1
      Libros/K8S/Makefile
  2. +1
    -0
      Libros/K8S/db-deployment.yaml
  3. +1
    -0
      Libros/K8S/db-service.yaml
  4. +1
    -1
      Libros/K8S/entra.sh
  5. +3
    -1
      Libros/K8S/env-prod-configmap.yaml
  6. +1
    -0
      Libros/K8S/env-prod-db-configmap.yaml
  7. +7
    -0
      Libros/K8S/libros-deployment.yaml
  8. +2
    -0
      Libros/K8S/libros-prod-persistentvolumeclaim.yaml
  9. +7
    -0
      Libros/K8S/namespace.yaml
  10. +2
    -1
      Libros/K8S/nginx-deployment.yaml
  11. +1
    -0
      Libros/K8S/nginx-service.yaml
  12. +1
    -0
      Libros/K8S/postgres-data-persistentvolumeclaim.yaml
  13. +5
    -1
      Libros/K8S/pv-local-libros.yaml
  14. +8
    -0
      Libros/K8S/reg-secret.yaml
  15. +1
    -0
      Libros/K8S/static-volume-persistentvolumeclaim.yaml
  16. +3
    -1
      Libros/biblioteca/biblioteca/settings.py
  17. +2
    -2
      Libros/nginx/Makefile

+ 5
- 1
Libros/K8S/Makefile View File

@ -1,5 +1,5 @@
export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':') export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':')
export IMG_VERSION = 1.30
export IMG_VERSION = 1.34
export IMG_NGINX_VERSION = 1.17 export IMG_NGINX_VERSION = 1.17
# limpia todo # limpia todo
@ -9,6 +9,8 @@ imagen:
cd ../; make cd ../; make
install: install:
-kubectl create -f namespace.yaml
-kubectl create -f reg-secret.yaml
-kubectl create -f env-prod-configmap.yaml -kubectl create -f env-prod-configmap.yaml
-kubectl create -f env-prod-db-configmap.yaml -kubectl create -f env-prod-db-configmap.yaml
@ -39,6 +41,8 @@ clean:
-kubectl delete -f static-volume-persistentvolumeclaim.yaml -kubectl delete -f static-volume-persistentvolumeclaim.yaml
-kubectl delete -f libros-prod-persistentvolumeclaim.yaml -kubectl delete -f libros-prod-persistentvolumeclaim.yaml
-kubectl delete -f pv-local-libros.yaml -kubectl delete -f pv-local-libros.yaml
-kubectl delete -f reg-secret.yaml
-kubectl delete -f namespace.yaml
nginx: nginx:
cd ../nginx; make cd ../nginx; make

+ 1
- 0
Libros/K8S/db-deployment.yaml View File

@ -7,6 +7,7 @@ metadata:
labels: labels:
io.kompose.service: db io.kompose.service: db
name: db name: db
namespace: libros
spec: spec:
replicas: 1 replicas: 1
selector: selector:


+ 1
- 0
Libros/K8S/db-service.yaml View File

@ -7,6 +7,7 @@ metadata:
labels: labels:
io.kompose.service: db io.kompose.service: db
name: db name: db
namespace: libros
spec: spec:
ports: ports:
- name: "5432" - name: "5432"


+ 1
- 1
Libros/K8S/entra.sh View File

@ -1 +1 @@
kubectl exec -ti deployment.apps/libros -- /bin/bash
kubectl -n libros exec -ti deployment.apps/libros -- /bin/bash

+ 3
- 1
Libros/K8S/env-prod-configmap.yaml View File

@ -1,7 +1,8 @@
apiVersion: v1 apiVersion: v1
data: data:
DEBUG: "0" DEBUG: "0"
DJANGO_ALLOWED_HOSTS: libros.reymota.es k8s-server localhost 127.0.0.1 [::1]
DJANGO_ALLOWED_HOSTS: "libros.reymota.es k8s-server localhost 127.0.0.1 [::1]"
CSRF_TRUSTED_ORIGINS: "https://libros.reymota.es"
SECRET_KEY: change_me SECRET_KEY: change_me
SQL_DATABASE: libros SQL_DATABASE: libros
SQL_ENGINE: django.db.backends.postgresql SQL_ENGINE: django.db.backends.postgresql
@ -15,3 +16,4 @@ metadata:
labels: labels:
io.kompose.service: web-env-prod io.kompose.service: web-env-prod
name: env-prod name: env-prod
namespace: libros

+ 1
- 0
Libros/K8S/env-prod-db-configmap.yaml View File

@ -8,3 +8,4 @@ metadata:
labels: labels:
io.kompose.service: db-env-prod-db io.kompose.service: db-env-prod-db
name: env-prod-db name: env-prod-db
namespace: libros

+ 7
- 0
Libros/K8S/libros-deployment.yaml View File

@ -2,6 +2,7 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: libros name: libros
namespace: libros
spec: spec:
ports: ports:
- name: "8000" - name: "8000"
@ -14,6 +15,7 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: libros name: libros
namespace: libros
labels: labels:
app: libros app: libros
spec: spec:
@ -51,6 +53,11 @@ spec:
configMapKeyRef: configMapKeyRef:
key: DJANGO_ALLOWED_HOSTS key: DJANGO_ALLOWED_HOSTS
name: env-prod name: env-prod
- name: CSRF_TRUSTED_ORIGINS
valueFrom:
configMapKeyRef:
key: CSRF_TRUSTED_ORIGINS
name: env-prod
- name: SECRET_KEY - name: SECRET_KEY
valueFrom: valueFrom:
configMapKeyRef: configMapKeyRef:


+ 2
- 0
Libros/K8S/libros-prod-persistentvolumeclaim.yaml View File

@ -5,6 +5,7 @@ metadata:
labels: labels:
io.kompose.service: libros-media io.kompose.service: libros-media
name: libros-media name: libros-media
namespace: libros
spec: spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
@ -20,6 +21,7 @@ metadata:
labels: labels:
io.kompose.service: libros-migrations io.kompose.service: libros-migrations
name: libros-migrations name: libros-migrations
namespace: libros
spec: spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce


+ 7
- 0
Libros/K8S/namespace.yaml View File

@ -0,0 +1,7 @@
###################################################
# Namespace Libros
###################################################
apiVersion: v1
kind: Namespace
metadata:
name: libros

+ 2
- 1
Libros/K8S/nginx-deployment.yaml View File

@ -7,6 +7,7 @@ metadata:
labels: labels:
io.kompose.service: nginx io.kompose.service: nginx
name: nginx name: nginx
namespace: libros
spec: spec:
replicas: 1 replicas: 1
selector: selector:
@ -23,7 +24,7 @@ spec:
io.kompose.service: nginx io.kompose.service: nginx
spec: spec:
containers: containers:
- image: registry.reymota.es/nginx-$ARQUITECTURA:$IMG_NGINX_VERSION
- image: registry.reymota.es/nginx-libros-$ARQUITECTURA:$IMG_NGINX_VERSION
name: nginx name: nginx
ports: ports:
- containerPort: 80 - containerPort: 80


+ 1
- 0
Libros/K8S/nginx-service.yaml View File

@ -7,6 +7,7 @@ metadata:
labels: labels:
io.kompose.service: nginx io.kompose.service: nginx
name: nginx name: nginx
namespace: libros
spec: spec:
type: NodePort type: NodePort
ports: ports:


+ 1
- 0
Libros/K8S/postgres-data-persistentvolumeclaim.yaml View File

@ -4,6 +4,7 @@ metadata:
labels: labels:
io.kompose.service: postgres-data io.kompose.service: postgres-data
name: postgres-data name: postgres-data
namespace: libros
spec: spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce


+ 5
- 1
Libros/K8S/pv-local-libros.yaml View File

@ -2,6 +2,7 @@ apiVersion: v1
kind: PersistentVolume kind: PersistentVolume
metadata: metadata:
name: libros-media-folder name: libros-media-folder
namespace: libros
labels: labels:
app: libros app: libros
spec: spec:
@ -16,6 +17,7 @@ apiVersion: v1
kind: PersistentVolume kind: PersistentVolume
metadata: metadata:
name: libros-migrations-folder name: libros-migrations-folder
namespace: libros
labels: labels:
app: libros app: libros
spec: spec:
@ -30,6 +32,7 @@ apiVersion: v1
kind: PersistentVolume kind: PersistentVolume
metadata: metadata:
name: libros-static-folder name: libros-static-folder
namespace: libros
labels: labels:
app: libros app: libros
spec: spec:
@ -44,6 +47,7 @@ apiVersion: v1
kind: PersistentVolume kind: PersistentVolume
metadata: metadata:
name: libros-pg-folder name: libros-pg-folder
namespace: libros
labels: labels:
app: libros app: libros
spec: spec:
@ -52,4 +56,4 @@ spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
hostPath: hostPath:
path: "/mnt/Externo/libros/pg"
path: "/mnt/Externo/libros/pg"

+ 8
- 0
Libros/K8S/reg-secret.yaml View File

@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: myregistrykey
namespace: libros
data:
.dockerconfigjson: ewoJImF1dGhzIjogewoJCSJyZWdpc3RyeS5yZXltb3RhLmVzIjogewoJCQkiYXV0aCI6ICJZM0psZVd4dmNHVjZPbEpsZVMweE1UYzIiCgkJfQoJfQp9
type: kubernetes.io/dockerconfigjson

+ 1
- 0
Libros/K8S/static-volume-persistentvolumeclaim.yaml View File

@ -4,6 +4,7 @@ metadata:
labels: labels:
io.kompose.service: static-volume io.kompose.service: static-volume
name: static-volume name: static-volume
namespace: libros
spec: spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce


+ 3
- 1
Libros/biblioteca/biblioteca/settings.py View File

@ -31,6 +31,8 @@ DEBUG = bool(os.environ.get("DEBUG", default=0))
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ")
print("HOSTS PERMITIDOS: ", ALLOWED_HOSTS)
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
@ -161,4 +163,4 @@ LOGGING = {
}, },
} }
CSRF_TRUSTED_ORIGINS = ["http://localhost:30443"]
CSRF_TRUSTED_ORIGINS = os.environ.get("CSRF_TRUSTED_ORIGINS").split(" ")

+ 2
- 2
Libros/nginx/Makefile View File

@ -2,7 +2,7 @@ install:
echo "Creando imagen con version ${IMG_NGINX_VERSION} para la arquitectura ${ARQUITECTURA}" echo "Creando imagen con version ${IMG_NGINX_VERSION} para la arquitectura ${ARQUITECTURA}"
docker build --no-cache -t registry.reymota.es/nginx-${ARQUITECTURA}:${IMG_NGINX_VERSION} .
docker push registry.reymota.es/nginx-${ARQUITECTURA}:${IMG_NGINX_VERSION}
docker build --no-cache -t registry.reymota.es/nginx-libros-${ARQUITECTURA}:${IMG_NGINX_VERSION} .
docker push registry.reymota.es/nginx-libros-${ARQUITECTURA}:${IMG_NGINX_VERSION}

Loading…
Cancel
Save