WINC-879: Introduce Pod Security admission labels#1230
Conversation
|
Skipping CI for Draft Pull Request. |
|
/test vsphere-e2e-operator |
|
/test azure-e2e-operator |
| # required labels for WMCO namespace | ||
| declare -a NS_LABELS=( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
The namespace creation I think is being done by the UI based on the suggested namespace in the CSV unless something has changed recently.
There was a problem hiding this comment.
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.
| return err | ||
| } | ||
| if err == nil { | ||
| // TODO: ensure required labels |
There was a problem hiding this comment.
Will this be a valid corner case? What is the probability that another entity created the wmco-test namespace?
There was a problem hiding this comment.
None. This is an e2e test. Lets not over think this.
|
/test azure-e2e-operator |
|
|
||
| workloadNamespaceLabels := map[string]string{ | ||
| // turn off the automatic label synchronization required for PodSecurity admission | ||
| "security.openshift.io/scc.podSecurityLabelSync": "false", |
There was a problem hiding this comment.
Should this be true or false did we get a clarity on this?
There was a problem hiding this comment.
As you pointed out, the test namespace (wmco-test) is not "openshift-" prefixed, hence false should be fine.
|
/test vsphere-e2e-operator |
|
/test azure-e2e-operator |
| "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" | ||
| ) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
The openshift-wmco namespace should have podSecurityLabelSync=true right? Just want to confirm since the posted output says false
There was a problem hiding this comment.
@saifshaikh48 you are correct. I updated the above output.
|
/test azure-e2e-operator |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
saifshaikh48
left a comment
There was a problem hiding this comment.
/hold
one comment in the e2e suite
| "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" | ||
| ) |
There was a problem hiding this comment.
The openshift-wmco namespace should have podSecurityLabelSync=true right? Just want to confirm since the posted output says false
| // 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! |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 😃 .
There was a problem hiding this comment.
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.
|
/test aws-e2e-operator PR merged in the release repo to fix CI issues with AWS compute capacity |
|
/lgtm Feel free to remove the hold when we can get passed the AWS cluster issues |
|
/retest-required |
|
/hold cancel Infrastructure resources successfully provisioned in AWS CI job |
|
/retest-required |
1 similar comment
|
/retest-required |
|
/hold to investigate CI failure in |
|
/test aws-e2e-ccm-install |
|
/retest-required |
|
/hold cancel Looks like the cluster came up and the WMCO tests are running |
|
/hold cancel |
|
@jrvaldes: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
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.podSecurityLabelSynclabel is set astrueto ensure the automatic Pod Security label synchronization.