Skip to content

Commit c089549

Browse files
committed
Adding features like serviceAccountName for OpenShift security constraints
parent 9cc5541 author Christopher Tate <computate@computate.org> 1677561053 -0700 committer Christopher Tate <computate@computate.org> 1677684028 -0700 - fix a bug with postgresql.enabled value - add optional serviceAccount to deployment for required security on OpenShift - add docs for the new serviceAccount values - allow customizing the postgresqlDatabase value and PGDATABASE environment variable on the betydb container - allow disabling the creation of a betydb Secret in order to use an ExternalSecret from a vault instead docs
1 parent 9cc5541 commit c089549

File tree

8 files changed

+70
-3
lines changed

8 files changed

+70
-3
lines changed

Chart.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ dependencies:
22
- name: postgresql
33
repository: https://raw.githubusercontent.com/bitnami/charts/pre-2022/bitnami
44
version: 8.9.9
5-
digest: sha256:526629d1646df6a72d4414adc89f3728f0e97e37a4e8ac65036c51e06361c7bb
6-
generated: "2022-06-22T22:35:06.775527-05:00"
5+
digest: sha256:9bf0731393755a97be066c786f40dd92f7a640137658a129a37c29cedd7d6560
6+
generated: "2023-02-27T22:24:29.970340243-07:00"

Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies:
3636
- name: postgresql
3737
version: ~8.9
3838
repository: https://raw.githubusercontent.com/bitnami/charts/pre-2022/bitnami
39-
condition: postgres.enabled
39+
condition: postgresql.enabled
4040

4141
annotations:
4242
artifacthub.io/links: |

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ The following table lists the configurable parameters of the Bety chart and thei
8686
| `betyPassword` | Password value for bety.password | `bety` |
8787
| `betyDatabase` | Name of the database for bety.database | `bety` |
8888

89+
### OpenShift/Kubernetes parameters
90+
91+
| Parameter | Description | Default |
92+
|-----------------------------------|----------------------------------------------------------|--------------------------------|
93+
| `serviceAccount.enabled` | Enable creation and use of a deployment service account | false |
94+
| `serviceAccount.name` | Add a serviceAccountName to the deployment | `` |
95+
| `serviceAccount.annotations` | Add annotations to the serviceAccount | {} |
96+
8997
### Ingress parameters
9098

9199
| Parameter | Description | Default |

templates/_helpers.tpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ If release name contains chart name it will be used as a full name.
2424
{{- end -}}
2525
{{- end -}}
2626

27+
{{/*
28+
Create a default service account name.
29+
If release name contains chart name it will be used as a full name.
30+
*/}}
31+
{{- define "serviceAccount.fullname" -}}
32+
{{- if .Values.serviceAccount.name -}}
33+
{{- .Values.serviceAccount.name | trunc 63 | trimSuffix "-" -}}
34+
{{- else -}}
35+
{{- $name := default .Chart.Name .Values.nameOverride -}}
36+
{{- if contains $name .Release.Name -}}
37+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
38+
{{- else -}}
39+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
40+
{{- end -}}
41+
{{- end -}}
42+
{{- end -}}
43+
2744
{{/*
2845
Create chart name and version as used by the chart label.
2946
*/}}
@@ -74,6 +91,8 @@ Environment variables for PostgreSQL
7491
value: {{ include "betydb.postgresqlHost" . | quote }}
7592
- name: PGPORT
7693
value: {{ include "betydb.postgresqlPort" . | quote }}
94+
- name: PGDATABASE
95+
value: {{ .Values.postgresql.postgresqlDatabase | default "postgres" | quote }}
7796
- name: PGUSER
7897
value: {{ .Values.postgresql.postgresqlUsername | default "postgres" | quote }}
7998
- name: PGPASSWORD

templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ spec:
100100
nodeSelector:
101101
{{- toYaml . | nindent 8 }}
102102
{{- end }}
103+
{{- if .Values.serviceAccount.enabled }}
104+
serviceAccountName: {{ include "serviceAccount.fullname" . | quote }}
105+
{{- end }}
103106
{{- with .Values.affinity }}
104107
affinity:
105108
{{- toYaml . | nindent 8 }}

templates/secrets.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.externalSecret }}
12
apiVersion: v1
23
kind: Secret
34
metadata:
@@ -11,3 +12,4 @@ data:
1112
{{- end }}
1213
betyPassword: {{ .Values.betyPassword | b64enc | quote }}
1314
secretKey: {{ .Values.secretKey | b64enc | quote }}
15+
{{- end }}

templates/serviceAccount.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.serviceAccount.enabled -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "serviceAccount.fullname" . }}
6+
labels:
7+
{{- include "betydb.labels" . | nindent 4 }}
8+
annotations:
9+
{{- with .Values.serviceAccount.annotations }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- end }}

values.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ betyDatabase: bety
3939
## changed users will not be able to login with their existing passwords.
4040
secretKey: thisisnotasecret
4141

42+
## Set to true if you will be managing the `betydb` secret with external secrets.
43+
## The `betydb` secret includes `betyPassword`, `postgresqlPassword`,
44+
## and `secretKey`.
45+
externalSecret: false
46+
4247
## dbtag is the tag of the database to load. Normally will use latest to
4348
## make sure latest tag is loaded, this might not work with an older database.
4449
## set this to "" to not load the database
@@ -107,6 +112,9 @@ postgresql:
107112
## not saved in the database.
108113
postgresqlPassword: supersecret
109114

115+
## postgresqlDatabase postgresql database to connect to load the database
116+
postgresqlDatabase: postgres
117+
110118
# need more space
111119
persistence:
112120
size: 20Gi
@@ -169,6 +177,21 @@ resources: {}
169177
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
170178
nodeSelector: {}
171179

180+
serviceAccount:
181+
182+
# Specifies whether a service account should be created
183+
enabled: false
184+
185+
# Specifies whether a service account should be created
186+
create: false
187+
188+
# Annotations to add to the service account
189+
annotations: {}
190+
191+
# The name of the service account to use.
192+
# If not set and create is true, a name is generated using the fullname template
193+
name: ""
194+
172195
## Tolerations
173196
## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
174197
tolerations: []

0 commit comments

Comments
 (0)