policy-controller

by sigstore

Helm chartv0.10.8App 0.13.1Apache-2.0Verified publisher

The Helm chart for Policy Controller

About this chart

policy-controller

The Helm chart for Policy Controller

Homepage: https://github.com/sigstore/policy-controller

Source Code

Deploy policy-controller Helm Chart

Install policy-controller using Helm:

helm repo add sigstore https://sigstore.github.io/helm-charts
helm repo update
kubectl create namespace cosign-system
helm install policy-controller -n cosign-system sigstore/policy-controller --devel

The policy-controller enforce images matching the defined list of ClusterImagePolicy for the labeled namespaces.

Note that, by default, the policy-controller offers a configurable behavior defining whether to allow, deny or warn whenever an image does not match a policy in a specific namespace. This behavior can be configured using the config-policy-controller ConfigMap created under the release namespace, and by adding an entry with the property no-match-policy and its value warn|allow|deny. By default, any image that does not match a policy is rejected whenever no-match-policy is not configured in the ConfigMap.

As supported in previous versions, you could create your own key pair:

export COSIGN_PASSWORD=<my_cosign_password>
cosign generate-key-pair

This command generates two key files cosign.key and cosign.pub. Next, create a secret to validate the signatures:

kubectl create secret generic mysecret -n \
cosign-system --from-file=cosign.pub=./cosign.pub

IMPORTANT: The cosign.secretKeyRef flag is not supported anymore. Finally, you could reuse your secret mysecret by creating a ClusterImagePolicy that sets it as listed authorities, as shown below.

apiVersion: policy.sigstore.dev/v1alpha1
kind: ClusterImagePolicy
metadata:
  name: cip-key-secret
spec:
  images:
  - glob: "**your-desired-value**"
  authorities:
  - key:
      secretRef:
        name: mysecret

Configuring Custom Certificate Authorities (CA)

The policy-controller can be configured to use custom CAs to communicate to container registries, for example, when you have a private registry with a self-signed TLS certificate.

To configure policy-controller to use custom CAs, follow these steps:

  1. Make sure the policy-controller namespace exists:

    kubectl create namespace cosign-system
    
  2. Create a bundle file with all the root and intermediate certificates and name it ca-bundle.crt.

  3. Create a ConfigMap from the bundle:

    kubectl -n cosign-system create cm ca-bundle-config \
      --from-file=ca-bundle.crt="ca-bundle.crt"
    
  4. Install the policy-controller:

    helm install -n cosign-system \
      --set webhook.registryCaBundle.name=ca-bundle-config \
      --set webhook.registryCaBundle.key=ca-bundle.crt \
      policy-controller sigstore/policy-controller
    

Enabling Admission control

To enable the policy admission webhook to check for signed images, you will need to add the following label in each namespace that you would want the webhook triggered:

Label: policy.sigstore.dev/include: "true"

apiVersion: v1
kind: Namespace
metadata:
  labels:
    policy.sigstore.dev/include: "true"
    kubernetes.io/metadata.name: my-namespace
  name: my-namespace
spec:
  finalizers:
  - kubernetes

Testing the webhook

  1. Using Unsigned Images: Creating a deployment referencing images that are not signed will yield the following error and no resources will be created:

    kubectl apply -f my-deployment.yaml
    Error from server (BadRequest): error when creating "my-deployment.yaml": admission webhook "policy.sigstore.dev" denied the request: validation failed: invalid image signature: spec.template.spec.containers[0].image
    
  2. Using Signed Images: Assuming a signed nginx image with a tag signed exists on a registry, the resource will be successfully created.

    kubectl run pod1-signed  --image=< REGISTRY_USER >/nginx:signed -n testns
    pod/pod1-signed created
    

More info

You can find more information about the policy-controller in here.

Uninstallation

To uninstall the Helm chart run following command.

helm uninstall [RELEASE_NAME]

Maintainers

NameEmailUrl
dlorenc
hectorj2f

Source Code

Values

KeyTypeDefaultDescription
commonAnnotationsobject{}
commonNodeSelectorobject{}
commonTolerationslist[]
cosign.cosignPubstring""
cosign.webhookNamestring"policy.sigstore.dev"
cosign.webhookTimeoutSecondsobject{}
imagePullSecretslist[]
installCRDsbooltrue
leasescleanup.automountServiceAccountTokenbooltrue
leasescleanup.image.pullPolicystring"IfNotPresent"
leasescleanup.image.repositorystring"cgr.dev/chainguard/kubectl"
leasescleanup.image.versionstring"latest-dev"
leasescleanup.podSecurityContext.enabledboolfalse
leasescleanup.priorityClassstring""
leasescleanup.resources.limits.cpustring""
leasescleanup.resources.limits.memorystring""
leasescleanup.resources.requests.cpustring""
leasescleanup.resources.requests.memorystring""
loglevelstring"info"
serviceMonitor.enabledboolfalse
webhook.affinityobject{}
webhook.automountServiceAccountTokenbooltrue
webhook.configDataobject{}
webhook.customLabelsobject{}
webhook.envobject{}
webhook.envFromobject{}
webhook.extraArgsobject{}
webhook.failurePolicystring"Fail"
webhook.image.pullPolicystring"IfNotPresent"
webhook.image.repositorystring"ghcr.io/sigstore/policy-controller/policy-controller"
webhook.image.versionstring"sha256:0bcd60beb93f4427c29cf3a669743caf58490e98ded4380c33c09f092734a6ab"
webhook.namestring"webhook"
webhook.namespaceSelector.matchExpressions[0].keystring"policy.sigstore.dev/include"
webhook.namespaceSelector.matchExpressions[0].operatorstring"In"
webhook.namespaceSelector.matchExpressions[0].values[0]string"true"
webhook.podAnnotationsobject{}
webhook.podDisruptionBudget.enabledbooltrue
webhook.podDisruptionBudget.minAvailableint1
webhook.podSecurityContext.allowPrivilegeEscalationboolfalse
webhook.podSecurityContext.capabilities.drop[0]string"ALL"
webhook.podSecurityContext.enabledbooltrue
webhook.podSecurityContext.readOnlyRootFilesystembooltrue
webhook.podSecurityContext.runAsUserint1000
webhook.priorityClassstring""
webhook.registryCaBundleobject{}
webhook.replicaCountint1
webhook.resources.limits.cpustring"200m"
webhook.resources.limits.memorystring"512Mi"
webhook.resources.requests.cpustring"100m"
webhook.resources.requests.memorystring"128Mi"
webhook.securityContext.enabledboolfalse
webhook.securityContext.runAsUserint65532
webhook.service.annotationsobject{}
webhook.service.portint443
webhook.service.typestring"ClusterIP"
webhook.serviceAccount.annotationsobject{}
webhook.serviceAccount.createbooltrue
webhook.serviceAccount.namestring""
webhook.strategy.rollingUpdate.maxSurgestring"25%"
webhook.strategy.rollingUpdate.maxUnavailablestring"25%"
webhook.strategy.typestring"RollingUpdate"
webhook.volumeMountslist[]
webhook.volumeslist[]
webhook.webhookNames.defaultingstring"defaulting.clusterimagepolicy.sigstore.dev"
webhook.webhookNames.validatingstring"validating.clusterimagepolicy.sigstore.dev"
webhook.webhookTimeoutSecondsobject{}

Deploy policy-controller with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has policy-controller on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartpolicy-controller is pinned at v0.10.8 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply