feat(template): Add support for leader election

This commit is contained in:
2024-01-09 21:37:53 +01:00
parent c34ca9c013
commit 7b31ab7a28
4 changed files with 41 additions and 2 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ apiVersion: v2
name: template
description: A Helm library chart containing common templates, keeping application templates short
type: library
version: 0.2.4
version: 0.3.0
maintainers:
- name: Jim Martens
url: https://2martens.de
@@ -11,7 +11,7 @@ sources:
annotations:
artifacthub.io/changes: |
- kind: added
description: Added "template.annotations"
description: Added role to allow watching on
artifacthub.io/signKey: |
fingerprint: F0F153B65BAD467201D7544E47393ABD1F96B7C8
url: https://mafiasi.de/pks/key/47393ABD1F96B7C8.asc
+3
View File
@@ -0,0 +1,3 @@
{{- include "template.leaderRole" . -}}
---
{{- include "template.leaderRoleBinding" . -}}
+3
View File
@@ -136,6 +136,9 @@ autoscaling:
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
leaderElection:
enabled: false
vault:
# If enabled, no ordinary secret resource will be created, even if secrets value is populated.
enabled: false
@@ -0,0 +1,33 @@
{{- define "template.leaderRole" -}}
{{- if .Values.leaderElection.enabled -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: leader-role
namespace: {{ .Release.Namespace }}
rules:
- verbs:
- watch
resources:
- configmaps
apiGroups:
- ""
{{- end }}
{{- end }}
---
{{- define "template.leaderRoleBinding" -}}
{{- if .Values.leaderElection.enabled -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: leader-role-binding
namespace: {{ .Release.Namespace }}
roleRef:
name: {{ include "template.fullname" . }}
apiGroup: rbac.authorization.k8s.io
kind: Role
subjects:
- kind: ServiceAccount
name: {{ include "template.serviceAccountName" . }}
{{- end }}
{{- end }}