fix: Leader election
This commit is contained in:
parent
c6bac2ec62
commit
6431474951
5 changed files with 52 additions and 3 deletions
|
@ -53,6 +53,12 @@ spec:
|
|||
args: [
|
||||
"-namespace", "{{ .Release.Namespace }}"
|
||||
]
|
||||
env:
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
|
|
30
charts/well-known/templates/role.yaml
Normal file
30
charts/well-known/templates/role.yaml
Normal file
|
@ -0,0 +1,30 @@
|
|||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: {{ include "well-known.fullname" . }}
|
||||
labels:
|
||||
{{- include "well-known.labels" . | nindent 4 }}
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- services
|
||||
verbs:
|
||||
- watch
|
||||
- list
|
||||
- get
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- configmaps
|
||||
verbs:
|
||||
- get
|
||||
- update
|
||||
- apiGroups:
|
||||
- coordination.k8s.io
|
||||
resources:
|
||||
- leases
|
||||
verbs:
|
||||
- get
|
||||
- create
|
||||
- update
|
14
charts/well-known/templates/rolebinding.yaml
Normal file
14
charts/well-known/templates/rolebinding.yaml
Normal file
|
@ -0,0 +1,14 @@
|
|||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: {{ include "well-known.fullname" . }}
|
||||
labels:
|
||||
{{- include "well-known.labels" . | nindent 4 }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ include "well-known.fullname" . }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "well-known.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
|
@ -2,7 +2,7 @@
|
|||
# This is a YAML-formatted file.
|
||||
# Declare variables to be passed into your templates.
|
||||
|
||||
replicaCount: 1
|
||||
replicaCount: 2
|
||||
|
||||
image:
|
||||
repository: ghcr.io/stenic/well-known
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -39,7 +38,7 @@ func main() {
|
|||
}
|
||||
flag.StringVar(&namespace, "namespace", "default", "namespace")
|
||||
flag.StringVar(&cmName, "configmap", "well-known-generated", "")
|
||||
flag.StringVar(&id, "id", uuid.New().String(), "the holder identity name")
|
||||
flag.StringVar(&id, "id", os.Getenv("POD_NAME"), "the holder identity name")
|
||||
flag.StringVar(&leaseLockName, "lease-lock-name", "well-known", "the lease lock resource name")
|
||||
|
||||
flag.Parse()
|
||||
|
|
Loading…
Reference in a new issue