Skip to content

Commit

Permalink
add linkerd_disabled env var if not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
sechmann committed Dec 21, 2024
1 parent 58a49d6 commit 3c076c7
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 5 deletions.
6 changes: 5 additions & 1 deletion pkg/resourcecreator/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ func imagePullSecrets(cfg Config) []corev1.LocalObjectReference {
func CreateContainerEnvVars(app EnvSource, ast *resource.Ast, cfg Config) {
ast.Env = append(ast.Env, defaultEnvVars(app, cfg.GetClusterName(), app.GetImage())...)
ast.Env = append(ast.Env, app.GetEnv().ToKubernetes()...)
if !cfg.IsLinkerdEnabled() {
disableLinkerd := corev1.EnvVar{Name: "LINKERD_DISABLED", Value: "true"}
ast.Env = append(ast.Env, disableLinkerd)
}
}

func CreateAppContainer(app Source, ast *resource.Ast, cfg Config) error {
Expand Down Expand Up @@ -561,4 +565,4 @@ func readOnlyFileSystem(annotations map[string]string) bool {
}

return strings.ToLower(val) != "false"
}
}
4 changes: 3 additions & 1 deletion pkg/resourcecreator/testdata/env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ tests:
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: LINKERD_DISABLED
value: "true"
envFrom:
- configMapRef:
name: mycm
- secretRef:
name: mysecret
name: mysecret
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ tests:
value: "8080"
- name: BIND_ADDRESS
value: "0.0.0.0:8080"
- name: LINKERD_DISABLED
value: "true"
image: ghcr.io/nais/testapp:latest
imagePullPolicy: IfNotPresent
lifecycle:
Expand Down Expand Up @@ -94,4 +96,4 @@ tests:
type: RuntimeDefault
volumeMounts:
- mountPath: /tmp
name: writable-tmp
name: writable-tmp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ tests:
value: "8080"
- name: BIND_ADDRESS
value: "0.0.0.0:8080"
- name: LINKERD_DISABLED
value: "true"
image: navikt/mynaisjob:1.2.3
securityContext:
runAsUser: 1069
Expand Down Expand Up @@ -196,4 +198,4 @@ tests:
topologyKey: kubernetes.io/hostname
weight: 10
schedule: "* 2 * * *"
successfulJobsHistoryLimit: 4
successfulJobsHistoryLimit: 4
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ tests:
value: "8080"
- name: BIND_ADDRESS
value: "0.0.0.0:8080"
- name: LINKERD_DISABLED
value: "true"
image: navikt/mynaisjob:1.2.3
securityContext:
runAsUser: 1069
Expand Down Expand Up @@ -194,4 +196,4 @@ tests:
- mynaisjob
topologyKey: kubernetes.io/hostname
weight: 10
ttlSecondsAfterFinished: 3
ttlSecondsAfterFinished: 3
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ tests:
value: "8080"
- name: BIND_ADDRESS
value: "0.0.0.0:8080"
- name: LINKERD_DISABLED
value: "true"
image: navikt/mynaisjob:1.2.3
securityContext:
runAsUser: 1069
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ tests:
value: "8080"
- name: BIND_ADDRESS
value: "0.0.0.0:8080"
- name: LINKERD_DISABLED
value: "true"
image: navikt/mynaisjob:1.2.3
securityContext:
runAsUser: 1069
Expand Down
2 changes: 2 additions & 0 deletions pkg/resourcecreator/testdata/vanilla_on_premises.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ tests:
value: "8080"
- name: BIND_ADDRESS
value: "0.0.0.0:8080"
- name: LINKERD_DISABLED
value: "true"
resources:
limits:
memory: 512Mi
Expand Down

0 comments on commit 3c076c7

Please sign in to comment.