@@ -5,43 +5,41 @@ set -eu
5
5
mount --make-shared /sys/fs/cgroup
6
6
mount --make-shared /var/gitpod/workspaces
7
7
8
- # prepare Gitpod helm installer
9
- if [ -f /var/lib/rancher/k3s/server/manifests/gitpod-helm-installer.yaml ]; then
10
-
11
- if [ -z " $DOMAIN " ]; then
12
- >&2 echo " Error: Environment variable DOMAIN is missing."
13
- exit 1;
14
- fi
15
-
16
- if [ -f /values.yaml ]; then
17
- sed ' s/^/ /' /values.yaml >> /var/lib/rancher/k3s/server/manifests/gitpod-helm-installer.yaml
18
- else
19
- echo " hostname: gitpod.{{ DOMAIN }}" >> /var/lib/rancher/k3s/server/manifests/gitpod-helm-installer.yaml
20
- fi
21
-
22
- sed -i " s/{{ DOMAIN }}/$DOMAIN /g" /var/lib/rancher/k3s/server/manifests/gitpod-helm-installer.yaml
23
-
24
- # gitpod-helm-installer.yaml needs access to kubernetes by the public host IP.
25
- kubeconfig_replacip () {
26
- while [ ! -f /etc/rancher/k3s/k3s.yaml ]; do sleep 1; done
27
- HOSTIP=$( hostname -i)
28
- sed " s+127.0.0.1+$HOSTIP +g" /etc/rancher/k3s/k3s.yaml > /etc/rancher/k3s/k3s_.yaml
29
- }
30
- kubeconfig_replacip &
31
-
32
- installation_completed_hook () {
33
- while [ -z " $( kubectl get pods | grep gitpod-helm-installer | grep Completed) " ]; do sleep 10; done
34
-
35
- echo " Removing network policies ..."
36
- kubectl delete networkpolicies.networking.k8s.io --all
37
-
38
- echo " Removing installer manifest ..."
39
- rm -f /var/lib/rancher/k3s/server/manifests/gitpod-helm-installer.yaml
40
- }
41
- installation_completed_hook &
42
-
8
+ if [ -z " $DOMAIN " ]; then
9
+ >&2 echo " Error: Environment variable DOMAIN is missing."
10
+ exit 1;
43
11
fi
44
12
13
+ /gitpod-installer init > config.yaml
14
+ /yq -i ' .domain = "' " $DOMAIN " ' "' config.yaml
15
+ /yq -i ' .workspace.runtime.containerdRuntimeDir = "/run/k3s/containerd/containerd.sock"' config.yaml
16
+
17
+ mkdir -p /var/lib/rancher/k3s/server/manifests/gitpod
18
+ /gitpod-installer render --config config.yaml --output-split-files /var/lib/rancher/k3s/server/manifests/gitpod
19
+ rm /var/lib/rancher/k3s/server/manifests/gitpod/* NetworkPolicy*
20
+ for f in /var/lib/rancher/k3s/server/manifests/gitpod/* PersistentVolumeClaim* .yaml; do /yq -i ' .spec.storageClassName="local-path"' " $f " ; done
21
+ for f in /var/lib/rancher/k3s/server/manifests/gitpod/* StatefulSet* .yaml; do /yq -i ' .spec.volumeClaimTemplates[0].spec.storageClassName="local-path"' " $f " ; done
22
+ for f in /var/lib/rancher/k3s/server/manifests/gitpod/* .yaml; do (cat " $f " ; echo) >> /var/lib/rancher/k3s/server/manifests/gitpod.yaml; done
23
+ rm -rf /var/lib/rancher/k3s/server/manifests/gitpod
24
+
25
+ # gitpod-helm-installer.yaml needs access to kubernetes by the public host IP.
26
+ kubeconfig_replacip () {
27
+ while [ ! -f /etc/rancher/k3s/k3s.yaml ]; do sleep 1; done
28
+ HOSTIP=$( hostname -i)
29
+ sed " s+127.0.0.1+$HOSTIP +g" /etc/rancher/k3s/k3s.yaml > /etc/rancher/k3s/k3s_.yaml
30
+ }
31
+ kubeconfig_replacip &
32
+
33
+ installation_completed_hook () {
34
+ while [ -z " $( kubectl get pods | grep gitpod-helm-installer | grep Completed) " ]; do sleep 10; done
35
+
36
+ echo " Removing network policies ..."
37
+ kubectl delete networkpolicies.networking.k8s.io --all
38
+
39
+ echo " Removing installer manifest ..."
40
+ rm -f /var/lib/rancher/k3s/server/manifests/gitpod.yaml
41
+ }
42
+ installation_completed_hook &
45
43
46
44
# add HTTPS certs secret
47
45
if [ -f /certs/chain.pem ] && [ -f /certs/dhparams.pem ] && [ -f /certs/fullchain.pem ] && [ -f /certs/privkey.pem ]; then
66
64
67
65
68
66
# patch DNS config
69
- if [ -n " $DOMAIN " ] && [ -n " $DNSSERVER " ]; then
70
- patchdns () {
71
- echo " Waiting for CoreDNS to patch config ..."
72
- while [ -z " $( kubectl get pods -n kube-system | grep coredns | grep Running) " ]; do sleep 10; done
73
-
74
- DOMAIN=$1
75
- DNSSERVER=$2
76
-
77
- if [ -z " $( kubectl get configmap -n kube-system coredns -o json | grep $DOMAIN ) " ]; then
78
- echo " Patching CoreDNS config ..."
79
-
80
- kubectl get configmap -n kube-system coredns -o json | \
81
- sed -e " s+.:53+$DOMAIN {\\\\ n forward . $DNSSERVER \\\\ n}\\\\ n.:53+g" | \
82
- kubectl apply -f -
83
- echo " CoreDNS config patched."
84
- else
85
- echo " CoreDNS has been patched already."
86
- fi
87
- }
88
- patchdns " $DOMAIN " " $DNSSERVER " &
89
- fi
67
+ # if [ -n "$DOMAIN" ] && [ -n "$DNSSERVER" ]; then
68
+ # patchdns() {
69
+ # echo "Waiting for CoreDNS to patch config ..."
70
+ # while [ -z "$(kubectl get pods -n kube-system | grep coredns | grep Running)" ]; do sleep 10; done
71
+
72
+ # DOMAIN=$1
73
+ # DNSSERVER=$2
74
+
75
+ # if [ -z "$(kubectl get configmap -n kube-system coredns -o json | grep $DOMAIN)" ]; then
76
+ # echo "Patching CoreDNS config ..."
77
+
78
+ # kubectl get configmap -n kube-system coredns -o json | \
79
+ # sed -e "s+.:53+$DOMAIN {\\\\n forward . $DNSSERVER\\\\n}\\\\n.:53+g" | \
80
+ # kubectl apply -f -
81
+ # echo "CoreDNS config patched."
82
+ # else
83
+ # echo "CoreDNS has been patched already."
84
+ # fi
85
+ # }
86
+ # patchdns "$DOMAIN" "$DNSSERVER" &
87
+ # fi
90
88
91
89
92
90
# start k3s
93
- /bin/k3s server --disable traefik
91
+ /bin/k3s server --disable traefik \
92
+ --node-label gitpod.io/workload_meta=true \
93
+ --node-label gitpod.io/workload_ide=true \
94
+ --node-label gitpod.io/workload_workspace_services=true \
95
+ --node-label gitpod.io/workload_workspace_regular=true \
96
+ --node-label gitpod.io/workload_workspace_headless=true
0 commit comments