From e4dcfd9a622be1f1ae01c9fe5b1d43a2e6cc1e84 Mon Sep 17 00:00:00 2001 From: Christopher Zell Date: Fri, 4 Feb 2022 07:13:55 +0100 Subject: [PATCH 1/2] refactor: remove unused startup script --- .../zeebe-gateway/templates/configmap.yaml | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/charts/ccsm-helm/charts/zeebe-gateway/templates/configmap.yaml b/charts/ccsm-helm/charts/zeebe-gateway/templates/configmap.yaml index c45e7b6cee..917b046717 100644 --- a/charts/ccsm-helm/charts/zeebe-gateway/templates/configmap.yaml +++ b/charts/ccsm-helm/charts/zeebe-gateway/templates/configmap.yaml @@ -4,36 +4,6 @@ metadata: labels: {{- include "zeebe.labels.gateway" . | nindent 4 }} apiVersion: v1 data: - startup.sh: | - #!/usr/bin/env bash - set -eux -o pipefail - - export ZEEBE_BROKER_NETWORK_ADVERTISEDHOST=${ZEEBE_BROKER_NETWORK_ADVERTISEDHOST:-$(hostname -f)} - export ZEEBE_BROKER_CLUSTER_NODEID=${ZEEBE_BROKER_CLUSTER_NODEID:-${K8S_POD_NAME##*-}} - - # As the number of replicas or the DNS is not obtainable from the downward API yet, - # defined them here based on conventions - export ZEEBE_BROKER_CLUSTER_CLUSTERSIZE=${ZEEBE_BROKER_CLUSTER_CLUSTERSIZE:-1} - contactPointPrefix=${K8S_POD_NAME%-*} - contactPoints=${ZEEBE_BROKER_CLUSTER_INITIALCONTACTPOINTS:-""} - if [[ -z "${contactPoints}" ]]; then - for ((i=0; i<${ZEEBE_BROKER_CLUSTER_CLUSTERSIZE}; i++)) - do - contactPoints="${contactPoints},${contactPointPrefix}-$i.$(hostname -d):{{ .Values.service.internalPort }}" - done - - export ZEEBE_BROKER_CLUSTER_INITIALCONTACTPOINTS="${contactPoints}" - fi - - if [ "$(ls -A /exporters/)" ]; then - mkdir /usr/local/zeebe/exporters/ - cp -a /exporters/*.jar /usr/local/zeebe/exporters/ - else - echo "No exporters available." - fi - - exec /usr/local/zeebe/bin/broker - gateway-log4j2.xml: | {{- if .Values.log4j2 }} {{ .Values.log4j2 | indent 4 | trim }} From 7a75a777e10c7da6a55c6803217a4a8966886b2a Mon Sep 17 00:00:00 2001 From: Christopher Zell Date: Fri, 4 Feb 2022 08:44:52 +0100 Subject: [PATCH 2/2] refactor: set zeebe env vars in manifest In order to have everything in one place and for better maintainability most of the env vars should be set in the statefulset manifest. This is done via this commit. The env vars can be calculated via kubernetes dependent environment variables, which are expanded at deploy time. The initial contact points can be calculated with helm template magic. --- .../charts/zeebe/templates/configmap.yaml | 20 +++---------------- .../charts/zeebe/templates/statefulset.yaml | 17 ++++++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/charts/ccsm-helm/charts/zeebe/templates/configmap.yaml b/charts/ccsm-helm/charts/zeebe/templates/configmap.yaml index 186e2fa3ca..e83eea94f5 100644 --- a/charts/ccsm-helm/charts/zeebe/templates/configmap.yaml +++ b/charts/ccsm-helm/charts/zeebe/templates/configmap.yaml @@ -8,30 +8,16 @@ data: #!/usr/bin/env bash set -eux -o pipefail - export ZEEBE_BROKER_NETWORK_ADVERTISEDHOST=${ZEEBE_BROKER_NETWORK_ADVERTISEDHOST:-$(hostname -f)} - export ZEEBE_BROKER_CLUSTER_NODEID=${ZEEBE_BROKER_CLUSTER_NODEID:-${K8S_POD_NAME##*-}} + export ZEEBE_BROKER_CLUSTER_NODEID=${ZEEBE_BROKER_CLUSTER_NODEID:-${K8S_NAME##*-}} - # As the number of replicas or the DNS is not obtainable from the downward API yet, - # defined them here based on conventions - export ZEEBE_BROKER_CLUSTER_CLUSTERSIZE=${ZEEBE_BROKER_CLUSTER_CLUSTERSIZE:-1} - contactPointPrefix=${K8S_POD_NAME%-*} - contactPoints=${ZEEBE_BROKER_CLUSTER_INITIALCONTACTPOINTS:-""} - if [[ -z "${contactPoints}" ]]; then - for ((i=0; i<${ZEEBE_BROKER_CLUSTER_CLUSTERSIZE}; i++)) - do - contactPoints="${contactPoints},${contactPointPrefix}-$i.$(hostname -d):{{ .Values.service.internalPort }}" - done - - export ZEEBE_BROKER_CLUSTER_INITIALCONTACTPOINTS="${contactPoints}" - fi - if [ "$(ls -A /exporters/)" ]; then mkdir /usr/local/zeebe/exporters/ cp -a /exporters/*.jar /usr/local/zeebe/exporters/ - else + else echo "No exporters available." fi + env exec /usr/local/zeebe/bin/broker application.yaml: | diff --git a/charts/ccsm-helm/charts/zeebe/templates/statefulset.yaml b/charts/ccsm-helm/charts/zeebe/templates/statefulset.yaml index 5be068867c..4e3a930e41 100644 --- a/charts/ccsm-helm/charts/zeebe/templates/statefulset.yaml +++ b/charts/ccsm-helm/charts/zeebe/templates/statefulset.yaml @@ -46,6 +46,23 @@ spec: env: - name: LC_ALL value: C.UTF-8 + - name: K8S_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: K8S_SERVICE_NAME + value: {{ include "zeebe.names.broker" . }} + - name: K8S_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: ZEEBE_BROKER_NETWORK_ADVERTISEDHOST + value: "$(K8S_NAME).$(K8S_SERVICE_NAME).$(K8S_NAMESPACE).svc.cluster.local" + - name: ZEEBE_BROKER_CLUSTER_INITIALCONTACTPOINTS + value: + {{- range (untilStep 0 (int .Values.clusterSize) 1) }} + $(K8S_SERVICE_NAME)-{{ . }}.$(K8S_SERVICE_NAME).$(K8S_NAMESPACE).svc.cluster.local, + {{- end }} - name: ZEEBE_BROKER_CLUSTER_CLUSTERNAME value: {{ tpl .Values.global.zeebeClusterName . }} - name: ZEEBE_LOG_LEVEL