upbound / up

The @upbound CLI
Apache License 2.0
52 stars 41 forks source link

Allow operators to override the registry and registry-endpoint for a spaces install #358

Closed tnthornton closed 1 year ago

tnthornton commented 1 year ago

Description of your changes

This is specifically useful for operators working in an airgapped environment.

Unfortunately, given we don't really know what the shape of the pull secret should be, we do our best to prompt for username/password and supply the registry-endpoint value.

Fixes #349

I have:

How has this code been tested

  1. Ensured that in the default case, installation via up space init --token-file=key.json version still works:
    
    ./_output/bin/darwin_arm64/up space init --token-file=key.json v0.14.0-23.ga50d1a87
    WARNING  One or more required prerequisites are not installed:

❌ cert-manager ❌ universal-crossplane ❌ ingress-nginx ❌ provider-kubernetes ❌ provider-helm

Would you like to install them now? [y/N]: Yes

√ [1/5]: Installing cert-manager √ [2/5]: Installing universal-crossplane √ [3/5]: Installing ingress-nginx √ [4/5]: Installing provider-kubernetes √ [5/5]: Installing provider-helm INFO Required prerequisites met! INFO Proceeding with Upbound Spaces installation... √ [1/3]: Creating pull secret upbound-pull-secret √ [2/3]: Initializing Space components √ [3/3]: Starting Space Components 🙌 Your Upbound Space is Ready!

👀 Next Steps 👇

👉 Check out Upbound Spaces docs @ https://docs.upbound.io

2. Overrode registry and registry-endpoint. Expectation is that the install will fail when attempting to pull helm chart due to bad creds:

./_output/bin/darwin_arm64/up space init --token-file=key.json v0.14.0-23.ga50d1a87 --registry=upbound/spaces-install --registry-endpoint=hub.docker.com Username: username Password: WARNING One or more required prerequisites are not installed:

❌ cert-manager ❌ universal-crossplane ❌ ingress-nginx ❌ provider-kubernetes ❌ provider-helm

Would you like to install them now? [y/N]: Yes

√ [1/5]: Installing cert-manager √ [2/5]: Installing universal-crossplane √ [3/5]: Installing ingress-nginx √ [4/5]: Installing provider-kubernetes √ [5/5]: Installing provider-helm INFO Required prerequisites met! INFO Proceeding with Upbound Spaces installation... √ [1/3]: Creating pull secret upbound-pull-secret ▄ [2/3]: Initializing Space components (1s)up: error: space.initCmd.Run(): could not pull chart: failed to get OCI image: GET https://auth.docker.io/token?scope=repository%3Aupbound%2Fspaces-install%2Fspaces%3Apull&service=registry.docker.io: unexpected status code 401 Unauthorized: {"details":"incorrect username or password"}

3. Verify that upbound-pull-secret has the correct creds from prompt steps:

kubectl -n upbound-system get secrets upbound-pull-secret -o go-template='{{index .data ".dockerconfigjson"}}' | base64 -d {"auths":{"hub.docker.com":{"username":"username","password":"password","auth":"dXNlcm5hbWU6cGFzc3dvcmQ="}}}%