-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·72 lines (46 loc) · 1.87 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
# Install OPA
curl -L -o opa https://github.com/open-policy-agent/opa/releases/download/v0.11.0/opa_linux_amd64
chmod 755 ./opa
sudo mv opa /usr/bin
echo -n "OPA client installed"
# Login
if ! oc whoami &> /dev/null; then
echo -e "You must log in"
exit 1
fi
# Create required projects
echo -n "Creating projects..."
oc new-project gatekeeper-system
oc new-project gatekeeper-project-excluded
oc new-project gatekeeper-project
oc new-project gatekeeper-resourcequota
# Set up gatekeeper operator
oc apply -f config/install-operator.yaml
echo -n "Waiting for pods ready..."
while [[ $(oc get pods -n openshift-operators -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do echo -n "." && sleep 1; done; echo -n -e " [OK]\n"
sleep 5
# Create gatekeeper instance
echo -n "Creating gatekeeper..."
oc apply -f config/create-gatekeeper.yaml
echo -n "Waiting for pods ready..."
while [[ $(oc get pods -n openshift-gatekeeper-system -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True True True" ]]; do echo -n "." && sleep 1; done; echo -n -e " [OK]\n"
sleep 5
# Deploy gatekeeper constraints and templates
echo -n "Deploying constraints..."
oc apply -f config/config.yaml
oc apply -f constraintTemplate/K8sMaxPods.yaml
oc apply -f constraintTemplate/K8sMaxRequests.yaml
oc apply -f constraintTemplate/K8sResourceQuota.yaml
sleep 10
oc apply -f constraints/K8sMaxPods.yaml
oc apply -f constraints/K8sMaxRequests.yaml
oc apply -f constraints/K8sResourceQuota.yaml
#oc apply -f constraintTemplate/K8sRequiredLabels.yaml
#oc apply -f constraintTemplate/NsRequiredLabel.yaml
#oc apply -f constraints/K8sRequiredLabels.yaml
#oc apply -f constraints/NsRequiredLabels.yaml
# Create roles
oc apply -f roles/gatekeeper-ops-const-role.yaml
oc apply -f roles/gatekeeper-opa-sec-ops.yaml
oc apply -f roles/gatekeeper-ops-role.yaml