Skip to content

Add projected SA token volume helpers to serviceaccount package and default security pod context helper - #720

Merged
stuggi merged 1 commit into
openstack-k8s-operators:mainfrom
lmiccini:lmiccini/sa-projected-token
Jul 24, 2026
Merged

Add projected SA token volume helpers to serviceaccount package and default security pod context helper#720
stuggi merged 1 commit into
openstack-k8s-operators:mainfrom
lmiccini:lmiccini/sa-projected-token

Conversation

@lmiccini

@lmiccini lmiccini commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Add KubeAPIAccessVolume() and KubeAPIAccessVolumeMount() helpers that create a projected volume replacing the default automounted SA token with a time-limited one (1h expiry). Use together with AutomountServiceAccountToken=false on the PodSpec.

This enables operators to harden workloads by disabling the default long-lived automounted token while still providing K8s API access via a short-lived projected token at the standard mount path.

Add RestrictiveSecurityContext helper to pod package: provides a centralized helper for building hardened container
SecurityContext for unprivileged workloads: RunAsNonRoot, drops all capabilities, disables privilege escalation, and applies the RuntimeDefault seccomp profile.

@lmiccini
lmiccini force-pushed the lmiccini/sa-projected-token branch 2 times, most recently from 23c7150 to 734fbfd Compare July 22, 2026 12:46
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 22, 2026
Reduce Redis workload SA pod verbs from
create/get/list/watch/update/patch/delete to get/list/watch/patch —
the only verb actually used is PATCH for pod label operations in
common.sh.

Add SecurityContext to Redis containers (RunAsUser/
RunAsGroup 42460), switch InstanceHA SCC from anyuid to nonroot-v2,
add SeccompProfile RuntimeDefault to InstanceHA container. Disable
AutomountServiceAccountToken on both workloads and replace with a
projected volume providing a time-limited (1h) SA token at the
standard mount path.

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lmiccini lmiccini changed the title Add projected SA token volume helpers to serviceaccount package Add projected SA token volume helpers to serviceaccount package and default security pod context helper Jul 23, 2026
@lmiccini
lmiccini force-pushed the lmiccini/sa-projected-token branch from ea217b0 to 89117b1 Compare July 23, 2026 13:57
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads except RabbitMQ.

Redis:
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
  (only PATCH is used by common.sh for pod label operations)
- Add SecurityContext (RunAsUser/RunAsGroup/RunAsNonRoot)
- Set AutomountServiceAccountToken: false with projected SA token volume

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
  (RunAsNonRoot, AllowPrivilegeEscalation: false, Drop ALL, SeccompProfile)

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add RunAsUser/RunAsGroup and Capabilities.Drop ALL via
  pod.RestrictiveSecurityContext helper

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads except RabbitMQ.

Redis:
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
  (only PATCH is used by common.sh for pod label operations)
- Add SecurityContext (RunAsUser/RunAsGroup/RunAsNonRoot)
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- SCC remains anyuid (sudo -E kolla_set_configs blocks nonroot-v2)

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
  (RunAsNonRoot, AllowPrivilegeEscalation: false, Drop ALL, SeccompProfile)

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add RunAsUser/RunAsGroup and Capabilities.Drop ALL via
  pod.RestrictiveSecurityContext helper

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread modules/common/serviceaccount/projected_token.go Outdated
Comment thread modules/common/pod/security.go
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
…ecurity

Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads.

Redis:
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
  (only PATCH is used by common.sh for pod label operations)
- Add SecurityContext (RunAsUser/RunAsGroup/RunAsNonRoot)
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- SCC remains anyuid (sudo -E kolla_set_configs blocks nonroot-v2)

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
  (RunAsNonRoot, AllowPrivilegeEscalation: false, Drop ALL, SeccompProfile)

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add RunAsUser/RunAsGroup and Capabilities.Drop ALL via
  pod.RestrictiveSecurityContext helper

RabbitMQ:
- Change SCC from anyuid to nonroot-v2 (bypasses kolla entrypoint,
  runs rabbitmq-server directly as UID 999, no sudo needed)
- Set AutomountServiceAccountToken: false with projected SA token volume
  (peer discovery uses standard SA token path)
- Add full SecurityContext via pod.RestrictiveSecurityContext on both
  rabbitmq and amqp-proxy containers
- Add kubebuilder RBAC annotation for nonroot-v2 SCC
- Keep FSGroup=0 to avoid chown overhead on existing PVCs

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lmiccini
lmiccini force-pushed the lmiccini/sa-projected-token branch from 89117b1 to 3bd9f32 Compare July 23, 2026 14:40
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
…ecurity

Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads.

Redis:
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
  (only PATCH is used by common.sh for pod label operations)
- Add SecurityContext (RunAsUser/RunAsGroup/RunAsNonRoot)
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- SCC remains anyuid (sudo -E kolla_set_configs blocks nonroot-v2)

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
  (RunAsNonRoot, AllowPrivilegeEscalation: false, Drop ALL, SeccompProfile)

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add RunAsUser/RunAsGroup and Capabilities.Drop ALL via
  pod.RestrictiveSecurityContext helper

RabbitMQ:
- Change SCC from anyuid to nonroot-v2 (bypasses kolla entrypoint,
  runs rabbitmq-server directly as UID 999, no sudo needed)
- Set AutomountServiceAccountToken: false with projected SA token volume
  (peer discovery uses standard SA token path)
- Add full SecurityContext via pod.RestrictiveSecurityContext on both
  rabbitmq and amqp-proxy containers
- Add kubebuilder RBAC annotation for nonroot-v2 SCC
- Keep FSGroup=0 to avoid chown overhead on existing PVCs

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
…ecurity

Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads.

Redis:
- Remove sudo -E kolla_set_configs from startup scripts — eliminates
  the only blocker for nonroot-v2. Config files are now read directly
  from the generated path (/var/lib/config-data/generated/), and TLS
  certs reference the volume-mounted paths instead of /etc/pki/tls/.
- Change SCC from anyuid to nonroot-v2
- Remove kolla-config volumes and mounts (config.json files deleted)
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
- Set AutomountServiceAccountToken: false with projected SA token volume

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

RabbitMQ:
- Change SCC from anyuid to nonroot-v2 (bypasses kolla entrypoint,
  runs rabbitmq-server directly as UID 999, no sudo needed)
- Set AutomountServiceAccountToken: false with projected SA token volume
- Add full SecurityContext via pod.RestrictiveSecurityContext on both
  rabbitmq and amqp-proxy containers
- Keep FSGroup=0 to avoid chown overhead on existing PVCs

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
…ecurity

Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads.

Redis:
- Remove sudo -E kolla_set_configs from startup scripts — eliminates
  the only blocker for nonroot-v2. Config files are now read directly
  from the generated path (/var/lib/config-data/generated/), and TLS
  certs reference the volume-mounted paths instead of /etc/pki/tls/.
- Change SCC from anyuid to nonroot-v2
- Remove kolla-config volumes and mounts (config.json files deleted)
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
- Set AutomountServiceAccountToken: false with projected SA token volume

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

RabbitMQ:
- Change SCC from anyuid to nonroot-v2 (bypasses kolla entrypoint,
  runs rabbitmq-server directly as UID 999, no sudo needed)
- Set AutomountServiceAccountToken: false with projected SA token volume
- Add full SecurityContext via pod.RestrictiveSecurityContext on both
  rabbitmq and amqp-proxy containers
- Keep FSGroup=0 to avoid chown overhead on existing PVCs

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
…ecurity

Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads.

Redis:
- Remove sudo -E kolla_set_configs from startup scripts — eliminates
  the only blocker for nonroot-v2. Config files are now read directly
  from the generated path (/var/lib/config-data/generated/), and TLS
  certs reference the volume-mounted paths instead of /etc/pki/tls/.
- Change SCC from anyuid to nonroot-v2
- Remove kolla-config volumes and mounts (config.json files deleted)
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
- Set AutomountServiceAccountToken: false with projected SA token volume

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Bypass kolla_start entrypoint — run memcached directly by sourcing
  /etc/sysconfig/memcached (volume-mounted) instead of going through
  kolla_set_configs which requires sudo. Delete kolla config.json and
  remove kolla-config volume/mount.
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

RabbitMQ:
- Change SCC from anyuid to nonroot-v2 (bypasses kolla entrypoint,
  runs rabbitmq-server directly as UID 999, no sudo needed)
- Set AutomountServiceAccountToken: false with projected SA token volume
- Add full SecurityContext via pod.RestrictiveSecurityContext on both
  rabbitmq and amqp-proxy containers
- Keep FSGroup=0 to avoid chown overhead on existing PVCs

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
…ecurity

Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads.

Redis:
- Remove sudo -E kolla_set_configs from startup scripts — eliminates
  the only blocker for nonroot-v2. Config files are now read directly
  from the generated path (/var/lib/config-data/generated/), and TLS
  certs reference the volume-mounted paths instead of /etc/pki/tls/.
- Change SCC from anyuid to nonroot-v2
- Remove kolla-config volumes and mounts (config.json files deleted)
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
- Set AutomountServiceAccountToken: false with projected SA token volume

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Bypass kolla_start entrypoint — run memcached directly by sourcing
  /etc/sysconfig/memcached (volume-mounted) instead of going through
  kolla_set_configs which requires sudo. Delete kolla config.json and
  remove kolla-config volume/mount.
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

RabbitMQ:
- Change SCC from anyuid to nonroot-v2 (bypasses kolla entrypoint,
  runs rabbitmq-server directly as UID 999, no sudo needed)
- Set AutomountServiceAccountToken: false with projected SA token volume
- Add full SecurityContext via pod.RestrictiveSecurityContext on both
  rabbitmq and amqp-proxy containers
- Keep FSGroup=0 to avoid chown overhead on existing PVCs

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
…ecurity

Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads.

Redis:
- Remove sudo -E kolla_set_configs from startup scripts — eliminates
  the only blocker for nonroot-v2. Config files are now read directly
  from the generated path (/var/lib/config-data/generated/), and TLS
  certs reference the volume-mounted paths instead of /etc/pki/tls/.
- Change SCC from anyuid to nonroot-v2
- Remove kolla-config volumes and mounts (config.json files deleted)
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
- Set AutomountServiceAccountToken: false with projected SA token volume

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Bypass kolla_start entrypoint — run memcached directly by sourcing
  /etc/sysconfig/memcached (volume-mounted) instead of going through
  kolla_set_configs which requires sudo. Delete kolla config.json and
  remove kolla-config volume/mount.
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

RabbitMQ:
- Change SCC from anyuid to nonroot-v2 (bypasses kolla entrypoint,
  runs rabbitmq-server directly as UID 999, no sudo needed)
- Set AutomountServiceAccountToken: false with projected SA token volume
- Add full SecurityContext via pod.RestrictiveSecurityContext on both
  rabbitmq and amqp-proxy containers
- Keep FSGroup=0 to avoid chown overhead on existing PVCs

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
…ecurity

Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads.

Redis:
- Remove sudo -E kolla_set_configs from startup scripts — eliminates
  the only blocker for nonroot-v2. Config files are now read directly
  from the generated path (/var/lib/config-data/generated/), and TLS
  certs reference the volume-mounted paths instead of /etc/pki/tls/.
- Change SCC from anyuid to nonroot-v2
- Remove kolla-config volumes and mounts (config.json files deleted)
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
- Set AutomountServiceAccountToken: false with projected SA token volume

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Bypass kolla_start entrypoint — run memcached directly by sourcing
  /etc/sysconfig/memcached (volume-mounted) instead of going through
  kolla_set_configs which requires sudo. Delete kolla config.json and
  remove kolla-config volume/mount.
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

RabbitMQ:
- Change SCC from anyuid to nonroot-v2 (bypasses kolla entrypoint,
  runs rabbitmq-server directly as UID 999, no sudo needed)
- Set AutomountServiceAccountToken: false with projected SA token volume
- Add full SecurityContext via pod.RestrictiveSecurityContext on both
  rabbitmq and amqp-proxy containers
- Keep FSGroup=0 to avoid chown overhead on existing PVCs

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
…ecurity

Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads.

Redis:
- Remove sudo -E kolla_set_configs from startup scripts — eliminates
  the only blocker for nonroot-v2. Config files are now read directly
  from the generated path (/var/lib/config-data/generated/), and TLS
  certs reference the volume-mounted paths instead of /etc/pki/tls/.
- Change SCC from anyuid to nonroot-v2
- Remove kolla-config volumes and mounts (config.json files deleted)
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
- Set AutomountServiceAccountToken: false with projected SA token volume

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Bypass kolla_start entrypoint — run memcached directly by sourcing
  /etc/sysconfig/memcached (volume-mounted) instead of going through
  kolla_set_configs which requires sudo. Delete kolla config.json and
  remove kolla-config volume/mount.
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

RabbitMQ:
- Change SCC from anyuid to nonroot-v2 (bypasses kolla entrypoint,
  runs rabbitmq-server directly as UID 999, no sudo needed)
- Set AutomountServiceAccountToken: false with projected SA token volume
- Add full SecurityContext via pod.RestrictiveSecurityContext on both
  rabbitmq and amqp-proxy containers
- Keep FSGroup=0 to avoid chown overhead on existing PVCs

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
…ecurity

Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads.

Redis:
- Remove sudo -E kolla_set_configs from startup scripts — eliminates
  the only blocker for nonroot-v2. Config files are now read directly
  from the generated path (/var/lib/config-data/generated/), and TLS
  certs reference the volume-mounted paths instead of /etc/pki/tls/.
- Change SCC from anyuid to nonroot-v2
- Remove kolla-config volumes and mounts (config.json files deleted)
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
- Set AutomountServiceAccountToken: false with projected SA token volume

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Bypass kolla_start entrypoint — run memcached directly by sourcing
  /etc/sysconfig/memcached (volume-mounted) instead of going through
  kolla_set_configs which requires sudo. Delete kolla config.json and
  remove kolla-config volume/mount.
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

RabbitMQ:
- Change SCC from anyuid to nonroot-v2 (bypasses kolla entrypoint,
  runs rabbitmq-server directly as UID 999, no sudo needed)
- Set AutomountServiceAccountToken: false with projected SA token volume
- Add full SecurityContext via pod.RestrictiveSecurityContext on both
  rabbitmq and amqp-proxy containers
- Keep FSGroup=0 to avoid chown overhead on existing PVCs

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lmiccini added a commit to lmiccini/infra-operator that referenced this pull request Jul 23, 2026
…ecurity

Address anyuid SCC and overly permissive RBAC findings
across all infra-operator workloads.

Redis:
- Remove sudo -E kolla_set_configs from startup scripts — eliminates
  the only blocker for nonroot-v2. Config files are now read directly
  from the generated path (/var/lib/config-data/generated/), and TLS
  certs reference the volume-mounted paths instead of /etc/pki/tls/.
- Change SCC from anyuid to nonroot-v2
- Remove kolla-config volumes and mounts (config.json files deleted)
- Reduce workload SA pod verbs from full CRUD to get/list/watch/patch
- Add full SecurityContext via pod.RestrictiveSecurityContext helper
- Set AutomountServiceAccountToken: false with projected SA token volume

InstanceHA:
- Change SCC from anyuid to nonroot-v2
- Add SeccompProfile RuntimeDefault
- Set AutomountServiceAccountToken: false with projected SA token volume
- Use lib-common pod.RestrictiveSecurityContext helper

Memcached:
- Bypass kolla_start entrypoint — run memcached directly by sourcing
  /etc/sysconfig/memcached (volume-mounted) instead of going through
  kolla_set_configs which requires sudo. Delete kolla config.json and
  remove kolla-config volume/mount.
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

DNSMasq:
- Change SCC from anyuid to nonroot-v2
- Remove full pod CRUD from workload SA (no SA token usage)
- Set AutomountServiceAccountToken: false
- Add DnsmasqUID constant (42435, neutron UID from kolla)
- Add full SecurityContext via pod.RestrictiveSecurityContext helper

RabbitMQ:
- Change SCC from anyuid to nonroot-v2 (bypasses kolla entrypoint,
  runs rabbitmq-server directly as UID 999, no sudo needed)
- Set AutomountServiceAccountToken: false with projected SA token volume
- Add full SecurityContext via pod.RestrictiveSecurityContext on both
  rabbitmq and amqp-proxy containers
- Keep FSGroup=0 to avoid chown overhead on existing PVCs

Depends-On: openstack-k8s-operators/lib-common#720

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread modules/common/pod/security_test.go
Comment thread modules/common/serviceaccount/projected_token.go Outdated
Comment thread modules/common/serviceaccount/projected_token_test.go Outdated
@lmiccini
lmiccini force-pushed the lmiccini/sa-projected-token branch from 3bd9f32 to 280daa9 Compare July 24, 2026 08:56
Add KubeAPIAccessVolume() and KubeAPIAccessVolumeMount() helpers that
create a projected volume replacing the default automounted SA token
with a time-limited one (1h default, configurable). Use together with
AutomountServiceAccountToken=false on the PodSpec.

Add RestrictiveSecurityContext helper to pod package: provides a
centralized helper for building hardened container SecurityContext for
unprivileged workloads.
@lmiccini
lmiccini force-pushed the lmiccini/sa-projected-token branch from 280daa9 to dc70b12 Compare July 24, 2026 08:56

@stuggi stuggi left a comment

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.

/lgtm

@stuggi
stuggi merged commit a86f6d2 into openstack-k8s-operators:main Jul 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants