GlodoUK / helm-charts

7 stars 2 forks source link

fix(odoo): extraManifests was broken and didn't follow general conventions #58

Open theangryangel opened 4 months ago

theangryangel commented 4 months ago

Description

extraManifests key did not follow general conventions, and would only work with a single manifest.

As it was never in use within Glo, I'm going to assume it was never in use anywhere. This is 100% a breaking change.

Associated risk level low

Type of change

dnplkndll commented 4 months ago

@theangryangel this ready to test?

I was hoping to get a little insight into the planned DB management as well. for reference using gitlab autodevops deploy image to manage the review ends. I think the design was to use cloudnative-pg

# DB
    # - helm repo add cnpg https://cloudnative-pg.github.io/charts
    - kubectl delete secrets 
      db-cluster-odoo db-cluster-superuser odoo-ro-prod-secret gcloud
      -n $KUBE_NAMESPACE || true  # odoo-secret
    - kubectl create secret generic gcloud -n $KUBE_NAMESPACE
      --from-file=application_default_credentials=$GOOGLE_APPLICATION_CREDENTIALS
    - kubectl create secret generic db-cluster-odoo -n $KUBE_NAMESPACE
      --from-literal=username=odoo --from-literal=password=$DB_PASSWORD
    - kubectl create secret generic db-cluster-superuser -n $KUBE_NAMESPACE
      --from-literal=username=postgres --from-literal=password=$DB_PASSWORD      
    - kubectl create secret generic odoo-ro-prod-secret -n $KUBE_NAMESPACE
      --from-literal=username=odoo --from-literal=password=$DB_URL_ODOO_RO_PASS
    - kubectl create secret generic backup-creds -n $KUBE_NAMESPACE
      --from-file=gcsCredentials=$GOOGLE_APPLICATION_CREDENTIALS || true
    - kubectl get secret -n $KUBE_NAMESPACE
    - kubectl apply -n $KUBE_NAMESPACE -f .gitlab/cluster.yaml || true

so you setup cluster.yaml with a db size and pas in the creds as secrets. now I would like to take a prod dump (from $BACKUP_PATH) and load into a $DB_BACK, sanitize it, then replace the $DB_APP

      kubectl exec -n $KUBE_NAMESPACE pod/db-1 -c postgres -it -- \
      psql -d postgres -c "CREATE DATABASE ${DB_BACK} ;" || true
      echo """
        \set AUTOCOMMIT on
        SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '${DB_BACK}';
        """ | \
      kubectl exec -n $KUBE_NAMESPACE pod/db-1 -c postgres -it -- psql -d postgres
      kubectl exec -n $KUBE_NAMESPACE pod/db-1 -c postgres -- pg_restore --no-acl 
      --no-owner -d $DB_BACK --jobs 8 --disable-triggers $BACKUP_PATH
    - cat sanitize.sql | kubectl exec -n $KUBE_NAMESPACE pod/db-1 -c postgres -it -- psql -d $DB_BACK
    - |
      echo """
        \set AUTOCOMMIT on
        SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '${DB_APP}';
        DROP DATABASE if exists ${DB_APP};
        CREATE DATABASE ${DB_APP} WITH TEMPLATE ${DB_BACK};" ;""" | \
      kubectl exec -n $KUBE_NAMESPACE pod/db-1 -c postgres -it -- psql -d postgres
    - echo starting sanitize
    - WEB_POD=$(k get pods -n $KUBE_NAMESPACE -o custom-columns="NAME:.metadata.name" | grep web | head -n 1)
    - kubectl exec -n $KUBE_NAMESPACE $WEB_POD -it -- click-odoo -d ${DB_BACK} /opt/odoo/custom/src/private/sanitize.py

something you can just just run the odoo part with is the goal. not sure if need to be 100% helm hook controled?

kubectl create job --from=cronjob.batch/odoo-santitize odoo-santitize_`date +%F_%H` -n $KUBE_NAMESPACE