Skip to content

Modify rad install to create default resource group and environment#11870

Open
zachcasper wants to merge 2 commits into
radius-project:mainfrom
zachcasper:rad-install-default-group-env
Open

Modify rad install to create default resource group and environment#11870
zachcasper wants to merge 2 commits into
radius-project:mainfrom
zachcasper:rad-install-default-group-env

Conversation

@zachcasper
Copy link
Copy Markdown
Contributor

Description

rad install kubernetes previously only installed the Radius Helm chart, leaving the cluster without a usable resource group or environment. Users then had to run additional commands (or use rad init) before they could deploy anything. This PR brings rad install kubernetes in line with rad init by automatically creating the default resource group and a default environment (in the default Kubernetes namespace) immediately after a successful Helm install.

Behavior:

  • After Helm.InstallRadius succeeds, the runner builds an in-process workspace targeting the just-installed control plane and calls CreateOrUpdateResourceGroup(ctx, "local", "default", …) and CreateOrUpdateEnvironment(ctx, "default", …) with KubernetesCompute{Namespace: "default"}.
  • CreateOrUpdate semantics make the calls idempotent — re-running with --reinstall will not corrupt user-edited groups/environments.
  • The early-return path for an existing install (without --reinstall) is unchanged: nothing is touched.
  • Kube context resolution mirrors what Helm itself targets: --kubecontext if set, otherwise the active context from kubeconfig. If kubeconfig has no active context, a clear error tells the user to pass --kubecontext.
  • If the post-install group/environment creation fails (e.g. transient UCP error), the error message tells the user how to recover (rad group create default / rad env create default) so they don't have to reinstall.
  • No client-side workspace is persisted to ~/.rad/config.yaml; the workspace used here is in-process only.

Files changed:

  • pkg/cli/cmd/install/kubernetes/kubernetes.go: adds ConnectionFactory + KubernetesInterface to Runner, the post-install createDefaultGroupAndEnvironment step, resolveKubeContext helper, default constants, updated Long description.
  • 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 assert Location == LocationGlobal and KubernetesCompute.Namespace == "default" on the env payload.

Type of change

  • This pull request fixes a bug in Radius and has an approved issue (issue link required).

Fixes: #11869

Contributor checklist

Please verify that the PR meets the following requirements, where applicable:

  • An overview of proposed schema changes is included in a linked GitHub issue.
    • Yes
    • Not applicable
  • A design document is added or updated under eng/design-notes/ in this repository, if new APIs are being introduced.
    • Yes
    • Not applicable
  • The design document has been reviewed and approved by Radius maintainers/approvers.
    • Yes
    • Not applicable
  • A PR for resource-types-contrib is created, if resource types or recipes are affected by the changes in this PR.
    • Yes
    • Not applicable
  • A PR for dashboard is created, if the Radius Dashboard is affected by the changes in this PR.
    • Yes
    • Not applicable
  • A PR for the documentation repository is created, if the changes in this PR affect the documentation or any user facing updates are made.
    • Yes — rad install kubernetes user-facing behavior changes; docs should call out the new default group/env and the new failure modes.
    • Not applicable

Signed-off-by: Zach Casper <zachcasper@microsoft.com>
Copilot AI review requested due to automatic review settings May 13, 2026 02:03
@zachcasper zachcasper requested review from a team as code owners May 13, 2026 02:03
@zachcasper zachcasper changed the title Modify rad install to create default rg and env Modify rad install to create default resource group and environment May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 default resource group and default environment after Helm installation completes.
  • Add kube context resolution logic that falls back to the current kubeconfig context when --kubecontext isn’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 / CreateOrUpdateEnvironment are full upserts (PUT) and will update an existing default group/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 {

Comment thread pkg/cli/cmd/install/kubernetes/kubernetes.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Zach Casper <zachcasper@microsoft.com>
@radius-functional-tests
Copy link
Copy Markdown

radius-functional-tests Bot commented May 13, 2026

Radius functional test overview

🔍 Go to test action run

Click here to see the test run details
Name Value
Repository zachcasper/radius
Commit ref 633c15a
Unique ID func3b4c180f49
Image tag pr-func3b4c180f49
  • gotestsum 1.13.0
  • KinD: v0.29.0
  • Dapr: 1.14.4
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-func3b4c180f49
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-func3b4c180f49
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-func3b4c180f49
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func3b4c180f49
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func3b4c180f49
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ ucp-cloud functional tests succeeded
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 83.67347% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.72%. Comparing base (f4234af) to head (633c15a).

Files with missing lines Patch % Lines
pkg/cli/cmd/install/kubernetes/kubernetes.go 83.67% 4 Missing and 4 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rad install kubernetes should create a default resource group and environment (match rad init behavior)

2 participants