Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure signals are passed to commands (#3548) #3558

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3548.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
helm: Change `/bin/sh -ec "<command>"` to `/bin/sh -ec "exec <command>"` in helm deployments
```
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-api-gateway server \
exec consul-api-gateway server \
-sds-server-host {{ template "consul.fullname" . }}-api-gateway-controller.{{ .Release.Namespace }}.svc \
-k8s-namespace {{ .Release.Namespace }} \
{{- if .Values.global.enableConsulNamespaces }}
Expand Down Expand Up @@ -188,7 +188,7 @@ spec:
lifecycle:
preStop:
exec:
command: [ "/bin/sh", "-ec", "/consul-bin/consul logout" ]
command: ["/consul-bin/consul", "logout" ]
{{- end }}
volumes:
{{- if .Values.global.acls.manageSystemACLs }}
Expand Down Expand Up @@ -274,7 +274,7 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane acl-init \
exec consul-k8s-control-plane acl-init \
{{- if and .Values.global.federation.enabled .Values.global.federation.primaryDatacenter }}
-auth-method-name={{ template "consul.fullname" . }}-k8s-component-auth-method-{{ .Values.global.datacenter }} \
{{- else }}
Expand Down
8 changes: 3 additions & 5 deletions charts/consul/templates/client-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,8 @@ spec:
preStop:
exec:
command:
- "/bin/sh"
- "-ec"
- |
consul logout
- "/bin/consul"
- "logout"
{{- end }}
env:
{{- if .Values.global.acls.manageSystemACLs }}
Expand Down Expand Up @@ -523,7 +521,7 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane acl-init \
exec consul-k8s-control-plane acl-init \
-log-level={{ default .Values.global.logLevel .Values.client.logLevel }} \
-log-json={{ .Values.global.logJSON }} \
-init-type="client"
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/connect-inject-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane inject-connect \
exec consul-k8s-control-plane inject-connect \
{{- if .Values.global.federation.enabled }}
-enable-federation \
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/create-federation-secret-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane create-federation-secret \
exec consul-k8s-control-plane create-federation-secret \
-log-level={{ default .Values.global.logLevel .Values.global.federation.logLevel }} \
-log-json={{ .Values.global.logJSON }} \
{{- if (or .Values.global.gossipEncryption.autoGenerate (and .Values.global.gossipEncryption.secretName .Values.global.gossipEncryption.secretKey)) }}
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/enterprise-license-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane acl-init \
exec consul-k8s-control-plane acl-init \
-secret-name="{{ template "consul.fullname" . }}-enterprise-license-acl-token" \
-k8s-namespace={{ .Release.Namespace }} \
-consul-api-timeout={{ .Values.global.consulAPITimeout }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane gossip-encryption-autogenerate \
exec consul-k8s-control-plane gossip-encryption-autogenerate \
-namespace={{ .Release.Namespace }} \
-secret-name={{ template "consul.fullname" . }}-gossip-encryption-key \
-secret-key="key" \
Expand Down
12 changes: 6 additions & 6 deletions charts/consul/templates/ingress-gateways-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane connect-init -pod-name=${POD_NAME} -pod-namespace=${NAMESPACE} \
-gateway-kind="ingress-gateway" \
-proxy-id-file=/consul/service/proxy-id \
-service-name={{ template "consul.fullname" $root }}-{{ .name }} \
-log-level={{ default $root.Values.global.logLevel $root.Values.ingressGateways.logLevel }} \
-log-json={{ $root.Values.global.logJSON }}
exec consul-k8s-control-plane connect-init -pod-name=${POD_NAME} -pod-namespace=${NAMESPACE} \
-gateway-kind="ingress-gateway" \
-proxy-id-file=/consul/service/proxy-id \
-service-name={{ template "consul.fullname" $root }}-{{ .name }} \
-log-level={{ default $root.Values.global.logLevel $root.Values.ingressGateways.logLevel }} \
-log-json={{ $root.Values.global.logJSON }}
volumeMounts:
- name: consul-service
mountPath: /consul/service
Expand Down
12 changes: 6 additions & 6 deletions charts/consul/templates/mesh-gateway-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane connect-init -pod-name=${POD_NAME} -pod-namespace=${NAMESPACE} \
-gateway-kind="mesh-gateway" \
-proxy-id-file=/consul/service/proxy-id \
-service-name={{ .Values.meshGateway.consulServiceName }} \
-log-level={{ default .Values.global.logLevel .Values.meshGateway.logLevel }} \
-log-json={{ .Values.global.logJSON }}
exec consul-k8s-control-plane connect-init -pod-name=${POD_NAME} -pod-namespace=${NAMESPACE} \
-gateway-kind="mesh-gateway" \
-proxy-id-file=/consul/service/proxy-id \
-service-name={{ .Values.meshGateway.consulServiceName }} \
-log-level={{ default .Values.global.logLevel .Values.meshGateway.logLevel }} \
-log-json={{ .Values.global.logJSON }}
volumeMounts:
- name: consul-service
mountPath: /consul/service
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/partition-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane partition-init \
exec consul-k8s-control-plane partition-init \
-log-level={{ .Values.global.logLevel }} \
-log-json={{ .Values.global.logJSON }} \
{{- if .Values.global.cloud.enabled }}
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/server-acl-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ spec:
- |
CONSUL_FULLNAME="{{template "consul.fullname" . }}"

consul-k8s-control-plane server-acl-init \
exec consul-k8s-control-plane server-acl-init \
-log-level={{ default .Values.global.logLevel .Values.global.acls.logLevel}} \
-log-json={{ .Values.global.logJSON }} \
-resource-prefix=${CONSUL_FULLNAME} \
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane fetch-server-region -node-name "$NODE_NAME" -output-file /consul/extra-config/locality.json
exec consul-k8s-control-plane fetch-server-region -node-name "$NODE_NAME" -output-file /consul/extra-config/locality.json
volumeMounts:
- name: extra-config
mountPath: /consul/extra-config
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/sync-catalog-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane sync-catalog \
exec consul-k8s-control-plane sync-catalog \
-log-level={{ default .Values.global.logLevel .Values.syncCatalog.logLevel }} \
-log-json={{ .Values.global.logJSON }} \
-k8s-default-sync={{ .Values.syncCatalog.default }} \
Expand Down
4 changes: 2 additions & 2 deletions charts/consul/templates/telemetry-collector-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ spec:
- /bin/sh
- -ec
- |-
consul-k8s-control-plane connect-init \
exec consul-k8s-control-plane connect-init \
-log-json={{ .Values.global.logJSON }} \
-log-level={{ default .Values.global.logLevel .Values.telemetryCollector.logLevel }} \
-pod-name=${POD_NAME} \
Expand Down Expand Up @@ -261,7 +261,7 @@ spec:
{{- end }}
{{- end }}

consul-telemetry-collector agent \
exec consul-telemetry-collector agent \
{{- if .Values.telemetryCollector.customExporterConfig }}
-config-file-path /consul/config/config.json \
{{ end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane connect-init -pod-name=${POD_NAME} -pod-namespace=${NAMESPACE} \
exec consul-k8s-control-plane connect-init -pod-name=${POD_NAME} -pod-namespace=${NAMESPACE} \
-gateway-kind="terminating-gateway" \
-proxy-id-file=/consul/service/proxy-id \
-service-name={{ .name }} \
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/tls-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ spec:
# Suppress globbing so we can interpolate the $NAMESPACE environment variable
# and use * at the start of the dns name when setting -additional-dnsname.
set -o noglob
consul-k8s-control-plane tls-init \
exec consul-k8s-control-plane tls-init \
-log-level={{ default .Values.global.logLevel .Values.global.tls.logLevel }} \
-log-json={{ .Values.global.logJSON }} \
-domain={{ .Values.global.domain }} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
- "/bin/sh"
- "-ec"
- |
consul-k8s-control-plane webhook-cert-manager \
exec consul-k8s-control-plane webhook-cert-manager \
-log-level={{ .Values.global.logLevel }} \
-log-json={{ .Values.global.logJSON }} \
-config-file=/bootstrap/config/webhook-config.json \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ load _helpers
--set 'apiGateway.image=foo' \
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq '[.spec.template.spec.containers[0].lifecycle.preStop.exec.command[2]] | any(contains("consul logout"))' | tee /dev/stderr)
yq '[.spec.template.spec.containers[0].lifecycle.preStop.exec.command[1]] | any(contains("logout"))' | tee /dev/stderr)
[ "${object}" = "true" ]
}

Expand Down
2 changes: 1 addition & 1 deletion charts/consul/test/unit/client-daemonset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ load _helpers
--set 'client.enabled=true' \
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq '[.spec.template.spec.containers[0].lifecycle.preStop.exec.command[2]] | any(contains("consul logout"))' | tee /dev/stderr)
yq '[.spec.template.spec.containers[0].lifecycle.preStop.exec.command[1]] | any(contains("logout"))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

Expand Down
Loading