Skip to content

Commit a562b55

Browse files
authored
Merge pull request #50929 from jayeshmahajan/policy
[hi] add example policy part 1
2 parents 1f11bb8 + 3e7131d commit a562b55

File tree

4 files changed

+121
-0
lines changed

4 files changed

+121
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
apiVersion: policy/v1beta1
2+
kind: PodSecurityPolicy
3+
metadata:
4+
name: baseline
5+
annotations:
6+
# Optional: Allow the default AppArmor profile, requires setting the default.
7+
apparmor.security.beta.kubernetes.io/allowedProfileNames: 'runtime/default'
8+
apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default'
9+
seccomp.security.alpha.kubernetes.io/allowedProfileNames: '*'
10+
spec:
11+
privileged: false
12+
# The moby default capability set, minus NET_RAW
13+
allowedCapabilities:
14+
- 'CHOWN'
15+
- 'DAC_OVERRIDE'
16+
- 'FSETID'
17+
- 'FOWNER'
18+
- 'MKNOD'
19+
- 'SETGID'
20+
- 'SETUID'
21+
- 'SETFCAP'
22+
- 'SETPCAP'
23+
- 'NET_BIND_SERVICE'
24+
- 'SYS_CHROOT'
25+
- 'KILL'
26+
- 'AUDIT_WRITE'
27+
# Allow all volume types except hostpath
28+
volumes:
29+
# 'core' volume types
30+
- 'configMap'
31+
- 'emptyDir'
32+
- 'projected'
33+
- 'secret'
34+
- 'downwardAPI'
35+
# Assume that ephemeral CSI drivers & persistentVolumes set up by the cluster admin are safe to use.
36+
- 'csi'
37+
- 'persistentVolumeClaim'
38+
- 'ephemeral'
39+
# Allow all other non-hostpath volume types.
40+
- 'awsElasticBlockStore'
41+
- 'azureDisk'
42+
- 'azureFile'
43+
- 'cephFS'
44+
- 'cinder'
45+
- 'fc'
46+
- 'flexVolume'
47+
- 'flocker'
48+
- 'gcePersistentDisk'
49+
- 'gitRepo'
50+
- 'glusterfs'
51+
- 'iscsi'
52+
- 'nfs'
53+
- 'photonPersistentDisk'
54+
- 'portworxVolume'
55+
- 'quobyte'
56+
- 'rbd'
57+
- 'scaleIO'
58+
- 'storageos'
59+
- 'vsphereVolume'
60+
hostNetwork: false
61+
hostIPC: false
62+
hostPID: false
63+
readOnlyRootFilesystem: false
64+
runAsUser:
65+
rule: 'RunAsAny'
66+
seLinux:
67+
# This policy assumes the nodes are using AppArmor rather than SELinux.
68+
# The PSP SELinux API cannot express the SELinux Pod Security Standards,
69+
# so if using SELinux, you must choose a more restrictive default.
70+
rule: 'RunAsAny'
71+
supplementalGroups:
72+
rule: 'RunAsAny'
73+
fsGroup:
74+
rule: 'RunAsAny'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: policy/v1beta1
2+
kind: PodSecurityPolicy
3+
metadata:
4+
name: example
5+
spec:
6+
privileged: false # Don't allow privileged pods!
7+
# The rest fills in some required fields.
8+
seLinux:
9+
rule: RunAsAny
10+
supplementalGroups:
11+
rule: RunAsAny
12+
runAsUser:
13+
rule: RunAsAny
14+
fsGroup:
15+
rule: RunAsAny
16+
volumes:
17+
- '*'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: gold-vac-pvc
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce
8+
resources:
9+
requests:
10+
storage: 2Gi
11+
storageClassName: # change this to the name of the storage class you want to use
12+
volumeAttributesClassName: gold
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: high-priority
5+
spec:
6+
containers:
7+
- name: high-priority
8+
image: ubuntu
9+
command: ["/bin/sh"]
10+
args: ["-c", "while true; do echo hello; sleep 10;done"]
11+
resources:
12+
requests:
13+
memory: "10Gi"
14+
cpu: "500m"
15+
limits:
16+
memory: "10Gi"
17+
cpu: "500m"
18+
priorityClassName: high

0 commit comments

Comments
 (0)