Skip to content

Commit

Permalink
move validation webhook installation to the kustomize
Browse files Browse the repository at this point in the history
  • Loading branch information
hisarbalik committed Nov 8, 2024
1 parent 22f3608 commit 053ea4f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 34 deletions.
2 changes: 1 addition & 1 deletion config/webhook/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
#- manifests.yaml
- manifests.yaml
- service.yaml

configurations:
Expand Down
12 changes: 9 additions & 3 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
labels:
app.kubernetes.io/instance: telemetry
app.kubernetes.io/name: manager
control-plane: telemetry-manager
kyma-project.io/component: controller
name: validation.webhook.telemetry.kyma-project.io
webhooks:
- admissionReviewVersions:
- v1beta1
- v1
clientConfig:
service:
name: telemetry-manager-webhook
name: manager-webhook
namespace: system
path: /validate-logpipeline
port: 443
Expand All @@ -37,13 +42,13 @@ webhooks:
- v1
clientConfig:
service:
name: telemetry-manager-webhook
name: manager-webhook
namespace: system
path: /validate-logparser
port: 443
failurePolicy: Fail
matchPolicy: Exact
name: validating.logparsers.telemetry.kyma-project.io
name: validation.logparsers.telemetry.kyma-project.io
namespaceSelector: {}
objectSelector: {}
rules:
Expand All @@ -59,3 +64,4 @@ webhooks:
scope: '*'
sideEffects: None
timeoutSeconds: 15

33 changes: 3 additions & 30 deletions internal/webhookcert/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ func applyWebhookConfigResources(ctx context.Context, c client.Client, caBundle
}

func makeValidatingWebhookConfig(caBundle []byte, config Config) admissionregistrationv1.ValidatingWebhookConfiguration {

Check failure on line 37 in internal/webhookcert/resources.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary leading newline (whitespace)
apiGroups := []string{"telemetry.kyma-project.io"}
apiVersions := []string{"v1alpha1"}
webhookTimeout := int32(15) //nolint:mnd // 15 seconds
labels := map[string]string{
"control-plane": "telemetry-manager",
"app.kubernetes.io/instance": "telemetry",
"app.kubernetes.io/name": "manager",
"kyma-project.io/component": "controller",
}

createWebhook := func(name, path string, resources []string) admissionregistrationv1.ValidatingWebhook {

Check failure on line 39 in internal/webhookcert/resources.go

View workflow job for this annotation

GitHub Actions / lint

`makeValidatingWebhookConfig$1` - `resources` is unused (unparam)
return admissionregistrationv1.ValidatingWebhook{
Expand All @@ -57,25 +48,8 @@ func makeValidatingWebhookConfig(caBundle []byte, config Config) admissionregist
},
CABundle: caBundle,
},
FailurePolicy: ptr.To(admissionregistrationv1.Fail),
MatchPolicy: ptr.To(admissionregistrationv1.Exact),
Name: name,
SideEffects: ptr.To(admissionregistrationv1.SideEffectClassNone),
TimeoutSeconds: &webhookTimeout,
Rules: []admissionregistrationv1.RuleWithOperations{
{
Operations: []admissionregistrationv1.OperationType{
admissionregistrationv1.Create,
admissionregistrationv1.Update,
},
Rule: admissionregistrationv1.Rule{
APIGroups: apiGroups,
APIVersions: apiVersions,
Scope: ptr.To(admissionregistrationv1.AllScopes),
Resources: resources,
},
},
},
Name: name,
SideEffects: ptr.To(admissionregistrationv1.SideEffectClassNone),
}
}

Expand All @@ -87,8 +61,7 @@ func makeValidatingWebhookConfig(caBundle []byte, config Config) admissionregist
return admissionregistrationv1.ValidatingWebhookConfiguration{
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{
Name: config.WebhookName.Name,
Labels: labels,
Name: config.WebhookName.Name,
},
Webhooks: webhooks,
}
Expand Down

0 comments on commit 053ea4f

Please sign in to comment.