From b2c571bf1b42a74dd84636fee295f2fc64f47179 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 16 Oct 2020 21:36:12 +0200 Subject: [PATCH] helm: add service account for controller, add option to enable it --- helm/templates/configmap.yaml | 8 ++-- helm/templates/secret.yaml | 4 +- helm/templates/service-account.yaml | 53 +++++++++++++++++++++++++++ helm/templates/worker-deployment.yaml | 3 ++ helm/values.test.yaml | 21 +++++++++++ helm/values.yaml | 10 +++-- 6 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 helm/templates/service-account.yaml create mode 100644 helm/values.test.yaml diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index 414953af4..5d9532fce 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -14,7 +14,7 @@ data: POSTGRESQL__S3_BACKUP__HOST: "{{ .Values.backup.host }}" {{- end}} REDIS__HOST: "{{ .Release.Name }}-redis-master" - ERROR_REPORTING__ENABLED: "{{ .Values.config.error_reporting.enabled }}" - ERROR_REPORTING__ENVIRONMENT: "{{ .Values.config.error_reporting.environment }}" - ERROR_REPORTING__SEND_PII: "{{ .Values.config.error_reporting.send_pii }}" - LOG_LEVEL: "{{ .Values.config.log_level }}" + ERROR_REPORTING__ENABLED: "{{ .Values.config.errorReporting.enabled }}" + ERROR_REPORTING__ENVIRONMENT: "{{ .Values.config.errorReporting.environment }}" + ERROR_REPORTING__SEND_PII: "{{ .Values.config.errorReporting.sendPii }}" + LOG_LEVEL: "{{ .Values.config.logLevel }}" diff --git a/helm/templates/secret.yaml b/helm/templates/secret.yaml index 5884635b0..819c764c8 100644 --- a/helm/templates/secret.yaml +++ b/helm/templates/secret.yaml @@ -5,8 +5,8 @@ metadata: name: {{ include "passbook.fullname" . }}-secret-key data: monitoring_username: bW9uaXRvcg== # monitor in base64 - {{- if .Values.config.secret_key }} - secret_key: {{ .Values.config.secret_key | b64enc | quote }} + {{- if .Values.config.secretKey }} + secret_key: {{ .Values.config.secretKey | b64enc | quote }} {{- else }} secret_key: {{ randAlphaNum 50 | b64enc | quote}} {{- end }} diff --git a/helm/templates/service-account.yaml b/helm/templates/service-account.yaml new file mode 100644 index 000000000..566ee6045 --- /dev/null +++ b/helm/templates/service-account.yaml @@ -0,0 +1,53 @@ +{{- if .Values.kubernetesIntegration }} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "passbook.fullname" . }}-sa-role +rules: +- apiGroups: + - "" + resources: + - secrets + - services + verbs: + - "get" + - "create" + - "delete" + - "read" + - "patch" +- apiGroups: + - "extensions" + - "apps" + resources: + - "deployments" + verbs: + - "get" + - "create" + - "delete" + - "read" + - "patch" +- apiGroups: + - "" + resources: + - namespaces + verbs: + - list +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "passbook.fullname" . }}-sa +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "passbook.fullname" . }}-sa-role-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "passbook.fullname" . }}-sa-role +subjects: +- kind: ServiceAccount + name: {{ include "passbook.fullname" . }}-sa + namespace: {{ .Release.Namespace }} +{{- end }} diff --git a/helm/templates/worker-deployment.yaml b/helm/templates/worker-deployment.yaml index 21aae23ca..b7bd41014 100644 --- a/helm/templates/worker-deployment.yaml +++ b/helm/templates/worker-deployment.yaml @@ -22,6 +22,9 @@ spec: app.kubernetes.io/instance: {{ .Release.Name }} k8s.passbook.beryju.org/component: worker spec: + {{- if .Values.kubernetesIntegration }} + serviceAccountName: {{ include "passbook.fullname" . }}-sa + {{- end }} affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: diff --git a/helm/values.test.yaml b/helm/values.test.yaml new file mode 100644 index 000000000..e953b68b5 --- /dev/null +++ b/helm/values.test.yaml @@ -0,0 +1,21 @@ +image: + tag: gh-master + +serverReplicas: 1 +workerReplicas: 1 + +config: + # Log level used by web and worker + # Can be either debug, info, warning, error + logLevel: debug + +ingress: + hosts: + - passbook.127.0.0.1.nip.io + +# These values influence the bundled postgresql and redis charts, but are also used by passbook to connect +postgresql: + postgresqlPassword: EK-5jnKfjrGRm<77 + +redis: + password: password diff --git a/helm/values.yaml b/helm/values.yaml index 5588de006..4a8987350 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -11,17 +11,19 @@ nameOverride: "" serverReplicas: 1 workerReplicas: 1 +kubernetesIntegration: true + config: # Optionally specify fixed secret_key, otherwise generated automatically - # secret_key: _k*@6h2u2@q-dku57hhgzb7tnx*ba9wodcb^s9g0j59@=y(@_o + # secretKey: _k*@6h2u2@q-dku57hhgzb7tnx*ba9wodcb^s9g0j59@=y(@_o # Enable error reporting - error_reporting: + errorReporting: enabled: false environment: customer - send_pii: false + sendPii: false # Log level used by web and worker # Can be either debug, info, warning, error - log_level: warning + logLevel: warning # Enable Database Backups to S3 # backup: