Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions applications/base/services/kyverno/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Kyverno – Base Configuration

This directory contains the **base manifests** for deploying [Kyverno](https://kyverno.io/), a Kubernetes-native policy engine that helps enforce best practices, security, and compliance through policies defined as Kubernetes resources.
It is designed to be **consumed by cluster repositories** as a remote base, allowing each cluster to apply **custom overrides** as needed.

**About Kyverno:**

- Allows defining and enforcing **policies as Kubernetes resources** without requiring custom programming or external policy languages.
- Enables automatic configuration management - for example, injecting labels, enforcing naming conventions, or setting security contexts.
- Integrates with **Admission Webhooks** to evaluate policies in real time during resource creation or modification.
- Provides **policy reports** and integrates with tools like **Prometheus** and **Grafana** for monitoring violations.
- Commonly used to implement governance, security, and multi-tenancy controls in Kubernetes clusters.
- Simplifies cluster compliance and enhances operational security through policy-driven automation.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
# Source: kyverno-policies/templates/restricted/disallow-capabilities-strict.yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-capabilities-strict
annotations:
policies.kyverno.io/title: Disallow Capabilities (Strict)
policies.kyverno.io/category: Pod Security Standards (Restricted)
policies.kyverno.io/severity: "high"
policies.kyverno.io/minversion: 1.6.0
kyverno.io/kyverno-version: v1.15.2
kyverno.io/kubernetes-version: ">=1.25.0-0"
policies.kyverno.io/subject: Pod
policies.kyverno.io/description: >-
Adding capabilities other than `NET_BIND_SERVICE` is disallowed. In addition,
all containers must explicitly drop `ALL` capabilities.

labels:
app.kubernetes.io/component: kyverno
app.kubernetes.io/instance: kyverno-policies
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: kyverno-policies
app.kubernetes.io/part-of: kyverno-policies
app.kubernetes.io/version: "3.5.2"
helm.sh/chart: kyverno-policies-3.5.2
spec:
background: true
failurePolicy: Ignore
rules:
- name: require-drop-all
match:
any:
- resources:
kinds:
- Pod
preconditions:
all:
- key: "{{ request.operation || 'BACKGROUND' }}"
operator: NotEquals
value: DELETE
validate:
failureAction: Audit
allowExistingViolations: true
message: >-
Containers must drop `ALL` capabilities.
foreach:
- list: request.object.spec.[ephemeralContainers, initContainers, containers][]
deny:
conditions:
all:
- key: ALL
operator: AnyNotIn
value: "{{ element.securityContext.capabilities.drop[] || `[]` }}"
- name: adding-capabilities-strict
match:
any:
- resources:
kinds:
- Pod
preconditions:
all:
- key: "{{ request.operation || 'BACKGROUND' }}"
operator: NotEquals
value: DELETE
validate:
failureAction: Audit
allowExistingViolations: true
message: >-
Any capabilities added other than NET_BIND_SERVICE are disallowed.
foreach:
- list: request.object.spec.[ephemeralContainers, initContainers, containers][]
deny:
conditions:
all:
- key: "{{ element.securityContext.capabilities.add[] || `[]` }}"
operator: AnyNotIn
value:
- NET_BIND_SERVICE
- ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
# Source: kyverno-policies/templates/baseline/disallow-capabilities.yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-capabilities
annotations:
policies.kyverno.io/title: Disallow Capabilities
policies.kyverno.io/category: Pod Security Standards (Baseline)
policies.kyverno.io/severity: medium
kyverno.io/kyverno-version: v1.16.0
policies.kyverno.io/minversion: 1.6.0
kyverno.io/kubernetes-version: ">=1.25.0-0"
policies.kyverno.io/subject: Pod
policies.kyverno.io/description: >-
Adding capabilities beyond those listed in the policy must be disallowed.

labels:
app.kubernetes.io/component: kyverno
app.kubernetes.io/instance: kyverno-policies
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: kyverno-policies
app.kubernetes.io/part-of: kyverno-policies
app.kubernetes.io/version: "3.6.0"
helm.sh/chart: kyverno-policies-3.6.0
spec:
background: true
failurePolicy: Ignore
rules:
- name: adding-capabilities
match:
any:
- resources:
kinds:
- Pod
preconditions:
all:
- key: "{{ request.operation || 'BACKGROUND' }}"
operator: NotEquals
value: DELETE
validate:
failureAction: Audit
allowExistingViolations: true
message: >-
Any capabilities added beyond the allowed list (AUDIT_WRITE, CHOWN, DAC_OVERRIDE, FOWNER,
FSETID, KILL, MKNOD, NET_BIND_SERVICE, SETFCAP, SETGID, SETPCAP, SETUID, SYS_CHROOT)
are disallowed.
deny:
conditions:
all:
- key: "{{ request.object.spec.[ephemeralContainers, initContainers, containers][].securityContext.capabilities.add[] }}"
operator: AnyNotIn
value:
- AUDIT_WRITE
- CHOWN
- DAC_OVERRIDE
- FOWNER
- FSETID
- KILL
- MKNOD
- NET_BIND_SERVICE
- SETFCAP
- SETGID
- SETPCAP
- SETUID
- SYS_CHROOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
# Source: kyverno-policies/templates/baseline/disallow-host-namespaces.yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-namespaces
annotations:
policies.kyverno.io/title: Disallow Host Namespaces
policies.kyverno.io/category: Pod Security Standards (Baseline)
policies.kyverno.io/severity: medium
kyverno.io/kyverno-version: v1.16.0
kyverno.io/kubernetes-version: ">=1.25.0-0"
policies.kyverno.io/subject: Pod
policies.kyverno.io/description: >-
Host namespaces (Process ID namespace, Inter-Process Communication namespace, and
network namespace) allow access to shared information and can be used to elevate
privileges. Pods should not be allowed access to host namespaces. This policy ensures
fields which make use of these host namespaces are unset or set to `false`.

labels:
app.kubernetes.io/component: kyverno
app.kubernetes.io/instance: kyverno-policies
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: kyverno-policies
app.kubernetes.io/part-of: kyverno-policies
app.kubernetes.io/version: "3.6.0"
helm.sh/chart: kyverno-policies-3.6.0
spec:
background: true
failurePolicy: Ignore
rules:
- name: host-namespaces
match:
any:
- resources:
kinds:
- Pod
validate:
failureAction: Audit
allowExistingViolations: true
message: >-
Sharing the host namespaces is disallowed. The fields spec.hostNetwork,
spec.hostIPC, and spec.hostPID must be unset or set to `false`.
pattern:
spec:
=(hostPID): "false"
=(hostIPC): "false"
=(hostNetwork): "false"
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
# Source: kyverno-policies/templates/baseline/disallow-host-path.yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-path
annotations:
policies.kyverno.io/title: Disallow hostPath
policies.kyverno.io/category: Pod Security Standards (Baseline)
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Pod,Volume
kyverno.io/kyverno-version: v1.16.0
kyverno.io/kubernetes-version: ">=1.25.0-0"
policies.kyverno.io/description: >-
HostPath volumes let Pods use host directories and volumes in containers.
Using host resources can be used to access shared data or escalate privileges
and should not be allowed. This policy ensures no hostPath volumes are in use.

labels:
app.kubernetes.io/component: kyverno
app.kubernetes.io/instance: kyverno-policies
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: kyverno-policies
app.kubernetes.io/part-of: kyverno-policies
app.kubernetes.io/version: "3.6.0"
helm.sh/chart: kyverno-policies-3.6.0
spec:
background: true
failurePolicy: Ignore
rules:
- name: host-path
match:
any:
- resources:
kinds:
- Pod
validate:
failureAction: Audit
allowExistingViolations: true
message: >-
HostPath volumes are forbidden. The field spec.volumes[*].hostPath must be unset.
pattern:
spec:
=(volumes):
- X(hostPath): "null"
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
# Source: kyverno-policies/templates/baseline/disallow-host-ports.yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-ports
annotations:
policies.kyverno.io/title: Disallow hostPorts
policies.kyverno.io/category: Pod Security Standards (Baseline)
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Pod
kyverno.io/kyverno-version: v1.16.0
kyverno.io/kubernetes-version: ">=1.25.0-0"
policies.kyverno.io/description: >-
Access to host ports allows potential snooping of network traffic and should not be
allowed, or at minimum restricted to a known list. This policy ensures the `hostPort`
field is unset or set to `0`.

labels:
app.kubernetes.io/component: kyverno
app.kubernetes.io/instance: kyverno-policies
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: kyverno-policies
app.kubernetes.io/part-of: kyverno-policies
app.kubernetes.io/version: "3.6.0"
helm.sh/chart: kyverno-policies-3.6.0
spec:
background: true
failurePolicy: Ignore
rules:
- name: host-ports-none
match:
any:
- resources:
kinds:
- Pod
validate:
failureAction: Audit
allowExistingViolations: true
message: >-
Use of host ports is disallowed. The fields spec.containers[*].ports[*].hostPort
, spec.initContainers[*].ports[*].hostPort, and spec.ephemeralContainers[*].ports[*].hostPort
must either be unset or set to `0`.
pattern:
spec:
=(ephemeralContainers):
- =(ports):
- =(hostPort): 0
=(initContainers):
- =(ports):
- =(hostPort): 0
containers:
- =(ports):
- =(hostPort): 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
# Source: kyverno-policies/templates/baseline/disallow-host-process.yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-process
annotations:
policies.kyverno.io/title: Disallow hostProcess
policies.kyverno.io/category: Pod Security Standards (Baseline)
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Pod
kyverno.io/kyverno-version: v1.16.0
kyverno.io/kubernetes-version: ">=1.25.0-0"
policies.kyverno.io/description: >-
Windows pods offer the ability to run HostProcess containers which enables privileged
access to the Windows node. Privileged access to the host is disallowed in the baseline
policy. HostProcess pods are an alpha feature as of Kubernetes v1.22. This policy ensures
the `hostProcess` field, if present, is set to `false`.

labels:
app.kubernetes.io/component: kyverno
app.kubernetes.io/instance: kyverno-policies
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: kyverno-policies
app.kubernetes.io/part-of: kyverno-policies
app.kubernetes.io/version: "3.6.0"
helm.sh/chart: kyverno-policies-3.6.0
spec:
background: true
failurePolicy: Ignore
rules:
- name: host-process-containers
match:
any:
- resources:
kinds:
- Pod
validate:
failureAction: Audit
allowExistingViolations: true
message: >-
HostProcess containers are disallowed. The fields spec.securityContext.windowsOptions.hostProcess,
spec.containers[*].securityContext.windowsOptions.hostProcess, spec.initContainers[*].securityContext.windowsOptions.hostProcess,
and spec.ephemeralContainers[*].securityContext.windowsOptions.hostProcess must either be undefined
or set to `false`.
pattern:
spec:
=(ephemeralContainers):
- =(securityContext):
=(windowsOptions):
=(hostProcess): "false"
=(initContainers):
- =(securityContext):
=(windowsOptions):
=(hostProcess): "false"
containers:
- =(securityContext):
=(windowsOptions):
=(hostProcess): "false"
Loading