diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index 78c618c4d8..9733dba00d 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -42,3 +42,25 @@ data: client.security.sasl.mechanism: {{ upper $internalMechanism }} {{- end }} {{- end }} + + entrypoint.sh: | + #!/bin/sh + set -e + + COMPONENT="$1" + + FLUSS_SERVER_ID=${POD_NAME##*-} + cp /opt/conf/server.yaml $FLUSS_HOME/conf + + BIND_LISTENERS="INTERNAL://${POD_IP}:{{ .Values.listeners.internal.port }}, CLIENT://${POD_IP}:{{ .Values.listeners.client.port }}" + ADVERTISED_LISTENERS="CLIENT://${POD_NAME}.${COMPONENT}-server-hs.${POD_NAMESPACE}.svc.cluster.local:{{ .Values.listeners.client.port }}" + + echo "" >> $FLUSS_HOME/conf/server.yaml + echo "bind.listeners: ${BIND_LISTENERS}" >> $FLUSS_HOME/conf/server.yaml + echo "advertised.listeners: ${ADVERTISED_LISTENERS}" >> $FLUSS_HOME/conf/server.yaml + + if [ "$COMPONENT" = "tablet" ]; then + echo "tablet-server.id: ${FLUSS_SERVER_ID}" >> $FLUSS_HOME/conf/server.yaml + fi + + exec bin/${COMPONENT}-server.sh start-foreground diff --git a/helm/templates/sts-coordinator.yaml b/helm/templates/sts-coordinator.yaml index c443e230fb..7691d56084 100644 --- a/helm/templates/sts-coordinator.yaml +++ b/helm/templates/sts-coordinator.yaml @@ -71,19 +71,8 @@ spec: containerPort: {{ .Values.listeners.client.port }} command: - "/bin/sh" - - "-c" - - | - export FLUSS_SERVER_ID=${POD_NAME##*-} && \ - cp /opt/conf/server.yaml $FLUSS_HOME/conf && \ - - BIND_LISTENERS="INTERNAL://${POD_IP}:{{ .Values.listeners.internal.port }}, CLIENT://${POD_IP}:{{ .Values.listeners.client.port }}" && \ - ADVERTISED_LISTENERS="CLIENT://${POD_NAME}.coordinator-server-hs.${POD_NAMESPACE}.svc.cluster.local:{{ .Values.listeners.client.port }}" && \ - - echo "" >> $FLUSS_HOME/conf/server.yaml && \ - echo "bind.listeners: ${BIND_LISTENERS}" >> $FLUSS_HOME/conf/server.yaml && \ - echo "advertised.listeners: ${ADVERTISED_LISTENERS}" >> $FLUSS_HOME/conf/server.yaml && \ - - bin/coordinator-server.sh start-foreground + - "/opt/conf/entrypoint.sh" + - "coordinator" livenessProbe: failureThreshold: 100 timeoutSeconds: 1 diff --git a/helm/templates/sts-tablet.yaml b/helm/templates/sts-tablet.yaml index 1ffe1af310..4ec65a876d 100644 --- a/helm/templates/sts-tablet.yaml +++ b/helm/templates/sts-tablet.yaml @@ -67,20 +67,8 @@ spec: containerPort: {{ .Values.listeners.client.port }} command: - "/bin/sh" - - "-c" - - | - export FLUSS_SERVER_ID=${POD_NAME##*-} && \ - cp /opt/conf/server.yaml $FLUSS_HOME/conf && \ - - BIND_LISTENERS="INTERNAL://${POD_IP}:{{ .Values.listeners.internal.port }}, CLIENT://${POD_IP}:{{ .Values.listeners.client.port }}" && \ - ADVERTISED_LISTENERS="CLIENT://${POD_NAME}.tablet-server-hs.${POD_NAMESPACE}.svc.cluster.local:{{ .Values.listeners.client.port }}" && \ - - echo "" >> $FLUSS_HOME/conf/server.yaml && \ - echo "tablet-server.id: ${FLUSS_SERVER_ID}" >> $FLUSS_HOME/conf/server.yaml && \ - echo "bind.listeners: ${BIND_LISTENERS}" >> $FLUSS_HOME/conf/server.yaml && \ - echo "advertised.listeners: ${ADVERTISED_LISTENERS}" >> $FLUSS_HOME/conf/server.yaml && \ - - bin/tablet-server.sh start-foreground + - "/opt/conf/entrypoint.sh" + - "tablet" livenessProbe: failureThreshold: 100 timeoutSeconds: 1 diff --git a/helm/tests/security_test.yaml b/helm/tests/security_test.yaml index f6d67f508e..c712976df1 100644 --- a/helm/tests/security_test.yaml +++ b/helm/tests/security_test.yaml @@ -274,11 +274,11 @@ tests: path: data["server.yaml"] pattern: 'security\.sasl\.enabled\.mechanisms: PLAIN,PLAIN' - it: writes server yaml using expected destination path - template: templates/sts-tablet.yaml + template: templates/configmap.yaml asserts: - matchRegex: - path: spec.template.spec.containers[0].command[2] + path: data["entrypoint.sh"] pattern: 'cp /opt/conf/server\.yaml \$FLUSS_HOME/conf' - matchRegex: - path: spec.template.spec.containers[0].command[2] + path: data["entrypoint.sh"] pattern: '>> \$FLUSS_HOME/conf/server\.yaml'