From dd1e41ef1b9eb3e1eb45dafa5ee0d35017dd9aa5 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Fri, 12 Apr 2024 08:23:56 -0500 Subject: [PATCH] feat: allow user to use a branch of their deploy repo Allow the user to use a branch of their deploy repo for templating out the configs. --- apps/components/argo-workflows.yaml | 2 +- apps/components/dexidp.yaml | 2 +- apps/components/ironic.yaml | 2 +- apps/components/keystone.yaml | 2 +- apps/components/mariadb.yaml | 2 +- apps/components/nautobot.yaml | 2 +- apps/operators/cert-manager.yaml | 2 +- apps/operators/ingress-nginx.yaml | 2 +- apps/operators/mariadb-operator.yaml | 2 +- apps/operators/messaging-topology-operator.yaml | 2 +- apps/operators/postgres-operator.yaml | 2 +- apps/operators/rabbitmq-operator.yaml | 2 +- docs/gitops-install.md | 3 +++ scripts/gitops-deploy.sh | 3 ++- 14 files changed, 17 insertions(+), 13 deletions(-) diff --git a/apps/components/argo-workflows.yaml b/apps/components/argo-workflows.yaml index 1a1a70832..7fd40b436 100644 --- a/apps/components/argo-workflows.yaml +++ b/apps/components/argo-workflows.yaml @@ -10,7 +10,7 @@ spec: targetRevision: ${UC_REPO_REF} - repoURL: ${UC_DEPLOY_GIT_URL} path: secrets/${DEPLOY_NAME}/ - targetRevision: HEAD + targetRevision: ${UC_DEPLOY_REF} directory: include: secret-argo-sso-argo.yaml destination: diff --git a/apps/components/dexidp.yaml b/apps/components/dexidp.yaml index 13fca5976..29ddae8f8 100644 --- a/apps/components/dexidp.yaml +++ b/apps/components/dexidp.yaml @@ -19,7 +19,7 @@ spec: ref: values - repoURL: ${UC_DEPLOY_GIT_URL} path: secrets/${DEPLOY_NAME}/ - targetRevision: HEAD + targetRevision: ${UC_DEPLOY_REF} directory: include: 'secret-*-sso-dex.yaml' ref: secrets diff --git a/apps/components/ironic.yaml b/apps/components/ironic.yaml index 3bcfeebb7..7c8273f02 100644 --- a/apps/components/ironic.yaml +++ b/apps/components/ironic.yaml @@ -23,7 +23,7 @@ spec: - $secrets/secrets/${DEPLOY_NAME}/secret-openstack.yaml - repoURL: ${UC_DEPLOY_GIT_URL} path: secrets/${DEPLOY_NAME}/ - targetRevision: HEAD + targetRevision: ${UC_DEPLOY_REF} directory: include: 'secret-ironic-*.yaml' ref: secrets diff --git a/apps/components/keystone.yaml b/apps/components/keystone.yaml index beb62edc8..7ab507857 100644 --- a/apps/components/keystone.yaml +++ b/apps/components/keystone.yaml @@ -21,7 +21,7 @@ spec: - $secrets/helm-configs/${DEPLOY_NAME}/keystone.yaml - repoURL: ${UC_DEPLOY_GIT_URL} path: secrets/${DEPLOY_NAME}/ - targetRevision: HEAD + targetRevision: ${UC_DEPLOY_REF} directory: include: 'secret-keystone-*.yaml' ref: secrets diff --git a/apps/components/mariadb.yaml b/apps/components/mariadb.yaml index 76514e4ce..724295ea7 100644 --- a/apps/components/mariadb.yaml +++ b/apps/components/mariadb.yaml @@ -10,7 +10,7 @@ spec: targetRevision: ${UC_REPO_REF} - repoURL: ${UC_DEPLOY_GIT_URL} path: secrets/${DEPLOY_NAME}/ - targetRevision: HEAD + targetRevision: ${UC_DEPLOY_REF} directory: include: secret-mariadb.yaml destination: diff --git a/apps/components/nautobot.yaml b/apps/components/nautobot.yaml index f02b74655..63ff66030 100644 --- a/apps/components/nautobot.yaml +++ b/apps/components/nautobot.yaml @@ -28,7 +28,7 @@ spec: value: ${DEPLOY_NAME}-cluster-issuer - repoURL: ${UC_DEPLOY_GIT_URL} path: secrets/${DEPLOY_NAME}/ - targetRevision: HEAD + targetRevision: ${UC_DEPLOY_REF} directory: include: 'secret-nautobot*.yaml' exclude: secret-nautobot-sso-dex.yaml diff --git a/apps/operators/cert-manager.yaml b/apps/operators/cert-manager.yaml index 72b1badb5..13f5b41bb 100644 --- a/apps/operators/cert-manager.yaml +++ b/apps/operators/cert-manager.yaml @@ -18,7 +18,7 @@ spec: installCRDs: true - repoURL: ${UC_DEPLOY_GIT_URL} path: secrets/${DEPLOY_NAME}/ - targetRevision: HEAD + targetRevision: ${UC_DEPLOY_REF} directory: include: cluster-issuer.yaml destination: diff --git a/apps/operators/ingress-nginx.yaml b/apps/operators/ingress-nginx.yaml index 2959f42de..799d74b71 100644 --- a/apps/operators/ingress-nginx.yaml +++ b/apps/operators/ingress-nginx.yaml @@ -17,7 +17,7 @@ spec: targetRevision: ${UC_REPO_REF} ref: values - repoURL: ${UC_DEPLOY_GIT_URL} - targetRevision: HEAD + targetRevision: ${UC_DEPLOY_REF} ref: secrets destination: server: "https://kubernetes.default.svc" diff --git a/apps/operators/mariadb-operator.yaml b/apps/operators/mariadb-operator.yaml index da3781280..3f8b1355b 100644 --- a/apps/operators/mariadb-operator.yaml +++ b/apps/operators/mariadb-operator.yaml @@ -7,7 +7,7 @@ spec: source: repoURL: https://github.com/rackerlabs/understack.git path: operators/mariadb-operator/ - targetRevision: HEAD + targetRevision: ${UC_DEPLOY_REF} destination: server: "https://kubernetes.default.svc" namespace: mariadb-operator diff --git a/apps/operators/messaging-topology-operator.yaml b/apps/operators/messaging-topology-operator.yaml index e2629e783..af3a9fd09 100644 --- a/apps/operators/messaging-topology-operator.yaml +++ b/apps/operators/messaging-topology-operator.yaml @@ -7,7 +7,7 @@ spec: source: repoURL: https://github.com/rackerlabs/understack.git path: operators/messaging-topology-operator/ - targetRevision: HEAD + targetRevision: ${UC_DEPLOY_REF} destination: server: "https://kubernetes.default.svc" namespace: rabbitmq-system diff --git a/apps/operators/postgres-operator.yaml b/apps/operators/postgres-operator.yaml index 465e39697..de77ceb76 100644 --- a/apps/operators/postgres-operator.yaml +++ b/apps/operators/postgres-operator.yaml @@ -7,7 +7,7 @@ spec: source: repoURL: https://github.com/rackerlabs/understack.git path: operators/postgres-operator/ - targetRevision: HEAD + targetRevision: ${UC_DEPLOY_REF} destination: server: "https://kubernetes.default.svc" namespace: postgres-operator diff --git a/apps/operators/rabbitmq-operator.yaml b/apps/operators/rabbitmq-operator.yaml index eafa59eb1..c232b5014 100644 --- a/apps/operators/rabbitmq-operator.yaml +++ b/apps/operators/rabbitmq-operator.yaml @@ -7,7 +7,7 @@ spec: source: repoURL: https://github.com/rackerlabs/understack.git path: operators/rabbitmq-operator/ - targetRevision: HEAD + targetRevision: ${UC_DEPLOY_REF} destination: server: "https://kubernetes.default.svc" namespace: rabbitmq-system diff --git a/docs/gitops-install.md b/docs/gitops-install.md index 865713c2f..58a4f31af 100644 --- a/docs/gitops-install.md +++ b/docs/gitops-install.md @@ -62,6 +62,9 @@ UC_DEPLOY_EMAIL="my@email" The `UC_REPO` and `UC_DEPLOY` variables are local paths on your machine to where these two repos have been cloned. +Optional variables of `UC_REPO_REF` and `UC_DEPLOY_REF` can be defined which +can be set to any valid git reference in their respective repos (e.g. branch or tag or commit). + #### Deployment Name The `DEPLOY_NAME` variable contains the name that you'll refer to your diff --git a/scripts/gitops-deploy.sh b/scripts/gitops-deploy.sh index ae3badc03..9c20a81ce 100755 --- a/scripts/gitops-deploy.sh +++ b/scripts/gitops-deploy.sh @@ -9,7 +9,7 @@ usage() { template() { local subvars - subvars="\$DNS_ZONE \$UC_DEPLOY_GIT_URL \$UC_REPO_REF \$DEPLOY_NAME" + subvars="\$DNS_ZONE \$UC_DEPLOY_GIT_URL \$UC_REPO_REF \$UC_DEPLOY_REF \$DEPLOY_NAME" cat "$1" | envsubst "${subvars}" > "$2" } @@ -48,6 +48,7 @@ export DNS_ZONE export UC_DEPLOY_GIT_URL export DEPLOY_NAME export UC_REPO_REF="${UC_REPO_REF:-HEAD}" +export UC_DEPLOY_REF="${UC_DEPLOY_REF:-HEAD}" for part in operators components; do echo "Creating ${part} configs"