Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with Pod security #8436

Merged
merged 9 commits into from Sep 15, 2022
Merged

Integrate with Pod security #8436

merged 9 commits into from Sep 15, 2022

Conversation

xpivarc
Copy link
Member

@xpivarc xpivarc commented Sep 8, 2022

What this PR does / why we need it:
Pod Security Standards shows Kubevirt still can't run as a restricted workload. Clusters enforcing restricted policy are not able to run VMs without manual adjustments of namespaces. There is also an issue with our upgrade path to the cluster that starts to enforce the policy.

This PR enables opt-in to an automatic escalation of namespaces where VMs run. This should be used only with additional security in place or after auditing of RBAC for Kubevirt access(ability to create VM/VMI or higher abstractions).

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Release note:

Kubevirt is able to run with restricted Pod Security Standard enabled with an automatic escalation of namespace privileges. 

@kubevirt-bot
Copy link
Contributor

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

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/L labels Sep 8, 2022
@xpivarc
Copy link
Member Author

xpivarc commented Sep 8, 2022

/test pull-kubevirt-e2e-k8s-1.24-psa-sig-compute
/test pull-kubevirt-e2e-k8s-1.24-psa-sig-storage

@xpivarc
Copy link
Member Author

xpivarc commented Sep 8, 2022

/test pull-kubevirt-e2e-k8s-1.24-psa-sig-compute
/test pull-kubevirt-e2e-k8s-1.24-psa-sig-storage

2 similar comments
@xpivarc
Copy link
Member Author

xpivarc commented Sep 8, 2022

/test pull-kubevirt-e2e-k8s-1.24-psa-sig-compute
/test pull-kubevirt-e2e-k8s-1.24-psa-sig-storage

@xpivarc
Copy link
Member Author

xpivarc commented Sep 9, 2022

/test pull-kubevirt-e2e-k8s-1.24-psa-sig-compute
/test pull-kubevirt-e2e-k8s-1.24-psa-sig-storage

@xpivarc xpivarc marked this pull request as ready for review September 9, 2022 14:36
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 9, 2022
@jean-edouard
Copy link
Contributor

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jean-edouard

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

The pull request process is described here

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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 9, 2022
@xpivarc xpivarc force-pushed the psa-enable branch 3 times, most recently from a37f81a to 13aabe2 Compare September 9, 2022 18:53
@xpivarc
Copy link
Member Author

xpivarc commented Sep 9, 2022

/retest
/test pull-kubevirt-e2e-k8s-1.24-psa-sig-compute
/test pull-kubevirt-e2e-k8s-1.24-psa-sig-storage

)

func RenderNFSServerWithPVC(generateName string, pvcName string) *k8sv1.Pod {
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

@@ -70,6 +70,15 @@ else
export KUBEVIRT_PROVIDER=${TARGET}
fi

if [[ $TARGET =~ psa ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

@xpivarc I am not sure that it's going to work, since we use -apply-default-e2e-configuration flag in the functests.sh and it overrides the feature-gate list.

Copy link
Contributor

Choose a reason for hiding this comment

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

@xpivarc Sorry my bad, we append. Also checked in the failed test artifacts.

Copy link
Member Author

Choose a reason for hiding this comment

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

BTW. We have also test that verify this holds true in the future.

@enp0s3
Copy link
Contributor

enp0s3 commented Sep 11, 2022

/cc

@kubevirt-commenter-bot
Copy link

/retest-required
This bot automatically retries required jobs that failed/flaked on approved PRs.
Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

VMs are unfortunatly still privileged workload(in Kubevirt).
We have to integrate with new Pod Security Standards in order to allow
seamless integration, upgrades.

This means we now make sure that target namespace allows
privileged workloads if PSA feature gate is enabled.
This unfortunatly means users escalate their privileges,
in terms of Pod security, by having ability to create VMs.

Signed-off-by: L. Pivarc <lpivarc@redhat.com>
Make sure we are not racing with cluster
sync mechanism on Openshift.

Signed-off-by: L. Pivarc <lpivarc@redhat.com>
Signed-off-by: L. Pivarc <lpivarc@redhat.com>
CDI is yet no integrated

Signed-off-by: L. Pivarc <lpivarc@redhat.com>
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 14, 2022
@xpivarc
Copy link
Member Author

xpivarc commented Sep 14, 2022

@jean-edouard @acardace There was cycle dependency. It should be good now

@acardace
Copy link
Member

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 14, 2022
We need privileged namespace in order to
create some of our pods that we need for
tests.

This commit also aligns pods that can run
as restricted PSS.

Signed-off-by: L. Pivarc <lpivarc@redhat.com>
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 14, 2022
@xpivarc
Copy link
Member Author

xpivarc commented Sep 14, 2022

@acardace I just made Bazel happy

@xpivarc
Copy link
Member Author

xpivarc commented Sep 15, 2022

/retest

@acardace
Copy link
Member

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2022
@acardace
Copy link
Member

/test pull-kubevirt-e2e-kind-1.22-sriov-nonroot

@brianmcarey
Copy link
Member

/test pull-kubevirt-verify-go-mod

@kubevirt-bot
Copy link
Contributor

kubevirt-bot commented Sep 15, 2022

@xpivarc: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubevirt-e2e-k8s-1.24-psa-sig-compute 13aabe2 link false /test pull-kubevirt-e2e-k8s-1.24-psa-sig-compute
pull-kubevirt-e2e-k8s-1.24-psa-sig-storage 13aabe2 link false /test pull-kubevirt-e2e-k8s-1.24-psa-sig-storage

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.

@kubevirt-bot kubevirt-bot merged commit ddef49d into kubevirt:main Sep 15, 2022
42 checks passed
@xpivarc
Copy link
Member Author

xpivarc commented Sep 21, 2022

/cherry-pick release-0.49
/cherry-pick release-0.44

@kubevirt-bot
Copy link
Contributor

@xpivarc: #8436 failed to apply on top of branch "release-0.49":

Applying: Enforce AllowPrivilegeEscalation
Using index info to reconstruct a base tree...
M	manifests/generated/operator-csv.yaml.in
M	pkg/virt-operator/resource/generate/components/deployments.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/virt-operator/resource/generate/components/deployments.go
Auto-merging manifests/generated/operator-csv.yaml.in
CONFLICT (content): Merge conflict in manifests/generated/operator-csv.yaml.in
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Enforce AllowPrivilegeEscalation
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-0.49
/cherry-pick release-0.44

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.

@xpivarc
Copy link
Member Author

xpivarc commented Sep 22, 2022

/cherry-pick release-0.53

@kubevirt-bot
Copy link
Contributor

@xpivarc: #8436 failed to apply on top of branch "release-0.53":

Applying: Enforce AllowPrivilegeEscalation
Applying: Drop ALL capabilities
Applying: Set SeccompProfile
Applying: Pod security label for Kubevirt
Applying: Integrate with Pod security
Using index info to reconstruct a base tree...
M	manifests/generated/operator-csv.yaml.in
M	manifests/generated/rbac-operator.authorization.k8s.yaml.in
M	pkg/virt-config/feature-gates.go
M	pkg/virt-controller/watch/BUILD.bazel
M	pkg/virt-controller/watch/application.go
M	pkg/virt-controller/watch/application_test.go
M	pkg/virt-controller/watch/migration.go
M	pkg/virt-controller/watch/migration_test.go
M	pkg/virt-controller/watch/vmi.go
M	pkg/virt-controller/watch/vmi_test.go
M	pkg/virt-operator/resource/generate/rbac/controller.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/virt-operator/resource/generate/rbac/controller.go
Auto-merging pkg/virt-controller/watch/vmi_test.go
Auto-merging pkg/virt-controller/watch/vmi.go
Auto-merging pkg/virt-controller/watch/migration_test.go
Auto-merging pkg/virt-controller/watch/migration.go
Auto-merging pkg/virt-controller/watch/application_test.go
Auto-merging pkg/virt-controller/watch/application.go
Auto-merging pkg/virt-controller/watch/BUILD.bazel
Auto-merging pkg/virt-config/feature-gates.go
CONFLICT (content): Merge conflict in pkg/virt-config/feature-gates.go
Auto-merging manifests/generated/rbac-operator.authorization.k8s.yaml.in
Auto-merging manifests/generated/operator-csv.yaml.in
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0005 Integrate with Pod security
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-0.53

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.

Comment on lines +241 to +242
namespaceStore cache.Store
onOpenshift bool
Copy link
Member

Choose a reason for hiding this comment

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

Hey @xpivarc ,
Do we really want boolean field called "onOpenshift" in here(or in any other place in our repo) that looks like code smell...

Copy link
Member Author

Choose a reason for hiding this comment

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

As of now, we have some additional integration with OKD/Openshift and this just extends the integration. We can look at how we could remove this altogether.

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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants