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

Adding AzurePolicyMode to Installation #3618

Merged
merged 4 commits into from
Nov 29, 2024
Merged

Conversation

vikastigera
Copy link
Contributor

Changes done to add Azure config to installation spec which has option to provide PolicyMode. This helps clients to have control over "control-plane" labels for namespaces.

Description

https://tigera.atlassian.net/browse/EV-5377

For context in design doc : https://docs.google.com/document/d/1sttHDBs18_JoTCd-f2snZBn5kCWwqIst1mCseWu1hec/edit?usp=sharing

For PR author

  • [ ✓] Tests for change.
  • [ ✓] If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

@vikastigera vikastigera requested a review from a team as a code owner November 26, 2024 18:44
@marvin-tigera marvin-tigera added this to the v1.37.0 milestone Nov 26, 2024
@vikastigera vikastigera changed the title Adding AzurePolicyMode to Installationx Adding AzurePolicyMode to Installation Nov 26, 2024
Changes done to add Azure config to installation spec
which has option to provide PolicyMode. This helps clients
to have control over "control-plane" labels for namespaces.

type Azure struct {
// PolicyMode determines whether the "control-plane" label is applied to namespaces. It offers two options: Default and Manual.
// The Default option adds the "control-plane" label to namespaces that have the PodSecurityStandard set to privileged.
Copy link
Member

@tmjd tmjd Nov 27, 2024

Choose a reason for hiding this comment

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

Why are we making this dependent on the PodSecurityStandard too? Did I miss something in the design or previous discussions that PodSecurityStandard was going to be a condition on setting the label?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, these shouldn't be directly tied to each other. We just brought that up as another similar configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you suggesting to add label to all the namespaces in Default option ?
In the meeting we decided to add it only to the privileged namespaces

Copy link
Member

Choose a reason for hiding this comment

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

Nope, not all namespaces.

We should only add it to namespaces that need this policy configured - that may or may not be the same set of namespaces as those that require PSSPrivileged, but the point is that doesn't mean hard equality between control-plane and PSSPrivileged, and it definitely isn't something the user should know about / be able to rely on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, I'll update the documentation.

}
return ns
}

func applyAzurePolicy(azure *operatorv1.Azure, pss PodSecurityStandard) bool {
if azure == nil || azure.PolicyMode == nil || *azure.PolicyMode == operatorv1.Default {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should only possibly return true if the PolicyMode is Default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it related to the previous comment, return "true" instead of "PSSPrivileged == pss" or not to return true for nil cases ?

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 believe not having this config set (nil cases) should apply default behavior.

Copy link
Member

@caseydavenport caseydavenport Nov 27, 2024

Choose a reason for hiding this comment

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

It should, but it should also always default nil -> Default based on our kubebuilder tags

Copy link
Member

Choose a reason for hiding this comment

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

In the unlikely case that we change the default value in the future, we would want nil to switch to that default here.

Copy link
Member

Choose a reason for hiding this comment

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

I think the tests in the core_controller and the renderer reflect the desired outcomes for each permutation and the tests pass.
So I think it is ok to proceed with merging this PR.

Copy link
Member

@rene-dekker rene-dekker left a comment

Choose a reason for hiding this comment

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

lgtm

@rene-dekker rene-dekker merged commit b2c3e4a into tigera:master Nov 29, 2024
5 checks passed
vikastigera added a commit to vikastigera/operator that referenced this pull request Nov 29, 2024
* Adding AzurePolicyMode to Installationx

Changes done to add Azure config to installation spec
which has option to provide PolicyMode. This helps clients
to have control over "control-plane" labels for namespaces.

* Fixing merge failure

* fixing test

* Updating documentation
marvin-tigera added a commit that referenced this pull request Nov 29, 2024
…v1.36

[Cherry-Pick] Adding AzurePolicyMode to Installation (#3618)
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.

5 participants