Skip to content

Commit 2f1bada

Browse files
authored
fix: skip projects init-container under restricted_security_context (#14)
The init-projects container chmod/chgrp's /var/lib/awx/projects. With restricted_security_context enabled it inherits the pod's runAsNonRoot (uid 1000) yet still runs chmod/chgrp, which a non-root process without CAP_FOWNER cannot do on a volume it does not own. The container exits "Operation not permitted" and the web/task pods never start. Under restricted_security_context the pod already sets fsGroup, which the kubelet applies to fsGroup-capable volumes (the same mechanism the option relies on for the backup pod). So skip the privileged init-projects container in that mode and rely on fsGroup, rather than shipping a chown that can only fail. Non-restricted behavior is unchanged. Note: fsGroup is not applied to NFS-backed RWX volumes, so such a volume must present a directory writable by the projects gid (many RWX provisioners create the share root world-writable).
1 parent f793f64 commit 2f1bada

2 files changed

Lines changed: 2 additions & 16 deletions

File tree

roles/installer/templates/deployments/task.yaml.j2

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,11 @@ spec:
194194
{% if init_container_extra_volume_mounts -%}
195195
{{ init_container_extra_volume_mounts | indent(width=12, first=True) }}
196196
{% endif %}
197-
{% if projects_persistence|bool and is_k8s|bool %}
197+
{% if projects_persistence|bool and is_k8s|bool and not (restricted_security_context | bool) %}
198198
- name: init-projects
199199
image: '{{ _init_projects_container_image }}'
200200
imagePullPolicy: '{{ image_pull_policy }}'
201201
resources: {{ init_container_resource_requirements }}
202-
{% if restricted_security_context | bool %}
203-
securityContext:
204-
allowPrivilegeEscalation: false
205-
capabilities:
206-
drop:
207-
- ALL
208-
{% endif %}
209202
command:
210203
- /bin/sh
211204
- -c

roles/installer/templates/deployments/web.yaml.j2

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,11 @@ spec:
138138
{{ init_container_extra_volume_mounts | indent(width=12, first=True) }}
139139
{% endif %}
140140
{% endif %}
141-
{% if projects_persistence|bool and is_k8s|bool %}
141+
{% if projects_persistence|bool and is_k8s|bool and not (restricted_security_context | bool) %}
142142
- name: init-projects
143143
image: '{{ _init_projects_container_image }}'
144144
imagePullPolicy: '{{ image_pull_policy }}'
145145
resources: {{ init_container_resource_requirements }}
146-
{% if restricted_security_context | bool %}
147-
securityContext:
148-
allowPrivilegeEscalation: false
149-
capabilities:
150-
drop:
151-
- ALL
152-
{% endif %}
153146
command:
154147
- /bin/sh
155148
- -c

0 commit comments

Comments
 (0)