-
Notifications
You must be signed in to change notification settings - Fork 971
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
deploy webhook by yaml #2346
deploy webhook by yaml #2346
Conversation
3a03db2
to
5614179
Compare
5614179
to
ae62368
Compare
v1 "k8s.io/api/admissionregistration/v1" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
"time" |
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.
Please sort the packages regularlly.
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.
done
ae62368
to
0f14fa4
Compare
cmd/webhook-manager/app/util.go
Outdated
func addCaCertForWebhook(kubeClient *kubernetes.Clientset, caBundle []byte) error { | ||
for _, mutatingWebhookName := range mutatingWebhooksName { | ||
var mutatingWebhook *v1.MutatingWebhookConfiguration | ||
if err := wait.PollInfinite(time.Second, func() (done bool, err error) { |
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.
it's better to add timeout and exit
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.
How long should the timeout be set?
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.
@shinytang6
I added a 5 minutes timeout.
dea17da
to
72aa2f9
Compare
cmd/webhook-manager/app/util.go
Outdated
klog.V(3).Infof("Registered mutating webhook for path <%s>.", service.Path) | ||
for index := 0; index < len(mutatingWebhook.Webhooks); index++ { | ||
if mutatingWebhook.Webhooks[index].ClientConfig.CABundle == nil || | ||
bytes.Equal(mutatingWebhook.Webhooks[index].ClientConfig.CABundle, caBundle) { |
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.
!bytes.Equal
?
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.
Yes, you are right. I fixed it.
cmd/webhook-manager/app/util.go
Outdated
service.ValidatingConfig.Webhooks[i].AdmissionReviewVersions = reviewVersions | ||
service.ValidatingConfig.Webhooks[i].ClientConfig = clientConfig | ||
service.ValidatingConfig.Webhooks[i].NamespaceSelector = webhookLabelSelector | ||
if _, err := kubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().Update(context.TODO(), mutatingWebhook, metav1.UpdateOptions{}); err != nil { |
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.
it's better to compare the updated webhook with original mutatingWebhook here, if no change, we don't need to call Update func
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.
Ok, I added a flag to record if the webhook has been changed, and if so. then call the update function. reflection is not used, which may affect performance
Will the scheduler connect to the webhook? l am a little confused here |
72aa2f9
to
05dc1fa
Compare
Yes, I got some error log
|
@hwdef Yes, it is a serious problem. Woud you elaborate more on "volcano-scheduler restart because it can not connect to the webhook". scheduler has no direct connection with webhook. |
After discussing it with @shinytang6 , we have roughly located the problem. I will try to solve it later. |
6c578f3
to
47e1ca6
Compare
The error mentioned above is caused by the failure to call the webhook when creating the initial queue.
|
47e1ca6
to
94a16dc
Compare
@shinytang6 |
fc88bca
to
68af3dc
Compare
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.
Another questions: due to we apply all the webhook configurations now, will enabled-admission
arguments still work as expected?
cmd/webhook-manager/app/util.go
Outdated
|
||
v1 "k8s.io/api/admissionregistration/v1" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
|
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.
remove the line
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.
Thanks for your suggestion. I deleted this.
After checking the source of this parameter and related code, I think that deploying webhook and this parameter are two separate functions that have no effect on each other |
dd804fb
to
1a86782
Compare
@@ -79,7 +79,7 @@ func (c *Config) AddFlags(fs *pflag.FlagSet) { | |||
fs.StringVar(&c.WebhookNamespace, "webhook-namespace", "", "The namespace of this webhook") | |||
fs.StringVar(&c.WebhookName, "webhook-service-name", "", "The name of this webhook") | |||
fs.StringVar(&c.WebhookURL, "webhook-url", "", "The url of this webhook") | |||
fs.StringVar(&c.EnabledAdmission, "enabled-admission", defaultEnabledAdmission, "enabled admission webhooks") | |||
fs.StringVar(&c.EnabledAdmission, "enabled-admission", defaultEnabledAdmission, "enabled admission webhooks,if this parameter is modified, please modify the deployed webhook as well. Make sure the same webhook is deployed and enabled.") |
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.
enabled admission webhooks, if this parameter is modified, make sure corresponding webhook configurations are the same.
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.
Thanks. I changed this.
Signed-off-by: hwdef <hwdefcom@outlook.com>
1a86782
to
35b0ac1
Compare
@shinytang6 @william-wang @Thor-wl |
Generally LGTM. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Thor-wl The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
ref: #2333
steps:
a little problem:
There will be a delay in supplementing the certificate fields through volcano-admission. During this period, volcano-scheduler will restart because it cannot connect to the webhook.
I don't know if this is a serious problem, please give me some advice.
@Thor-wl @william-wang @shinytang6 @qiankunli