Skip to content

Commit

Permalink
feat(securityContext): Add the ability to set securityContext values (#…
Browse files Browse the repository at this point in the history
…135)

Adds the capability to set securityContext values at the pod and container levels. This is needed in order to deploy into a namespace with PSA enforcing at the restricted level.

Signed-off-by: bryopsida <[email protected]>
  • Loading branch information
bryopsida authored Jan 2, 2024
1 parent 0dba8af commit d85bc67
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion couchdb/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: couchdb
version: 4.4.5
version: 4.5.0
appVersion: 3.3.2
description: A database featuring seamless multi-master sync, that scales from
big data to mobile, with an intuitive HTTP/JSON API and designed for
Expand Down
4 changes: 4 additions & 0 deletions couchdb/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# NEWS

## 4.5.0

- Add capability to set pod and container level securityContext settings.

## 4.4.1

- Add possibility to customize `service.targetPort` from values. Set default to 5984.
Expand Down
12 changes: 7 additions & 5 deletions couchdb/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CouchDB

![Version: 4.4.1](https://img.shields.io/badge/Version-4.4.1-informational?style=flat-square) ![AppVersion: 3.3.2](https://img.shields.io/badge/AppVersion-3.3.2-informational?style=flat-square)
![Version: 4.5.0](https://img.shields.io/badge/Version-4.5.0-informational?style=flat-square) ![AppVersion: 3.3.2](https://img.shields.io/badge/AppVersion-3.3.2-informational?style=flat-square)

Apache CouchDB is a database featuring seamless multi-master sync, that scales
from big data to mobile, with an intuitive HTTP/JSON API and designed for
Expand All @@ -18,7 +18,7 @@ storage volumes to each Pod in the Deployment.
```bash
$ helm repo add couchdb https://apache.github.io/couchdb-helm
$ helm install couchdb/couchdb \
--version=4.4.1 \
--version=4.5.0 \
--set allowAdminParty=true \
--set couchdbConfig.couchdb.uuid=$(curl https://www.uuidgenerator.net/api/version4 2>/dev/null | tr -d -)
```
Expand All @@ -44,7 +44,7 @@ Afterwards install the chart replacing the UUID
```bash
$ helm install \
--name my-release \
--version=4.4.1 \
--version=4.5.0 \
--set couchdbConfig.couchdb.uuid=decafbaddecafbaddecafbaddecafbad \
couchdb/couchdb
```
Expand Down Expand Up @@ -78,7 +78,7 @@ and then install the chart while overriding the `createAdminSecret` setting:
```bash
$ helm install \
--name my-release \
--version=4.4.1 \
--version=4.5.0 \
--set createAdminSecret=false \
--set couchdbConfig.couchdb.uuid=decafbaddecafbaddecafbaddecafbad \
couchdb/couchdb
Expand Down Expand Up @@ -133,7 +133,7 @@ version semantics. You can upgrade directly from `stable/couchdb` to this chart

```bash
$ helm repo add couchdb https://apache.github.io/couchdb-helm
$ helm upgrade my-release --version=4.4.1 couchdb/couchdb
$ helm upgrade my-release --version=4.5.0 couchdb/couchdb
```

## Configuration
Expand Down Expand Up @@ -239,6 +239,8 @@ A variety of other parameters are also configurable. See the comments in the
| `placementConfig.enabled` | false |
| `placementConfig.image.repository` | caligrafix/couchdb-autoscaler-placement-manager |
| `placementConfig.image.tag` | 0.1.0 |
| `podSecurityContext` | |
| `containerSecurityContext` | |

## Feedback, Issues, Contributing

Expand Down
2 changes: 2 additions & 0 deletions couchdb/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ A variety of other parameters are also configurable. See the comments in the
| `placementConfig.enabled` | false |
| `placementConfig.image.repository` | caligrafix/couchdb-autoscaler-placement-manager |
| `placementConfig.image.tag` | 0.1.0 |
| `podSecurityContext` | |
| `containerSecurityContext | |

## Feedback, Issues, Contributing

Expand Down
6 changes: 6 additions & 0 deletions couchdb/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ spec:
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
spec:
restartPolicy: OnFailure
{{- if .Values.podSecurityContext }}
securityContext: {{ .Values.podSecurityContext | toYaml | nindent 8 }}
{{- end }}
containers:
- name: cluster-setup
image: {{ .Values.autoSetup.image.repository }}:{{ .Values.autoSetup.image.tag }}
Expand All @@ -44,6 +47,9 @@ spec:
secretKeyRef:
name: {{ template "couchdb.fullname" . }}
key: adminPassword
{{- if .Values.containerSecurityContext }}
securityContext: {{ .Values.containerSecurityContext | toYaml | nindent 12 }}
{{- end }}
backoffLimit: 2
ttlSecondsAfterFinished: 600
{{- end -}}
Expand Down
6 changes: 6 additions & 0 deletions couchdb/templates/placementmanager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ spec:
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
spec:
restartPolicy: OnFailure
{{- if .Values.podSecurityContext }}
securityContext: {{ .Values.podSecurityContext | toYaml | nindent 8 }}
{{- end }}
containers:
- name: placement-tagging-job
image: {{ .Values.placementConfig.image.repository }}:{{ .Values.placementConfig.image.tag }}
Expand All @@ -41,4 +44,7 @@ spec:
value: {{ template "couchdb.svcname" . }}
- name: COUCHDB_PORT
value: {{ .Values.service.externalPort | quote }}
{{- if .Values.containerSecurityContext }}
securityContext: {{ .Values.containerSecurityContext | toYaml | nindent 10 }}
{{- end }}
{{- end -}}
15 changes: 15 additions & 0 deletions couchdb/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ spec:
{{- if .Values.schedulerName }}
schedulerName: "{{ .Values.schedulerName }}"
{{- end }}
{{- if .Values.podSecurityContext }}
securityContext: {{ .Values.podSecurityContext | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.serviceAccount.enabled }}
serviceAccountName: {{ template "couchdb.serviceAccount" . }}
{{- end }}
Expand All @@ -51,6 +54,9 @@ spec:
mountPath: /tmp/
- name: config-storage
mountPath: /default.d
{{- if .Values.containerSecurityContext }}
securityContext: {{ .Values.containerSecurityContext | toYaml | nindent 12 }}
{{- end }}
resources:
{{ toYaml .Values.initResources | indent 12 }}
{{- if .Values.adminHash }}
Expand All @@ -72,6 +78,9 @@ spec:
volumeMounts:
- name: local-config-storage
mountPath: /local.d
{{- if .Values.containerSecurityContext }}
securityContext: {{ .Values.containerSecurityContext | toYaml | nindent 12 }}
{{- end }}
resources:
{{ toYaml .Values.initResources | indent 12 }}
{{- end }}
Expand Down Expand Up @@ -163,13 +172,19 @@ spec:
{{- end }}
- name: database-storage
mountPath: /opt/couchdb/data
{{- if .Values.containerSecurityContext }}
securityContext: {{ .Values.containerSecurityContext | toYaml | nindent 12 }}
{{- end }}
{{- if .Values.enableSearch }}
- name: clouseau
image: "{{ .Values.searchImage.repository }}:{{ .Values.searchImage.tag }}"
imagePullPolicy: {{ .Values.searchImage.pullPolicy }}
volumeMounts:
- name: database-storage
mountPath: /opt/couchdb-search/data
{{- if .Values.containerSecurityContext }}
securityContext: {{ .Values.containerSecurityContext | toYaml | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.sidecars }}
{{ toYaml .Values.sidecars | indent 8}}
Expand Down

0 comments on commit d85bc67

Please sign in to comment.