-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove namespace from
linkerd-smi
chart (#16)
Another part of #6584 This PR - stops rendering `namespace.yaml` in the `linkerd-smi` chart. - Adds a new `post-install` hook to add the `linkerd.io/extension` label to the namespace after the chart is installed. Signed-off-by: Tarun Pothulapati <[email protected]>
- Loading branch information
1 parent
b55b212
commit fb70b3c
Showing
14 changed files
with
113 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{- define "partials.namespace" -}} | ||
{{ if eq .Release.Service "CLI" }}namespace: {{.Release.Namespace}}{{ end }} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
kind: ServiceAccount | ||
apiVersion: v1 | ||
metadata: | ||
annotations: | ||
"helm.sh/hook": post-install | ||
"helm.sh/hook-weight": "0" | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
name: namespace-metadata | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
annotations: | ||
"helm.sh/hook": post-install | ||
"helm.sh/hook-weight": "0" | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
name: namespace-metadata | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["namespaces"] | ||
verbs: ["get", "patch"] | ||
resourceNames: ["{{.Release.Namespace}}"] | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
annotations: | ||
"helm.sh/hook": post-install | ||
"helm.sh/hook-weight": "0" | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
name: namespace-metadata | ||
roleRef: | ||
kind: Role | ||
name: namespace-metadata | ||
apiGroup: rbac.authorization.k8s.io | ||
subjects: | ||
- kind: ServiceAccount | ||
name: namespace-metadata | ||
namespace: {{.Release.Namespace}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
annotations: | ||
"helm.sh/hook": post-install | ||
"helm.sh/hook-weight": "0" | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
labels: | ||
app.kubernetes.io/name: namespace-metadata | ||
app.kubernetes.io/part-of: linkerd-smi | ||
app.kubernetes.io/version: {{.Values.adaptor.image.tag}} | ||
name: namespace-metadata | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: namespace-metadata | ||
app.kubernetes.io/part-of: linkerd-smi | ||
app.kubernetes.io/version: {{.Values.adaptor.image.tag}} | ||
spec: | ||
restartPolicy: Never | ||
serviceAccountName: namespace-metadata | ||
containers: | ||
- name: namespace-metadata | ||
image: curlimages/curl:7.78.0 | ||
command: ["/bin/sh"] | ||
args: | ||
- -c | ||
- | | ||
ops='' | ||
token=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) | ||
ns=$(curl -kfv -H "Authorization: Bearer $token" \ | ||
"https://kubernetes.default.svc/api/v1/namespaces/{{.Release.Namespace}}") | ||
if echo "$ns" | grep -vq 'labels'; then | ||
ops="$ops{\"op\": \"add\",\"path\": \"/metadata/labels\",\"value\": {}}," | ||
fi | ||
ops="$ops{\"op\": \"add\", \"path\": \"/metadata/labels/linkerd.io~1extension\", \"value\": \"smi\"}" | ||
curl -kfv -XPATCH -H "Content-Type: application/json-patch+json" -H "Authorization: Bearer $token" \ | ||
-d "[$ops]" \ | ||
"https://kubernetes.default.svc/api/v1/namespaces/{{.Release.Namespace}}?fieldManager=kubectl-label" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
{{- if (.Values.installNamespace) -}} | ||
{{- if eq .Release.Service "CLI" -}} | ||
--- | ||
kind: Namespace | ||
apiVersion: v1 | ||
metadata: | ||
name: {{.Values.namespace}} | ||
name: {{.Release.Namespace}} | ||
labels: | ||
linkerd.io/extension: smi | ||
annotations: | ||
linkerd.io/inject: enabled | ||
{{ end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters