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

[Bug]: NamespaceSelector is not correctly rendered for the validating webhook. #387

Open
jerome-blanche opened this issue Nov 4, 2024 · 0 comments
Assignees
Labels

Comments

@jerome-blanche
Copy link

Describe the bug

When the validation webhook is enabled (trow:validationWebhook:enabled: true), and the webhook namespace selector is defined, helm generates an invalid ValidatingWebhookConfiguration resource.

To Reproduce

helm repo add trow https://trow-registry.github.io/trow
cat << EOF > values.yaml 
trow:
  validationWebhook:
    enabled: true

webhooks:
  namespaceSelector:
    matchLabels:
      webhook: "allowed"
EOF
helm template trow/trow --version 0.8.1 -f ./values.yaml --namespace trow > manifests.yaml

Expected behavior

A valid manifest for the ValidatingWebhookConfiguration resource:

  • metadata.annotations property should be removed
  • webhooks[0].namespaceSelector should be correctly formatted

Output/Logs

Rendered manifest:

# Source: trow/templates/webhooks/validatingwebhook.yaml
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
  name: server-trow-validation
  labels:
    helm.sh/chart: trow-0.8.1
    app.kubernetes.io/part-of: trow
    app.kubernetes.io/instance: server
    app.kubernetes.io/version: "0.6.4"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: admission-webhook
  annotations:
webhooks:
  - name: validate.trow.io
    admissionReviewVersions: ["v1"]
    sideEffects: None
    
    namespaceSelector:      |-
        matchLabels:
          webhook: allowed
    rules:
      - apiGroups: [""]
        apiVersions: ["v1"]
        operations: ["CREATE"]
        resources: ["pods"]
        scope: "Namespaced"
    # Patched by job-patchWebhook.yaml
    # At first deploy we have to set to "Ignore" otherwise Trow fails to deploy
    # because the Trow webhook doesn't exist yet :/
    failurePolicy: Ignore
    clientConfig:
      service:
        name: server-trow-admission
        path: "/validate-image"
        namespace: trow

Expected manifest:

# Source: trow/templates/webhooks/validatingwebhook.yaml
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
  name: server-trow-validation
  labels:
    helm.sh/chart: trow-0.8.1
    app.kubernetes.io/part-of: trow
    app.kubernetes.io/instance: server
    app.kubernetes.io/version: "0.6.4"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: admission-webhook
webhooks:
  - name: validate.trow.io
    admissionReviewVersions: ["v1"]
    sideEffects: None
    
    namespaceSelector:
      matchLabels:
        webhook: allowed
    rules:
      - apiGroups: [""]
        apiVersions: ["v1"]
        operations: ["CREATE"]
        resources: ["pods"]
        scope: "Namespaced"
    # Patched by job-patchWebhook.yaml
    # At first deploy we have to set to "Ignore" otherwise Trow fails to deploy
    # because the Trow webhook doesn't exist yet :/
    failurePolicy: Ignore
    clientConfig:
      service:
        name: server-trow-admission
        path: "/validate-image"
        namespace: trow

Trow Info

Helm chart version 0.8.1

Kubernetes

helm version:
version.BuildInfo{Version:"v3.16.1", GitCommit:"5a5449dc42be07001fd5771d56429132984ab3ab", GitTreeState:"clean", GoVersion:"go1.22.7"}

Additional context

Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants