Skip to content

Commit 700b9e7

Browse files
committed
fix: remove runAsUser/Group to support OpenShift 3
These values are automatically generated by OpenShift and cannot be the ones we have been enforcing until now. Also update the Dockerfile to run with the numeric user and group -- this allows the deployment to proceed, otherwise Kubernetes cannot infer the UID of the user "snyk" and fails to deploy.
1 parent 6a136c8 commit 700b9e7

File tree

5 files changed

+1
-25
lines changed

5 files changed

+1
-25
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RUN addgroup -S -g 10001 snyk
3737
RUN adduser -S -G snyk -h /srv/app -u 10001 snyk
3838

3939
WORKDIR /srv/app
40-
USER snyk:snyk
40+
USER 10001:10001
4141

4242
COPY --chown=snyk:snyk --from=skopeo-build /usr/bin/skopeo /usr/bin/skopeo
4343
COPY --chown=snyk:snyk --from=skopeo-build /etc/containers/registries.d/default.yaml /etc/containers/registries.d/default.yaml

scripts/create-operator.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,11 @@ HELM_CHART_LOCATION="${PWD}/${HELM_CHART_NAME}"
3333
# Also, the end location should be "helm-charts", as this is what the operator-sdk expects when building the Operator image!
3434
OPERATOR_HELM_CHARTS_LOCATION="${OPERATOR_LOCATION}/helm-charts"
3535
OPERATOR_HELM_VALUES_LOCATION="${OPERATOR_HELM_CHARTS_LOCATION}/${HELM_CHART_NAME}/values.yaml"
36-
OPERATOR_HELM_DEPLOYMENT_LOCATION="${OPERATOR_HELM_CHARTS_LOCATION}/${HELM_CHART_NAME}/templates/deployment.yaml"
3736

3837
mkdir -p "${OPERATOR_HELM_CHARTS_LOCATION}"
3938

4039
cp -R "${HELM_CHART_LOCATION}" "${OPERATOR_HELM_CHARTS_LOCATION}"
4140

42-
# The following fields will be automatically generated by OpenShift when deploying the snyk-monitor; we can't hardcode them.
43-
sed -i.bak "s|runAsUser: 10001|# runAsUser: 10001|g" "${OPERATOR_HELM_DEPLOYMENT_LOCATION}"
44-
sed -i.bak "s|runAsGroup: 10001|# runAsGroup: 10001|g" "${OPERATOR_HELM_DEPLOYMENT_LOCATION}"
45-
rm "${OPERATOR_HELM_DEPLOYMENT_LOCATION}.bak"
46-
4741
sed -i.bak "s|IMAGE_TAG_OVERRIDE_WHEN_PUBLISHING|${SNYK_MONITOR_IMAGE_TAG}|g" "${OPERATOR_HELM_VALUES_LOCATION}"
4842
rm "${OPERATOR_HELM_VALUES_LOCATION}.bak"
4943

snyk-monitor-deployment.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ spec:
6666
cpu: '1'
6767
memory: '2Gi'
6868
securityContext:
69-
runAsUser: 10001
70-
runAsGroup: 10001
7169
privileged: false
7270
runAsNonRoot: true
7371
allowPrivilegeEscalation: false

snyk-monitor/templates/deployment.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ spec:
5656
cpu: {{ .Values.limits.cpu }}
5757
memory: {{ .Values.limits.memory }}
5858
securityContext:
59-
runAsUser: 10001
60-
runAsGroup: 10001
6159
privileged: false
6260
runAsNonRoot: true
6361
allowPrivilegeEscalation: false

test/helpers/deployment.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,6 @@ export function validateSecureConfiguration(test: tap, deployment: V1Deployment)
6262
tap.ok(securityContext.allowPrivilegeEscalation === false, 'must explicitly set allowPrivilegeEscalation to false');
6363
tap.ok(securityContext.privileged === false, 'must explicitly set privileged to false');
6464
tap.ok(securityContext.runAsNonRoot === true, 'must explicitly set runAsNonRoot to true');
65-
66-
// On the OpenShift platform we delete runAsUser/runAsGroup from the Operator that creates this Deployment, so we cannot test their presence.
67-
if (process.env['TEST_PLATFORM'] !== 'openshift4') {
68-
tap.ok(
69-
securityContext.runAsUser !== undefined &&
70-
securityContext.runAsUser >= 10001,
71-
'must explicitly set runAsUser to be 10001 or greater',
72-
);
73-
tap.ok(
74-
securityContext.runAsGroup !== undefined &&
75-
securityContext.runAsGroup >= 10001,
76-
'must explicitly set runAsGroup to be 10001 or greater',
77-
);
78-
}
7965
}
8066

8167
export function validateVolumeMounts(test: tap, deployment: V1Deployment) {

0 commit comments

Comments
 (0)