Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Fix leader election with RBAC in tests #70

Merged
merged 2 commits into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion contrib/charts/navigator/templates/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ spec:
image: "{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag }}"
args:
- navigator-controller
- --namespace={{ .Values.controller.namespace | quote }}
{{- if .Values.controller.namespace }}
- --namespace={{ .Values.controller.namespace }}
- --leader-election-namespace={{ .Values.controller.namespace }}
{{- end }}
- --v=100
imagePullPolicy: {{ .Values.controller.image.pullPolicy }}
resources:
Expand Down
10 changes: 10 additions & 0 deletions contrib/charts/navigator/templates/leaderelection-endpoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Endpoints
metadata:
name: navigator-controller
{{- if .Values.controller.namespace }}
namespace: {{ .Values.controller.namespace }}
{{- else }}
namespace: kube-system
{{- end }}
subsets: []
18 changes: 13 additions & 5 deletions contrib/charts/navigator/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,21 @@ items:
kind: Role
{{- end }}
metadata:
name: "{{ template "fullname" . }}:controller-elasticsearch"
name: "{{ template "fullname" . }}:controller"
rules:
- apiGroups: ["navigator.jetstack.io"]
resources: ["elasticsearchclusters", "pilots"]
verbs: ["get", "list", "watch", "update"]
verbs: ["get", "list", "watch", "update", "create", "delete"]
- apiGroups: [""]
resources: ["services","configmaps","serviceaccounts"]
resources: ["services", "configmaps", "serviceaccounts", "pods"]
verbs: ["get", "list", "watch", "update", "create", "delete"]
- apiGroups: ["apps"]
resources: ["statefulsets"]
verbs: ["get", "list", "watch", "update", "create", "delete"]
- apiGroups: [""]
resources: ["endpoints"]
verbs: ["*"]
resourceNames: ["navigator-controller"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ What does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows navigator-controller to modify Endpoints resources with the name navigator-controller. This is the resource used for leader election 😄


- apiVersion: rbac.authorization.k8s.io/v1beta1
{{- if not .Values.controller.namespace }}
Expand All @@ -103,11 +107,15 @@ items:
kind: RoleBinding
{{- end }}
metadata:
name: "{{ template "fullname" . }}:controller-elasticsearch"
name: "{{ template "fullname" . }}:controller"
roleRef:
apiGroup: rbac.authorization.k8s.io
{{- if not .Values.controller.namespace }}
kind: ClusterRole
name: "{{ template "fullname" . }}:controller-elasticsearch"
{{- else }}
kind: Role
{{- end }}
name: "{{ template "fullname" . }}:controller"
subjects:
- apiGroup: ""
kind: ServiceAccount
Expand Down
4 changes: 2 additions & 2 deletions contrib/charts/navigator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ apiserver:

controller:
## Optional: namespace to watch for resources in. This can be used when RBAC
# restricts you to a single namespace.
namespace: default
## restricts you to a single namespace.
# namespace: default
## Optional: if not set, a service account will be automatically created
# serviceAccount: "controller-svc-acct"
image:
Expand Down