Modify rad install to create default resource group and environment#11870
Modify rad install to create default resource group and environment#11870zachcasper wants to merge 2 commits into
Conversation
Signed-off-by: Zach Casper <zachcasper@microsoft.com>
There was a problem hiding this comment.
Pull request overview
This PR updates rad install kubernetes so that, after a successful Helm install, it also ensures a usable default setup by creating a default resource group and a default environment targeting the default Kubernetes namespace—bringing the command in line with rad init.
Changes:
- Add a post-install step to create the
defaultresource group anddefaultenvironment after Helm installation completes. - Add kube context resolution logic that falls back to the current kubeconfig context when
--kubecontextisn’t provided. - Update/install unit tests to cover the new post-install behavior and kubeconfig edge cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/cli/cmd/install/kubernetes/kubernetes.go | Adds post-install default resource group/environment creation and kube context resolution helpers. |
| pkg/cli/cmd/install/kubernetes/kubernetes_test.go | Updates existing tests for new expectations and adds tests for kubecontext fallback and missing current context. |
Comments suppressed due to low confidence (1)
pkg/cli/cmd/install/kubernetes/kubernetes.go:235
CreateOrUpdateResourceGroup/CreateOrUpdateEnvironmentare full upserts (PUT) and will update an existingdefaultgroup/environment to match the payload here. That contradicts the comment about leaving existing resources unchanged and can reset user edits during--reinstall(e.g., environment compute kind/namespace). To preserve user changes, check for existence first (GET; treat 404 as "missing"), and only create when absent (or explicitly skip update when an existing resource differs).
// createDefaultGroupAndEnvironment ensures that a resource group named "default" and an environment named
// "default" exist on the cluster Radius was just installed on. Existing resources with the same names are
// left unchanged (CreateOrUpdate semantics), so re-running install is safe.
func (r *Runner) createDefaultGroupAndEnvironment(ctx context.Context) error {
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Zach Casper <zachcasper@microsoft.com>
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11870 +/- ##
==========================================
+ Coverage 51.69% 51.72% +0.03%
==========================================
Files 725 725
Lines 45595 45642 +47
==========================================
+ Hits 23570 23609 +39
- Misses 19799 19803 +4
- Partials 2226 2230 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
rad install kubernetespreviously only installed the Radius Helm chart, leaving the cluster without a usable resource group or environment. Users then had to run additional commands (or userad init) before they could deploy anything. This PR bringsrad install kubernetesin line withrad initby automatically creating thedefaultresource group and adefaultenvironment (in thedefaultKubernetes namespace) immediately after a successful Helm install.Behavior:
Helm.InstallRadiussucceeds, the runner builds an in-process workspace targeting the just-installed control plane and callsCreateOrUpdateResourceGroup(ctx, "local", "default", …)andCreateOrUpdateEnvironment(ctx, "default", …)withKubernetesCompute{Namespace: "default"}.CreateOrUpdatesemantics make the calls idempotent — re-running with--reinstallwill not corrupt user-edited groups/environments.--reinstall) is unchanged: nothing is touched.--kubecontextif set, otherwise the active context from kubeconfig. If kubeconfig has no active context, a clear error tells the user to pass--kubecontext.rad group create default/rad env create default) so they don't have to reinstall.~/.rad/config.yaml; the workspace used here is in-process only.Files changed:
pkg/cli/cmd/install/kubernetes/kubernetes.go: addsConnectionFactory+KubernetesInterfacetoRunner, the post-installcreateDefaultGroupAndEnvironmentstep,resolveKubeContexthelper, default constants, updatedLongdescription.pkg/cli/cmd/install/kubernetes/kubernetes_test.go: updates all successful-install tests with the new mock expectations, adds a test for the kubeconfig-fallback path and a test for the empty-current-context failure path. Mock expectations assertLocation == LocationGlobalandKubernetesCompute.Namespace == "default"on the env payload.Type of change
Fixes: #11869
Contributor checklist
Please verify that the PR meets the following requirements, where applicable:
eng/design-notes/in this repository, if new APIs are being introduced.rad install kubernetesuser-facing behavior changes; docs should call out the new default group/env and the new failure modes.