Skip to content

Commit

Permalink
feat: Add overlays with environments configuration (#3344)
Browse files Browse the repository at this point in the history
* adjust kustomize

* remove unused file

* fix build
  • Loading branch information
dbadura authored Sep 16, 2024
1 parent 79aacbc commit c2393c5
Show file tree
Hide file tree
Showing 31 changed files with 52 additions and 22 deletions.
2 changes: 1 addition & 1 deletion config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
new CopyPlugin({
patterns: [
{
from: 'resources/resource-validation/rule-sets/**/*.yaml',
from: 'resources/base/resource-validation/rule-sets/**/*.yaml',
to: 'resource-validation/rule-set.yaml',
transformAll(assets) {
return assets.reduce((accumulator, asset) => {
Expand Down
15 changes: 9 additions & 6 deletions resources/apply-resources-istio.sh
Original file line number Diff line number Diff line change
@@ -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
21 changes: 13 additions & 8 deletions resources/apply-resources.sh
Original file line number Diff line number Diff line change
@@ -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}"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion resources/ingress.yaml → resources/base/ingress.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
spec:
ingressClassName: nginx
rules:
- host: %DOMAIN%
- host: $DOMAIN
http:
paths:
- backend:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ kind: Kustomization
resources:
- ingress.yaml
- ingressClass.yaml
bases:
- backend
- web
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions resources/environments/dev/environment.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENVIRONMENT=dev
6 changes: 6 additions & 0 deletions resources/environments/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resources:
- ../../base
configMapGenerator:
- name: environment
envs:
- environment.env
1 change: 1 addition & 0 deletions resources/environments/prod/environment.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENVIRONMENT=prod
6 changes: 6 additions & 0 deletions resources/environments/prod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resources:
- ../../base
configMapGenerator:
- name: environment
envs:
- environment.env
1 change: 1 addition & 0 deletions resources/environments/stage/environment.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENVIRONMENT=stage
6 changes: 6 additions & 0 deletions resources/environments/stage/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resources:
- ../../base
configMapGenerator:
- name: environment
envs:
- environment.env
4 changes: 0 additions & 4 deletions resources/istio/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c2393c5

Please sign in to comment.