47 lines
1.6 KiB
Bash
Executable File
47 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# ---------------------------------------------------------------------
|
|
# This script should bootstrap a new environment, or update
|
|
# existing ones
|
|
# Get the configmap name and namespace to prepare the
|
|
# ---------------------------------------------------------------------
|
|
|
|
if [[ $1 == "--config" ]] ; then
|
|
cat <<EOF
|
|
configVersion: v1
|
|
kubernetes:
|
|
- name: Watch application configmaps getting created
|
|
apiVersion: v1
|
|
kind: Secret
|
|
executeHookOnSynchronization: false
|
|
executeHookOnEvent: ["Added", "Modified"]
|
|
jqFilter: ".data"
|
|
labelSelector:
|
|
matchExpressions:
|
|
- key: "component"
|
|
operator: "In"
|
|
values: ["install"]
|
|
EOF
|
|
else
|
|
export $(jq -r .[0].object.data.vars $BINDING_CONTEXT_PATH)
|
|
export SP_CUSTOMER_ID=$(jq -r .[0].object.metadata.namespace $BINDING_CONTEXT_PATH)
|
|
export SP_CONFIG_NAME=$(jq -r .[0].object.metadata.name $BINDING_CONTEXT_PATH)
|
|
export SP_APPLICATION=$(jq -r .[0].object.data."values.yaml" $BINDING_CONTEXT_PATH | base64 -d | yq '.helm.release')
|
|
|
|
flux create source helm $SP_APPLICATION \
|
|
--namespace=$SP_CUSTOMER_ID \
|
|
--url=oci://registry.badhouseplants.net/softplayer/helm
|
|
|
|
flux create helmrelease $SP_APPLICATION \
|
|
--source=HelmRepository/$SP_APPLICATION \
|
|
--namespace=$SP_CUSTOMER_ID \
|
|
--chart=helmrelease \
|
|
--values-from Secret/$SP_CONFIG_NAME \
|
|
--kubeconfig-secret-ref=$SP_CUSTOMER_ID-config \
|
|
--target-namespace=default --export \
|
|
| yq '.spec.storageNamespace="helm-installations"' \
|
|
| kubectl apply -f -
|
|
flux reconcile helmrelease --namespace=$SP_CUSTOMER_ID $SP_APPLICATION
|
|
|
|
fi
|
|
|