Browse Source

Corrijo path a gitea

main
Celestino Rey 9 months ago
parent
commit
629a736c99
9 changed files with 156 additions and 16 deletions
  1. +50
    -16
      README.md
  2. +11
    -0
      Yamls/env-prod-db-configmap.yaml
  3. +52
    -0
      Yamls/postgresql-deployment.yaml
  4. +17
    -0
      Yamls/postgresql-service.yaml
  5. +17
    -0
      Yamls/pvc-postgresql.yaml
  6. +3
    -0
      borraDB.sh
  7. +4
    -0
      creaDB.sh
  8. +1
    -0
      entra.sh
  9. +1
    -0
      nuevaapp.sh

+ 50
- 16
README.md View File

@ -1,30 +1,64 @@
# Running Commands as Root in OpenShift
# Versión para openshift
## Opción 1
## Instalación
### Crear un proyecto
oc new-project jugaralpadel
#### Permitir que los pods puedan funcionar como root
oc adm policy add-scc-to-user anyuid -z default
## Opción 2
### Añadir la app desde gitea
oc new-app http://gitea.reymota.es/creylopez/JugarAlPadelOC.git -e DEBUG="False" -e VERSION=11.0 --name='jugaralpadel'
Tal y como está la estructura de directorios, deberia detectar automáticamente una compilación Python
## Asignación de los volúmenes
### Si la pvc no está creada
oc set volume deployment.apps/jugaralpadel --add -t pvc --claim-size=300M --name=jugaralpadel-eventos-migrations --claim-name='jugaralpadel-eventos-migrations' --mount-path='/app/eventos/migrations'
oc set volume deployment.apps/jugaralpadel --add -t pvc --claim-size=300M --name=jugaralpadel-media --claim-name='jugaralpadel-media' --mount-path='/app/mediafiles'
oc set volume deployment.apps/jugaralpadel --add -t pvc --claim-size=300M --name=reymota-reymotausers-migrations --claim-name='reymota-reymotausers-migrations' --mount-path='/app/reymotausers/migrations'
oc set volume deployment.apps/jugaralpadel --add -t pvc --claim-size=50G --name=static-volume --claim-name='static-volume' --mount-path='/app/staticfiles'
### Si la pvc ya está creada
oc set volume deployment.apps/jugaralpadel --add -t pvc --name=jugaralpadel-eventos-migrations --claim-name='jugaralpadel-eventos-migrations' --mount-path='/app/eventos/migrations'
oc set volume deployment.apps/jugaralpadel --add -t pvc --name=jugaralpadel-media --claim-name='jugaralpadel-media' --mount-path='/app/mediafiles'
oc set volume deployment.apps/jugaralpadel --add -t pvc --name=reymota-reymotausers-migrations --claim-name='reymota-reymotausers-migrations' --mount-path='/app/reymotausers/migrations'
oc set volume deployment.apps/jugaralpadel --add -t pvc --name=static-volume --claim-name='static-volume' --mount-path='/app/staticfiles'
## Exponer el servicio
oc expose service/reymota
### postgresql
Los ficheros yaml están en el directorio Yamls.
Esta es la que usé la primera vez, pero hay que hacerlo para cada deployment. La opción 1 es una vez por proyecto.
Se crea el deployment y el servicio con la shell creaDB.sh
Se borran con borraDB.sh
Running commands as root in OpenShift is restricted by default due to security policies. To allow a container to run as root, you need to use the anyuid Security Context Constraints (SCC) or create a custom SCC. Here are the steps to enable running commands as root:
Hay que tener en cuenta que la PVC *no* se crea en estas shells. Hay que crearla a mano. Esto se hace para no perder los datos.
1. Create a Service Account: First, create a new service account in the project where you want to run the container as root.
oc create serviceaccount runasanyuid
2. Grant the anyuid SCC to the Service Account: As a cluster administrator, grant the anyuid SCC to the service account.
## Cosas a hacer la primera vez
Desde dentro de la shell del pod
oc adm policy add-scc-to-user anyuid -z runasanyuid --as system:admin
3. Update the Deployment Configuration: Modify the deployment configuration to use the newly created service account.
python manage.py createsuperuser
oc patch deployment.apps/django-nginx-git --patch '{"spec":{"template":{"spec":{"serviceAccountName": "runasanyuid"}}}}'
4. Trigger a New Deployment: After updating the deployment configuration, trigger a new deployment if necessary.
python manage.py makemigrations
oc rollout latest minimal-notebook
python manage.py migrate
# Cambiar la secuencia de los id


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

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

+ 52
- 0
Yamls/postgresql-deployment.yaml View File

@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db)
labels:
io.kompose.service: postgresql
name: postgresql
namespace: jugaralpadel
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: postgresql
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db)
labels:
io.kompose.service: postgresql
spec:
containers:
- env:
- name: POSTGRES_DB
valueFrom:
configMapKeyRef:
key: POSTGRES_DB
name: env-prod-db
- name: POSTGRES_PASSWORD
valueFrom:
configMapKeyRef:
key: POSTGRES_PASSWORD
name: env-prod-db
- name: POSTGRES_USER
valueFrom:
configMapKeyRef:
key: POSTGRES_USER
name: env-prod-db
image: postgres:15
name: postgresql
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgresql
restartPolicy: Always
volumes:
- name: postgresql
persistentVolumeClaim:
claimName: postgresql

+ 17
- 0
Yamls/postgresql-service.yaml View File

@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db)
labels:
io.kompose.service: postgresql
name: postgresql
namespace: jugaralpadel
spec:
ports:
- name: "5432"
port: 5432
targetPort: 5432
selector:
io.kompose.service: postgresql

+ 17
- 0
Yamls/pvc-postgresql.yaml View File

@ -0,0 +1,17 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
finalizers:
- kubernetes.io/pvc-protection
labels:
template: postgresql-persistent-template
name: postgresql
namespace: jugaralpadel
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: lvms-vg1
volumeMode: Filesystem

+ 3
- 0
borraDB.sh View File

@ -0,0 +1,3 @@
oc delete -f Yamls/env-prod-db-configmap.yaml
oc delete -f Yamls/postgresql-deployment.yaml
oc delete -f Yamls/postgresql-service.yaml

+ 4
- 0
creaDB.sh View File

@ -0,0 +1,4 @@
oc create -f Yamls/env-prod-db-configmap.yaml
#oc create -f Yamls/pvc-postgresql.yaml
oc create -f Yamls/postgresql-deployment.yaml
oc create -f Yamls/postgresql-service.yaml

+ 1
- 0
entra.sh View File

@ -0,0 +1 @@
oc exec -it deployment.apps/reymotaappsoc -- bash

+ 1
- 0
nuevaapp.sh View File

@ -0,0 +1 @@
oc new-app http://gitea.reymota.es/creylopez/ReyMotaAppsOC.git -e DEBUG=True

Loading…
Cancel
Save