Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
name: pgdog
version: v0.80
version: v0.81
appVersion: "v0.1.58"
4 changes: 4 additions & 0 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ spec:
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["mkdir", "-p", "/var/lib/pgdog/wal"]
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: wal
mountPath: /var/lib/pgdog
Expand Down
15 changes: 15 additions & 0 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,20 @@ else
exit 1
fi

# The WAL init container needs its own privilege settings; these cannot be set
# through podSecurityContext or the main container's securityContext.
echo ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should put an instruction into AGENTS.md to stop doing this. We already validate the yaml with kubeconform.

echo "==> Validating WAL init container privilege settings..."
wal_init_security_context=$(helm template test-release "$CHART_DIR" -f "$TEST_DIR/values-statefulset.yaml" \
| yq -o=json -I=0 'select(.kind == "StatefulSet") | .spec.template.spec.initContainers[] | select(.name == "create-wal-directory") | .securityContext')

if [ "$wal_init_security_context" = '{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]}}' ]; then
echo " WAL init container drops capabilities and disallows privilege escalation"
else
echo " FAIL: WAL init container lacks required privilege settings"
echo " Got: $wal_init_security_context"
exit 1
fi

echo ""
echo "==> All tests passed!"
Loading