This is unreleased documentation for Admission Controller 1.40-dev.

ArgoCD Installation

You can install Kubewarden Admission Controller with Argo CD. Argo CD renders the Helm chart with helm template, without access to the cluster.

Admission Controller v1.17.0 removed the cert-manager dependency. The Admission Controller controller creates and renews the certificates, the root CA included. Since v1.39, the controller also creates the first certificates and the webhook configurations of the controller. The Helm chart does not contain a certificate, a CA bundle (caBundle), or a webhook configuration of the controller. Thus each render of the chart is the same, and Argo CD does not show the certificates as out of sync. You do not need an ignoreDifferences configuration or a special sync option for the certificates.

This is an example of an Argo CD application:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: admission-controller
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://charts.kubewarden.io
    chart: admission-controller
    targetRevision: 6.1.0
  destination:
    server: https://kubernetes.default.svc
    namespace: kubewarden
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

For more information about the certificates, refer to Certificate rotation.

Upgrade from an earlier version

Before v1.39, the Helm chart contained the three secrets of the controller and the two webhook configurations of the controller. The chart of v1.39 does not contain them. These are the objects:

  • The secret kubewarden-ca.

  • The secret kubewarden-webhook-server-cert.

  • The secret kubewarden-audit-scanner-client-cert.

  • The ValidatingWebhookConfiguration kubewarden-controller-validating-webhook-configuration.

  • The MutatingWebhookConfiguration kubewarden-controller-mutating-webhook-configuration.

Argo CD runs the pre-upgrade hook of the chart before each sync. The hook adds Prune=false to the argocd.argoproj.io/sync-options annotation of these objects. Thus Argo CD does not prune them, and the controller keeps the same root CA.

After the upgrade, Argo CD can show these objects as out of sync or as objects to prune. Argo CD does not prune them, because of Prune=false.

The ignoreDifferences entries for the certificates and the CA bundles of earlier versions have no effect on these objects. You can keep or remove them.

If a person or a tool writes a CA bundle that is not correct into a webhook configuration of Admission Controller, the controller writes the correct CA bundle within seconds. For more information, refer to The CA bundles of the webhook configurations.

Do not add the label app.kubernetes.io/part-of: kubewarden to other webhook configurations. The controller replaces their CA bundle, and an uninstall deletes them.

Uninstall with Argo CD

On helm uninstall, a pre-delete hook of the chart runs the controller binary with --mode=cleanup. Argo CD before version 3.3 does not run this hook when you delete the application. Argo CD 3.3 and later run the hook as a PreDelete hook. We did not test the cleanup with these versions.

Without the hook, these objects stay in the cluster:

  • The webhook configurations of the controller, kubewarden-controller-validating-webhook-configuration and kubewarden-controller-mutating-webhook-configuration.

  • The webhook configurations of the policies. They have the label app.kubernetes.io/part-of=kubewarden.

  • The secrets kubewarden-ca, kubewarden-webhook-server-cert, and kubewarden-audit-scanner-client-cert.

  • The default PolicyServer and the recommended policies. The controller creates them, not the chart. They have the label kubewarden.io/managed-by=kubewarden-controller-defaults.

  • The Deployment, Service, Secret, ConfigMap, and PodDisruptionBudget objects of each policy server. The policy servers continue to run.

  • The finalizer kubewarden.io/finalizer of each PolicyServer and each policy. A finalizer is a key that stops the deletion of an object until a controller removes it. The controller is gone, so if you delete one of these objects later, the deletion does not complete.

A webhook configuration with failurePolicy: Fail that calls a deleted service rejects the requests that it matches. If your Argo CD version is earlier than 3.3, do these steps after you delete the application. The commands use the namespace kubewarden. If the application uses another namespace, change the commands.

  1. Delete all the webhook configurations of Admission Controller. This command also deletes the webhook configurations of the controller, because they have the same label:

    kubectl delete validatingwebhookconfigurations,mutatingwebhookconfigurations -l app.kubernetes.io/part-of=kubewarden --ignore-not-found
  2. Remove the finalizers of the PolicyServer resources and of the policies. These commands remove all the finalizers of these objects, also the finalizers of other tools:

    for kind in policyservers clusteradmissionpolicies clusteradmissionpolicygroups; do
      kubectl get "$kind.policies.kubewarden.io" -o name |
        xargs -r -n 1 kubectl patch --type=merge -p '{"metadata":{"finalizers":null}}'
    done
    for kind in admissionpolicies admissionpolicygroups; do
      kubectl get "$kind.policies.kubewarden.io" -A \
        -o jsonpath='{range .items[*]}{.metadata.namespace}{"/"}{.metadata.name}{"\n"}{end}' |
        while IFS=/ read -r namespace name; do
          kubectl -n "$namespace" patch "$kind.policies.kubewarden.io" "$name" \
            --type=merge -p '{"metadata":{"finalizers":null}}'
        done
    done
  3. Delete the default PolicyServer and the recommended policies:

    kubectl delete policyservers.policies.kubewarden.io,clusteradmissionpolicies.policies.kubewarden.io,clusteradmissionpolicygroups.policies.kubewarden.io,admissionpolicies.policies.kubewarden.io,admissionpolicygroups.policies.kubewarden.io \
      -A -l kubewarden.io/managed-by=kubewarden-controller-defaults --ignore-not-found
  4. Delete the objects of the policy servers:

    kubectl -n kubewarden delete deployments,services,secrets,configmaps,poddisruptionbudgets \
      -l app.kubernetes.io/part-of=kubewarden,app.kubernetes.io/component=policy-server --ignore-not-found

    The ConfigMap objects of policy servers that controller v1.36 created can have only the label kubewarden/policy-server. Delete them too:

    kubectl -n kubewarden delete configmaps -l kubewarden/policy-server --ignore-not-found
  5. Delete the secrets of the controller:

    kubectl -n kubewarden delete secret kubewarden-ca kubewarden-webhook-server-cert kubewarden-audit-scanner-client-cert --ignore-not-found