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

WIP: add a namespace selector to the provisioner spec #1496

Closed

Conversation

tzneal
Copy link
Contributor

@tzneal tzneal commented Mar 10, 2022

1. Issue, if available:

Fixes #1493

2. Description of changes:

This is modeled after the NamespaceSelector on pod affinity terms
and works the same way.

3. How was this change tested?

Unit testing and creating/editing namespaces on an EKS cluster to watch pods be rejected or accepted by Karpenter.

4. Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: link to issue
  • No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@netlify
Copy link

netlify bot commented Mar 10, 2022

✔️ Deploy Preview for karpenter-docs-prod ready!

🔨 Explore the source changes: 39aed08

🔍 Inspect the deploy log: https://app.netlify.com/sites/karpenter-docs-prod/deploys/622a392f435d310008394fc5

😎 Browse the preview: https://deploy-preview-1496--karpenter-docs-prod.netlify.app

@tzneal
Copy link
Contributor Author

tzneal commented Mar 10, 2022

This likely requires more docs related to upgrading Karpenter versions. We needed the ability to list namespaces on the cluster role that current users likely won't have.

@tzneal tzneal force-pushed the allow-provisioners-to-filter-on-namespace branch from a6cb9c8 to c433c76 Compare March 10, 2022 16:17
@@ -96,13 +101,30 @@ func (c *Controller) selectProvisioner(ctx context.Context, pod *v1.Pod) (errs e
if len(provisioners) == 0 {
return nil
}

// lookup the pod namespace for matching against the provisioner
podNamespace, err := c.getPodNamespace(ctx, pod)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we encapsulate this inside provisionerCanProvision?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You could, but then you're looking up the namespace n times. Maybe it doesn't matter?

This is modeled after the NamespaceSelector on pod affinity terms
and works the same way.

Fixes aws#1493
@tzneal tzneal force-pushed the allow-provisioners-to-filter-on-namespace branch from c433c76 to 39aed08 Compare March 10, 2022 17:45
@@ -52,6 +52,7 @@ apply: ## Deploy the controller into your ~/.kube/config cluster
$(HELM_OPTS) \
--set controller.image=$(shell $(WITH_GOFLAGS) ko build -B github.com/aws/karpenter/cmd/controller) \
--set webhook.image=$(shell $(WITH_GOFLAGS) ko build -B github.com/aws/karpenter/cmd/webhook)
kubectl apply -f charts/karpenter/crds/
Copy link
Contributor

Choose a reason for hiding this comment

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

Totally minor nit, but I just realized that our CRD should be installed first, since our webhooks reference them. I believe it only matters on first installation.

@@ -96,13 +100,29 @@ func (c *Controller) selectProvisioner(ctx context.Context, pod *v1.Pod) (errs e
if len(provisioners) == 0 {
return nil
}

// lookup the pod namespace for matching against the provisioner
var podNamespace v1.Namespace
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd leave things unqualified unless it's unclear

Suggested change
var podNamespace v1.Namespace
var namespace v1.Namespace

@robertd
Copy link
Contributor

robertd commented Mar 11, 2022

Holy cow!!! This PR was so quick!!! ❤️ @tzneal & @ellistarn

@tzneal tzneal marked this pull request as draft March 11, 2022 18:08
@tzneal tzneal changed the title add a namespace selector to the provisioner spec WIP: add a namespace selector to the provisioner spec Mar 11, 2022
@tzneal
Copy link
Contributor Author

tzneal commented Mar 14, 2022

This solution has several issues, will update docs to further clarify.

@tzneal tzneal closed this Mar 14, 2022
@tzneal tzneal deleted the allow-provisioners-to-filter-on-namespace branch April 17, 2022 01:56
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.

Scope provisioner to only serve specified namespaces
3 participants