Skip to content
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 polexes for vsphere cloud provider app (it contains 4 sub-charts) #292

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added PolicyExceptions for `cloud-provider-vsphere-app`.

## [0.15.2] - 2023-09-01

### Changed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if .Values.policyExceptions.enableVsphereProviderPolex }}
apiVersion: kyverno.io/v2alpha1
kind: PolicyException
metadata:
name: vsphere-cloud-provider-exceptions
namespace: {{ .Release.Namespace }}
labels:
{{- include "kyverno-stack.labels" . | nindent 4 }}
annotations:
{{- include "kyverno-stack.policyInstallAnnotations" . | nindent 4 }}
spec:
exceptions:
- policyName: disallow-host-path
ruleNames:
- autogen-host-path
- host-path
- policyName: disallow-host-namespaces
ruleNames:
- host-namespaces
- autogen-host-namespaces
- policyName: restrict-seccomp-strict
ruleNames:
- check-seccomp-strict
- autogen-check-seccomp-strict
match:
any:
- resources:
kinds:
- DaemonSet
- ReplicaSet
- Pod
namespaces:
- kube-system
names:
- cloud-provider-for-vsphere*
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if .Values.policyExceptions.enableVsphereProviderPolex }}
apiVersion: kyverno.io/v2alpha1
kind: PolicyException
metadata:
name: kube-vip-cloud-provider-exceptions
namespace: {{ .Release.Namespace }}
labels:
{{- include "kyverno-stack.labels" . | nindent 4 }}
annotations:
{{- include "kyverno-stack.policyInstallAnnotations" . | nindent 4 }}
spec:
exceptions:
- policyName: disallow-host-path
ruleNames:
- autogen-host-path
- host-path
- policyName: disallow-host-namespaces
ruleNames:
- host-namespaces
- autogen-host-namespaces
- policyName: restrict-seccomp-strict
ruleNames:
- check-seccomp-strict
- autogen-check-seccomp-strict
match:
any:
- resources:
kinds:
- Deployment
- ReplicaSet
- Pod
namespaces:
- kube-system
names:
- kube-vip-cloud-provider*
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{- if .Values.policyExceptions.enableVsphereProviderPolex }}
apiVersion: kyverno.io/v2alpha1
kind: PolicyException
metadata:
name: kube-vip-exceptions
namespace: {{ .Release.Namespace }}
labels:
{{- include "kyverno-stack.labels" . | nindent 4 }}
annotations:
{{- include "kyverno-stack.policyInstallAnnotations" . | nindent 4 }}
spec:
exceptions:
- policyName: disallow-capabilities
ruleNames:
- autogen-adding-capabilities
- adding-capabilities
- policyName: disallow-capabilities-strict
ruleNames:
- autogen-require-drop-all
- require-drop-all
- autogen-adding-capabilities-strict
- adding-capabilities-strict
- policyName: disallow-host-namespaces
ruleNames:
- autogen-host-namespaces
- host-namespaces
- policyName: disallow-privilege-escalation
ruleNames:
- autogen-privilege-escalation
- privilege-escalation
- policyName: require-run-as-nonroot
ruleNames:
- autogen-run-as-non-root
- run-as-non-root
- policyName: restrict-seccomp-strict
ruleNames:
- autogen-check-seccomp-strict
- check-seccomp-strict
- policyName: restrict-image-registries
ruleNames:
- autogen-validate-registries
- validate-registries
- policyName: restrict-volume-types
ruleNames:
- autogen-restricted-volumes
- restricted-volumes
match:
any:
- resources:
kinds:
- DaemonSet
- Pod
namespaces:
- kube-system
names:
- kube-vip-svc-lb*
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{- if .Values.policyExceptions.enableVsphereProviderPolex }}
apiVersion: kyverno.io/v2alpha1
kind: PolicyException
metadata:
name: vsphere-csi-exceptions
namespace: {{ .Release.Namespace }}
labels:
{{- include "kyverno-stack.labels" . | nindent 4 }}
annotations:
{{- include "kyverno-stack.policyInstallAnnotations" . | nindent 4 }}
spec:
exceptions:
- policyName: disallow-privileged-containers
ruleNames:
- autogen-privileged-containers
- privileged-containers
- policyName: disallow-host-path
ruleNames:
- autogen-host-path
- host-path
- policyName: disallow-host-namespaces
ruleNames:
- host-namespaces
- autogen-host-namespaces
- policyName: disallow-host-ports
ruleNames:
- host-ports-none
- autogen-host-ports-none
- policyName: restrict-volume-types
ruleNames:
- restricted-volumes
- autogen-restricted-volumes
- policyName: require-run-as-nonroot
ruleNames:
- run-as-non-root
- autogen-run-as-non-root
- policyName: restrict-seccomp-strict
ruleNames:
- check-seccomp-strict
- autogen-check-seccomp-strict
- policyName: disallow-privilege-escalation
ruleNames:
- privilege-escalation
- autogen-privilege-escalation
match:
any:
- resources:
kinds:
- DaemonSet
- Deployment
- ReplicaSet
- Pod
namespaces:
- kube-system
names:
- vsphere-csi*
{{- end }}
3 changes: 3 additions & 0 deletions helm/kyverno/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2211,6 +2211,9 @@
"enableChartOperatorPolex": {
"type": "boolean"
},
"enableVsphereProviderPolex": {
"type": "boolean"
},
"enableNoisyContextsPolicy": {
"type": "boolean"
},
Expand Down
3 changes: 3 additions & 0 deletions helm/kyverno/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ policyExceptions:
# Deploy a PolicyException for chart-operator (required for Giant Swarm clusters).
enableChartOperatorPolex: true

# Deploy PolicyExceptions for vsphere provider - cpi, kubevip, etc. (required for Giant Swarm clusters).
enableVsphereProviderPolex: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this would be enabled on MCs through config -- is there a way to enable it also for CAPV workload clusters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be an option in default apps, I am actually working on adding Kyverno to WCs for vsphere - https://github.com/giantswarm/default-apps-vsphere/pull/140/files#diff-0708195cf15ea7b702d1af55719e20899a250b27e9dca539819647317b672144R34-R41 And I've just found your comment on the issue about security bundle repo :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw. it's set to false because other provider don't care about vsphere related things, but we can make it true your call, true would be actually much easier for multi-provider environments (like wepa)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My question was because I don't know enough about our current CAPI config setup to know what's involved in enabling it in WCs if it isn't done here.
Obviously I'd prefer not to deploy exceptions which aren't needed, so if it's possible to enable the exception through some provider-specific means, that's nicer IMO (so leaving this false).


# Deploy a ClusterPolicy which prevents other Policies and ClusterPolicies from matching all resource types.
# Matching all (*) kinds results in excessive and unnecessary admission review load.
enableWildcardMatchPolicy: true
Expand Down