diff --git a/resources/apply-resources-istio.sh b/resources/apply-resources-istio.sh index 89f8cb0ddf..f1c10eade5 100755 --- a/resources/apply-resources-istio.sh +++ b/resources/apply-resources-istio.sh @@ -1,15 +1,18 @@ -if [ -z "$1" ] ; then +#!/bin/bash +set -e + +if [ -z "$1" ] ; then echo "No domain passed as first argument, aborting." exit 1 fi export DOMAIN=$1 export NAMESPACE=${2:-busola} +export ENVIRONMENT=$3 +TMP_DIR="../temp/resources" -mkdir -p ../temp/resources -cp -rf . ../temp/resources - -envsubst < ../temp/resources/istio/virtualservice-busola-template.yaml > ../temp/resources/istio/virtualservice-busola.yaml +./apply-resources.sh "$@" -kubectl apply -k ../temp/resources/istio --namespace=$NAMESPACE +envsubst < "${TMP_DIR}"/istio/virtualservice-busola.tpl.yaml > "${TMP_DIR}"/istio/virtualservice-busola.yaml +kubectl apply -k "${TMP_DIR}"/istio --namespace=$NAMESPACE diff --git a/resources/apply-resources.sh b/resources/apply-resources.sh index d7eca07ace..f624eec7ef 100755 --- a/resources/apply-resources.sh +++ b/resources/apply-resources.sh @@ -1,16 +1,21 @@ -if [ -z "$1" ] ; then +#!/bin/bash +set -e + +if [ -z "$1" ] ; then echo "No domain passed as first argument, aborting." exit 1 fi -namespace=${2:-busola} +export DOMAIN=$1 +NAMESPACE=${2:-busola} +export ENVIRONMENT=$3 +TMP_DIR="../temp/resources" -mkdir -p ../temp/resources -cp -rf . ../temp/resources +mkdir -p "${TMP_DIR}" +cp -rf . "${TMP_DIR}" -for i in ../temp/resources/**{/*,}.yaml; do - sed -i'' "s/%DOMAIN%/$1/g" $i -done +envsubst < "${TMP_DIR}"/base/ingress.tpl.yaml > "${TMP_DIR}"/base/ingress.yaml -kubectl apply -k ../temp/resources --namespace=$namespace +kubectl create namespace "${NAMESPACE}" || true +kubectl apply -k "${TMP_DIR}/environments/${ENVIRONMENT}" --namespace="${NAMESPACE}" diff --git a/resources/backend/deployment.yaml b/resources/base/backend/deployment.yaml similarity index 100% rename from resources/backend/deployment.yaml rename to resources/base/backend/deployment.yaml diff --git a/resources/backend/hpa.yaml b/resources/base/backend/hpa.yaml similarity index 100% rename from resources/backend/hpa.yaml rename to resources/base/backend/hpa.yaml diff --git a/resources/backend/kustomization.yaml b/resources/base/backend/kustomization.yaml similarity index 100% rename from resources/backend/kustomization.yaml rename to resources/base/backend/kustomization.yaml diff --git a/resources/backend/service.yaml b/resources/base/backend/service.yaml similarity index 100% rename from resources/backend/service.yaml rename to resources/base/backend/service.yaml diff --git a/resources/base/environment.env b/resources/base/environment.env new file mode 100644 index 0000000000..52ad709329 --- /dev/null +++ b/resources/base/environment.env @@ -0,0 +1 @@ +ENVIRONMENT="test" diff --git a/resources/extensions-patch/builtin-resource-extensions.configmap.yaml b/resources/base/extensions-patch/builtin-resource-extensions.configmap.yaml similarity index 100% rename from resources/extensions-patch/builtin-resource-extensions.configmap.yaml rename to resources/base/extensions-patch/builtin-resource-extensions.configmap.yaml diff --git a/resources/extensions-patch/kustomization.yaml b/resources/base/extensions-patch/kustomization.yaml similarity index 100% rename from resources/extensions-patch/kustomization.yaml rename to resources/base/extensions-patch/kustomization.yaml diff --git a/resources/extensions-patch/web-deployment.patch.yaml b/resources/base/extensions-patch/web-deployment.patch.yaml similarity index 100% rename from resources/extensions-patch/web-deployment.patch.yaml rename to resources/base/extensions-patch/web-deployment.patch.yaml diff --git a/resources/ingress.yaml b/resources/base/ingress.tpl.yaml similarity index 97% rename from resources/ingress.yaml rename to resources/base/ingress.tpl.yaml index ba3589f0f4..afda2cee0a 100644 --- a/resources/ingress.yaml +++ b/resources/base/ingress.tpl.yaml @@ -10,7 +10,7 @@ metadata: spec: ingressClassName: nginx rules: - - host: %DOMAIN% + - host: $DOMAIN http: paths: - backend: diff --git a/resources/ingressClass.yaml b/resources/base/ingressClass.yaml similarity index 100% rename from resources/ingressClass.yaml rename to resources/base/ingressClass.yaml diff --git a/resources/kustomization.yaml b/resources/base/kustomization.yaml similarity index 95% rename from resources/kustomization.yaml rename to resources/base/kustomization.yaml index 2fcd961732..79ab6dae88 100644 --- a/resources/kustomization.yaml +++ b/resources/base/kustomization.yaml @@ -3,6 +3,5 @@ kind: Kustomization resources: - ingress.yaml - ingressClass.yaml -bases: - backend - web diff --git a/resources/resource-validation/rule-sets/datree/rules.yaml b/resources/base/resource-validation/rule-sets/datree/rules.yaml similarity index 100% rename from resources/resource-validation/rule-sets/datree/rules.yaml rename to resources/base/resource-validation/rule-sets/datree/rules.yaml diff --git a/resources/resource-validation/rule-sets/default/policies.yaml b/resources/base/resource-validation/rule-sets/default/policies.yaml similarity index 100% rename from resources/resource-validation/rule-sets/default/policies.yaml rename to resources/base/resource-validation/rule-sets/default/policies.yaml diff --git a/resources/resource-validation/rule-sets/kubernetes-pod-security-standards/policies.yaml b/resources/base/resource-validation/rule-sets/kubernetes-pod-security-standards/policies.yaml similarity index 100% rename from resources/resource-validation/rule-sets/kubernetes-pod-security-standards/policies.yaml rename to resources/base/resource-validation/rule-sets/kubernetes-pod-security-standards/policies.yaml diff --git a/resources/resource-validation/rule-sets/kubernetes-pod-security-standards/rules.yaml b/resources/base/resource-validation/rule-sets/kubernetes-pod-security-standards/rules.yaml similarity index 100% rename from resources/resource-validation/rule-sets/kubernetes-pod-security-standards/rules.yaml rename to resources/base/resource-validation/rule-sets/kubernetes-pod-security-standards/rules.yaml diff --git a/resources/resource-validation/rulesetSchema.json b/resources/base/resource-validation/rulesetSchema.json similarity index 100% rename from resources/resource-validation/rulesetSchema.json rename to resources/base/resource-validation/rulesetSchema.json diff --git a/resources/web/configmap.yaml b/resources/base/web/configmap.yaml similarity index 100% rename from resources/web/configmap.yaml rename to resources/base/web/configmap.yaml diff --git a/resources/web/deployment.yaml b/resources/base/web/deployment.yaml similarity index 80% rename from resources/web/deployment.yaml rename to resources/base/web/deployment.yaml index 54d5c4630f..cfb4d8ff2c 100644 --- a/resources/web/deployment.yaml +++ b/resources/base/web/deployment.yaml @@ -16,8 +16,14 @@ spec: spec: containers: - name: busola - image: europe-docker.pkg.dev/kyma-project/prod/busola-web:latest + image: europe-docker.pkg.dev/kyma-project/prod/busola-kyma-web:latest imagePullPolicy: Always + env: + - name: ENVIRONMENT + valueFrom: + configMapKeyRef: + key: ENVIRONMENT + name: environment resources: requests: cpu: 100m diff --git a/resources/web/hpa.yaml b/resources/base/web/hpa.yaml similarity index 100% rename from resources/web/hpa.yaml rename to resources/base/web/hpa.yaml diff --git a/resources/web/kustomization.yaml b/resources/base/web/kustomization.yaml similarity index 100% rename from resources/web/kustomization.yaml rename to resources/base/web/kustomization.yaml diff --git a/resources/web/service.yaml b/resources/base/web/service.yaml similarity index 100% rename from resources/web/service.yaml rename to resources/base/web/service.yaml diff --git a/resources/environments/dev/environment.env b/resources/environments/dev/environment.env new file mode 100644 index 0000000000..baf48fa88b --- /dev/null +++ b/resources/environments/dev/environment.env @@ -0,0 +1 @@ +ENVIRONMENT=dev diff --git a/resources/environments/dev/kustomization.yaml b/resources/environments/dev/kustomization.yaml new file mode 100644 index 0000000000..407303f71f --- /dev/null +++ b/resources/environments/dev/kustomization.yaml @@ -0,0 +1,6 @@ +resources: + - ../../base +configMapGenerator: + - name: environment + envs: + - environment.env diff --git a/resources/environments/prod/environment.env b/resources/environments/prod/environment.env new file mode 100644 index 0000000000..2237a08b79 --- /dev/null +++ b/resources/environments/prod/environment.env @@ -0,0 +1 @@ +ENVIRONMENT=prod diff --git a/resources/environments/prod/kustomization.yaml b/resources/environments/prod/kustomization.yaml new file mode 100644 index 0000000000..407303f71f --- /dev/null +++ b/resources/environments/prod/kustomization.yaml @@ -0,0 +1,6 @@ +resources: + - ../../base +configMapGenerator: + - name: environment + envs: + - environment.env diff --git a/resources/environments/stage/environment.env b/resources/environments/stage/environment.env new file mode 100644 index 0000000000..f5c101f28d --- /dev/null +++ b/resources/environments/stage/environment.env @@ -0,0 +1 @@ +ENVIRONMENT=stage diff --git a/resources/environments/stage/kustomization.yaml b/resources/environments/stage/kustomization.yaml new file mode 100644 index 0000000000..407303f71f --- /dev/null +++ b/resources/environments/stage/kustomization.yaml @@ -0,0 +1,6 @@ +resources: + - ../../base +configMapGenerator: + - name: environment + envs: + - environment.env diff --git a/resources/istio/kustomization.yaml b/resources/istio/kustomization.yaml index b286bf2b18..ff3b2d8a2b 100644 --- a/resources/istio/kustomization.yaml +++ b/resources/istio/kustomization.yaml @@ -6,7 +6,3 @@ resources: # This will tell the istio sidecar to use TLS to connect to the backend service. # For this to work, you need to enable TLS in the backend. See docs/install-kyma-dashboard-manually.md for more information. # - destinationrule-busola-backend.yaml - -bases: - - ../backend - - ../web diff --git a/resources/istio/virtualservice-busola-template.yaml b/resources/istio/virtualservice-busola.tpl.yaml similarity index 100% rename from resources/istio/virtualservice-busola-template.yaml rename to resources/istio/virtualservice-busola.tpl.yaml