Skip to content

Commit 28bdf0a

Browse files
Simon Emmsmrsimonemms
authored andcommitted
Update the guide to use the KOTS installer
1 parent c072f94 commit 28bdf0a

File tree

5 files changed

+83
-143
lines changed

5 files changed

+83
-143
lines changed

Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ RUN apk add --no-cache \
44
gettext \
55
jq
66

7-
ARG GITPOD_VERSION="2022.03.1"
87
ARG HELM_VERSION=v3.6.3
98

109
RUN curl -fsSL "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl \
@@ -18,9 +17,6 @@ RUN mkdir -p /tmp/helm/ \
1817
RUN curl -fsSL https://github.com/mikefarah/yq/releases/download/v4.12.2/yq_linux_amd64 -o /usr/local/bin/yq \
1918
&& chmod +x /usr/local/bin/yq
2019

21-
RUN curl -fsSL https://github.com/gitpod-io/gitpod/releases/download/${GITPOD_VERSION}/gitpod-installer-linux-amd64 -o /usr/local/bin/gitpod-installer \
22-
&& chmod +x /usr/local/bin/gitpod-installer
23-
2420
WORKDIR /gitpod
2521

2622
COPY . /gitpod

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SHELL=/bin/bash -o pipefail -o errexit
66
IMG=ghcr.io/gitpod-io/gitpod-microsoft-aks-guide:latest
77

88
build: ## Build docker image containing the required tools for the installation
9-
@docker build --quiet . -t ${IMG}
9+
@docker build . -t ${IMG}
1010

1111
DOCKER_RUN_CMD = docker run -it --rm \
1212
--volume $$HOME/.kube:/root/.kube \

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ The whole process takes around twenty minutes. In the end, the following resourc
3838
- Azure container registry.
3939
- [calico](https://docs.projectcalico.org) as CNI and NetworkPolicy implementation.
4040
- [cert-manager](https://cert-manager.io/) for self-signed SSL certificates.
41-
- [Jaeger operator](https://github.com/jaegertracing/helm-charts/tree/main/charts/jaeger-operator) - and Jaeger deployment for Gitpod distributed tracing.
42-
- [gitpod.io](https://github.com/gitpod-io/gitpod) deployment.
41+
42+
Upon completion, it will print the config for resource (including passwords) and instructions on what
43+
to do next. **IMPORTANT** - running the `make install` command after the initial install will change
44+
your database password which will require you to update your KOTS configuration.
4345

4446
## DNS records
4547

@@ -78,7 +80,7 @@ Once applied, please allow a few minutes to for DNS propagation.
7880

7981
The most likely reason is because the [DNS01 challenge](https://cert-manager.io/docs/configuration/acme/dns01/) has yet to resolve. If using `SETUP_MANAGED_DNS`, you will need to update your DNS records to point to the Azure DNS zone nameserver.
8082

81-
Once the DNS record has been updated, you will need to delete all Cert Manager pods to retrigger the certificate request
83+
Once the DNS record has been updated, you will need to delete all cert-manager pods to retrigger the certificate request
8284

8385
```shell
8486
kubectl delete pods -n cert-manager --all

charts/assets/issuer.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,3 @@ spec:
1515
subscriptionID: $AZURE_SUBSCRIPTION_ID
1616
resourceGroupName: $RESOURCE_GROUP
1717
hostedZoneName: $DOMAIN
18-
---
19-
apiVersion: cert-manager.io/v1
20-
kind: Certificate
21-
metadata:
22-
name: $CERT_NAME
23-
spec:
24-
secretName: $CERT_NAME
25-
issuerRef:
26-
name: gitpod-issuer
27-
kind: ClusterIssuer
28-
dnsNames:
29-
- $DOMAIN
30-
- "*.$DOMAIN"
31-
- "*.ws.$DOMAIN"

setup.sh

Lines changed: 77 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,7 @@ set -a
1616
SERVICES_POOL="services"
1717
WORKSPACES_POOL="workspaces"
1818

19-
K8S_NODE_VM_SIZE=${K8S_NODE_VM_SIZE:="Standard_DS3_v2"}
20-
CERT_NAME="https-certificates"
21-
MYSQL_GITPOD_ENCRYPTION_KEY='[{"name":"general","version":1,"primary":true,"material":"4uGh1q8y2DYryJwrVMHs0kWXJlqvHWWt/KJuNi04edI="}]'
22-
23-
# Secrets
24-
SECRET_DATABASE="az-sql-token"
25-
SECRET_REGISTRY="az-registry-token"
26-
SECRET_STORAGE="az-storage-token"
19+
K8S_NODE_VM_SIZE=${K8S_NODE_VM_SIZE:="Standard_D4_v3"}
2720

2821
function check_prerequisites() {
2922
if [ -z "${AZURE_SUBSCRIPTION_ID}" ]; then
@@ -63,8 +56,6 @@ function check_prerequisites() {
6356
}
6457

6558
function install() {
66-
echo "Gitpod installer version: $(gitpod-installer version | jq -r '.version')"
67-
6859
check_prerequisites
6960

7061
echo "Updating helm repositories..."
@@ -104,7 +95,7 @@ function install() {
10495
--kubernetes-version "${AKS_VERSION}" \
10596
--max-count "50" \
10697
--max-pods "110" \
107-
--min-count "3" \
98+
--min-count "1" \
10899
--name "${CLUSTER_NAME}" \
109100
--node-osdisk-size "100" \
110101
--node-vm-size "${K8S_NODE_VM_SIZE}" \
@@ -127,7 +118,7 @@ function install() {
127118
--labels gitpod.io/workload_workspace_services=true gitpod.io/workload_workspace_regular=true gitpod.io/workload_workspace_headless=true \
128119
--max-count "50" \
129120
--max-pods "110" \
130-
--min-count "3" \
121+
--min-count "1" \
131122
--name "${WORKSPACES_POOL}" \
132123
--node-osdisk-size "100" \
133124
--node-vm-size "${K8S_NODE_VM_SIZE}" \
@@ -150,14 +141,7 @@ function install() {
150141
setup_managed_dns
151142
setup_mysql_database
152143
setup_storage
153-
install_gitpod
154-
155-
cat << EOF
156-
==========================
157-
Gitpod is now installed on your cluster
158-
159-
Please update your DNS records with the relevant nameserver.
160-
EOF
144+
output_config
161145
}
162146

163147
function install_cert_manager() {
@@ -174,65 +158,89 @@ function install_cert_manager() {
174158
--wait \
175159
cert-manager \
176160
jetstack/cert-manager
177-
178-
# ensure cert-manager and CRDs are installed and running
179-
kubectl wait --for=condition=available --timeout=300s deployment/cert-manager -n cert-manager
180161
}
181162

182-
function install_gitpod() {
183-
echo "Installing Gitpod..."
163+
function output_config() {
164+
DOCKER_USER=$(az acr credential show \
165+
--name "${REGISTRY_NAME}" \
166+
--output tsv \
167+
--query username \
168+
--resource-group "${RESOURCE_GROUP}")
184169

185-
local CONFIG_FILE="${DIR}/gitpod-config.yaml"
170+
DOCKER_REGISTRY_SERVER=$(az acr show \
171+
--name "${REGISTRY_NAME}" \
172+
--output tsv \
173+
--query loginServer \
174+
--resource-group "${RESOURCE_GROUP}")
186175

187-
gitpod-installer init > "${CONFIG_FILE}"
176+
DOCKER_PASSWORD=$(az acr credential show \
177+
--name "${REGISTRY_NAME}" \
178+
--output tsv \
179+
--query passwords[0].value \
180+
--resource-group "${RESOURCE_GROUP}")
188181

189-
echo "Updating config..."
182+
STORAGE_ACCOUNT_KEY=$(az storage account keys list \
183+
--account-name "${STORAGE_ACCOUNT_NAME}" \
184+
--resource-group "${RESOURCE_GROUP}" \
185+
--output json \
186+
| jq -r '.[] | select(.keyName == "key1") | .value')
190187

191-
yq e -i ".certificate.name = \"${CERT_NAME}\"" "${CONFIG_FILE}"
192-
yq e -i ".containerRegistry.inCluster = false" "${CONFIG_FILE}"
193-
yq e -i ".containerRegistry.external.url = \"${DOCKER_REGISTRY_SERVER}\"" "${CONFIG_FILE}"
194-
yq e -i ".containerRegistry.external.certificate.kind = \"secret\"" "${CONFIG_FILE}"
195-
yq e -i ".containerRegistry.external.certificate.name = \"${SECRET_REGISTRY}\"" "${CONFIG_FILE}"
196-
yq e -i ".database.inCluster = false" "${CONFIG_FILE}"
197-
yq e -i ".database.external.certificate.kind = \"secret\"" "${CONFIG_FILE}"
198-
yq e -i ".database.external.certificate.name = \"${SECRET_DATABASE}\"" "${CONFIG_FILE}"
199-
yq e -i ".domain = \"${DOMAIN}\"" "${CONFIG_FILE}"
200-
yq e -i ".metadata.region = \"${LOCATION}\"" "${CONFIG_FILE}"
201-
yq e -i ".objectStorage.inCluster = false" "${CONFIG_FILE}"
202-
yq e -i ".objectStorage.azure.credentials.kind = \"secret\"" "${CONFIG_FILE}"
203-
yq e -i ".objectStorage.azure.credentials.name = \"${SECRET_STORAGE}\"" "${CONFIG_FILE}"
204-
yq e -i '.workspace.runtime.containerdRuntimeDir = "/var/lib/containerd/io.containerd.runtime.v2.task/k8s.io"' "${CONFIG_FILE}"
188+
cat << EOF
205189
206-
gitpod-installer \
207-
render \
208-
--config="${CONFIG_FILE}" > gitpod.yaml
209190
210-
# See https://github.com/gitpod-io/gitpod/tree/main/install/installer#error-validating-statefulsetstatus
211-
yq eval-all --inplace \
212-
'del(select(.kind == "StatefulSet" and .metadata.name == "openvsx-proxy").status)' \
213-
gitpod.yaml
191+
==========================
192+
🎉🥳🔥🧡🚀
214193
215-
kubectl apply -f gitpod.yaml
216-
}
194+
Your cloud infrastructure is ready to install Gitpod. Please visit
195+
https://www.gitpod.io/docs/self-hosted/latest/getting-started#step-4-install-gitpod
196+
for your next steps.
217197
218-
function install_jaeger_operator(){
219-
echo "Installing Jaeger operator..."
220-
kubectl apply -f https://raw.githubusercontent.com/jaegertracing/helm-charts/main/charts/jaeger-operator/crds/crd.yaml
221-
helm upgrade \
222-
--atomic \
223-
--cleanup-on-fail \
224-
--create-namespace \
225-
--install \
226-
--namespace='jaeger-operator' \
227-
--reset-values \
228-
--set installCRDs=true \
229-
--set crd.install=false \
230-
--values "${DIR}/charts/assets/jaeger-values.yaml" \
231-
--wait \
232-
jaegeroperator \
233-
jaegertracing/jaeger-operator
198+
Passwords may change on subsequents runs of this guide.
234199
235-
kubectl apply -f "${DIR}/charts/assets/jaeger-gitpod.yaml"
200+
=================
201+
Config Parameters
202+
=================
203+
204+
Domain Name: ${DOMAIN}
205+
206+
Registry
207+
========
208+
URL: ${DOCKER_REGISTRY_SERVER}
209+
Registry Server: <blank>
210+
Username: ${DOCKER_USER}
211+
Password: ${DOCKER_PASSWORD}
212+
213+
Database
214+
========
215+
Host: ${MYSQL_INSTANCE_NAME}.mysql.database.azure.com
216+
Username: ${MYSQL_GITPOD_USERNAME}@${MYSQL_INSTANCE_NAME}
217+
Password: ${MYSQL_GITPOD_PASSWORD}
218+
Port: 3306
219+
220+
Storage
221+
=======
222+
Region: ${LOCATION}
223+
Account Name: ${STORAGE_ACCOUNT_NAME}
224+
Access Key: ${STORAGE_ACCOUNT_KEY}
225+
226+
TLS Certificates
227+
================
228+
Issuer name: gitpod-issuer
229+
Issuer type: Cluster issuer
230+
231+
EOF
232+
233+
if [ -n "${SETUP_MANAGED_DNS}" ] && [ "${SETUP_MANAGED_DNS}" == "true" ]; then
234+
cat << EOF
235+
===========
236+
DNS Records
237+
===========
238+
239+
Domain Name: ${DOMAIN}
240+
Nameserver(s):
241+
$(az network dns zone show --name ${DOMAIN} --resource-group ${RESOURCE_GROUP} --query "nameServers" -o tsv)
242+
EOF
243+
fi
236244
}
237245

238246
function login() {
@@ -255,32 +263,6 @@ function setup_container_registry() {
255263
--resource-group "${RESOURCE_GROUP}" \
256264
--sku Premium
257265
fi
258-
259-
DOCKER_USER=$(az acr credential show \
260-
--name "${REGISTRY_NAME}" \
261-
--output tsv \
262-
--query username \
263-
--resource-group "${RESOURCE_GROUP}")
264-
265-
export DOCKER_REGISTRY_SERVER=$(az acr show \
266-
--name "${REGISTRY_NAME}" \
267-
--output tsv \
268-
--query loginServer \
269-
--resource-group "${RESOURCE_GROUP}")
270-
271-
DOCKER_PASSWORD=$(az acr credential show \
272-
--name "${REGISTRY_NAME}" \
273-
--output tsv \
274-
--query passwords[0].value \
275-
--resource-group "${RESOURCE_GROUP}")
276-
277-
echo "Create registry secret..."
278-
kubectl create secret docker-registry "${SECRET_REGISTRY}" \
279-
--docker-server="${DOCKER_REGISTRY_SERVER}" \
280-
--docker-username="${DOCKER_USER}" \
281-
--docker-password="${DOCKER_PASSWORD}" \
282-
--dry-run=client -o yaml | \
283-
kubectl replace --force -f -
284266
}
285267

286268
function setup_kubectl() {
@@ -315,8 +297,6 @@ function setup_managed_dns() {
315297
--role "DNS Zone Contributor" \
316298
--scope "${ZONE_ID}"
317299

318-
# Use v5.4.8 as external-dns v0.10.x has issue using Azure managed identities not in v0.9.0
319-
# @link https://github.com/kubernetes-sigs/external-dns/issues/2383
320300
helm upgrade \
321301
--atomic \
322302
--cleanup-on-fail \
@@ -331,7 +311,6 @@ function setup_managed_dns() {
331311
--set azure.useManagedIdentityExtension=true \
332312
--set azure.userAssignedIdentityID="${KUBELET_CLIENT_ID}" \
333313
--set logFormat=json \
334-
--version=5.4.8 \
335314
--wait \
336315
external-dns \
337316
bitnami/external-dns
@@ -343,7 +322,7 @@ function setup_managed_dns() {
343322

344323
function setup_mysql_database() {
345324
MYSQL_GITPOD_USERNAME="gitpod"
346-
MYSQL_GITPOD_PASSWORD=$(openssl rand -base64 20)
325+
export MYSQL_GITPOD_PASSWORD=$(openssl rand -base64 20)
347326

348327
if [ "$(az mysql server show --name ${MYSQL_INSTANCE_NAME} --resource-group ${RESOURCE_GROUP} --query "name == '${MYSQL_INSTANCE_NAME}'" || echo "empty")" == "true" ]; then
349328
echo "MySQL instance exists - updating password..."
@@ -385,16 +364,6 @@ function setup_mysql_database() {
385364
--resource-group "${RESOURCE_GROUP}" \
386365
--server-name "${MYSQL_INSTANCE_NAME}" \
387366
--start-ip-address "0.0.0.0"
388-
389-
echo "Create database secret..."
390-
kubectl create secret generic "${SECRET_DATABASE}" \
391-
--from-literal=encryptionKeys="${MYSQL_GITPOD_ENCRYPTION_KEY}" \
392-
--from-literal=host="${MYSQL_INSTANCE_NAME}.mysql.database.azure.com" \
393-
--from-literal=password="${MYSQL_GITPOD_PASSWORD}" \
394-
--from-literal=port="3306" \
395-
--from-literal=username="${MYSQL_GITPOD_USERNAME}@${MYSQL_INSTANCE_NAME}" \
396-
--dry-run=client -o yaml | \
397-
kubectl replace --force -f -
398367
}
399368

400369
function setup_storage() {
@@ -423,19 +392,6 @@ function setup_storage() {
423392
--assignee "${PRINCIPAL_ID}" \
424393
--role "Storage Blob Data Contributor" \
425394
--scope "${STORAGE_ACCOUNT_ID}"
426-
427-
STORAGE_ACCOUNT_KEY=$(az storage account keys list \
428-
--account-name "${STORAGE_ACCOUNT_NAME}" \
429-
--resource-group "${RESOURCE_GROUP}" \
430-
--output json \
431-
| jq -r '.[] | select(.keyName == "key1") | .value')
432-
433-
echo "Create storage secret..."
434-
kubectl create secret generic "${SECRET_STORAGE}" \
435-
--from-literal=accountName="${STORAGE_ACCOUNT_NAME}" \
436-
--from-literal=accountKey="${STORAGE_ACCOUNT_KEY}" \
437-
--dry-run=client -o yaml | \
438-
kubectl replace --force -f -
439395
}
440396

441397
function uninstall() {

0 commit comments

Comments
 (0)