feat: add install psa config#1168
Draft
ihcsim wants to merge 1 commit intoharvester:masterfrom
Draft
Conversation
Signed-off-by: Ivan Sim <ivan.sim@suse.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
Currently, Harvester doesn't provide any visibility into the security context of the workloads that are admitted into non-system namespaces. This leads to a security gap where unauthorized privileged workloads may be run in these namespaces.
Solution:
Provide an installation configuration to enable pod security admission and specify the default enforcement standard. With this change, the K8s API server is updated to read the Harvester cluster-wide PSA configuration at
/etc/rancher/rke2/config.yaml.d/99-harvester-psa.yaml. The configurable security enforcement level and all exempted system namespaces are defined in this manifest.The K8s audit policy is also updated to log and report admission violation incidents.
The following tasks will be done in separate PRs:
Related Issue(s):
harvester/harvester#8196
Test plan:
Test Case 1 - Violation Warnings Are Recorded In Audit Logs
Install Harvester using an installer containing this enhancement.
Once Harvester is ready,
/etc/rancher/rke2/config.yaml.d/99-harvester-psa.yaml:k -n kube-system get po kube-apiserver-isim-dev3 -ojsonpath='{.spec.containers[0].args[0]}'demonamespace:hostPathandhostNetworkproperties:{ "authorization.k8s.io/decision": "allow", "authorization.k8s.io/reason": "RBAC: allowed by ClusterRoleBinding \"system:controller:replicaset-controller\" of ClusterRole \"system:controller:replicaset-controller\" to ServiceAccount \"replicaset-controller/kube-system\"", "mutation.webhook.admission.k8s.io/round_0_index_2": "{\"configuration\":\"harvester-mutator\",\"webhook\":\"mutator.harvesterhci.io\",\"mutated\":false}", "pod-security.kubernetes.io/audit-violations": "would violate PodSecurity \"baseline:latest\": host namespaces (hostNetwork=true), hostPath volumes (volume \"host-vol\")", "pod-security.kubernetes.io/enforce-policy": "privileged:latest" }Note that with the current
privilegeddefault configuration, the pod is still permitted to run:Test Case 2 - More restrictive PSA Configuration In User Namespace
Create a more restrictive namespace to enforce
baselinesecurity level:Try to create the same
nginx-hostdeployment from test case 1Expect the pods to be prohibited from running even though its deployment and replicaset are created:
Additional documentation or context