-
Notifications
You must be signed in to change notification settings - Fork 92
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
Add ability to disable namespace opt-in #268
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
{{ template "chart.header" . }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: Why do we need this file ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't have to do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also makes it easy to validate because if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sgtm, what do you think @cpanato ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned, let's revert this change and keep only the opt-in functionality. |
||
|
||
{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }} | ||
|
||
{{ template "chart.description" . }} | ||
|
||
**Homepage:** <https://github.com/sigstore/policy-controller> | ||
|
||
|
||
## Maintainers | ||
|
||
| Name | Email | Url | | ||
| ---- | ------ | --- | | ||
| dlorenc | | | | ||
| hectorj2f | | | | ||
|
||
## Source Code | ||
|
||
* <https://github.com/sigstore/policy-controller> | ||
|
||
|
||
{{ template "chart.requirementsSection" . }} | ||
|
||
{{ template "chart.valuesSection" . }} | ||
|
||
### Deploy `policy-controller` Helm Chart | ||
|
||
Install `policy-controller` using Helm: | ||
|
||
```shell | ||
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: | ||
|
||
```shell | ||
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: | ||
|
||
```shell | ||
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. | ||
|
||
```yaml | ||
apiVersion: policy.sigstore.dev/v1alpha1 | ||
kind: ClusterImagePolicy | ||
metadata: | ||
name: cip-key-secret | ||
spec: | ||
images: | ||
- glob: "**your-desired-value**" | ||
authorities: | ||
- key: | ||
secretRef: | ||
name: mysecret | ||
|
||
``` | ||
|
||
### 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"` | ||
|
||
```yaml | ||
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: | ||
|
||
```shell | ||
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. | ||
|
||
```shell | ||
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](https://docs.sigstore.dev/policy-controller/overview/). | ||
{{ template "helm-docs.versionFooter" . }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this change to a separate PR, so we can address the issue itself.