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

Commit

Permalink
Merge pull request #70 from munnerz/fix-rbac-leaderelection
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue.

Fix leader election with RBAC in tests

**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
  • Loading branch information
jetstack-bot committed Oct 31, 2017
2 parents 17fda44 + 4f0d08b commit 0e2c5a4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
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"]

- 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

0 comments on commit 0e2c5a4

Please sign in to comment.