Browse Source

Cambios en README

main
Celestino Rey 9 months ago
parent
commit
3ed1e60ff2
1 changed files with 19 additions and 61 deletions
  1. +19
    -61
      README.md

+ 19
- 61
README.md View File

@ -1,64 +1,30 @@
# Versión para openshift
# Running Commands as Root in OpenShift
## Instalación
### Crear un proyecto
oc new-project jugaralpadel
#### Permitir que los pods puedan funcionar como root
## Opción 1
oc adm policy add-scc-to-user anyuid -z default
### 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' --claim-class='lvms-vg1'
oc set volume deployment.apps/jugaralpadel --add -t pvc --claim-size=300M --name=jugaralpadel-media --claim-name='jugaralpadel-media' --mount-path='/app/mediafiles' --claim-class='lvms-vg1'
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' --claim-class='lvms-vg1'
oc set volume deployment.apps/jugaralpadel --add -t pvc --claim-size=50G --name=static-volume --claim-name='static-volume' --mount-path='/app/staticfiles' --claim-class='lvms-vg1'
## Opción 2
Esta es la que usé la primera vez, pero hay que hacerlo para cada deployment. La opción 1 es una vez por proyecto.
### Si la pvc ya está creada
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:
oc set volume deployment.apps/jugaralpadel --add -t pvc --name=jugaralpadel-eventos-migrations --claim-name='jugaralpadel-eventos-migrations' --mount-path='/app/eventos/migrations'
1. Create a Service Account: First, create a new service account in the project where you want to run the container as root.
oc set volume deployment.apps/jugaralpadel --add -t pvc --name=jugaralpadel-media --claim-name='jugaralpadel-media' --mount-path='/app/mediafiles'
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.
oc set volume deployment.apps/jugaralpadel --add -t pvc --name=reymota-reymotausers-migrations --claim-name='reymota-reymotausers-migrations' --mount-path='/app/reymotausers/migrations'
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.
oc set volume deployment.apps/jugaralpadel --add -t pvc --name=static-volume --claim-name='static-volume' --mount-path='/app/staticfiles'
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.
## Exponer el servicio
oc expose service/jugaralpadel
### postgresql
Los ficheros yaml están en el directorio Yamls.
Se crea el deployment y el servicio con la shell creaDB.sh
Se borran con borraDB.sh
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.
## Cosas a hacer la primera vez
Desde dentro de la shell del pod
python manage.py createsuperuser
python manage.py makemigrations
python manage.py migrate
oc rollout latest minimal-notebook
# Cambiar la secuencia de los id
@ -74,14 +40,6 @@ avoid credentials:
después se hace un pull o push o lo que sea que te pida el usuario y password, los metes y ya la próxima no hace falta
## PVC y paths
volumeMounts:
- mountPath: /app/mediafiles
name: jugaralpadel-media
- mountPath: /app/eventos/migrations
name: jugaralpadel-eventos-migrations
- mountPath: /app/reymotausers/migrations
name: jugaralpadel-reymotausers-migrations
- mountPath: /app/staticfiles
name: static-volume
# Deploy Postgresql
Hay que hacerlo creando un deployment, no cogiendo del catalogo un Deployment Config que está obsoleto

Loading…
Cancel
Save