# Running Commands as Root in OpenShift

## Opción 1

    oc adm policy add-scc-to-user anyuid -z default

## 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.

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:

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.

    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 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

# 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.

# GIT

avoid credentials:

    git config credential.helper store

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
