Skip to content

Commit 664071f

Browse files
committed
add make example
1 parent fe34984 commit 664071f

File tree

4 files changed

+42
-44
lines changed

4 files changed

+42
-44
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ all: build test
55
test:
66
@echo "+ $@"
77
./scripts/test
8+
example:
9+
@echo "+ $@"
10+
./scripts/example
811
build:
912
@echo "+ $@"
1013
./scripts/build

examples/clean.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

examples/deploy.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

scripts/example

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
kubectl delete -f examples/ns.yaml || true
6+
7+
kubectl delete psp psp-privileged psp-restricted || true
8+
9+
# create namespaces
10+
kubectl apply -f examples/ns.yaml || true
11+
12+
# create service accounts
13+
kubectl apply -f examples/sa.yaml || true
14+
15+
# create roles and rolebindings for service accounts to use pod security policies
16+
kubectl apply -f examples/roles.yaml || true
17+
18+
# create pods
19+
kubectl apply -f examples/pods.yaml || true
20+
21+
# generate psp and update the pod security policy name
22+
./kube-psp-advisor --namespace privileged | sed -e 's/pod-security.*/psp-privileged/g' | kubectl apply -f -
23+
24+
./kube-psp-advisor --namespace restricted | sed -e 's/pod-security.*/psp-restricted/g' | kubectl apply -f -
25+
26+
# test creating pods that pass the pod security policies
27+
kubectl apply -f examples/pods-allow.yaml || true
28+
29+
kubectl get pods -n privileged
30+
31+
kubectl get pods -n restricted
32+
33+
# test creating pod that violate pod security policies
34+
kubectl apply -f examples/pods-deny.yaml || true
35+
36+
kubectl get pods -n privileged
37+
38+
kubectl get pods -n restricted
39+

0 commit comments

Comments
 (0)