Skip to content

ROX-10034: Deactivate PodSecurityPolicies by default#1747

Merged
mtesseract merged 14 commits intomasterfrom
mc/psp-deactivated
Jun 20, 2022
Merged

ROX-10034: Deactivate PodSecurityPolicies by default#1747
mtesseract merged 14 commits intomasterfrom
mc/psp-deactivated

Conversation

@mtesseract
Copy link
Contributor

@mtesseract mtesseract commented May 17, 2022

Description

This PR is built on top of #1249 and toggles the defaults for generating deprecated PodSecurityPolicies effectively disabling them by default while still supporting explicit generation of them.

Checklist

  • Investigated and inspected CI test results
  • Unit test and regression tests added
  • Evaluated and added CHANGELOG entry if required
  • Determined and documented upgrade steps
  • Documented user facing changes (create PR based on openshift/openshift-docs and merge into rhacs-docs)

If any of these don't apply, please comment below.

Testing Performed

TODO(replace-me)
Use this space to explain how you tested your PR, or, if you didn't test it, why
you did not do so. Valid reasons include, for example, "CI is sufficient",
"No testable changes". Feel free to attach JSON snippets, curl commands,
screenshots.

In addition to reviewing your code, reviewers must also review your testing
instructions and make sure they are sufficient.

@openshift-ci
Copy link

openshift-ci bot commented May 17, 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

@ghost
Copy link

ghost commented May 17, 2022

Tag for build #686872 is 3.70.x-438-gf1fd3fce33.

💻 For deploying this image using the dev scripts, run the following first:

export MAIN_IMAGE_TAG='3.70.x-438-gf1fd3fce33'

🕹️ A roxctl binary can be downloaded from the CircleCI artifacts.

@mtesseract mtesseract force-pushed the mc/psp-deactivated branch from 61238b0 to 38763b1 Compare May 17, 2022 15:40
@mtesseract mtesseract force-pushed the mc/psp-deactivated branch from 818526b to fb1d56f Compare May 18, 2022 08:23
@mtesseract mtesseract marked this pull request as ready for review May 18, 2022 08:27
@mtesseract mtesseract requested a review from a team May 18, 2022 08:27
@mtesseract mtesseract requested a review from a team as a code owner May 18, 2022 08:27
@mtesseract mtesseract changed the title Deactivate PSPs Deactivate PodSecurityPolicies by default May 18, 2022
@mtesseract mtesseract force-pushed the mc/psp-deactivated branch from fb1d56f to 1da8696 Compare May 19, 2022 07:16
@mtesseract mtesseract removed the request for review from a team May 23, 2022 14:02
@mtesseract mtesseract force-pushed the mc/psp-deactivated branch 2 times, most recently from 5e4b22e to aa2ee54 Compare May 29, 2022 22:28
@ghost
Copy link

ghost commented Jun 1, 2022

Images are ready for the commit at f1fd3fc.

To use with deploy scripts, first export MAIN_IMAGE_TAG=3.70.x-439-g2de0900833.

Copy link
Contributor

@SimonBaeumer SimonBaeumer left a comment

Choose a reason for hiding this comment

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

LGTM from a code perspective.
Can you write in the PR description why PSPs are disabled by default for documentation purposes?

To be honest I forgot why we disable them by default immediately as kube 1.25 is not released yet and unsure about the impact it might has on roxctl based installations.

@mtesseract mtesseract requested a review from SimonBaeumer June 9, 2022 10:19
Copy link
Contributor

@SimonBaeumer SimonBaeumer left a comment

Choose a reason for hiding this comment

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

Only two small changes

logger.InfofLn("Generating deployment bundle...")

if config.EnablePodSecurityPolicies {
logger.InfofLn("Central deployment bundle includes PodSecurityPolicies (PSPs). This is incompatible with Kubernetes >= v1.25.")
Copy link
Contributor

Choose a reason for hiding this comment

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

If the message excludes the deployment name it can be extracted into a function which can be called for all components and reducing duplicated code in all three places.

Suggested change
logger.InfofLn("Central deployment bundle includes PodSecurityPolicies (PSPs). This is incompatible with Kubernetes >= v1.25.")
logger.InfofLn("Deployment bundle includes PodSecurityPolicies (PSPs). This is incompatible with Kubernetes >= v1.25.")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


if config.EnablePodSecurityPolicies {
logger.InfofLn("Central deployment bundle includes PodSecurityPolicies (PSPs). This is incompatible with Kubernetes >= v1.25.")
logger.InfofLn("Use --enable-pod-security-policies=false for disabling PodSecurityPolicies.")
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not a grammar expert, but using this form sounds cleaner to me:

Suggested change
logger.InfofLn("Use --enable-pod-security-policies=false for disabling PodSecurityPolicies.")
logger.InfofLn("Use --enable-pod-security-policies=false to disable PodSecurityPolicies.")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you are right.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@mtesseract
Copy link
Contributor Author

I have decided to implement auto-sensing in this PR, since otherwise master would be in a somewhat inconsistent state: deployment bundles have PSPs enabled by default and Helm charts have PSPs disabled by default.
Now the Helm charts use auto-sensing and should just work.

@mtesseract mtesseract force-pushed the mc/psp-deactivated branch from 365cb7e to 8ada6f7 Compare June 14, 2022 22:36
@mtesseract mtesseract changed the title Deactivate PodSecurityPolicies by default ROX-10034: Deactivate PodSecurityPolicies by default Jun 15, 2022
Copy link
Contributor

@SimonBaeumer SimonBaeumer left a comment

Choose a reason for hiding this comment

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

Auto-Sensing LGTM!

Small notes:

  • Extracting into one func the if-cases are missing
  • Conflict with CHANGELOG

values:
meta:
apiServer:
overrideAPIResources:
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, never saw this, would like to learn a bit about it.
How does this work? Can you share a documentation link?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Malte came up with this. It's an abstraction layer on top of Helm's lookup functionality which is quite convenient to use and valuable in particular for testing purposes, allows mocking (un)availability of APIs.

I don't have a pointer to documentation for this unfortunately.

func OutputZip(logger logger.Logger, config renderer.Config) error {
logger.InfofLn("Generating deployment bundle...")

if config.EnablePodSecurityPolicies {
Copy link
Contributor

Choose a reason for hiding this comment

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

The logic of the if-case is still duplicated.
Moving this if-case to a function printPSPInfoLog(config.EnablePodSecurityPolicies) and call it from all other occurrences of this clause.


func (cmd *scannerGenerateCommand) generate() error {
func (cmd *scannerGenerateCommand) generate(logger logger.Logger) error {
if cmd.enablePodSecurityPolicies {
Copy link
Contributor

Choose a reason for hiding this comment

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

Extract into one func

}
s.setClusterDefaults(env)

if s.enablePodSecurityPolicies {
Copy link
Contributor

Choose a reason for hiding this comment

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

Extract into one func

@mtesseract mtesseract force-pushed the mc/psp-deactivated branch from 19c078c to f1fd3fc Compare June 20, 2022 09:17
@mtesseract mtesseract requested a review from SimonBaeumer June 20, 2022 09:17
@mtesseract mtesseract merged commit 7856a66 into master Jun 20, 2022
@mtesseract mtesseract deleted the mc/psp-deactivated branch June 20, 2022 20:47
@Maddosaurus Maddosaurus mentioned this pull request Feb 1, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants