1{{ $prefix := .Values.pathPrefix -}}
2{{/*
3$initIndex represents the patch insertion index of the next initContainer when
4proxy.nativeSidecar is true. If enabled, the proxy-init or network-validator
5should run first, immediately followed by the proxy. This ordering allows us
6to proxy traffic in subsequent initContainers.
7
8Note: dig is not used directly on .Values because it rejects chartutil.Values
9structs.
10*/}}
11{{- $initIndex := ternary "0" "-" (.Values.proxy | default (dict) | dig "nativeSidecar" false) -}}
12[
13 {{- if .Values.addRootMetadata }}
14 {
15 "op": "add",
16 "path": "{{$prefix}}/metadata",
17 "value": {}
18 },
19 {{- end }}
20 {{- if .Values.addRootAnnotations }}
21 {
22 "op": "add",
23 "path": "{{$prefix}}/metadata/annotations",
24 "value": {}
25 },
26 {{- end }}
27 {{- range $label, $value := .Values.annotations }}
28 {
29 "op": "add",
30 "path": "{{$prefix}}/metadata/annotations/{{$label | replace "/" "~1"}}",
31 "value": "{{$value}}"
32 },
33 {{- end }}
34 {{- if .Values.addRootLabels }}
35 {
36 "op": "add",
37 "path": "{{$prefix}}/metadata/labels",
38 "value": {}
39 },
40 {{- end }}
41 {{- range $label, $value := .Values.labels }}
42 {
43 "op": "add",
44 "path": "{{$prefix}}/metadata/labels/{{$label | replace "/" "~1"}}",
45 "value": "{{$value}}"
46 },
47 {{- end }}
48 {{- if or .Values.proxyInit .Values.proxy }}
49 {{- if .Values.addRootVolumes }}
50 {
51 "op": "add",
52 "path": "{{$prefix}}/spec/volumes",
53 "value": []
54 },
55 {{- end }}
56 {{- end}}
57 {{- if .Values.addRootInitContainers }}
58 {
59 "op": "add",
60 "path": "{{$prefix}}/spec/initContainers",
61 "value": []
62 },
63 {{- end}}
64 {{- if and .Values.proxyInit (not .Values.cniEnabled) }}
65 {
66 "op": "add",
67 "path": "{{$prefix}}/spec/volumes/-",
68 "value": {
69 "emptyDir": {},
70 "name": "linkerd-proxy-init-xtables-lock"
71 }
72 },
73 {
74 "op": "add",
75 "path": "{{$prefix}}/spec/initContainers/{{$initIndex}}{{$initIndex = add1 $initIndex}}",
76 "value":
77 {{- include "partials.proxy-init" . | fromYaml | toPrettyJson | nindent 6 }}
78 },
79 {{- else if and .Values.proxy .Values.cniEnabled }}
80 {
81 "op": "add",
82 "path": "{{$prefix}}/spec/initContainers/{{$initIndex}}{{$initIndex = add1 $initIndex}}",
83 "value":
84 {{- include "partials.network-validator" . | fromYaml | toPrettyJson | nindent 6 }}
85 },
86 {{- end }}
87 {{- if .Values.debugContainer }}
88 {
89 "op": "add",
90 "path": "{{$prefix}}/spec/containers/-",
91 "value":
92 {{- include "partials.debug" . | fromYaml | toPrettyJson | nindent 6 }}
93 },
94 {{- end }}
95 {{- if .Values.proxy }}
96 {
97 "op": "add",
98 "path": "{{$prefix}}/spec/volumes/-",
99 "value": {
100 "name": "linkerd-identity-end-entity",
101 "emptyDir": {
102 "medium": "Memory"
103 }
104 }
105 },
106 {{- if .Values.identity.serviceAccountTokenProjection}}
107 {
108 "op": "add",
109 "path": "{{$prefix}}/spec/volumes/-",
110 "value":
111 {{- include "partials.proxy.volumes.service-account-token" . | fromYaml | toPrettyJson | nindent 6 }}
112 },
113 {{- end }}
114 {
115 "op": "add",
116 {{- if .Values.proxy.nativeSidecar }}
117 "path": "{{$prefix}}/spec/initContainers/{{$initIndex}}",
118 {{- else if .Values.proxy.await }}
119 "path": "{{$prefix}}/spec/containers/0",
120 {{- else }}
121 "path": "{{$prefix}}/spec/containers/-",
122 {{- end }}
123 "value":
124 {{- include "partials.proxy" . | fromYaml | toPrettyJson | nindent 6 }}
125 },
126 {{- end }}
127]
View as plain text