I'm deploying my chart with helm like this:
helm upgrade --install --namespace newnamespace --create-namespace testing mychart My understanding is everything should be deployed into newnamespace
I have this in my chart:
apiVersion: v1 kind: ServiceAccount metadata: name: {{ include "mychart.serviceAccountName" . }} --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRole metadata: name: {{ include "mychart.serviceAccountName" . }} rules: - apiGroups: [""] resources: ["services","endpoints","pods"] verbs: ["get","watch","list"] - apiGroups: ["extensions","networking.k8s.io"] resources: ["ingresses"] verbs: ["get","watch","list"] - apiGroups: [""] resources: ["nodes"] verbs: ["get", "watch", "list"] --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: name: {{ include "mychart.serviceAccountName" . }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: {{ include "mychart.serviceAccountName" . }} subjects: - kind: ServiceAccount name: {{ include "mychart.serviceAccountName" . }} When deployed I get this error:
Error: ClusterRoleBinding.rbac.authorization.k8s.io "my-service-account" is invalid: subjects[0].namespace: Required value Then I add this and the deploy works:
... subjects: - kind: ServiceAccount name: {{ include "mychart.serviceAccountName" . }} namespace: {{ .Release.Namespace }} Why is this? What is this requirement of ClusterRoleBinding? I can't it see the namespace where it's being deployed?
Is it because ClusterRoleBinding is cluster wide it must have the namespace defined in its definition? Are ClusterRoleBinding resources not created in any namespaces? If so where do they live kube-system?
Does this mean that if I deleted the namespace containing my helm release before doing a helm uninstall the ClusterRoleBinding would be left behind?