Skip to content

Commit 82b244d

Browse files
zamichellengnx
authored andcommitted
id: added files on examples folder
netlify was failing
1 parent 9809d2e commit 82b244d

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: nginx
5+
spec:
6+
containers:
7+
- image: nginx
8+
name: nginx
9+
ports:
10+
- containerPort: 80
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/sh
2+
mkdir -p /tmp/pss
3+
cat <<EOF > /tmp/pss/cluster-level-pss.yaml
4+
apiVersion: apiserver.config.k8s.io/v1
5+
kind: AdmissionConfiguration
6+
plugins:
7+
- name: PodSecurity
8+
configuration:
9+
apiVersion: pod-security.admission.config.k8s.io/v1
10+
kind: PodSecurityConfiguration
11+
defaults:
12+
enforce: "baseline"
13+
enforce-version: "latest"
14+
audit: "restricted"
15+
audit-version: "latest"
16+
warn: "restricted"
17+
warn-version: "latest"
18+
exemptions:
19+
usernames: []
20+
runtimeClasses: []
21+
namespaces: [kube-system]
22+
EOF
23+
cat <<EOF > /tmp/pss/cluster-config.yaml
24+
kind: Cluster
25+
apiVersion: kind.x-k8s.io/v1alpha4
26+
nodes:
27+
- role: control-plane
28+
kubeadmConfigPatches:
29+
- |
30+
kind: ClusterConfiguration
31+
apiServer:
32+
extraArgs:
33+
admission-control-config-file: /etc/config/cluster-level-pss.yaml
34+
extraVolumes:
35+
- name: accf
36+
hostPath: /etc/config
37+
mountPath: /etc/config
38+
readOnly: false
39+
pathType: "DirectoryOrCreate"
40+
extraMounts:
41+
- hostPath: /tmp/pss
42+
containerPath: /etc/config
43+
# optional: if set, the mount is read-only.
44+
# default false
45+
readOnly: false
46+
# optional: if set, the mount needs SELinux relabeling.
47+
# default false
48+
selinuxRelabel: false
49+
# optional: set propagation mode (None, HostToContainer or Bidirectional)
50+
# see https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation
51+
# default None
52+
propagation: None
53+
EOF
54+
kind create cluster --name psa-with-cluster-pss --config /tmp/pss/cluster-config.yaml
55+
kubectl cluster-info --context kind-psa-with-cluster-pss
56+
57+
# Wait for 15 seconds (arbitrary) ServiceAccount Admission Controller to be available
58+
sleep 15
59+
cat <<EOF |
60+
apiVersion: v1
61+
kind: Pod
62+
metadata:
63+
name: nginx
64+
spec:
65+
containers:
66+
- image: nginx
67+
name: nginx
68+
ports:
69+
- containerPort: 80
70+
EOF
71+
kubectl apply -f -
72+
73+
# Await input
74+
sleep 1
75+
( bash -c 'true' 2>/dev/null && bash -c 'read -p "Press any key to continue... " -n1 -s' ) || \
76+
( printf "Press Enter to continue... " && read ) 1>&2
77+
78+
# Clean up
79+
printf "\n\nCleaning up:\n" 1>&2
80+
set -e
81+
kubectl delete pod --all -n example --now
82+
kubectl delete ns example
83+
kind delete cluster --name psa-with-cluster-pss
84+
rm -f /tmp/pss/cluster-config.yaml

0 commit comments

Comments
 (0)