Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Aug 16, 2023

Conversation

tnthornton
Copy link
Member

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:

  • Read and followed Upbound's contribution process.
  • Run make reviewable to ensure this PR is ready for review.

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
  1. 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"}
  1. 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="}}}%                                                 

@tnthornton tnthornton requested a review from a team August 14, 2023 23:49
@@ -57,7 +61,18 @@ type Cmd struct {
}

type commonParams struct {
Repo *url.URL `hidden:"" env:"UPBOUND_REPO" default:"us-west1-docker.pkg.dev/orchestration-build/upbound-environments" help:"Set repo for Upbound."`
Registry *url.URL `hidden:"" env:"UPBOUND_REPO" default:"us-west1-docker.pkg.dev/orchestration-build/upbound-environments" help:"Set repo for Upbound."`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example in your PR has: --registry=upbound/spaces-install. Is it correct that it's a URL?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API that takes this property is looking for a url:

func NewManager(config *rest.Config, chartName string, repoURL *url.URL, modifiers ...InstallerModifierFn) (install.Manager, error) {

invoked like:

	mgr, err := helm.NewManager(insCtx.Kubeconfig,
		spacesChart,
		c.Registry,
		helm.WithNamespace(ns),
		helm.WithBasicAuth(c.id, c.token),
		helm.IsOCI(),
		helm.WithChart(c.Bundle),
		helm.Wait(),
	)
	if err != nil {
		return err
	}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fairly confused -- if someone looks at the help (I know it's hidden, but in the source), would they know what to do?

I'll approve, but there may be a more clear description.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I misunderstood your question before. I've updated the help string. If it's still confusing I'm happy to take another pass at it.

…spaces install

- default to json_key auth
- if the registry is overridden, prompt for username/password

Signed-off-by: Taylor Thornton <thornton.tn@gmail.com>
Signed-off-by: Taylor Thornton <thornton.tn@gmail.com>
@tnthornton tnthornton merged commit d052835 into upbound:main Aug 16, 2023
6 checks passed
@tnthornton tnthornton deleted the container-registry-override branch August 16, 2023 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

up space init should allow users to specify an alternate container registery
2 participants