This adds support for profiles that work with a Space.
up space init behaves the same, except it updates the active profile to be a Spaces profile after a successful install, using the kubeconfig it was provided (or default kubeconfig).
up space upgrade and destroy build a kubeconfig from the active Spaces profile if --kubeconfig and --kubecontext flags are not provided. If kube flags are not provided and the active profile is not a Spaces profile, they will exit with an error.
New command up profile set space updates the active profile to be a Spaces profile without needing to install Spaces via up space init first. It uses the default kubeconfig and context unless --kubeconfig or --kubecontext are provided.
All commands that assume a non-Spaces profile will exit with an error if active profile is for Spaces.
[x] Run make reviewable to ensure this PR is ready for review.
[x] Added backport release-x.y labels to auto-backport this PR, as appropriate.
How has this code been tested
branden@crateria kind % up profile list
No profiles found
branden@crateria kind % kubectl config current-context
kind-kind
branden@crateria kind % up space init --token-file="${SPACES_TOKEN_PATH}" "v${SPACES_VERSION}" \
--set "ingress.host=${SPACES_ROUTER_HOST}" \
--set "clusterType=${SPACES_CLUSTER_TYPE}" \
--set "account=${UPBOUND_ACCOUNT}"
INFO Setting defaults for vanilla Kubernetes (type kind)
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/concepts/upbound-spaces
branden@crateria kind % up profile list
CURRENT NAME TYPE ACCOUNT KUBECONFIG KUBECONTEXT
* default spaces kind-kind
branden@crateria kind % up profile view
{
"default": {
"type": "spaces",
"kube_context": "kind-kind"
}
}
branden@crateria kind % kubectl config use-context kind-kuttl-test # set default kubecontext to an old context for a nonexistent cluster to demonstrate that the profile doesn't depend on the default kubecontext
Switched to context "kind-kuttl-test".
branden@crateria kind % up space upgrade --token-file="${SPACES_TOKEN_PATH}" "v${SPACES_VERSION}"
√ Upgrading Space from v1.0.1 to v1.0.1
branden@crateria kind % up ctp list
up: error: controlplane.listCmd.Run(): list is not supported for Spaces profile "default"
branden@crateria kind % up ctp get foo
up: error: controlplane.getCmd.Run(): get is not supported for Spaces profile "default"
branden@crateria kind % up ctp kubeconfig get --token=whatever foo
up: error: kubeconfig.getCmd.Run(): get is not supported for Spaces profile "default"
branden@crateria kind % up ctp connect foo bar
up: error: controlplane.connectCmd.Run(): connect is not supported for Spaces profile "default"
branden@crateria kind % up ctp create foo --configuration-name=foo
up: error: controlplane.createCmd.Run(): create is not supported for Spaces profile "default"
branden@crateria kind % up ctp pull-secret create
up: error: pullsecret.createCmd.AfterApply(): create is not supported for Spaces profile "default"
branden@crateria kind % up login --token=$UP_TOKEN
3122e6b9-78c3-4264-995f-068364b00051 logged in
branden@crateria kind % up profile list
CURRENT NAME TYPE ACCOUNT KUBECONFIG KUBECONTEXT
* default token branden
branden@crateria kind % up profile view
{
"default": {
"id": "3122e6b9-78c3-4264-995f-068364b00051",
"type": "token",
"session": "REDACTED",
"account": "branden"
}
}
branden@crateria kind % up ctp list
up: error: controlplane.listCmd.Run(): Forbidden: {"message":"branden is not an organization and only organizations can manage control planes"}{"controlPlanes":[],"count":0,"page":0,"size":100}
branden@crateria kind % up space upgrade --token-file="${SPACES_TOKEN_PATH}" "v${SPACES_VERSION}"
up: error: space.upgradeCmd.AfterApply(): upgrade is not supported for non-Spaces profile "default"
branden@crateria kind % up space destroy
up: error: space.destroyCmd.AfterApply(): destroy is not supported for non-Spaces profile "default"
branden@crateria kind % up profile set space --kubecontext kind-kind
branden@crateria kind % up profile list
CURRENT NAME TYPE ACCOUNT KUBECONFIG KUBECONTEXT
* default spaces kind-kind
branden@crateria kind % up profile view
{
"default": {
"type": "spaces",
"kube_context": "kind-kind"
}
}
branden@crateria kind % up space destroy
******************** DESTRUCTIVE COMMAND ********************
********************* DATA-LOSS WARNING *********************
WARNING Destroying Spaces is a destructive command that will destroy data and orphan resources.
WARNING Before proceeding ensure that Managed Resources in Control Planes have been deleted.
WARNING All Spaces components including Control Planes will be destroyed.
WARNING If you want to retain data, abort and run 'up space destroy --orphan'
To proceed, type: "CONFIRMED": CONFIRMED
branden@crateria kind % echo $?
0
branden@crateria kind %
Description of your changes
This adds support for profiles that work with a Space.
up space init
behaves the same, except it updates the active profile to be a Spaces profile after a successful install, using the kubeconfig it was provided (or default kubeconfig).up space upgrade
anddestroy
build a kubeconfig from the active Spaces profile if--kubeconfig
and--kubecontext
flags are not provided. If kube flags are not provided and the active profile is not a Spaces profile, they will exit with an error.up profile set space
updates the active profile to be a Spaces profile without needing to install Spaces viaup space init
first. It uses the default kubeconfig and context unless--kubeconfig
or--kubecontext
are provided.Fixes #373
I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR, as appropriate.How has this code been tested