Create an app

This commit is contained in:
Nikolai Rodionov 2024-05-04 19:54:14 +02:00
parent 3a55008066
commit dfedadb1e6
Signed by: allanger
GPG Key ID: 0AA46A90E25592AD
3 changed files with 60 additions and 0 deletions

0
hooks/cleanup-pipelineruns.sh Normal file → Executable file
View File

33
hooks/install-application.sh Executable file
View File

@ -0,0 +1,33 @@
#!/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: ConfigMap
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_ENVIRONMENT=$(jq -r .[0].object.metadata.name $BINDING_CONTEXT_PATH)
export SP_APPLICATION=$(jq -r .[0].object.data.values $BINDING_CONTEXT_PATH | base64 -d | yq '.helm.release')
envsubst < /tpls/flux-create.yaml | kubectl create -f -
kubectl patch configmap -n ${SP_CUSTOMER_ID} ${SP_ENVIRONMENT} \
-p '{"metadata":{"finalizers":["softplayer.net/bootstrapped"]}}' --type=merge
fi

27
tpls/flux-create.yaml Normal file
View File

@ -0,0 +1,27 @@
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: install-app
labels:
softplayer.net/env_name: "${SP_TEKTON_RUNTIME_NS}"
softplayer.net/user-uuid: "${SP_CUSTOMER_ID}"
tekton.dev/pipeline: hetzner-k3sf9p5s
namespace: "${SP_TEKTON_RUNTIME_NS}"
spec:
params:
- name: namespace
value: "${SP_CUSTOMER_ID}"
- name: environment
value: "${SP_ENVIRONMENT}"
- name: application
value: "${SP_APPLICATION}"
pipelineRef:
params:
- name: kind
value: pipeline
- name: name
value: install-app
- name: namespace
value: tekton-pipelines
resolver: cluster
serviceAccountName: secret-manager