Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
Support leader election for Connect-Inject controller
Browse files Browse the repository at this point in the history
- Leader election required creating a configmap that is owned by the
  instance of the controller that is the leader. This required RBAC to
perform CRUD operations on configmaps to the controller.
- Additionally the latest version of the controller runtime requires the
  controller to read "leases" from kubernetes and we now have to support
that for the connect-inject controller.
- Increase the number of replicas of the connect inject deployment to 3
  as we can now be HA.
  • Loading branch information
Ashwin Venkatesh committed Apr 8, 2021
1 parent 277aece commit 265adb5
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
9 changes: 9 additions & 0 deletions templates/connect-inject-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ rules:
- "get"
- "list"
- "watch"
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- get
- list
- update
{{- if .Values.global.enablePodSecurityPolicies }}
- apiGroups: ["policy"]
resources: ["podsecuritypolicies"]
Expand Down
2 changes: 1 addition & 1 deletion templates/connect-inject-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
spec:
replicas: 1
replicas: 3
selector:
matchLabels:
app: {{ template "consul.name" . }}
Expand Down
40 changes: 40 additions & 0 deletions templates/connect-inject-leader-election-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{- if or (and (ne (.Values.connectInject.enabled | toString) "-") .Values.connectInject.enabled) (and (eq (.Values.connectInject.enabled | toString) "-") .Values.global.enabled) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ template "consul.fullname" . }}-connect-inject-leader-election
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: controller
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- ""
resources:
- configmaps/status
verbs:
- get
- update
- patch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
{{- end }}
20 changes: 20 additions & 0 deletions templates/connect-inject-leader-election-rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if or (and (ne (.Values.connectInject.enabled | toString) "-") .Values.connectInject.enabled) (and (eq (.Values.connectInject.enabled | toString) "-") .Values.global.enabled) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ template "consul.fullname" . }}-connect-inject-leader-election
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: controller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ template "consul.fullname" . }}-connect-inject-leader-election
subjects:
- kind: ServiceAccount
name: {{ template "consul.fullname" . }}-connect-injector-webhook-svc-account
namespace: {{ .Release.Namespace }}
{{- end }}

0 comments on commit 265adb5

Please sign in to comment.