diff --git a/charts/postgreslet-support/templates/_helpers.tpl b/charts/postgreslet-support/templates/_helpers.tpl new file mode 100644 index 00000000..b01f369f --- /dev/null +++ b/charts/postgreslet-support/templates/_helpers.tpl @@ -0,0 +1,73 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "postgreslet-support.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "postgreslet-support.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "postgreslet-support.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "postgreslet-support.labels" -}} +helm.sh/chart: {{ include "postgreslet-support.chart" . }} +{{ include "postgreslet-support.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "postgreslet-support.selectorLabels" -}} +app.kubernetes.io/name: {{ include "postgreslet-support.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the prefix to use in (cluster)role names and bindings +*/}} +{{- define "postgreslet-support.roleName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "postgreslet-support.fullname" .) .Values.serviceAccount.roleNamePrefix }} +{{- else }} +{{- default "postgreslet-support" .Values.serviceAccount.roleNamePrefix }} +{{- end }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "postgreslet-support.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "postgreslet-support.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/postgreslet-support/templates/clusterrole.yaml b/charts/postgreslet-support/templates/clusterrole.yaml new file mode 100644 index 00000000..1ad1dfb6 --- /dev/null +++ b/charts/postgreslet-support/templates/clusterrole.yaml @@ -0,0 +1,22 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "postgreslet-support.roleName" . }} +rules: +- apiGroups: + - "database.fits.cloud" + resources: + - postgres + verbs: + - get + - list + - watch + - update +- apiGroups: + - "database.fits.cloud" + resources: + - postgres/status + verbs: + - get + - update + - patch diff --git a/charts/postgreslet-support/templates/clusterrolebinding.yaml b/charts/postgreslet-support/templates/clusterrolebinding.yaml new file mode 100644 index 00000000..aa2cc400 --- /dev/null +++ b/charts/postgreslet-support/templates/clusterrolebinding.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "postgreslet-support.roleName" . }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "postgreslet-support.roleName" . }} +subjects: +- kind: ServiceAccount + name: {{ include "postgreslet-support.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} \ No newline at end of file diff --git a/charts/postgreslet-support/templates/serviceaccount.yaml b/charts/postgreslet-support/templates/serviceaccount.yaml new file mode 100644 index 00000000..ab873bfa --- /dev/null +++ b/charts/postgreslet-support/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "postgreslet-support.serviceAccountName" . }} + labels: + {{- include "postgreslet-support.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/postgreslet-support/values.yaml b/charts/postgreslet-support/values.yaml new file mode 100644 index 00000000..c8795f05 --- /dev/null +++ b/charts/postgreslet-support/values.yaml @@ -0,0 +1,18 @@ +# Default values for postgreslet-support. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + # A prefix to use in all the (Cluster)Roles that are being created for this service account. + # If not set and create is true, a name is generated using the fullname template + roleNamePrefix: ""