11# The installer job is where the magic happens. It generates
2- # the config and installs Gitpod
2+ # the config, installs Gitpod and then deletes itself when
3+ # it's finished
34apiVersion : batch/v1
45kind : Job
56metadata :
@@ -27,22 +28,35 @@ spec:
2728 args :
2829 - |
2930 set -e
31+
3032 echo "Gitpod: Install jq"
3133 apk add --no-cache jq
34+
3235 echo "Gitpod: Perform the check"
3336 while [ "$(helm status -n {{repl Namespace }} cert-manager -o json | jq '.info.status == "deployed"')" = "false" ];
3437 do
3538 echo "Gitpod: Release not found - will retry in 10s"
3639 sleep 10
3740 done
41+
3842 echo "Gitpod: Release found - goodbye"
3943 containers :
4044 - name : installer
4145 # This will normally be the release tag - using this tag as need the license evaluator
4246 image : ' eu.gcr.io/gitpod-core-dev/build/installer:main.2569'
47+ volumeMounts :
48+ - mountPath : /mnt/node0
49+ name : node-fs0
50+ readOnly : true
4351 env :
4452 - name : CONFIG_FILE
4553 value : /tmp/gitpod-config.yaml
54+ - name : CONTAINERD_DIR_K3S
55+ value : /run/k3s/containerd/io.containerd.runtime.v2.task/k8s.io
56+ - name : CONTAINERD_SOCKET_K3S
57+ value : /run/k3s/containerd/containerd.sock
58+ - name : GITPOD_OBJECTS
59+ value : /tmp/gitpod
4660 command :
4761 - /bin/sh
4862 - -c
@@ -53,10 +67,102 @@ spec:
5367 echo "Gitpod: Generate the base Installer config"
5468 /app/installer init > "${CONFIG_FILE}"
5569
70+ echo "Gitpod: auto-detecting containerd location on host machine"
71+ if [ -d "/mnt/node0${CONTAINERD_DIR_K3S}" ]; then
72+ echo "Gitpod: containerd dir detected as k3s"
73+
74+ yq e -i ".workspace.runtime.containerdRuntimeDir = \"${CONTAINERD_DIR_K3S}\"" "${CONFIG_FILE}"
75+ fi
76+
77+ if [ -S "/mnt/node0${CONTAINERD_SOCKET_K3S}" ]; then
78+ echo "Gitpod: containerd socket detected as k3s"
79+
80+ yq e -i ".workspace.runtime.containerdSocket = \"${CONTAINERD_SOCKET_K3S}\"" "${CONFIG_FILE}"
81+ fi
82+
5683 echo "Gitpod: Inject the Replicated variables into the config"
5784 yq e -i '.domain = "{{repl ConfigOption "domain" }}"' "${CONFIG_FILE}"
85+ yq e -i '.license.kind = "secret"' "${CONFIG_FILE}"
86+ yq e -i '.license.name = "gitpod-license"' "${CONFIG_FILE}"
87+
88+ if [ '{{repl and (ConfigOptionEquals "db_incluster" "0") (ConfigOptionEquals "db_cloudsql_enabled" "1") }}' = "true" ];
89+ then
90+ echo "Gitpod: configuring CloudSQLProxy"
91+
92+ yq e -i ".database.inCluster = false" "${CONFIG_FILE}"
93+ yq e -i ".database.cloudSQL.instance = \"{{repl ConfigOption "db_cloudsql_instance" }}\"" "${CONFIG_FILE}"
94+ yq e -i ".database.cloudSQL.serviceAccount.kind = \"secret\"" "${CONFIG_FILE}"
95+ yq e -i ".database.cloudSQL.serviceAccount.name = \"cloudsql\"" "${CONFIG_FILE}"
96+ fi
97+
98+ if [ '{{repl and (ConfigOptionEquals "db_incluster" "0") (ConfigOptionEquals "db_cloudsql_enabled" "0") }}' = "true" ];
99+ then
100+ echo "Gitpod: configuring external database"
101+
102+ yq e -i ".database.inCluster = false" "${CONFIG_FILE}"
103+ yq e -i ".database.external.certificate.kind = \"secret\"" "${CONFIG_FILE}"
104+ yq e -i ".database.external.certificate.name = \"database\"" "${CONFIG_FILE}"
105+ fi
106+
107+ if [ '{{repl ConfigOptionEquals "reg_incluster" "0" }}' = "true" ];
108+ then
109+ echo "Gitpod: configuring external container registry"
110+
111+ yq e -i ".containerRegistry.inCluster = false" "${CONFIG_FILE}"
112+ yq e -i ".containerRegistry.external.url = \"{{repl ConfigOption "reg_url" }}\"" "${CONFIG_FILE}"
113+ yq e -i ".containerRegistry.external.certificate.kind = \"secret\"" "${CONFIG_FILE}"
114+ yq e -i ".containerRegistry.external.certificate.name = \"container-registry\"" "${CONFIG_FILE}"
115+
116+ if [ '{{repl ConfigOptionEquals "reg_s3storage" "1" }}' = "true" ];
117+ then
118+ echo "Gitpod: configuring container registry S3 backend"
119+
120+ yq e -i ".containerRegistry.s3storage.bucket = \"{{repl ConfigOption "reg_bucketname" }}\"" "${CONFIG_FILE}"
121+ yq e -i ".containerRegistry.s3storage.certificate.kind = \"secret\"" "${CONFIG_FILE}"
122+ yq e -i ".containerRegistry.s3storage.certificate.name = \"container-registry-s3-backend\"" "${CONFIG_FILE}"
123+ fi
124+ fi
125+
126+ if [ '{{repl ConfigOptionNotEquals "store_provider" "incluster" }}' = "true" ];
127+ then
128+ echo "Gitpod: configuring the storage"
129+
130+ yq e -i ".metadata.region = \"{{repl ConfigOption "store_region" }}\"" "${CONFIG_FILE}"
131+ yq e -i ".objectStorage.inCluster = false" "${CONFIG_FILE}"
132+
133+ if [ '{{repl ConfigOptionEquals "store_provider" "azure" }}' = "true" ];
134+ then
135+ echo "Gitpod: configuring storage for Azure"
136+
137+ yq e -i ".objectStorage.azure.credentials.kind = \"secret\"" "${CONFIG_FILE}"
138+ yq e -i ".objectStorage.azure.credentials.name = \"storage-azure\"" "${CONFIG_FILE}"
139+ fi
140+
141+ if [ '{{repl ConfigOptionEquals "store_provider" "gcp" }}' = "true" ];
142+ then
143+ echo "Gitpod: configuring storage for GCP"
144+
145+ yq e -i ".objectStorage.cloudStorage.project = \"{{repl ConfigOption "store_gcp_project" }}\"" "${CONFIG_FILE}"
146+ yq e -i ".objectStorage.cloudStorage.serviceAccount.kind = \"secret\"" "${CONFIG_FILE}"
147+ yq e -i ".objectStorage.cloudStorage.serviceAccount.name = \"storage-gcp\"" "${CONFIG_FILE}"
148+ fi
149+
150+ if [ '{{repl ConfigOptionEquals "store_provider" "s3" }}' = "true" ];
151+ then
152+ echo "Gitpod: configuring storage for S3"
153+
154+ yq e -i ".objectStorage.s3.endpoint = \"{{repl ConfigOption "store_s3_endpoint" }}\"" "${CONFIG_FILE}"
155+ yq e -i ".objectStorage.s3.credentials.secret = \"secret\"" "${CONFIG_FILE}"
156+ yq e -i ".objectStorage.s3.credentials.name = \"storage-s3\"" "${CONFIG_FILE}"
157+ fi
158+ fi
58159
59160 echo "Gitpod: Generate the Kubernetes objects and apply"
60161 /app/installer render -c "${CONFIG_FILE}" --namespace {{repl Namespace }} | kubectl apply -f -
61162
62163 echo "Gitpod: Installer job finished - goodbye"
164+ volumes :
165+ - name : node-fs0
166+ hostPath :
167+ path : /
168+ type : Directory
0 commit comments