Skip to content

Commit

Permalink
Remove namespace for linkerd2 chart
Browse files Browse the repository at this point in the history
First part of #6584

With this change, the `namespace.yaml` template is rendered only for CLI installs and not Helm, and likewise the `namespace:` entry in the namespace-level objects (using a new `partials.namespace` helper).

The `installNamespace` and `namespace` entries in `values.yaml` have been removed.

There in the templates where the namespace is required, we moved from `.Values.namespace` to `.Release.Namespace` which is filled-in automatically by Helm. For the CLI, `install.go` now explicitly defines the contents of the `Release` map alongside `Values`.

The proxy-injector has a new `linkerd-namespace` argument given the namespace is no longer persisted in the `linkerd-config` ConfigMap, so it has to be passed in. To pass it further down to `injector.Inject()` without modifying the `Handler` signature, a closure was used.

To land later in a followup: same deal for the other charts. Extensions will require usage of the post-install hook for adding metadata though.
  • Loading branch information
alpeb committed Aug 9, 2021
1 parent 730d3b6 commit 4ab0a32
Show file tree
Hide file tree
Showing 51 changed files with 871 additions and 969 deletions.
4 changes: 1 addition & 3 deletions charts/linkerd2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,8 @@ Kubernetes: `>=1.16.0-0`
| identityTrustDomain | string | clusterDomain | Trust domain used for identity |
| imagePullPolicy | string | `"IfNotPresent"` | Docker image pull policy |
| imagePullSecrets | list | `[]` | For Private docker registries, authentication is needed. Registry secrets are applied to the respective service accounts |
| installNamespace | bool | `true` | Set to false when installing Linkerd in a custom namespace. See the [Linkerd documentation](https://linkerd.io/2/tasks/install-helmcustomizing-the-namespace) for more information. |
| linkerdVersion | string | `"linkerdVersionValue"` | control plane version. See Proxy section for proxy version |
| namespace | string | `"linkerd"` | Control plane namespace |
| nodeSelector | object | `{"beta.kubernetes.io/os":"linux"}` | NodeSelector section, See the [K8S documentation](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) for more information |
| nodeSelector."beta.kubernetes.io/os" | string | `"linux"` | |
| omitWebhookSideEffects | bool | `false` | Omit the `sideEffects` flag in the webhook manifests |
| podAnnotations | object | `{}` | Additional annotations to add to all pods |
| podLabels | object | `{}` | Additional labels to add to all pods |
Expand Down
4 changes: 2 additions & 2 deletions charts/linkerd2/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ kind: ConfigMap
apiVersion: v1
metadata:
name: linkerd-config
namespace: {{.Values.namespace}}
{{ include "partials.namespace" . }}
labels:
linkerd.io/control-plane-component: controller
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
annotations:
{{ include "partials.annotations.created-by" . }}
data:
Expand Down
26 changes: 13 additions & 13 deletions charts/linkerd2/templates/destination-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-{{.Values.namespace}}-destination
name: linkerd-{{.Release.Namespace}}-destination
labels:
linkerd.io/control-plane-component: destination
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
rules:
- apiGroups: ["apps"]
resources: ["replicasets"]
Expand All @@ -34,40 +34,40 @@ rules:
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-{{.Values.namespace}}-destination
name: linkerd-{{.Release.Namespace}}-destination
labels:
linkerd.io/control-plane-component: destination
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: linkerd-{{.Values.namespace}}-destination
name: linkerd-{{.Release.Namespace}}-destination
subjects:
- kind: ServiceAccount
name: linkerd-destination
namespace: {{.Values.namespace}}
namespace: {{.Release.Namespace}}
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-destination
namespace: {{.Values.namespace}}
{{ include "partials.namespace" . }}
labels:
linkerd.io/control-plane-component: destination
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
{{- include "partials.image-pull-secrets" .Values.imagePullSecrets }}
---
{{- $host := printf "linkerd-sp-validator.%s.svc" .Values.namespace }}
{{- $host := printf "linkerd-sp-validator.%s.svc" .Release.Namespace }}
{{- $ca := genSelfSignedCert $host (list) (list $host) 365 }}
{{- if (not .Values.profileValidator.externalSecret) }}
kind: Secret
apiVersion: v1
metadata:
name: linkerd-sp-validator-k8s-tls
namespace: {{ .Values.namespace }}
{{ include "partials.namespace" . }}
labels:
linkerd.io/control-plane-component: destination
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
annotations:
{{ include "partials.annotations.created-by" . }}
type: kubernetes.io/tls
Expand All @@ -82,15 +82,15 @@ metadata:
name: linkerd-sp-validator-webhook-config
labels:
linkerd.io/control-plane-component: destination
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
webhooks:
- name: linkerd-sp-validator.linkerd.io
namespaceSelector:
{{- toYaml .Values.profileValidator.namespaceSelector | trim | nindent 4 }}
clientConfig:
service:
name: linkerd-sp-validator
namespace: {{ .Values.namespace }}
namespace: {{ .Release.Namespace }}
path: "/"
{{- if and (.Values.profileValidator.externalSecret) (empty .Values.profileValidator.caBundle) }}
{{- fail "If profileValidator.externalSecret is true then you need to provide profileValidator.caBundle" }}
Expand Down
28 changes: 14 additions & 14 deletions charts/linkerd2/templates/destination.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ kind: Service
apiVersion: v1
metadata:
name: linkerd-dst
namespace: {{.Values.namespace}}
{{ include "partials.namespace" . }}
labels:
linkerd.io/control-plane-component: destination
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
annotations:
{{ include "partials.annotations.created-by" . }}
spec:
Expand All @@ -25,10 +25,10 @@ kind: Service
apiVersion: v1
metadata:
name: linkerd-dst-headless
namespace: {{.Values.namespace}}
{{ include "partials.namespace" . }}
labels:
linkerd.io/control-plane-component: destination
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
annotations:
{{ include "partials.annotations.created-by" . }}
spec:
Expand All @@ -44,10 +44,10 @@ kind: Service
apiVersion: v1
metadata:
name: linkerd-sp-validator
namespace: {{.Values.namespace}}
{{ include "partials.namespace" . }}
labels:
linkerd.io/control-plane-component: destination
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
annotations:
{{ include "partials.annotations.created-by" . }}
spec:
Expand All @@ -64,10 +64,10 @@ kind: PodDisruptionBudget
apiVersion: policy/v1beta1
metadata:
name: linkerd-dst
namespace: {{.Values.namespace}}
{{ include "partials.namespace" . }}
labels:
linkerd.io/control-plane-component: destination
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
annotations:
{{ include "partials.annotations.created-by" . }}
spec:
Expand All @@ -91,15 +91,15 @@ metadata:
app.kubernetes.io/part-of: Linkerd
app.kubernetes.io/version: {{default .Values.linkerdVersion .Values.controllerImageVersion}}
linkerd.io/control-plane-component: destination
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
name: linkerd-destination
namespace: {{.Values.namespace}}
{{ include "partials.namespace" . }}
spec:
replicas: {{.Values.controllerReplicas}}
selector:
matchLabels:
linkerd.io/control-plane-component: destination
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
{{- include "partials.proxy.labels" $tree.Values.proxy | nindent 6}}
{{- if .Values.enablePodAntiAffinity }}
strategy:
Expand All @@ -114,8 +114,8 @@ spec:
{{- with .Values.podAnnotations }}{{ toYaml . | trim | nindent 8 }}{{- end }}
labels:
linkerd.io/control-plane-component: destination
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/workload-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
linkerd.io/workload-ns: {{.Release.Namespace}}
{{- include "partials.proxy.labels" $tree.Values.proxy | nindent 8}}
{{- with .Values.podLabels }}{{ toYaml . | trim | nindent 8 }}{{- end }}
spec:
Expand All @@ -139,7 +139,7 @@ spec:
- args:
- destination
- -addr=:8086
- -controller-namespace={{.Values.namespace}}
- -controller-namespace={{.Release.Namespace}}
- -enable-h2-upgrade={{.Values.enableH2Upgrade}}
- -log-level={{.Values.controllerLogLevel}}
- -log-format={{.Values.controllerLogFormat}}
Expand Down
20 changes: 10 additions & 10 deletions charts/linkerd2/templates/heartbeat-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: linkerd-heartbeat
namespace: {{.Values.namespace}}
{{ include "partials.namespace" . }}
labels:
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
rules:
- apiGroups: [""]
resources: ["configmaps"]
Expand All @@ -20,24 +20,24 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: linkerd-heartbeat
namespace: {{.Values.namespace}}
{{ include "partials.namespace" . }}
labels:
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
roleRef:
kind: Role
name: linkerd-heartbeat
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: linkerd-heartbeat
namespace: {{.Values.namespace}}
namespace: {{.Release.Namespace}}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: linkerd-heartbeat
labels:
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
rules:
- apiGroups: [""]
resources: ["namespaces"]
Expand All @@ -51,23 +51,23 @@ kind: ClusterRoleBinding
metadata:
name: linkerd-heartbeat
labels:
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
roleRef:
kind: ClusterRole
name: linkerd-heartbeat
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: linkerd-heartbeat
namespace: {{.Values.namespace}}
namespace: {{.Release.Namespace}}
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-heartbeat
namespace: {{.Values.namespace}}
{{ include "partials.namespace" . }}
labels:
linkerd.io/control-plane-component: heartbeat
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
{{- include "partials.image-pull-secrets" .Values.imagePullSecrets }}
{{- end }}
8 changes: 4 additions & 4 deletions charts/linkerd2/templates/heartbeat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: linkerd-heartbeat
namespace: {{.Values.namespace}}
{{ include "partials.namespace" . }}
labels:
app.kubernetes.io/name: heartbeat
app.kubernetes.io/part-of: Linkerd
app.kubernetes.io/version: {{default .Values.linkerdVersion .Values.controllerImageVersion}}
linkerd.io/control-plane-component: heartbeat
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
annotations:
{{ include "partials.annotations.created-by" . }}
spec:
Expand All @@ -30,7 +30,7 @@ spec:
metadata:
labels:
linkerd.io/control-plane-component: heartbeat
linkerd.io/workload-ns: {{.Values.namespace}}
linkerd.io/workload-ns: {{.Release.Namespace}}
{{- with .Values.podLabels }}{{ toYaml . | trim | nindent 12 }}{{- end }}
annotations:
{{ include "partials.annotations.created-by" . }}
Expand All @@ -51,7 +51,7 @@ spec:
value: "the heartbeat controller does not use the proxy"
args:
- "heartbeat"
- "-controller-namespace={{.Values.namespace}}"
- "-controller-namespace={{.Release.Namespace}}"
- "-log-level={{.Values.controllerLogLevel}}"
- "-log-format={{.Values.controllerLogFormat}}"
- "-prometheus-url=http://prometheus.linkerd-viz.svc.{{.Values.clusterDomain}}:9090"
Expand Down
16 changes: 8 additions & 8 deletions charts/linkerd2/templates/identity-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-{{.Values.namespace}}-identity
name: linkerd-{{.Release.Namespace}}-identity
labels:
linkerd.io/control-plane-component: identity
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
rules:
- apiGroups: ["authentication.k8s.io"]
resources: ["tokenreviews"]
Expand All @@ -24,26 +24,26 @@ rules:
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-{{.Values.namespace}}-identity
name: linkerd-{{.Release.Namespace}}-identity
labels:
linkerd.io/control-plane-component: identity
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: linkerd-{{.Values.namespace}}-identity
name: linkerd-{{.Release.Namespace}}-identity
subjects:
- kind: ServiceAccount
name: linkerd-identity
namespace: {{.Values.namespace}}
namespace: {{.Release.Namespace}}
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-identity
namespace: {{.Values.namespace}}
{{ include "partials.namespace" . }}
labels:
linkerd.io/control-plane-component: identity
linkerd.io/control-plane-ns: {{.Values.namespace}}
linkerd.io/control-plane-ns: {{.Release.Namespace}}
{{- include "partials.image-pull-secrets" .Values.imagePullSecrets }}
{{ end -}}
Loading

0 comments on commit 4ab0a32

Please sign in to comment.