@@ -171,8 +171,10 @@ const (
171171type WebhookDescription struct {
172172 GenerateName string `json:"generateName"`
173173 // +kubebuilder:validation:Enum=ValidatingAdmissionWebhook;MutatingAdmissionWebhook;ConversionWebhook
174- Type WebhookAdmissionType `json:"type"`
175- DeploymentName string `json:"deploymentName,omitempty"`
174+ Type WebhookAdmissionType `json:"type"`
175+ DeploymentName string `json:"deploymentName,omitempty"`
176+ // +kubebuilder:validation:Maximum=65535
177+ // +kubebuilder:validation:Minimum=1
176178 ContainerPort int32 `json:"containerPort,omitempty"`
177179 TargetPort * intstr.IntOrString `json:"targetPort,omitempty"`
178180 Rules []admissionregistrationv1.RuleWithOperations `json:"rules,omitempty"`
@@ -189,6 +191,9 @@ type WebhookDescription struct {
189191
190192// GetValidatingWebhook returns a ValidatingWebhook generated from the WebhookDescription
191193func (w * WebhookDescription ) GetValidatingWebhook (namespace string , namespaceSelector * metav1.LabelSelector , caBundle []byte ) admissionregistrationv1.ValidatingWebhook {
194+ if w .ContainerPort == 0 {
195+ w .ContainerPort = 443
196+ }
192197 return admissionregistrationv1.ValidatingWebhook {
193198 Name : w .GenerateName ,
194199 Rules : w .Rules ,
@@ -213,6 +218,9 @@ func (w *WebhookDescription) GetValidatingWebhook(namespace string, namespaceSel
213218
214219// GetMutatingWebhook returns a MutatingWebhook generated from the WebhookDescription
215220func (w * WebhookDescription ) GetMutatingWebhook (namespace string , namespaceSelector * metav1.LabelSelector , caBundle []byte ) admissionregistrationv1.MutatingWebhook {
221+ if w .ContainerPort == 0 {
222+ w .ContainerPort = 443
223+ }
216224 return admissionregistrationv1.MutatingWebhook {
217225 Name : w .GenerateName ,
218226 Rules : w .Rules ,
0 commit comments