Skip to content

Commit 30f3e6e

Browse files
committed
Expose the deployment strategy values for the policy controller
Prior to this change, the policy controller webhook was not able to have its deployment strategy modified. If you only deployed a single replica, it could not perform a rolling update due to the default `maxSurge: 25%` being rounded down to 0. This change exposes those values, so that the `maxSurge` can be updated and a single instance can be rolled. Fixes #748. Signed-off-by: Alex Shearn <[email protected]>
1 parent a9557ed commit 30f3e6e

File tree

2 files changed

+8
-116
lines changed

2 files changed

+8
-116
lines changed

charts/policy-controller/README.md

+1-116
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The Helm chart for Policy Controller
4040
| webhook.failurePolicy | string | `"Fail"` | |
4141
| webhook.image.pullPolicy | string | `"IfNotPresent"` | |
4242
| webhook.image.repository | string | `"ghcr.io/sigstore/policy-controller/policy-controller"` | |
43-
| webhook.image.version | string | `"sha256:f291fce5b9c1a69ba54990eda7e0fe4114043b1afefb0f4ee3e6f84ec9ef1605"` | `"v0.8.2"` |
43+
| webhook.image.version | string | `"sha256:f291fce5b9c1a69ba54990eda7e0fe4114043b1afefb0f4ee3e6f84ec9ef1605"` | |
4444
| webhook.name | string | `"webhook"` | |
4545
| webhook.namespaceSelector.matchExpressions[0].key | string | `"policy.sigstore.dev/include"` | |
4646
| webhook.namespaceSelector.matchExpressions[0].operator | string | `"In"` | |
@@ -71,118 +71,3 @@ The Helm chart for Policy Controller
7171
| webhook.webhookNames.defaulting | string | `"defaulting.clusterimagepolicy.sigstore.dev"` | |
7272
| webhook.webhookNames.validating | string | `"validating.clusterimagepolicy.sigstore.dev"` | |
7373

74-
75-
### Deploy `policy-controller` Helm Chart
76-
77-
Install `policy-controller` using Helm:
78-
79-
```shell
80-
helm repo add sigstore https://sigstore.github.io/helm-charts
81-
helm repo update
82-
kubectl create namespace cosign-system
83-
helm install policy-controller -n cosign-system sigstore/policy-controller --devel
84-
```
85-
86-
The `policy-controller` enforce images matching the defined list of `ClusterImagePolicy` for the labeled namespaces.
87-
88-
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`.
89-
By default, any image that does not match a policy is rejected whenever `no-match-policy` is not configured in the ConfigMap.
90-
91-
As supported in previous versions, you could create your own key pair:
92-
93-
```shell
94-
export COSIGN_PASSWORD=<my_cosign_password>
95-
cosign generate-key-pair
96-
```
97-
98-
This command generates two key files `cosign.key` and `cosign.pub`. Next, create a secret to validate the signatures:
99-
100-
```shell
101-
kubectl create secret generic mysecret -n \
102-
cosign-system --from-file=cosign.pub=./cosign.pub
103-
```
104-
105-
**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.
106-
107-
```yaml
108-
apiVersion: policy.sigstore.dev/v1alpha1
109-
kind: ClusterImagePolicy
110-
metadata:
111-
name: cip-key-secret
112-
spec:
113-
images:
114-
- glob: "**your-desired-value**"
115-
authorities:
116-
- key:
117-
secretRef:
118-
name: mysecret
119-
```
120-
#### Configuring Custom Certificate Authorities (CA)
121-
122-
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.
123-
124-
To configure `policy-controller` to use custom CAs, follow these steps:
125-
126-
1. Make sure the `policy-controller` namespace exists:
127-
128-
```shell
129-
kubectl create namespace cosign-system
130-
```
131-
132-
2. Create a bundle file with all the root and intermediate certificates and name it `ca-bundle.crt`.
133-
134-
3. Create a `ConfigMap` from the bundle:
135-
```shell
136-
kubectl -n cosign-system create cm ca-bundle-config \
137-
--from-file=ca-bundle.crt="ca-bundle.crt"
138-
```
139-
140-
4. Install the `policy-controller`:
141-
142-
```shell
143-
helm install -n cosign-system \
144-
--set webhook.registryCaBundle.name=ca-bundle-config \
145-
--set webhook.registryCaBundle.key=ca-bundle.crt \
146-
policy-controller sigstore/policy-controller
147-
```
148-
149-
### Enabling Admission control
150-
151-
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:
152-
153-
Label: `policy.sigstore.dev/include: "true"`
154-
155-
```yaml
156-
apiVersion: v1
157-
kind: Namespace
158-
metadata:
159-
labels:
160-
policy.sigstore.dev/include: "true"
161-
kubernetes.io/metadata.name: my-namespace
162-
name: my-namespace
163-
spec:
164-
finalizers:
165-
- kubernetes
166-
```
167-
168-
### Testing the webhook
169-
170-
1. Using Unsigned Images:
171-
Creating a deployment referencing images that are not signed will yield the following error and no resources will be created:
172-
173-
```shell
174-
kubectl apply -f my-deployment.yaml
175-
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
176-
```
177-
178-
2. Using Signed Images: Assuming a signed `nginx` image with a tag `signed` exists on a registry, the resource will be successfully created.
179-
180-
```shell
181-
kubectl run pod1-signed --image=< REGISTRY_USER >/nginx:signed -n testns
182-
pod/pod1-signed created
183-
```
184-
185-
186-
## More info
187-
188-
You can find more information about the policy-controller in [here](https://docs.sigstore.dev/policy-controller/overview/).

charts/policy-controller/templates/webhook/deployment_webhook.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ spec:
1212
matchLabels:
1313
{{- include "policy-controller.selectorLabels" . | nindent 6 }}
1414
control-plane: {{ template "policy-controller.fullname" . }}-webhook
15+
16+
{{- if .Values.deployment.strategy }}
17+
strategy:
18+
{{ toYaml .Values.deployment.strategy | trim | indent 4 }}
19+
{{ if eq .Values.deployment.strategy.type "Recreate" }}rollingUpdate: null{{ end }}
20+
{{- end }}
21+
1522
template:
1623
metadata:
1724
labels:

0 commit comments

Comments
 (0)