diff --git a/charts/well-known/templates/deployment.yaml b/charts/well-known/templates/deployment.yaml index df4fedb..68ace3d 100644 --- a/charts/well-known/templates/deployment.yaml +++ b/charts/well-known/templates/deployment.yaml @@ -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 }} diff --git a/charts/well-known/templates/role.yaml b/charts/well-known/templates/role.yaml new file mode 100644 index 0000000..e8f1ebb --- /dev/null +++ b/charts/well-known/templates/role.yaml @@ -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 \ No newline at end of file diff --git a/charts/well-known/templates/rolebinding.yaml b/charts/well-known/templates/rolebinding.yaml new file mode 100644 index 0000000..e12955d --- /dev/null +++ b/charts/well-known/templates/rolebinding.yaml @@ -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 }} diff --git a/charts/well-known/values.yaml b/charts/well-known/values.yaml index 8fe6c47..4f4d49d 100644 --- a/charts/well-known/values.yaml +++ b/charts/well-known/values.yaml @@ -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 diff --git a/server/main.go b/server/main.go index 4f8130f..65ce64e 100644 --- a/server/main.go +++ b/server/main.go @@ -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()