Skip to content

Commit

Permalink
helm: Add experimentalEnv settings (#11908)
Browse files Browse the repository at this point in the history
Enable setting arbitrary environment variables on all Go-based Control
Plane containers

For example, via CLI:

```
--set destinationController.experimentalEnv[0].name=ENV_VAR,destinationController.experimentalEnv[0].value=ENV_VAL
```

Via values file:

```
destinationController:
  experimentalEnv:
  - name: DEST_ENV_VAR
    value: DEST_ENV_VAL
  - name: DEST_CONFIG_MAP_VAR
    valueFrom:
      configMapKeyRef:
        key: dest_config_map_key
        name: dest-config-map-name
heartbeat:
  experimentalEnv:
identity:
  experimentalEnv:
proxyInjector:
  experimentalEnv:
spValidator:
  experimentalEnv:

serviceMirrorExperimentalEnv:
```

Relates to #11862 and #11874

Signed-off-by: Andrew Seigner <[email protected]>
  • Loading branch information
siggy authored Jan 12, 2024
1 parent be41965 commit f1f5367
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 13 deletions.
8 changes: 8 additions & 0 deletions charts/linkerd-control-plane/templates/destination.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ spec:
{{- range (.Values.destinationController).experimentalArgs }}
- {{ . }}
{{- end }}
{{- with (.Values.destinationController).experimentalEnv }}
env:
{{- toYaml . | nindent 8 -}}
{{- end }}
{{- include "partials.linkerd.trace" . | nindent 8 -}}
image: {{.Values.controllerImage}}:{{.Values.controllerImageVersion | default .Values.linkerdVersion}}
imagePullPolicy: {{.Values.imagePullPolicy}}
Expand Down Expand Up @@ -245,6 +249,10 @@ spec:
- -log-level={{.Values.controllerLogLevel}}
- -log-format={{.Values.controllerLogFormat}}
- -enable-pprof={{.Values.enablePprof | default false}}
{{- with (.Values.spValidator).experimentalEnv }}
env:
{{- toYaml . | nindent 8 -}}
{{- end }}
image: {{.Values.controllerImage}}:{{.Values.controllerImageVersion | default .Values.linkerdVersion}}
imagePullPolicy: {{.Values.imagePullPolicy}}
livenessProbe:
Expand Down
3 changes: 3 additions & 0 deletions charts/linkerd-control-plane/templates/heartbeat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ spec:
env:
- name: LINKERD_DISABLED
value: "the heartbeat controller does not use the proxy"
{{- with (.Values.heartbeat).experimentalEnv }}
{{- toYaml . | nindent 12 -}}
{{- end }}
args:
- "heartbeat"
- "-controller-namespace={{.Release.Namespace}}"
Expand Down
3 changes: 3 additions & 0 deletions charts/linkerd-control-plane/templates/identity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ spec:
env:
- name: LINKERD_DISABLED
value: "linkerd-await cannot block the identity controller"
{{- with (.Values.identity).experimentalEnv }}
{{- toYaml . | nindent 8 -}}
{{- end }}
image: {{.Values.controllerImage}}:{{.Values.controllerImageVersion | default .Values.linkerdVersion}}
imagePullPolicy: {{.Values.imagePullPolicy}}
livenessProbe:
Expand Down
4 changes: 4 additions & 0 deletions charts/linkerd-control-plane/templates/proxy-injector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ spec:
- -log-format={{.Values.controllerLogFormat}}
- -linkerd-namespace={{.Release.Namespace}}
- -enable-pprof={{.Values.enablePprof | default false}}
{{- with (.Values.proxyInjector).experimentalEnv }}
env:
{{- toYaml . | nindent 8 -}}
{{- end }}
image: {{.Values.controllerImage}}:{{.Values.controllerImageVersion | default .Values.linkerdVersion}}
imagePullPolicy: {{.Values.imagePullPolicy}}
livenessProbe:
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var (
"templates/workload/external-workload.yaml",
}

templatesControlPlane = []string{
TemplatesControlPlane = []string{
"templates/namespace.yaml",
"templates/identity-rbac.yaml",
"templates/destination-rbac.yaml",
Expand Down Expand Up @@ -365,7 +365,7 @@ func renderControlPlane(w io.Writer, values *l5dcharts.Values, valuesOverrides m
files := []*loader.BufferedFile{
{Name: chartutil.ChartfileName},
}
for _, template := range templatesControlPlane {
for _, template := range TemplatesControlPlane {
files = append(files, &loader.BufferedFile{Name: template})
}
if err := charts.FilesReader(static.Templates, l5dcharts.HelmChartDirCP+"/", files); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/install_helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func chartControlPlane(t *testing.T, ha bool, additionalConfig string, ignoreOut

linkerd2Chart.AddDependency(chartPartials)

for _, filepath := range templatesControlPlane {
for _, filepath := range TemplatesControlPlane {
linkerd2Chart.Templates = append(linkerd2Chart.Templates, &chart.File{
Name: filepath,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ spec:
{{- end }}
- -enable-pprof={{.Values.enablePprof | default false}}
- {{.Values.targetClusterName}}
{{- with .Values.serviceMirrorExperimentalEnv }}
env:
{{- toYaml . | nindent 8 -}}
{{- end }}
image: {{.Values.controllerImage}}:{{.Values.controllerImageVersion}}
name: service-mirror
securityContext:
Expand Down
25 changes: 15 additions & 10 deletions multicluster/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ type (
}
)

var TemplatesMulticluster = []string{
chartutil.ChartfileName,
chartutil.ValuesfileName,
"templates/namespace.yaml",
"templates/gateway.yaml",
"templates/gateway-policy.yaml",
"templates/psp.yaml",
"templates/remote-access-service-mirror-rbac.yaml",
"templates/link-crd.yaml",
"templates/service-mirror-policy.yaml",
}

func newMulticlusterInstallCommand() *cobra.Command {
options, err := newMulticlusterInstallOptionsWithDefault()
var ha bool
Expand Down Expand Up @@ -129,16 +141,9 @@ func install(ctx context.Context, w io.Writer, options *multiclusterInstallOptio
}

func render(w io.Writer, values *multicluster.Values, valuesOverrides map[string]interface{}) error {
files := []*loader.BufferedFile{
{Name: chartutil.ChartfileName},
{Name: chartutil.ValuesfileName},
{Name: "templates/namespace.yaml"},
{Name: "templates/gateway.yaml"},
{Name: "templates/gateway-policy.yaml"},
{Name: "templates/psp.yaml"},
{Name: "templates/remote-access-service-mirror-rbac.yaml"},
{Name: "templates/link-crd.yaml"},
{Name: "templates/service-mirror-policy.yaml"},
var files []*loader.BufferedFile
for _, template := range TemplatesMulticluster {
files = append(files, &loader.BufferedFile{Name: template})
}

var partialFiles []*loader.BufferedFile
Expand Down

0 comments on commit f1f5367

Please sign in to comment.