Commit e40cecf
fix: update PostgreSQL securityContext for OpenShift SCC compliance (#823)
## Problem
The ambient-api-server PostgreSQL pod was failing to start in some
OpenShift environments due to Security Context Constraint (SCC)
violations. The pod was configured with:
```yaml
securityContext:
runAsUser: 999 # Explicit UID
runAsGroup: 999 # Explicit GID
fsGroup: 999 # Explicit fsGroup
# runAsNonRoot: NOT SET (defaults to false)
```
**Root Cause**: While UID 999 is non-root, some OpenShift namespaces
have SCC policies that restrict which specific UIDs are allowed. The
explicit `runAsUser: 999` was being rejected because 999 was outside the
namespace's allowed UID range.
## Solution
Replace explicit UID/GID specifications with `runAsNonRoot: true`,
allowing OpenShift to auto-assign secure UIDs from the namespace's
allowed ranges:
### Pod-level securityContext:
```yaml
# BEFORE:
securityContext:
runAsUser: 999
runAsGroup: 999
fsGroup: 999
# AFTER:
securityContext:
runAsNonRoot: true
```
### Container-level securityContext:
```yaml
# BEFORE:
securityContext:
runAsUser: 999
runAsGroup: 999
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false
capabilities:
drop:
- ALL
# AFTER:
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false
runAsNonRoot: true
capabilities:
drop:
- ALL
```
## Benefits
- ✅ **Portable across OpenShift clusters** - works regardless of
namespace UID ranges
- ✅ **SCC compliant** - compatible with restricted-v2 and other strict
SCCs
- ✅ **Auto-assigned security** - OpenShift assigns appropriate
UID/GID/fsGroup
- ✅ **No functionality loss** - PostgreSQL continues to run as non-root
with proper permissions
## Test Plan
- [ ] Deploy to OpenShift namespace with restricted SCC
- [ ] Verify pod starts successfully (1/1 Ready)
- [ ] Verify PostgreSQL service accepts connections
- [ ] Verify data persistence works correctly
- [ ] Check that OpenShift auto-assigns secure UID/GID values
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Claude <noreply@anthropic.com>1 parent c270847 commit e40cecf
1 file changed
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
| 58 | + | |
60 | 59 | | |
61 | 60 | | |
62 | 61 | | |
| |||
100 | 99 | | |
101 | 100 | | |
102 | 101 | | |
103 | | - | |
104 | | - | |
105 | 102 | | |
106 | 103 | | |
| 104 | + | |
107 | 105 | | |
108 | 106 | | |
109 | 107 | | |
| |||
0 commit comments