diff --git a/README.md b/README.md index 9c4ef0e..232fd78 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,73 @@ -# 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 -Esta es la que usé la primera vez, pero hay que hacerlo para cada deployment. La opción 1 es una vez por proyecto. + oc new-app http://gitea.reymota.es/creylopez/ReyMotaAppsOC.git -e DEBUG="False" -e VERSION=11.0 --name='jugaralpadel' -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: +Tal y como está la estructura de directorios, deberia detectar automáticamente una compilación Python -1. Create a Service Account: First, create a new service account in the project where you want to run the container as root. +## Asignación de los volúmenes +### Si la pvc no está creada - 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 --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=jugaralpadel-gestion_reservas-migrations --claim-name='jugaralpadel-gestion_reservas-migrations' --mount-path='/app/gestion_reservas/migrations' + + oc set volume deployment.apps/jugaralpadel --add -t pvc --claim-size=300M --name=jugaralpadel-reymotausers-migrations --claim-name='jugaralpadel-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 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=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=jugaralpadel-gestion_reservas-migrations --claim-name='jugaralpadel-gestion_reservas-migrations' --mount-path='/app/gestion_reservas/migrations' + + oc set volume deployment.apps/jugaralpadel --add -t pvc --name=jugaralpadel-reymotausers-migrations --claim-name='jugaralpadel-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' - 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. - oc rollout latest minimal-notebook +## Exponer el servicio + oc expose service/jugaralpadel + +### postgresql +Los ficheros yaml están en el directorio Yamls. -# Cambiar la secuencia de los id +Se crea el deployment y el servicio con la shell creaDB.sh +Se borran con borraDB.sh -ALTER SEQUENCE tablename_id_seq RESTART WITH nn; +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. -esto se hace cuando restauro un volcado de la bd sobre una instalación nueva. Si hay índices ya creados, hay que reinciar a partir del último. -# GIT +## Cosas a hacer la primera vez +Desde dentro de la shell del pod -avoid credentials: + python manage.py createsuperuser - git config credential.helper store + python manage.py makemigrations -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 + python manage.py migrate -# Deploy Postgresql -Hay que hacerlo creando un deployment, no cogiendo del catalogo un Deployment Config que está obsoleto +## Cambiar la secuencia de los id + +ALTER SEQUENCE tablename_id_seq RESTART WITH nn; + +esto se hace cuando restauro un volcado de la bd sobre una instalación nueva. Si hay índices ya creados, hay que reinciar a partir del último. + diff --git a/nuevaapp.sh b/nuevaapp.sh index 3e8172a..f3637f0 100644 --- a/nuevaapp.sh +++ b/nuevaapp.sh @@ -1 +1 @@ -oc new-app http://gitea.reymota.es/creylopez/JugarAlPadelOC.git -e DEBUG=True +oc new-app http://gitea.reymota.es/creylopez/JugarAlPadelOC.git -e DEBUG=True jugaralpadel