-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathk8s-install.sh
44 lines (38 loc) · 1.04 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
#!/bin/bash
DEVBOX_HOSTNAME=${DEVBOX_HOSTNAME:-dev.localhost}
DEVBOX_INGRESS=${DEVBOX_INGRESS:-traefik}
DEVBOX_ISSUER=${DEVBOX_ISSUER:-mkcert}
# Add helm repository
helm repo add portainer https://portainer.github.io/k8s
# Update helm repositories
helm repo update
# Create namespace portainer if not exists
kubectl create namespace portainer --dry-run=client -o yaml | kubectl apply -f -
# Deploy portainer with helm
helm -n portainer upgrade --install portainer portainer/portainer
# Create Ingress with dynamic hostname
cat <<EOF | kubectl -n portainer apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: portainer
annotations:
cert-manager.io/cluster-issuer: "${DEVBOX_ISSUER}"
spec:
ingressClassName: ${DEVBOX_INGRESS}
rules:
- host: portainer.$DEVBOX_HOSTNAME
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: portainer
port:
number: 9000
tls:
- hosts:
- portainer.$DEVBOX_HOSTNAME
secretName: portainer-cert
EOF