Skip to content

WINC-879: Introduce Pod Security admission labels#1230

Merged
openshift-merge-robot merged 3 commits into
openshift:masterfrom
jrvaldes:WINC-879
Sep 6, 2022
Merged

WINC-879: Introduce Pod Security admission labels#1230
openshift-merge-robot merged 3 commits into
openshift:masterfrom
jrvaldes:WINC-879

Conversation

@jrvaldes
Copy link
Copy Markdown
Contributor

@jrvaldes jrvaldes commented Sep 1, 2022

This change adds the Pod Security admission enforcement labels to
the test namespace created in the e2e tests and to the WMCO namespace
created at deployment, allowing the automatic synchronization of privileged
pods directly without any intermediate pod controller, so that the serviceaccount
has enough privileges to run it. The WMCO namespace is a system namespace ("openshift-" prefixed)
and the security.openshift.io/scc.podSecurityLabelSync label is set as
true to ensure the automatic Pod Security label synchronization.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 1, 2022
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Sep 1, 2022

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 1, 2022

/test vsphere-e2e-operator

@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 1, 2022

/test azure-e2e-operator

Comment thread hack/common.sh
@jrvaldes jrvaldes changed the title WINC-879: [e2e] Add Pod Security admission labels to WMCO namespace WINC-879: [e2e] Add Pod Security admission labels to test namespace Sep 1, 2022
Comment thread hack/common.sh
Comment on lines +125 to +126
# required labels for WMCO namespace
declare -a NS_LABELS=(
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.

Why is this being done here and not in the namespace we are creating when installing the operator:
https://github.com/openshift/windows-machine-config-operator/blob/master/config/manager/manager.yaml#L1

How is this going to work for actual users and not just CI?

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.

I dont understand why in general we create the namespace before attempting to install the operator. The only thing i can see is that we want to create the cloud-private-key secret ahead of time for some reason. I dont see that as necesary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebsoto you are correct. As per standup, this is out of the scope in this PR and should be tackled in a follow-up story.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont understand why in general we create the namespace before attempting to install the operator. The only thing i can see is that we want to create the cloud-private-key secret ahead of time for some reason. I dont see that as necesary

After attempting to install the operator without creating the namespace, got:

FATA[0000] Failed to run packagemanifests: create catalog: error creating catalog source: namespaces "openshift-windows-machine-config-operator" not found 
Error from server (NotFound): namespaces "openshift-windows-machine-config-operator" not found

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.

The namespace creation I think is being done by the UI based on the suggested namespace in the CSV unless something has changed recently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct when deploying the operator using the official deployment method using the CatalogSource along with an operator index.

However, for the e2e tests (run-ci-e2e-test.sh) the operator is deployed using OLM where the namespace is created first followed by the creation of the cloud-private-key secret. Therefore, the Pod Security Admission labels are required in this step.

Comment thread test/e2e/network_test.go Outdated
return err
}
if err == nil {
// TODO: ensure required labels
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be a valid corner case? What is the probability that another entity created the wmco-test namespace?

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.

None. This is an e2e test. Lets not over think this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 1, 2022

/test azure-e2e-operator

Comment thread test/e2e/main_test.go

workloadNamespaceLabels := map[string]string{
// turn off the automatic label synchronization required for PodSecurity admission
"security.openshift.io/scc.podSecurityLabelSync": "false",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be true or false did we get a clarity on this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you pointed out, the test namespace (wmco-test) is not "openshift-" prefixed, hence false should be fine.

@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 1, 2022

/test vsphere-e2e-operator

@jrvaldes jrvaldes requested review from aravindhp, mansikulkarni96 and sebsoto and removed request for aravindhp, mansikulkarni96 and sebsoto September 1, 2022 16:15
@jrvaldes jrvaldes changed the title WINC-879: [e2e] Add Pod Security admission labels to test namespace WINC-879: [e2e] Add Pod Security admission labels Sep 1, 2022
@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 1, 2022

/test azure-e2e-operator

Comment thread hack/common.sh
"security.openshift.io/scc.podSecurityLabelSync=true"
# set pods security profile to privileged. See https://kubernetes.io/docs/concepts/security/pod-security-admission/#pod-security-levels
"pod-security.kubernetes.io/enforce=privileged"
)
Copy link
Copy Markdown
Contributor Author

@jrvaldes jrvaldes Sep 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WMCO namespace with labels applied:

$oc describe ns openshift-windows-machine-config-operator
Name:         openshift-windows-machine-config-operator
Labels:       kubernetes.io/metadata.name=openshift-windows-machine-config-operator
              olm.operatorgroup.uid/04ec388c-2739-4afb-88e4-50c10642787d=
              olm.operatorgroup.uid/573918ed-b56e-4294-bc58-c7d84338c639=
              openshift.io/cluster-monitoring=true
              pod-security.kubernetes.io/enforce=privileged
              security.openshift.io/scc.podSecurityLabelSync=true
Annotations:  openshift.io/sa.scc.mcs: s0:c27,c4
              openshift.io/sa.scc.supplemental-groups: 1000710000/10000
              openshift.io/sa.scc.uid-range: 1000710000/10000
Status:       Active

No resource quota.

No LimitRange resource.

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.

The openshift-wmco namespace should have podSecurityLabelSync=true right? Just want to confirm since the posted output says false

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saifshaikh48 you are correct. I updated the above output.

@jrvaldes jrvaldes marked this pull request as ready for review September 1, 2022 20:01
@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 2, 2022

/test azure-e2e-operator

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Sep 2, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aravindhp, jrvaldes

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 2, 2022
Copy link
Copy Markdown
Contributor

@saifshaikh48 saifshaikh48 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/hold

one comment in the e2e suite

Comment thread hack/common.sh
"security.openshift.io/scc.podSecurityLabelSync=true"
# set pods security profile to privileged. See https://kubernetes.io/docs/concepts/security/pod-security-admission/#pod-security-levels
"pod-security.kubernetes.io/enforce=privileged"
)
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.

The openshift-wmco namespace should have podSecurityLabelSync=true right? Just want to confirm since the posted output says false

Comment thread test/e2e/network_test.go
Comment on lines +380 to +387
// ensure namespace was properly created with the required labels
for k, expectedValue := range labels {
if foundValue, found := ns.Labels[k]; found && expectedValue != foundValue {
return fmt.Errorf("labels mismatch for namespace %s label: %s expected: %s found: %s",
name, k, expectedValue, foundValue)
}
}
// required labels present in namespace, nothing to do!
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.

I'm not sure this logic is complete. What if the namespace already exists but without a required label? We should by applying the missing ones

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the namespace already exists but without a required label?

Throws an error. The probability for this edge case to happen is very low since the namespace is maintained by the e2e test suite.

I was overthinking this, and now you are too 😃 .

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.

Fair enough

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.

The only use case I see is in our local testing where we are playing around with the labels and don't want the tests to fail if they don't exist.

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 2, 2022
@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 2, 2022

/test aws-e2e-operator

PR merged in the release repo to fix CI issues with AWS compute capacity

@saifshaikh48
Copy link
Copy Markdown
Contributor

/lgtm

Feel free to remove the hold when we can get passed the AWS cluster issues

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Sep 2, 2022
@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 2, 2022

/retest-required

@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 2, 2022

/hold cancel

Infrastructure resources successfully provisioned in AWS CI job

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 2, 2022
@openshift-ci-robot
Copy link
Copy Markdown

/retest-required

Remaining retests: 0 against base HEAD 9db93ab and 2 for PR HEAD e2aa015 in total

@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 3, 2022

/retest-required

1 similar comment
@aravindhp
Copy link
Copy Markdown
Contributor

/retest-required

@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 4, 2022

/hold

to investigate CI failure in aws-e2e-ccm-install jobs

time="2022-09-02T22:24:49Z" level=error msg="Bootstrap failed to complete: timed out waiting for the condition"
time="2022-09-02T22:24:49Z" level=error msg="Failed to wait for bootstrapping to complete. This error usually happens when there is a problem with control plane hosts that prevents the control plane operators from creating the control plane."

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 4, 2022
@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 5, 2022

/test aws-e2e-ccm-install

@aravindhp
Copy link
Copy Markdown
Contributor

/retest-required

@aravindhp
Copy link
Copy Markdown
Contributor

/hold cancel

Looks like the cluster came up and the WMCO tests are running

INFO[2022-09-06T19:41:08Z] Running step aws-e2e-ccm-install-ipi-install-install. 
INFO[2022-09-06T20:26:08Z] Step aws-e2e-ccm-install-ipi-install-install succeeded after 45m0s. 
INFO[2022-09-06T20:26:08Z] Running step aws-e2e-ccm-install-ipi-install-times-collection. 
INFO[2022-09-06T20:26:28Z] Step aws-e2e-ccm-install-ipi-install-times-collection succeeded after 20s. 
INFO[2022-09-06T20:26:28Z] Step phase pre succeeded after 47m10s.       
INFO[2022-09-06T20:26:28Z] Running multi-stage phase test               
INFO[2022-09-06T20:26:28Z] Running step aws-e2e-ccm-install-windows-e2e-operator-test.

@jrvaldes
Copy link
Copy Markdown
Contributor Author

jrvaldes commented Sep 6, 2022

/hold cancel

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 6, 2022
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Sep 6, 2022

@jrvaldes: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants