Skip to content

Commit cccb609

Browse files
committed
Add parameter to set global pull-secret secret
Some projects might want to have an access to secured registry, but the credentials are not shared across projects. This commit adds GLOBAL_SECURED_REGISTRIES parameter, that will allow user to create similar pull-secret as it is done in openshift-config namespace to be available for other projects [1]. For example, the openshift-marketplace can not start properly, because it can not pull the image. We can add the pull-secret into the /var/lib/kubelet/config.json, but after clustersetup.sh script finish the Machine Config Pool would be marked as degraded (because there would be a missmatch). Adding the pull secret globaly will help avoid issue, that the image can not be downloaded. On the end, it can be deleted. [1] https://docs.openshift.com/container-platform/4.15/openshift_images/managing_images/using-image-pull-secrets.html#images-allow-pods-to-reference-images-from-secure-registries_using-image-pull-secrets
1 parent eac7dcf commit cccb609

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/bundle/setup/clustersetup.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ PASS_DEVELOPER="${PASS_DEVELOPER:-"_PASS_DEVELOPER_"}"
1515
PASS_KUBEADMIN="${PASS_KUBEADMIN:-"_PASS_KUBEADMIN_"}"
1616
PASS_REDHAT="${PASS_REDHAT:-"_PASS_REDHAT_"}"
1717
MAXIMUM_LOGIN_RETRY=500
18+
GLOBAL_SECURED_REGISTRIES="${GLOBAL_SECURED_REGISTRIES:-"false"}"
1819

1920
pr_info() {
2021
echo "[INF] $1" | tee -a $LOG_FILE > /dev/null
@@ -182,6 +183,15 @@ patch_pull_secret() {
182183
sleep $STEPS_SLEEP_TIME
183184
}
184185

186+
global_pull_secret() {
187+
pr_info "adding pull-secret as global cluster pull secret"
188+
oc get secret/pull-secret -n openshift-config --template='{{index .data ".dockerconfigjson" | base64decode}}' > /tmp/pull-secret.txt
189+
oc create secret generic global-pull-secret --from-file=.dockercfg=/tmp/pull-secret.txt --type=kubernetes.io/dockercfg
190+
stop_if_failed $? "failed to create global pull secret"
191+
rm /tmp/pull-secret.txt
192+
sleep $STEPS_SLEEP_TIME
193+
}
194+
185195
create_certificate_and_patch_secret() {
186196
pr_info "creating OpenShift secrets"
187197
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout nip.key -out nip.crt -subj "/CN=$EIP.nip.io" -addext "subjectAltName=DNS:apps.$EIP.nip.io,DNS:*.apps.$EIP.nip.io,DNS:api.$EIP.nip.io"
@@ -262,6 +272,9 @@ stop_if_failed $? "failed to recover Cluster after $(expr $CLUSTER_HEALTH_RETRIE
262272

263273

264274
patch_pull_secret
275+
if [[ "$GLOBAL_SECURED_REGISTRIES" =~ True|true ]]; then
276+
global_pull_secret
277+
fi
265278
wait_cluster_become_healthy "etcd|openshift-apiserver"
266279
stop_if_failed $? "failed to recover Cluster after $(expr $CLUSTER_HEALTH_RETRIES \* $CLUSTER_HEALTH_SLEEP) seconds"
267280

0 commit comments

Comments
 (0)