-
Notifications
You must be signed in to change notification settings - Fork 2
/
k8s-install.sh
48 lines (41 loc) · 1.15 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
#!/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}
# Create namespace whoami if not exists
kubectl create namespace whoami --dry-run=client -o yaml | kubectl apply -f -
# Deploy traefik with helm
kubectl -n whoami apply -k ${SCRIPT_DIR}/manifest/base
# Create Ingress with dynamic hostname
cat <<EOF | kubectl -n whoami apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: whoami
annotations:
cert-manager.io/cluster-issuer: "${DEVBOX_ISSUER}"
spec:
ingressClassName: ${DEVBOX_INGRESS}
rules:
- host: whoami.$DEVBOX_HOSTNAME
http:
paths:
- pathType: ImplementationSpecific
path: "/"
backend:
service:
name: whoami
port:
number: 80
tls:
- hosts:
- whoami.$DEVBOX_HOSTNAME
secretName: whoami-cert
EOF
kubectl wait --namespace whoami \
--for=condition=ready pod \
--selector=app=whoami \
--timeout=90s
# Display resources
kubectl -n whoami get pods,svc,ingress