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

allow multiple namespaces to be watched for policies #42

Merged
merged 2 commits into from
Jun 19, 2019

Conversation

janwillies
Copy link
Contributor

this fixes an inconsistency with the docs:

--policies stringSlice
automatically load policies from these namespaces

but v1.NamespaceAll was hardcoded

@janwillies
Copy link
Contributor Author

reading #11 this seems a bit more work than this?

Copy link
Member

@tsandall tsandall left a comment

Choose a reason for hiding this comment

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

@janwillies this looks fine. I have one comment we should address but other than that, LGTM. Also, you'll need to sign-off on your changes before we can merge this.

source := cache.NewListWatchFromClient(
client,
"configmaps",
namespace,
Copy link
Member

Choose a reason for hiding this comment

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

Users can deploy kube-mgmt with --policies=* in which case configmaps in all namespaces will be replicated into OPA (this is used in conjunction with --require-policy-label` to filter configmaps.)

Could you add a flag to kube-mgmt so that users can tell it to watch specific namespaces? Otherwise this change will not be backwards compatible.

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'm a bit afraid that adding another parameter would maybe clutter the UI too much? Note that the help for --policies currently says:

 --policies stringSlice                automatically load policies from these namespaces (default [opa,kube-federation-scheduling-policy]) 

Can we not simply parse the --policies= parameter and in case of * use v1.NamespaceAll? Something like

	if namespaces[0] == "*" {
		namespaces[0] = v1.NamespaceAll
		namespaces = namespaces[0:1]
	}

Copy link
Member

Choose a reason for hiding this comment

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

This looks fine. I would probably check whether the slice contained * at all but this will work.

Copy link
Member

@tsandall tsandall left a comment

Choose a reason for hiding this comment

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

LGTM

source := cache.NewListWatchFromClient(
client,
"configmaps",
namespace,
Copy link
Member

Choose a reason for hiding this comment

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

This looks fine. I would probably check whether the slice contained * at all but this will work.

@tsandall tsandall merged commit 45a6ece into open-policy-agent:master Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants