forked from kubernetes-sigs/kubespray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the option to enable default Pod Security Configuration (kubernet…
…es-sigs#9017) * Add the option to enable default Pod Security Configuration Enable Pod Security in all namespaces by default with the option to exempt some namespaces. Without the change only namespaces explicitly configured will receive the admission plugin treatment. * Fix the PR according to code review comments * Revert the latest changes - leave the empty file when kube_pod_security_use_default, but add comment explaining the empty file - don't attempt magic at conditionally adding PodSecurity to kube_apiserver_admission_plugins_needs_configuration
- Loading branch information
1 parent
1418d6e
commit 0be6f0c
Showing
4 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
roles/kubernetes/control-plane/templates/podsecurity.yaml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% if kube_pod_security_use_default %} | ||
apiVersion: pod-security.admission.config.k8s.io/v1beta1 | ||
kind: PodSecurityConfiguration | ||
defaults: | ||
enforce: "{{ kube_pod_security_default_enforce }}" | ||
enforce-version: "{{ kube_pod_security_default_enforce_version }}" | ||
audit: "{{ kube_pod_security_default_audit }}" | ||
audit-version: "{{ kube_pod_security_default_audit_version }}" | ||
warn: "{{ kube_pod_security_default_warn }}" | ||
warn-version: "{{ kube_pod_security_default_warn_version }}" | ||
exemptions: | ||
usernames: {{ kube_pod_security_exemptions_usernames|to_json }} | ||
runtimeClasses: {{ kube_pod_security_exemptions_runtime_class_names|to_json }} | ||
namespaces: {{ kube_pod_security_exemptions_namespaces|to_json }} | ||
{% else %} | ||
# This file is intentinally left empty as kube_pod_security_use_default={{ kube_pod_security_use_default }} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
--- | ||
# list of admission plugins that needs to be configured | ||
kube_apiserver_admission_plugins_needs_configuration: [EventRateLimit] | ||
kube_apiserver_admission_plugins_needs_configuration: [EventRateLimit, PodSecurity] |