Skip to content

Commit 2e8fb27

Browse files
Pothulapatiroboquat
authored andcommitted
[kots] Add new config to upload dockerConfigJson file
Signed-off-by: Tarun Pothulapati <[email protected]>
1 parent 135bc0f commit 2e8fb27

File tree

2 files changed

+54
-15
lines changed

2 files changed

+54
-15
lines changed

install/kots/manifests/gitpod-installer-job.yaml

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ spec:
7878
fi
7979
fi
8080
81+
echo "Gitpod: Create a Helm template directory"
82+
rm -Rf "${GITPOD_OBJECTS}"
83+
mkdir -p "${GITPOD_OBJECTS}/templates"
84+
cat <<EOF >> "${GITPOD_OBJECTS}/Chart.yaml"
85+
apiVersion: v2
86+
name: gitpod-kots
87+
description: Always ready-to-code
88+
version: "1.0.0"
89+
appVersion: "$(/app/installer version | yq e '.version' -)"
90+
EOF
91+
8192
echo "Gitpod: Generate the base Installer config"
8293
/app/installer init > "${CONFIG_FILE}"
8394
@@ -174,8 +185,7 @@ spec:
174185
kubectl create secret docker-registry container-registry \
175186
--namespace "{{repl Namespace }}" \
176187
--from-file=.dockerconfigjson=/tmp/container-registry-secret \
177-
-o yaml --dry-run=client | \
178-
kubectl replace --namespace "{{repl Namespace }}" --force -f -
188+
-o yaml --dry-run=client > "${GITPOD_OBJECTS}/templates/gitpod.yaml"
179189
180190
yq e -i ".containerRegistry.inCluster = false" "${CONFIG_FILE}"
181191
yq e -i ".containerRegistry.external.url = \"{{repl ConfigOption "reg_url" }}\"" "${CONFIG_FILE}"
@@ -298,19 +308,8 @@ spec:
298308
config=$(cat "${CONFIG_FILE}")
299309
echo "Gitpod: ${CONFIG_FILE}=${config}"
300310
301-
echo "Gitpod: Create a Helm template directory"
302-
rm -Rf "${GITPOD_OBJECTS}"
303-
mkdir -p "${GITPOD_OBJECTS}/templates"
304-
cat <<EOF >> "${GITPOD_OBJECTS}/Chart.yaml"
305-
apiVersion: v2
306-
name: gitpod-kots
307-
description: Always ready-to-code
308-
version: "1.0.0"
309-
appVersion: "$(/app/installer version | yq e '.version' -)"
310-
EOF
311-
312311
echo "Gitpod: render Kubernetes manifests"
313-
/app/installer render -c "${CONFIG_FILE}" --namespace {{repl Namespace }} --use-experimental-config > "${GITPOD_OBJECTS}/templates/gitpod.yaml"
312+
/app/installer render -c "${CONFIG_FILE}" --namespace {{repl Namespace }} --use-experimental-config >> "${GITPOD_OBJECTS}/templates/gitpod.yaml"
314313
315314
if [ '{{repl ConfigOptionEquals "reg_incluster" "1" }}' = "true" ];
316315
then
@@ -329,6 +328,33 @@ spec:
329328
"${GITPOD_OBJECTS}/templates/gitpod.yaml"
330329
fi
331330
331+
# figure out the secret to use
332+
if [ '{{repl ConfigOptionEquals "reg_incluster" "0" }}' = "true" ];
333+
then
334+
export REGISTRY_SECRET_NAME="container-registry"
335+
else
336+
export REGISTRY_SECRET_NAME="builtin-registry-auth"
337+
fi
338+
339+
if [ '{{repl ConfigOptionNotEquals "reg_docker_config" "" }}' = "true" ];
340+
then
341+
echo "Gitpod: Add given extra docker config json file to ${REGISTRY_SECRET_NAME}"
342+
343+
yq eval-all '(select(.kind == "Secret" and .metadata.name == env(REGISTRY_SECRET_NAME)) | .data.".dockerconfigjson")' \
344+
"${GITPOD_OBJECTS}/templates/gitpod.yaml" \
345+
| base64 -d \
346+
> /tmp/currentconfig.json
347+
348+
DOCKER_CONFIG='{{repl ConfigOptionData "reg_docker_config" | Base64Encode }}'
349+
echo "${DOCKER_CONFIG}" | base64 -d > /tmp/userconfig.json
350+
351+
export REGISTRY_SECRET=$(jq -s '.[0] * .[1]' /tmp/userconfig.json /tmp/currentconfig.json | base64 -w 0)
352+
353+
echo "Gitpod: update the in-cluster registry secret"
354+
yq eval-all --inplace '(select(.kind == "Secret" and .metadata.name == env(REGISTRY_SECRET_NAME)) | .data.".dockerconfigjson") |= env(REGISTRY_SECRET)' \
355+
"${GITPOD_OBJECTS}/templates/gitpod.yaml"
356+
fi
357+
332358
echo "Gitpod: Escape any Golang template values"
333359
sed -i -r 's/(.*\{\{.*)/{{`\1`}}/' "${GITPOD_OBJECTS}/templates/gitpod.yaml"
334360

install/kots/manifests/kots-config.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323

2424
- name: container_registry
2525
title: Container registry
26-
description: Gitpod requires a container registry to store container images. This can either be an in-cluster or external container registry.
26+
description: Gitpod [requires a container registry](https://www.gitpod.io/docs/self-hosted/latest/reference-architecture/single-cluster-ref-arch#oci-image-registry) to push and store workspace images. This can either be an in-cluster or external container registry.
2727
items:
2828
- name: reg_incluster
2929
title: Use in-cluster container registry
@@ -108,6 +108,19 @@ spec:
108108
required: true
109109
help_text: The password for your container registry.
110110

111+
- name: reg_docker_config_enable
112+
title: Configure additional registry credentials for pulling workspace images
113+
type: bool
114+
default: "0"
115+
help_text: This is useful when you have base workspace images in private registries other than the above configured ones.
116+
117+
- name: reg_docker_config
118+
title: Registry credentials
119+
when: '{{repl ConfigOptionEquals "reg_docker_config_enable" "1" }}'
120+
type: file
121+
required: true
122+
help_text: Docker [config JSON file](https://docs.docker.com/engine/reference/commandline/cli/#sample-configuration-file) with auth credentials used to access private registries, for workspace images.
123+
111124
- name: database
112125
title: Database
113126
description: Gitpod requires an instance of MySQL 5.7 for data storage. This can either be an in-cluster or external database.

0 commit comments

Comments
 (0)