Skip to content

Commit df553f6

Browse files
waipengmnasiadka
authored andcommitted
Remove PodSecurityPolicy
PodSecurityPolicy has been removed in Kubernetes v1.25 [1]. To allow Magnum to support Kubernetes v1.25 and above, PodSecurityPolicy Admission Controller has has been removed. [1] https://kubernetes.io/docs/concepts/security/pod-security-policy/ Change-Id: I0fb0c372b484275b0677114193289469ee788b84
1 parent e7b88b3 commit df553f6

File tree

4 files changed

+14
-113
lines changed

4 files changed

+14
-113
lines changed

magnum/drivers/common/templates/kubernetes/fragments/flannel-service.sh

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,62 +14,11 @@ if [ "$NETWORK_DRIVER" = "flannel" ]; then
1414
set +x
1515
cat << EOF > ${FLANNEL_DEPLOY}
1616
---
17-
apiVersion: policy/v1beta1
18-
kind: PodSecurityPolicy
19-
metadata:
20-
name: psp.flannel.unprivileged
21-
annotations:
22-
seccomp.security.alpha.kubernetes.io/allowedProfileNames: docker/default
23-
seccomp.security.alpha.kubernetes.io/defaultProfileName: docker/default
24-
apparmor.security.beta.kubernetes.io/allowedProfileNames: runtime/default
25-
apparmor.security.beta.kubernetes.io/defaultProfileName: runtime/default
26-
spec:
27-
privileged: false
28-
volumes:
29-
- configMap
30-
- secret
31-
- emptyDir
32-
- hostPath
33-
allowedHostPaths:
34-
- pathPrefix: "/etc/cni/net.d"
35-
- pathPrefix: "/etc/kube-flannel"
36-
- pathPrefix: "/run/flannel"
37-
readOnlyRootFilesystem: false
38-
# Users and groups
39-
runAsUser:
40-
rule: RunAsAny
41-
supplementalGroups:
42-
rule: RunAsAny
43-
fsGroup:
44-
rule: RunAsAny
45-
# Privilege Escalation
46-
allowPrivilegeEscalation: false
47-
defaultAllowPrivilegeEscalation: false
48-
# Capabilities
49-
allowedCapabilities: ['NET_ADMIN']
50-
defaultAddCapabilities: []
51-
requiredDropCapabilities: []
52-
# Host namespaces
53-
hostPID: false
54-
hostIPC: false
55-
hostNetwork: true
56-
hostPorts:
57-
- min: 0
58-
max: 65535
59-
# SELinux
60-
seLinux:
61-
# SELinux is unsed in CaaSP
62-
rule: 'RunAsAny'
63-
---
6417
kind: ClusterRole
6518
apiVersion: rbac.authorization.k8s.io/v1
6619
metadata:
6720
name: flannel
6821
rules:
69-
- apiGroups: ['extensions']
70-
resources: ['podsecuritypolicies']
71-
verbs: ['use']
72-
resourceNames: ['psp.flannel.unprivileged']
7322
- apiGroups:
7423
- ""
7524
resources:

magnum/drivers/common/templates/kubernetes/fragments/kube-apiserver-to-kubelet-role.sh

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -78,67 +78,6 @@ EOF
7878
}
7979
kubectl apply --validate=false -f ${ADMIN_RBAC}
8080

81-
POD_SECURITY_POLICIES=/srv/magnum/kubernetes/podsecuritypolicies.yaml
82-
# Pod Security Policies
83-
[ -f ${POD_SECURITY_POLICIES} ] || {
84-
echo "Writing File: $POD_SECURITY_POLICIES"
85-
mkdir -p $(dirname ${POD_SECURITY_POLICIES})
86-
cat > ${POD_SECURITY_POLICIES} <<EOF
87-
---
88-
apiVersion: policy/v1beta1
89-
kind: PodSecurityPolicy
90-
metadata:
91-
name: magnum.privileged
92-
annotations:
93-
kubernetes.io/description: 'privileged allows full unrestricted access to
94-
pod features, as if the PodSecurityPolicy controller was not enabled.'
95-
seccomp.security.alpha.kubernetes.io/allowedProfileNames: '*'
96-
labels:
97-
kubernetes.io/cluster-service: "true"
98-
addonmanager.kubernetes.io/mode: Reconcile
99-
spec:
100-
privileged: true
101-
allowPrivilegeEscalation: true
102-
allowedCapabilities:
103-
- '*'
104-
volumes:
105-
- '*'
106-
hostNetwork: true
107-
hostPorts:
108-
- min: 0
109-
max: 65535
110-
hostIPC: true
111-
hostPID: true
112-
runAsUser:
113-
rule: 'RunAsAny'
114-
seLinux:
115-
rule: 'RunAsAny'
116-
supplementalGroups:
117-
rule: 'RunAsAny'
118-
fsGroup:
119-
rule: 'RunAsAny'
120-
readOnlyRootFilesystem: false
121-
---
122-
apiVersion: rbac.authorization.k8s.io/v1
123-
kind: ClusterRole
124-
metadata:
125-
name: magnum:podsecuritypolicy:privileged
126-
labels:
127-
kubernetes.io/cluster-service: "true"
128-
addonmanager.kubernetes.io/mode: Reconcile
129-
rules:
130-
- apiGroups:
131-
- policy
132-
resourceNames:
133-
- magnum.privileged
134-
resources:
135-
- podsecuritypolicies
136-
verbs:
137-
- use
138-
EOF
139-
}
140-
kubectl apply -f ${POD_SECURITY_POLICIES}
141-
14281
# Add the openstack trustee as a secret under kube-system
14382
kubectl -n kube-system create secret generic os-trustee \
14483
--from-literal=os-authURL=${AUTH_URL} \

magnum/drivers/k8s_fedora_coreos_v1/templates/kubecluster.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ parameters:
226226
type: string
227227
description: >
228228
List of admission control plugins to activate
229-
default: "PodSecurityPolicy,NamespaceLifecycle,LimitRanger,ServiceAccount,ResourceQuota,TaintNodesByCondition,Priority,DefaultTolerationSeconds,DefaultStorageClass,StorageObjectInUseProtection,PersistentVolumeClaimResize,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,RuntimeClass"
229+
default: "NamespaceLifecycle,LimitRanger,ServiceAccount,ResourceQuota,TaintNodesByCondition,Priority,DefaultTolerationSeconds,DefaultStorageClass,StorageObjectInUseProtection,PersistentVolumeClaimResize,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,RuntimeClass"
230230

231231
kube_allow_priv:
232232
type: string
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
deprecations:
3+
- |
4+
PodSecurityPolicy has been removed in Kubernetes v1.25 [1]. To allow Magnum
5+
to support Kubernetes v1.25 and above, PodSecurityPolicy Admission
6+
Controller has has been removed.
7+
8+
This means that there is a behaviour change in Cluster Templates created
9+
after this change, where new Clusters with such Cluster Templates will not
10+
have PodSecurityPolicy. Please be aware of the subsequent impact on Helm
11+
Charts, etc.
12+
13+
[1] https://kubernetes.io/docs/concepts/security/pod-security-policy/

0 commit comments

Comments
 (0)