From 1a3e677295758e8b2cfe7f583e16145e9576e959 Mon Sep 17 00:00:00 2001 From: Gary Pennington Date: Fri, 25 Aug 2023 17:28:50 +0100 Subject: [PATCH] Declare `extraContainers` ahead of the router container (#3633) Currently `extraContainers` are declared after the router container. Moving the `extraContainers` ahead of the router container will make it simpler to co-ordinate container startup sequencing and take full advantage of kubernetes lifecycle hooks. fixes: #3632 **Checklist** Complete the checklist (and note appropriate exceptions) before a final PR is raised. - [x] Changes are compatible[^1] - [x] Documentation[^2] completed - [x] Performance impact assessed and acceptable - Tests added and passing[^3] - [ ] Unit Tests - [ ] Integration Tests - [ ] Manual Tests **Exceptions** *Note any exceptions here* **Notes** [^1]. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. [^2]. Configuration is an important part of many changes. Where applicable please try to document configuration examples. [^3]. Tick whichever testing boxes are applicable. If you are adding Manual Tests: - please document the manual testing (extensively) in the Exceptions. - please raise a separate issue to automate the test and label it (or ask for it to be labeled) as `manual test` --------- Co-authored-by: Jesse Rosenberger Co-authored-by: o0Ignition0o Co-authored-by: Bryn Cooke Co-authored-by: bryn Co-authored-by: Geoffroy Couprie Co-authored-by: Lenny Burdette Co-authored-by: Maria Elisabeth Schreiber Co-authored-by: Lucas Leadbetter <5595530+lleadbet@users.noreply.github.com> Co-authored-by: Simon Sapin Co-authored-by: Chandrika Srinivasan Co-authored-by: Nicolas Moutschen --- .changesets/fix_garypen_3632_extras_declared_first.md | 5 +++++ helm/chart/router/templates/deployment.yaml | 9 ++++----- 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 .changesets/fix_garypen_3632_extras_declared_first.md diff --git a/.changesets/fix_garypen_3632_extras_declared_first.md b/.changesets/fix_garypen_3632_extras_declared_first.md new file mode 100644 index 0000000000..f3c8130aa8 --- /dev/null +++ b/.changesets/fix_garypen_3632_extras_declared_first.md @@ -0,0 +1,5 @@ +### Declare `extraContainers` ahead of the router container ([Issue #3632](https://github.com/apollographql/router/issues/3632)) + +Currently `extraContainers` are declared after the router container. Moving the `extraContainers` ahead of the router container will make it simpler to co-ordinate container startup sequencing and take full advantage of kubernetes lifecycle hooks. + +By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3633 \ No newline at end of file diff --git a/helm/chart/router/templates/deployment.yaml b/helm/chart/router/templates/deployment.yaml index 2e5962a509..dcda27697b 100644 --- a/helm/chart/router/templates/deployment.yaml +++ b/helm/chart/router/templates/deployment.yaml @@ -23,15 +23,14 @@ spec: {{- include "router.selectorLabels" . | nindent 6 }} template: metadata: - {{- if or .Values.podAnnotations .Values.supergraphFile }} annotations: + kubectl.kubernetes.io/default-container: {{ .Chart.Name }} {{- if .Values.supergraphFile }} checksum/supergraph-config-map: {{ .Values.supergraphFile | sha256sum }} {{- end }} {{- if .Values.podAnnotations }} {{- toYaml .Values.podAnnotations | nindent 8 }} {{- end }} - {{- end }} labels: {{- include "router.selectorLabels" . | nindent 8 }} {{- if .Values.extraLabels }} @@ -46,6 +45,9 @@ spec: securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: + {{- if .Values.extraContainers }} + {{- include "common.tplvalues.render" (dict "value" .Values.extraContainers "context" $) | nindent 8 }} + {{- end }} - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} @@ -127,9 +129,6 @@ spec: {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }} {{- end }} {{- end }} - {{- if .Values.extraContainers }} - {{- include "common.tplvalues.render" (dict "value" .Values.extraContainers "context" $) | nindent 8 }} - {{- end }} {{- if .Values.initContainers }} initContainers: {{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }}