-
Notifications
You must be signed in to change notification settings - Fork 951
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
chore: decouple webhook logic from cloud provider API #2079
Conversation
✅ Deploy Preview for karpenter-docs-prod ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
cmd/webhook/main.go
Outdated
// Webhooks | ||
{ | ||
certificates.NewController, | ||
newCRDDefaultingWebhook, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't newCRDDefaultingWebhook
and newAWSDefaultingWebhook
both defaulting webhooks for v1alpha5.Provisioner
. Do both get called, or are we lucky because of registration order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, they're called in a random ordering
You can use reinvocation to enforce ordering, but we don't have interdependence.
https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#reinvocation-policy
hasLabel := false | ||
if _, ok := p.Spec.Labels[key]; ok { | ||
hasLabel = true | ||
} | ||
for _, requirement := range p.Spec.Requirements { | ||
if requirement.Key == key { | ||
hasLabel = true | ||
} | ||
} | ||
if !hasLabel { | ||
p.Spec.Requirements = append(p.Spec.Requirements, v1.NodeSelectorRequirement{ | ||
Key: key, Operator: v1.NodeSelectorOpIn, Values: []string{value}, | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasLabel := false | |
if _, ok := p.Spec.Labels[key]; ok { | |
hasLabel = true | |
} | |
for _, requirement := range p.Spec.Requirements { | |
if requirement.Key == key { | |
hasLabel = true | |
} | |
} | |
if !hasLabel { | |
p.Spec.Requirements = append(p.Spec.Requirements, v1.NodeSelectorRequirement{ | |
Key: key, Operator: v1.NodeSelectorOpIn, Values: []string{value}, | |
}) | |
} | |
_, hasLabel := p.Spec.Labels[key] | |
for _, requirement := range p.Spec.Requirements { | |
if requirement.Key == key || hasLabel { | |
hasLabel = true | |
break | |
} | |
} | |
if !hasLabel { | |
p.Spec.Requirements = append(p.Spec.Requirements, v1.NodeSelectorRequirement{ | |
Key: key, Operator: v1.NodeSelectorOpIn, Values: []string{value}, | |
}) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just coping this, but will check out this cleanup.
- provisioners | ||
- provisioners/status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about AWSNodeTemplate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to move this as part of a separate change. These APIs really need to be owned by pkg/cloudprovider/aws, but they're not currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…)" This reverts commit 836f854.
…)" This reverts commit 836f854.
…)" This reverts commit 836f854.
Fixes #2052
Description
Separate aws specific webhook logic into a separate webhook that's hosted from the same webhook binary.
How was this change tested?
make test
make apply
and manual verificationDoes this change impact docs?
Release Note
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.