Skip to content

Commit

Permalink
Merge branch 'main' into gctx-cli-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JimBugwadia authored Oct 28, 2024
2 parents 535048e + 01e599a commit f4855a1
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 4 deletions.
4 changes: 2 additions & 2 deletions content/en/docs/installation/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ The following flags can be used to control the advanced behavior of the various
| `eventsRateLimitQPS` (ABCR) | 1000 | Configures the maximum QPS to the API server from Kyverno for events. Uses the client default if zero. |
| `enableConfigMapCaching` (ABR) | true | Enables the ConfigMap caching feature. |
| `enableDeferredLoading` (A) | true | Enables deferred (lazy) loading of variables (1.10.1+). Set to `false` to disable deferred loading of variables which was the default behavior in versions < 1.10.0. |
| `enablePolicyException` (ABR) | true | Set to `true` to enable the [PolicyException capability](../writing-policies/exceptions.md). |
| `enablePolicyException` (ABR) | false | Set to `true` to enable the [PolicyException capability](../writing-policies/exceptions.md). |
| `enableReporting` (ABCR) | validate,mutate,mutateExisting,generate,imageVerify | Comma separated list to enables reporting for different rule types. (validate,mutate,mutateExisting,generate,imageVerify) |
| `enableTracing` (ABCR) | false | Set to enable exposing traces. |
| `enableTuf` (AR) | | Enable tuf for private sigstore deployments. |
| `exceptionNamespace` (ABR) | | Set to the name of a Namespace where [PolicyExceptions](../writing-policies/exceptions.md) will only be permitted. PolicyExceptions created in any other Namespace will throw a warning. If not set, PolicyExceptions from all Namespaces will be considered. Implies the `enablePolicyException` flag is set to `true`. Neither wildcards nor multiple Namespaces are currently accepted. |
| `exceptionNamespace` (ABR) | | Set to the name of a Namespace where [PolicyExceptions](../writing-policies/exceptions.md) will only be permitted. PolicyExceptions created in any other Namespace will throw a warning. If set to "*", PolicyExceptions from all Namespaces will be accepted. Note that wildcards and multiple Namespace entries are not supported. It is required if the `enablePolicyException` flag is set to true. |
| `forceFailurePolicyIgnore` (A) | false | Set to force Failure Policy to `Ignore`. |
| `generateValidatingAdmissionPolicy` (A) | false | Specifies whether to enable generating Kubernetes ValidatingAdmissionPolicies. |
| `genWorkers` (B) | 10 | The number of workers for processing generate policies concurrently. |
Expand Down
2 changes: 1 addition & 1 deletion content/en/docs/installation/uninstallation.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ helm uninstall kyverno kyverno/kyverno -n kyverno

### Clean up Webhooks

Kyverno by default will try to clean up all its webhooks when terminated. But in cases where its RBAC resources are removed first, it will lose the permission to do so properly.
Kyverno by default will try to clean up all its webhooks when terminated for helm based installations. But in other cases where Kyverno's RBAC resources are removed first, it will lose the permission to do so properly. Kyverno supports deletion using finalizers to ensure resource deletion in right order. Use `--autoDeleteWebhooks` in admission-controller and cleanup-controller deployment to enable this feature, this feature will be enabled by default in future releases.

If manual webhook removal is necessary, use the below commands.

Expand Down
2 changes: 1 addition & 1 deletion content/en/docs/installation/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Direct upgrades from previous versions are not supported when using the YAML man

### Upgrade Kyverno with Helm

An upgrade from versions prior to Kyverno 1.10 to versions at 1.10 or higher using Helm requires manual intervention and cannot be performed via a direct upgrade process. Please see the 1.10 migration guide [here](https://githubviewRoleName.com/kyverno/kyverno/blob/release-1.13/charts/kyverno/README.md#migrating-from-v2-to-v3) for more complete information.
An upgrade from versions prior to Kyverno 1.10 to versions at 1.10 or higher using Helm requires manual intervention and cannot be performed via a direct upgrade process. Please see the Helm chart v2 to v3 migration guide [here](https://github.com/kyverno/kyverno/blob/release-1.13/charts/kyverno/README.md#migrating-from-v2-to-v3) for more complete information.


## Upgrading to Kyverno v1.13
Expand Down
5 changes: 5 additions & 0 deletions content/en/docs/writing-policies/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ description: >
weight: 80
---

{{% alert title="Warning" color="warning" %}}
PolicyExceptions are disabled by default. To enable them, set the `enablePolicyException` flag to `true`. When enabling PolicyExceptions, you must also specify which namespaces they can be used in by setting the `exceptionNamespace` flag.
For more information, see [Container Flags](../installation/customization.md#container-flags).
{{% /alert %}}

Although Kyverno policies contain multiple methods to provide fine-grained control as to which resources they act upon in the form of [`match`/`exclude` blocks](match-exclude.md#match-statements), [preconditions](preconditions.md) at multiple hierarchies, [anchors](validate.md#anchors), and more, all these mechanisms have in common that the resources which they are intended to exclude must occur in the same rule definition. This may be limiting in situations where policies may not be directly editable, or doing so imposes an operational burden.

For example, in organizations where multiple teams must interact with the same cluster, a team responsible for policy authoring and administration may not be the same team responsible for submission of resources. In these cases, it can be advantageous to decouple the policy definition from certain exclusions. Additionally, there are often times where an organization or team must allow certain exceptions which would violate otherwise valid rules but on a one-time basis if the risks are known and acceptable.
Expand Down
4 changes: 4 additions & 0 deletions content/en/docs/writing-policies/mutate.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@ spec:
- <(emptyDir): {}
```

{{% alert title="Note" color="info" %}}
Set `spec.emitWarning` to `true` to enable API response warnings for mutate policies upon resource's admission events.
{{% /alert %}}

## Mutate Existing resources

In addition to standard mutations, Kyverno also supports mutation on existing resources with `patchStrategicMerge` and `patchesJson6902`. Unlike regular mutate policies that are applied through the AdmissionReview process, mutate existing policies are applied in the background (via the background controller) which update existing resources in the cluster. These "mutate existing" policies, like traditional mutate policies, are still triggered via the AdmissionReview process but apply to existing resources. This decoupling also allows triggering on one resource and mutating a totally different one. They may also optionally be configured to apply upon updates to the policy itself. This has two important implications:
Expand Down
122 changes: 122 additions & 0 deletions content/en/docs/writing-policies/validate.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ The `FailureAction` attribute controls admission control behaviors for resources
The field `spec.validationFailureAction` is deprecated and will be removed in a future release. Instead, use `spec.rules[*].validate[*].failureAction`.
{{% /alert %}}

{{% alert title="Note" color="info" %}}
When `spec.rules[*].validate[*].failureAction` is set to `Audit`, set `spec.emitWarning` to `true` to show audit policy violation in admission response warnings.
{{% /alert %}}

## Failure Action Overrides

Using `failureActionOverrides`, you can specify which actions to apply per Namespace. This attribute is only available for ClusterPolicies.
Expand Down Expand Up @@ -2033,3 +2037,121 @@ spec:
policyName: disallow-host-path
validationActions: [Audit, Warn]
```

## Kyverno JSON Assertion

Starting in Kyverno 1.13, a new subrule type called `assert` is available. This subrule type allows users to use Kyverno JSON assertion trees for resource validation. Standard `match` and `exclude` processing is available just like with other rules. This subrule type is enabled when a validate rule is written with a `assert` object, detailed below.

For example, this policy ensures that a pod does not use the default service account.

```yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-default-sa
spec:
validationFailureAction: Enforce
rules:
- match:
any:
- resources:
kinds:
- Pod
name: disallow-default-sa
validate:
message: default ServiceAccount should not be used
assert:
object:
spec:
(serviceAccountName == 'default'): false
```

The `assert.object` contains an assertion tree to validate the applied resource. If an assertion evaluates to false, the validation check is enforced according to the `spec.validationFailureAction` field.

When trying to create a Deployment with the "default" ServiceAccount, the creation of the Deployment will be blocked.

```
Error from server: admission webhook "validate.kyverno.svc-fail" denied the request:

resource Pod/default/nginx was blocked due to the following policies

disallow-default-sa:
disallow-default-sa: 'object.spec.(serviceAccountName == ''default''): Invalid value:
true: Expected value: false'
```
assertions have access to the contents of the Admission request/response, organized as seperared trees as well as some other useful variables:
- `object` - The object from the incoming request. The value is null for DELETE requests.
- `oldObject` - The existing object. The value is null for CREATE requests.
- `admissionInfo` - Additional admission information. Contains user information like `roles`, `clusterRoles` and `username`.
- `operation` - Admission Operation.
- `namespaceLabels` - Map of labels of the target namespace, not available for cluster scoped objects.
- `admissionOperation` - Bool value which indicates if the policy was triggered from an admission request.
`validate.assert` subrules also supports autogen rules for higher-level controllers that directly or indirectly manage Pods: Deployment, DaemonSet, StatefulSet, Job, and CronJob resources. Check the [autogen](autogen.md) section for more information.
```yaml
status:
autogen:
rules:
- exclude:
resources: {}
generate:
clone: {}
cloneList: {}
match:
all:
- resources:
kinds:
- DaemonSet
- Deployment
- Job
- ReplicaSet
- ReplicationController
- StatefulSet
operations:
- CREATE
- UPDATE
resources: {}
mutate: {}
name: autogen-disallow-default-sa
skipBackgroundRequests: true
validate:
assert:
object:
spec:
template:
spec:
(serviceAccountName == 'default'): false
message: default ServiceAccount should not be used
validationFailureAction: Audit
- exclude:
resources: {}
generate:
clone: {}
cloneList: {}
match:
all:
- resources:
kinds:
- CronJob
operations:
- CREATE
- UPDATE
resources: {}
mutate: {}
name: autogen-cronjob-disallow-default-sa
skipBackgroundRequests: true
validate:
assert:
object:
spec:
jobTemplate:
spec:
template:
spec:
(serviceAccountName == 'default'): false
message: default ServiceAccount should not be used
validationFailureAction: Audit
```
80 changes: 80 additions & 0 deletions content/en/docs/writing-policies/verify-images/sigstore/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,86 @@ verifyImages:
-----END PUBLIC KEY-----
```

## Using a Custom TSA cert chain
Cosign accepts custom timestamping authorities during image signing. To verify images signed with custom TSA, Use `ctlog.tsaCertChain` field to provide cert chain of the custom TSA.

```yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: keyed-tsa-policy
spec:
background: false
failurePolicy: Fail
rules:
- match:
any:
- resources:
kinds:
- Pod
name: keyed-tsa-rule
verifyImages:
- attestors:
- entries:
- keys:
publicKeys: |-
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEstG5Xl7UxkQsmLUxdmS85HLgYBFy
c/P/oQ22iazkKm8P0sNlaZiaZC4TSEea3oh2Pim0+wxSubhKoK+7jq9Egg==
-----END PUBLIC KEY-----
ctlog:
tsaCertChain: |-
-----BEGIN CERTIFICATE-----
MIIH/zCCBeegAwIBAgIJAMHphhYNqOmAMA0GCSqGSIb3DQEBDQUAMIGVMREwDwYD
VQQKEwhGcmVlIFRTQTEQMA4GA1UECxMHUm9vdCBDQTEYMBYGA1UEAxMPd3d3LmZy
ZWV0c2Eub3JnMSIwIAYJKoZIhvcNAQkBFhNidXNpbGV6YXNAZ21haWwuY29tMRIw
EAYDVQ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ze2u30bAQt0n0iIyRLz
aWuhtpAtd7ffwEbASgzB7E+NGF4tpV37e8KiA2xiGSRqT5ndu28fgpOY87gD3ArZ
DctZvvTCfHdAS5kEO3gnGGeZEVLDmfEsv8TGJa3AljVa5E40IQDsUXpQLi8G+UC4
1DWZu8EVT4rnYaCw1VX7ShOR1PNCCvjb8S8tfdudd9zhU3gEB0rxdeTy1tVbNLXW
99y90xcwr1ZIDUwM/xQ/noO8FRhm0LoPC73Ef+J4ZBdrvWwauF3zJe33d4ibxEcb
8/pz5WzFkeixYM2nsHhqHsBKw7JPouKNXRnl5IAE1eFmqDyC7G/VT7OF669xM6hb
Ut5G21JE4cNK6NNucS+fzg1JPX0+3VhsYZjj7D5uljRvQXrJ8iHgr/M6j2oLHvTA
I2MLdq2qjZFDOCXsxBxJpbmLGBx9ow6ZerlUxzws2AWv2pk=
-----END CERTIFICATE-----
imageReferences:
- ghcr.io/kyverno/test-verify-image:*
validationFailureAction: Enforce
webhookTimeoutSeconds: 30
```

## Using a custom TUF for custom Sigstore deployments

If you want to have your own Sigstore infrastructure to be fully in control of the entire signing and verification stack, including the root key material, you can set up your own root of trust to use TUF. To configure Kyverno to use your TUF setup, use `--tufRoot` and `--tufMirror` flags for custom Sigstore deployments.
Expand Down

0 comments on commit f4855a1

Please sign in to comment.