@@ -218,13 +218,32 @@ func (rp *SQLiteRegistryPod) podForBundleRegistry() (*corev1.Pod, error) {
218
218
Namespace : rp .cfg .Namespace ,
219
219
},
220
220
Spec : corev1.PodSpec {
221
- SecurityContext : & corev1.PodSecurityContext {
222
- RunAsNonRoot : pointer .Bool (false ),
223
- RunAsUser : pointer .Int64 (0 ),
224
- SeccompProfile : & corev1.SeccompProfile {
225
- Type : corev1 .SeccompProfileTypeRuntimeDefault ,
226
- },
227
- },
221
+ // DO NOT set RunAsUser and RunAsNonRoot, we must leave this empty to allow
222
+ // those that want to use this command against Openshift vendor do not face issues.
223
+ //
224
+ // Why not set RunAsUser?
225
+ // RunAsUser cannot be set because in OpenShift each namespace has a valid range like
226
+ // [1000680000, 1000689999]. Therefore, values like 1001 will not work. Also, in OCP each namespace
227
+ // has a valid range allocate. Therefore, by leaving it empty the OCP will adopt RunAsUser strategy
228
+ // of MustRunAsRange. The PSA will look for the openshift.io/sa.scc.uid-range annotation
229
+ // in the namespace to populate RunAsUser fields when the pod be admitted. Note that
230
+ // is NOT possible to know a valid value that could be accepeted beforehand.
231
+ //
232
+ // Why not set RunAsNonRoot?
233
+ // If we set RunAsNonRoot = true and the image informed does not define the UserID
234
+ // (i.e. in the Dockerfile we have not `USER 11211:11211 `) then, the Pod will fail to run with the
235
+ // error `"container has runAsNonRoot and image will run as root …` in ANY Kubernetes cluster.
236
+ // (vanilla or OCP). Therefore, by leaving it empty this field will be set by OCP if/when the Pod be
237
+ // qualified for restricted-v2 SCC policy.
238
+ //
239
+ // TODO: remove when OpenShift 4.10 and Kubernetes 1.19 be no longer supported
240
+ // Why not set SeccompProfile?
241
+ // This option can only work in OCP versions >= 4.11 and Kubernetes versions >= 19.
242
+ //SecurityContext: &corev1.PodSecurityContext{
243
+ // SeccompProfile: &corev1.SeccompProfile{
244
+ // Type: corev1.SeccompProfileTypeRuntimeDefault,
245
+ // },
246
+ //},
228
247
Containers : []corev1.Container {
229
248
{
230
249
Name : defaultContainerName ,
0 commit comments