Skip to content

Commit

Permalink
Keep pgAdmin configuration writable
Browse files Browse the repository at this point in the history
The init container should have permission to write and replace these
files. Kubernetes ensures the application container cannot write to
them.

Issue: PGO-1280
  • Loading branch information
cbandy committed Oct 3, 2024
1 parent ed52367 commit fc0aee0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions internal/controller/standalone_pgadmin/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,11 @@ with open('` + configMountPath + `/` + gunicornConfigFilePath + `') as _f:

script := strings.Join([]string{
// Use the initContainer to create this path to avoid the error noted here:
// - https://github.com/kubernetes/kubernetes/issues/121294
`mkdir -p /etc/pgadmin/conf.d`,
// Write the system configuration into a read-only file.
`(umask a-w && echo "$1" > ` + scriptMountPath + `/config_system.py` + `)`,
// Write the server configuration into a read-only file.
`(umask a-w && echo "$2" > ` + scriptMountPath + `/gunicorn_config.py` + `)`,
// - https://issue.k8s.io/121294
`mkdir -p ` + configMountPath,
// Write the system and server configurations.
`echo "$1" > ` + scriptMountPath + `/config_system.py`,
`echo "$2" > ` + scriptMountPath + `/gunicorn_config.py`,
}, "\n")

return append([]string{"bash", "-ceu", "--", script, "startup"}, args...)
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/standalone_pgadmin/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ initContainers:
- --
- |-
mkdir -p /etc/pgadmin/conf.d
(umask a-w && echo "$1" > /etc/pgadmin/config_system.py)
(umask a-w && echo "$2" > /etc/pgadmin/gunicorn_config.py)
echo "$1" > /etc/pgadmin/config_system.py
echo "$2" > /etc/pgadmin/gunicorn_config.py
- startup
- |
import glob, json, re, os
Expand Down Expand Up @@ -328,8 +328,8 @@ initContainers:
- --
- |-
mkdir -p /etc/pgadmin/conf.d
(umask a-w && echo "$1" > /etc/pgadmin/config_system.py)
(umask a-w && echo "$2" > /etc/pgadmin/gunicorn_config.py)
echo "$1" > /etc/pgadmin/config_system.py
echo "$2" > /etc/pgadmin/gunicorn_config.py
- startup
- |
import glob, json, re, os
Expand Down

0 comments on commit fc0aee0

Please sign in to comment.