-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathk8s-install.sh
69 lines (56 loc) · 2.03 KB
/
k8s-install.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
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
DEVBOX_HOSTNAME=${DEVBOX_HOSTNAME:-dev.localhost}
DEVBOX_INGRESS=${DEVBOX_INGRESS:-traefik}
DEVBOX_ISSUER=${DEVBOX_ISSUER:-mkcert}
#-------------------------------------------------------------------------
# kyverno and kyverno-policies
#-------------------------------------------------------------------------
# Add helm repository
helm repo add kyverno https://kyverno.github.io/kyverno/
# Update helm repositories
helm repo update
# Create namespace kyverno if not exists
kubectl create namespace kyverno --dry-run=client -o yaml | kubectl apply -f -
# Install kyverno
helm -n kyverno upgrade --install kyverno kyverno/kyverno \
-f "${SCRIPT_DIR}/helm/kyverno/values.yaml"
# Install kyverno-policies (after due to CRDs)
helm -n kyverno upgrade --install kyverno-policies kyverno/kyverno-policies \
-f "${SCRIPT_DIR}/helm/kyverno-policies/values.yaml"
#-------------------------------------------------------------------------
# policy-reporter for kyverno
#-------------------------------------------------------------------------
# add helm repository
helm repo add policy-reporter https://kyverno.github.io/policy-reporter
# update helm repositories
helm repo update
# deploy in namespace kyverno-ui
helm -n kyverno upgrade --install policy-reporter policy-reporter/policy-reporter \
-f "${SCRIPT_DIR}/helm/policy-reporter/values.yaml"
# Create Ingress with dynamic hostname for policy-reporter-ui
cat <<EOF | kubectl -n kyverno apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: policy-reporter-ui
annotations:
cert-manager.io/cluster-issuer: "${DEVBOX_ISSUER}"
spec:
ingressClassName: ${DEVBOX_INGRESS}
rules:
- host: kyverno.$DEVBOX_HOSTNAME
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: policy-reporter-ui
port:
number: 8080
tls:
- hosts:
- kyverno.$DEVBOX_HOSTNAME
secretName: policy-reporter-ui-cert
EOF