Browse Source

Preparado para k8s

politica
Celestino Rey 1 year ago
parent
commit
c2895f31e7
17 changed files with 110 additions and 121 deletions
  1. +7
    -7
      JugarAlPadel/K8S/Makefile
  2. +1
    -1
      JugarAlPadel/K8S/db-deployment.yaml
  3. +1
    -1
      JugarAlPadel/K8S/db-service.yaml
  4. +1
    -1
      JugarAlPadel/K8S/entra.sh
  5. +1
    -1
      JugarAlPadel/K8S/entraPsql.sh
  6. +3
    -3
      JugarAlPadel/K8S/env-prod-configmap.yaml
  7. +0
    -11
      JugarAlPadel/K8S/env-prod-db-configmap.yaml
  8. +32
    -32
      JugarAlPadel/K8S/jugaralpadel-deployment.yaml
  9. +15
    -15
      JugarAlPadel/K8S/jugaralpadel-prod-persistentvolumeclaim.yaml
  10. +1
    -1
      JugarAlPadel/K8S/namespace.yaml
  11. +7
    -7
      JugarAlPadel/K8S/nginx-deployment.yaml
  12. +2
    -2
      JugarAlPadel/K8S/nginx-service.yaml
  13. +1
    -1
      JugarAlPadel/K8S/postgres-data-persistentvolumeclaim.yaml
  14. +35
    -35
      JugarAlPadel/K8S/pv-local-jugaralpadel.yaml
  15. +1
    -1
      JugarAlPadel/K8S/reg-secret.yaml
  16. +1
    -1
      JugarAlPadel/K8S/static-volume-persistentvolumeclaim.yaml
  17. +1
    -1
      JugarAlPadel/K8S/verImg.sh

+ 7
- 7
JugarAlPadel/K8S/Makefile View File

@ -1,7 +1,7 @@
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.cube.local #export REGISTRY=registry.cube.local
export REGISTRY=registry.reymota.es export REGISTRY=registry.reymota.es
export IMG_VERSION = 0.16
export IMG_VERSION = 0.01
export IMG_NGINX_VERSION = 1.0 export IMG_NGINX_VERSION = 1.0
# limpia todo # limpia todo
@ -16,22 +16,22 @@ install:
-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
-kubectl create -f pv-local-reymota.yaml
-kubectl create -f reymota-prod-persistentvolumeclaim.yaml
-kubectl create -f pv-local-jugaralpadel.yaml
-kubectl create -f jugaralpadel-prod-persistentvolumeclaim.yaml
-kubectl create -f static-volume-persistentvolumeclaim.yaml -kubectl create -f static-volume-persistentvolumeclaim.yaml
-kubectl create -f postgres-data-persistentvolumeclaim.yaml -kubectl create -f postgres-data-persistentvolumeclaim.yaml
-kubectl create -f db-deployment.yaml -kubectl create -f db-deployment.yaml
-kubectl create -f db-service.yaml -kubectl create -f db-service.yaml
-envsubst < reymota-deployment.yaml |kubectl create -f -
-envsubst < jugaralpadel-deployment.yaml |kubectl create -f -
-envsubst < nginx-deployment.yaml |kubectl create -f - -envsubst < nginx-deployment.yaml |kubectl create -f -
-kubectl create -f nginx-service.yaml -kubectl create -f nginx-service.yaml
clean: clean:
-envsubst < nginx-deployment.yaml |kubectl delete -f - -envsubst < nginx-deployment.yaml |kubectl delete -f -
-kubectl delete -f nginx-service.yaml -kubectl delete -f nginx-service.yaml
-envsubst < reymota-deployment.yaml |kubectl delete -f -
-envsubst < jugaralpadel-deployment.yaml |kubectl delete -f -
-kubectl delete -f db-deployment.yaml -kubectl delete -f db-deployment.yaml
-kubectl delete -f db-service.yaml -kubectl delete -f db-service.yaml
@ -41,8 +41,8 @@ clean:
-kubectl delete -f postgres-data-persistentvolumeclaim.yaml -kubectl delete -f postgres-data-persistentvolumeclaim.yaml
-kubectl delete -f static-volume-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 jugaralpadel-prod-persistentvolumeclaim.yaml
-kubectl delete -f pv-local-jugaralpadel.yaml
-kubectl delete -f reg-secret.yaml -kubectl delete -f reg-secret.yaml
-kubectl delete -f namespace.yaml -kubectl delete -f namespace.yaml


+ 1
- 1
JugarAlPadel/K8S/db-deployment.yaml View File

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


+ 1
- 1
JugarAlPadel/K8S/db-service.yaml View File

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


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

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

+ 1
- 1
JugarAlPadel/K8S/entraPsql.sh View File

@ -1 +1 @@
kubectl -n reymota exec -ti deployment.apps/db -- psql --username=creylopez --dbname=reymota
kubectl -n jugaralpadel exec -ti deployment.apps/db -- psql --username=creylopez --dbname=jugaralpadel

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

@ -1,10 +1,10 @@
apiVersion: v1 apiVersion: v1
data: data:
DEBUG: "True"
DEBUG: "False"
DJANGO_ALLOWED_HOSTS: "reymota.es k8s-server localhost 127.0.0.1 [::1]" DJANGO_ALLOWED_HOSTS: "reymota.es k8s-server localhost 127.0.0.1 [::1]"
CSRF_TRUSTED_ORIGINS: "https://reymota.es" CSRF_TRUSTED_ORIGINS: "https://reymota.es"
SECRET_KEY: change_me SECRET_KEY: change_me
SQL_DATABASE: reymota
SQL_DATABASE: jugaralpadel
SQL_ENGINE: django.db.backends.postgresql SQL_ENGINE: django.db.backends.postgresql
SQL_HOST: db SQL_HOST: db
SQL_PASSWORD: Dsa-0213 SQL_PASSWORD: Dsa-0213
@ -16,4 +16,4 @@ metadata:
labels: labels:
io.kompose.service: web-env-prod io.kompose.service: web-env-prod
name: env-prod name: env-prod
namespace: reymota
namespace: jugaralpadel

+ 0
- 11
JugarAlPadel/K8S/env-prod-db-configmap.yaml View File

@ -1,11 +0,0 @@
apiVersion: v1
data:
POSTGRES_DB: reymota
POSTGRES_PASSWORD: Dsa-0213
POSTGRES_USER: creylopez
kind: ConfigMap
metadata:
labels:
io.kompose.service: db-env-prod-db
name: env-prod-db
namespace: reymota

+ 32
- 32
JugarAlPadel/K8S/jugaralpadel-deployment.yaml View File

@ -1,43 +1,43 @@
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: reymota
namespace: reymota
name: jugaralpadel
namespace: jugaralpadel
spec: spec:
ports: ports:
- name: "8000" - name: "8000"
port: 8000 port: 8000
targetPort: 8000 targetPort: 8000
selector: selector:
app: reymota
app: jugaralpadel
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: reymota
namespace: reymota
name: jugaralpadel
namespace: jugaralpadel
labels: labels:
app: reymota
app: jugaralpadel
spec: spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
app: reymota
app: jugaralpadel
strategy: strategy:
type: Recreate type: Recreate
template: template:
metadata: metadata:
labels: labels:
app: reymota
app: jugaralpadel
spec: spec:
containers: containers:
- args: - args:
- gunicorn - gunicorn
- reymota.wsgi:application
- gestion_reservas.wsgi:application
- --bind - --bind
- 0.0.0.0:8000 - 0.0.0.0:8000
name: reymota
image: $REGISTRY/reymota-$ARQUITECTURA:$IMG_VERSION
name: jugaralpadel
image: $REGISTRY/jugaralpadel-$ARQUITECTURA:$IMG_VERSION
env: env:
- name: VERSION - name: VERSION
value: "$IMG_VERSION" value: "$IMG_VERSION"
@ -102,39 +102,39 @@ spec:
- containerPort: 8000 - containerPort: 8000
protocol: TCP protocol: TCP
volumeMounts: volumeMounts:
- mountPath: /app/reymota/mediafiles
name: reymota-media
- mountPath: /app/jugaralpadel/mediafiles
name: jugaralpadel-media
- mountPath: /app/reymota/lyrics/migrations
name: reymota-lyrics-migrations
- mountPath: /app/reymota/repostajes/migrations
name: reymota-repostajes-migrations
- mountPath: /app/reymota/libros/migrations
name: reymota-libros-migrations
- mountPath: /app/reymota/reymotausers/migrations
name: reymota-reymotausers-migrations
- mountPath: /app/jugaralpadel/lyrics/migrations
name: jugaralpadel-lyrics-migrations
- mountPath: /app/jugaralpadel/repostajes/migrations
name: jugaralpadel-repostajes-migrations
- mountPath: /app/jugaralpadel/libros/migrations
name: jugaralpadel-libros-migrations
- mountPath: /app/jugaralpadel/jugaralpadelusers/migrations
name: jugaralpadel-jugaralpadelusers-migrations
- mountPath: /app/reymota/staticfiles
- mountPath: /app/jugaralpadel/staticfiles
name: static-volume name: static-volume
imagePullSecrets: imagePullSecrets:
- name: myregistrykey - name: myregistrykey
restartPolicy: Always restartPolicy: Always
volumes: volumes:
- name: reymota-media
- name: jugaralpadel-media
persistentVolumeClaim: persistentVolumeClaim:
claimName: reymota-media
- name: reymota-lyrics-migrations
claimName: jugaralpadel-media
- name: jugaralpadel-lyrics-migrations
persistentVolumeClaim: persistentVolumeClaim:
claimName: reymota-lyrics-migrations
- name: reymota-repostajes-migrations
claimName: jugaralpadel-lyrics-migrations
- name: jugaralpadel-repostajes-migrations
persistentVolumeClaim: persistentVolumeClaim:
claimName: reymota-repostajes-migrations
- name: reymota-libros-migrations
claimName: jugaralpadel-repostajes-migrations
- name: jugaralpadel-libros-migrations
persistentVolumeClaim: persistentVolumeClaim:
claimName: reymota-libros-migrations
- name: reymota-reymotausers-migrations
claimName: jugaralpadel-libros-migrations
- name: jugaralpadel-jugaralpadelusers-migrations
persistentVolumeClaim: persistentVolumeClaim:
claimName: reymota-reymotausers-migrations
claimName: jugaralpadel-jugaralpadelusers-migrations
- name: static-volume - name: static-volume
persistentVolumeClaim: persistentVolumeClaim:
claimName: static-volume claimName: static-volume


+ 15
- 15
JugarAlPadel/K8S/jugaralpadel-prod-persistentvolumeclaim.yaml View File

@ -3,9 +3,9 @@ kind: PersistentVolumeClaim
metadata: metadata:
creationTimestamp: null creationTimestamp: null
labels: labels:
io.kompose.service: reymota-media
name: reymota-media
namespace: reymota
io.kompose.service: jugaralpadel-media
name: jugaralpadel-media
namespace: jugaralpadel
spec: spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
@ -19,9 +19,9 @@ kind: PersistentVolumeClaim
metadata: metadata:
creationTimestamp: null creationTimestamp: null
labels: labels:
io.kompose.service: reymota-libros-migrations
name: reymota-libros-migrations
namespace: reymota
io.kompose.service: jugaralpadel-libros-migrations
name: jugaralpadel-libros-migrations
namespace: jugaralpadel
spec: spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
@ -35,9 +35,9 @@ kind: PersistentVolumeClaim
metadata: metadata:
creationTimestamp: null creationTimestamp: null
labels: labels:
io.kompose.service: reymota-lyrics-migrations
name: reymota-lyrics-migrations
namespace: reymota
io.kompose.service: jugaralpadel-lyrics-migrations
name: jugaralpadel-lyrics-migrations
namespace: jugaralpadel
spec: spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
@ -51,9 +51,9 @@ kind: PersistentVolumeClaim
metadata: metadata:
creationTimestamp: null creationTimestamp: null
labels: labels:
io.kompose.service: reymota-repostajes-migrations
name: reymota-repostajes-migrations
namespace: reymota
io.kompose.service: jugaralpadel-repostajes-migrations
name: jugaralpadel-repostajes-migrations
namespace: jugaralpadel
spec: spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
@ -67,9 +67,9 @@ kind: PersistentVolumeClaim
metadata: metadata:
creationTimestamp: null creationTimestamp: null
labels: labels:
io.kompose.service: reymota-reymotausers-migrations
name: reymota-reymotausers-migrations
namespace: reymota
io.kompose.service: jugaralpadel-jugaralpadelusers-migrations
name: jugaralpadel-jugaralpadelusers-migrations
namespace: jugaralpadel
spec: spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce


+ 1
- 1
JugarAlPadel/K8S/namespace.yaml View File

@ -4,4 +4,4 @@
apiVersion: v1 apiVersion: v1
kind: Namespace kind: Namespace
metadata: metadata:
name: reymota
name: jugaralpadel

+ 7
- 7
JugarAlPadel/K8S/nginx-deployment.yaml View File

@ -7,7 +7,7 @@ metadata:
labels: labels:
io.kompose.service: nginx io.kompose.service: nginx
name: nginx name: nginx
namespace: reymota
namespace: jugaralpadel
spec: spec:
replicas: 1 replicas: 1
selector: selector:
@ -24,16 +24,16 @@ spec:
io.kompose.service: nginx io.kompose.service: nginx
spec: spec:
containers: containers:
- image: $REGISTRY/nginx-reymota-$ARQUITECTURA:$IMG_NGINX_VERSION
- image: $REGISTRY/nginx-jugaralpadel-$ARQUITECTURA:$IMG_NGINX_VERSION
name: nginx name: nginx
ports: ports:
- containerPort: 80 - containerPort: 80
protocol: TCP protocol: TCP
volumeMounts: volumeMounts:
- mountPath: /app/reymota/staticfiles
- mountPath: /app/jugaralpadel/staticfiles
name: static-volume name: static-volume
- mountPath: /app/reymota/mediafiles
name: reymota-media
- mountPath: /app/jugaralpadel/mediafiles
name: jugaralpadel-media
imagePullSecrets: imagePullSecrets:
- name: myregistrykey - name: myregistrykey
restartPolicy: Always restartPolicy: Always
@ -41,6 +41,6 @@ spec:
- name: static-volume - name: static-volume
persistentVolumeClaim: persistentVolumeClaim:
claimName: static-volume claimName: static-volume
- name: reymota-media
- name: jugaralpadel-media
persistentVolumeClaim: persistentVolumeClaim:
claimName: reymota-media
claimName: jugaralpadel-media

+ 2
- 2
JugarAlPadel/K8S/nginx-service.yaml View File

@ -7,13 +7,13 @@ metadata:
labels: labels:
io.kompose.service: nginx io.kompose.service: nginx
name: nginx name: nginx
namespace: reymota
namespace: jugaralpadel
spec: spec:
type: NodePort type: NodePort
ports: ports:
- name: "1337" - name: "1337"
port: 1337 port: 1337
nodePort: 30341
nodePort: 30345
targetPort: 80 targetPort: 80
selector: selector:
io.kompose.service: nginx io.kompose.service: nginx


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

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


+ 35
- 35
JugarAlPadel/K8S/pv-local-jugaralpadel.yaml View File

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

+ 1
- 1
JugarAlPadel/K8S/reg-secret.yaml View File

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

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

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


+ 1
- 1
JugarAlPadel/K8S/verImg.sh View File

@ -1 +1 @@
docker run -it registry.reymota.es/reymota-x86_64:0.1 bash
docker run -it registry.jugaralpadel.es/jugaralpadel-x86_64:0.1 bash

Loading…
Cancel
Save