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

Installing the Dapr Helm Chart via the CLI #8033

Merged
8 changes: 4 additions & 4 deletions .github/workflows/functional-test-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -595,10 +595,10 @@ jobs:
service-account-private-key-file: /etc/kubernetes/pki/sa.key
EOF

- name: Install dapr into cluster
run: |
wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash -s ${{ env.DAPR_VER }}
dapr init -k --wait --timeout 600 --runtime-version ${{ env.DAPR_VER }} --dashboard-version ${{ env.DAPR_DASHBOARD_VER }}
# - name: Install dapr into cluster
# run: |
# wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash -s ${{ env.DAPR_VER }}
# dapr init -k --wait --timeout 600 --runtime-version ${{ env.DAPR_VER }} --dashboard-version ${{ env.DAPR_DASHBOARD_VER }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @superbeeny - I have a question about removing this.

Does rad install kubernetes install fail when Dapr is already installed? I think we should make sure that case succeeds.

I'm trying to assess whether this is being removed because it's unnecessary, or whether it's being removed because it's broken.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also I'd prefer this be deleted rather than commented out. As well as the env-vars if they are unused. We have source control to see the history 👍

We can resolve that after the question above ^^^.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rad init will not fail for an existing dapr install


- name: Install Azure Keyvault CSI driver chart
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/functional-test-noncloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ jobs:
registry-server: ${{ env.LOCAL_REGISTRY_SERVER }}
registry-port: ${{ env.LOCAL_REGISTRY_PORT }}

- name: Install dapr into cluster
run: |
wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash -s ${{ env.DAPR_VER }}
dapr init -k --wait --timeout 600 --runtime-version ${{ env.DAPR_VER }} --dashboard-version ${{ env.DAPR_DASHBOARD_VER }}
# - name: Install dapr into cluster
# run: |
# wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash -s ${{ env.DAPR_VER }}
# dapr init -k --wait --timeout 600 --runtime-version ${{ env.DAPR_VER }} --dashboard-version ${{ env.DAPR_DASHBOARD_VER }}

- name: Install Radius
run: |
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/cmd/install/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error {
// to the cli version. It then returns any errors that occur during the installation.
func (r *Runner) Run(ctx context.Context) error {
cliOptions := helm.CLIClusterOptions{
Radius: helm.RadiusOptions{
Radius: helm.ChartOptions{
Reinstall: r.Reinstall,
ChartPath: r.Chart,
SetArgs: r.Set,
Expand All @@ -132,13 +132,13 @@ func (r *Runner) Run(ctx context.Context) error {
return err
}

if state.Installed && !r.Reinstall {
if state.RadiusInstalled && !r.Reinstall {
r.Output.LogInfo("Found existing Radius installation. Use '--reinstall' to force reinstallation.")
return nil
}

version := version.Version()
if state.Installed {
if state.RadiusInstalled {
r.Output.LogInfo("Reinstalling Radius version %s to namespace: %s...", version, helm.RadiusSystemNamespace)
} else {
r.Output.LogInfo("Installing Radius version %s to namespace: %s...", version, helm.RadiusSystemNamespace)
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/cmd/install/kubernetes/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func Test_Run(t *testing.T) {
Times(1)

expectedOptions := helm.PopulateDefaultClusterOptions(helm.CLIClusterOptions{
Radius: helm.RadiusOptions{
Radius: helm.ChartOptions{
ChartPath: "test-chart",
SetArgs: []string{"foo=bar", "bar=baz"},
},
Expand Down Expand Up @@ -109,7 +109,7 @@ func Test_Run(t *testing.T) {
}

helmMock.EXPECT().CheckRadiusInstall("test-context").
Return(helm.InstallState{Installed: true, Version: "test-version"}, nil).
Return(helm.InstallState{RadiusInstalled: true, RadiusVersion: "test-version"}, nil).
Times(1)

err := runner.Run(ctx)
Expand Down Expand Up @@ -139,11 +139,11 @@ func Test_Run(t *testing.T) {
}

helmMock.EXPECT().CheckRadiusInstall("test-context").
Return(helm.InstallState{Installed: true, Version: "test-version"}, nil).
Return(helm.InstallState{RadiusInstalled: true, RadiusVersion: "test-version"}, nil).
Times(1)

expectedOptions := helm.PopulateDefaultClusterOptions(helm.CLIClusterOptions{
Radius: helm.RadiusOptions{
Radius: helm.ChartOptions{
ChartPath: "test-chart",
SetArgs: []string{"foo=bar", "bar=baz"},
Reinstall: true,
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/cmd/radinit/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func (r *Runner) enterClusterOptions(options *initOptions) error {
if err != nil {
return clierrors.MessageWithCause(err, "Unable to verify Radius installation.")
}
options.Cluster.Install = !state.Installed
options.Cluster.Install = !state.RadiusInstalled || !state.DaprInstalled
ytimocin marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a test for this new case?


if state.Installed {
if state.RadiusInstalled && state.DaprInstalled {
options.Cluster.Install = false
options.Cluster.Version = state.Version
options.Cluster.Version = state.RadiusVersion
}

if options.Cluster.Install {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cmd/radinit/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (r *Runner) Run(ctx context.Context) error {

if r.Options.Cluster.Install {
cliOptions := helm.CLIClusterOptions{
Radius: helm.RadiusOptions{
Radius: helm.ChartOptions{
SetArgs: r.Options.SetValues,
},
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/cmd/radinit/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1064,13 +1064,13 @@ func initSelectCloudProvider(prompter *prompt.MockInterface, value string) {
func initHelmMockRadiusInstalled(helmMock *helm.MockInterface) {
helmMock.EXPECT().
CheckRadiusInstall(gomock.Any()).
Return(helm.InstallState{Installed: true, Version: "test-version"}, nil).Times(1)
Return(helm.InstallState{RadiusInstalled: true, RadiusVersion: "test-version", DaprInstalled: true, DaprVersion: "test-version"}, nil).Times(1)
}

func initHelmMockRadiusNotInstalled(helmMock *helm.MockInterface) {
helmMock.EXPECT().
CheckRadiusInstall(gomock.Any()).
Return(helm.InstallState{Installed: false}, nil).Times(1)
Return(helm.InstallState{RadiusInstalled: false}, nil).Times(1)
}

func setExistingEnvironments(clientMock *clients.MockApplicationsManagementClient, environments []corerp.EnvironmentResource) {
Expand Down
15 changes: 13 additions & 2 deletions pkg/cli/cmd/uninstall/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package kubernetes

import (
"context"

"github.com/radius-project/radius/pkg/cli/kubernetes"

"github.com/radius-project/radius/pkg/cli/cmd/commonflags"
Expand Down Expand Up @@ -91,13 +92,23 @@ func (r *Runner) Run(ctx context.Context) error {
if err != nil {
return err
}
if !state.Installed {
if !state.RadiusInstalled {
r.Output.LogInfo("Radius is not installed on the Kubernetes cluster")
return nil
}

r.Output.LogInfo("Uninstalling Radius...")
err = r.Helm.UninstallRadius(ctx, r.KubeContext)
err = r.Helm.UninstallRadius(ctx, helm.ClusterOptions{
Radius: helm.ChartOptions{
Namespace: helm.RadiusSystemNamespace,
ReleaseName: helm.NewDefaultClusterOptions().Radius.ReleaseName,
},
Dapr: helm.ChartOptions{
rynowak marked this conversation as resolved.
Show resolved Hide resolved
Namespace: helm.DaprSystemNamespace,
ReleaseName: helm.NewDefaultClusterOptions().Dapr.ReleaseName,
},
}, r.KubeContext)

if err != nil {
return err
}
Expand Down
31 changes: 25 additions & 6 deletions pkg/cli/cmd/uninstall/kubernetes/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package kubernetes

import (
"context"
"github.com/radius-project/radius/pkg/cli/kubernetes"
"testing"

"github.com/radius-project/radius/pkg/cli/kubernetes"

"github.com/radius-project/radius/pkg/cli/helm"
"github.com/radius-project/radius/pkg/cli/output"
"github.com/radius-project/radius/test/radcli"
Expand Down Expand Up @@ -68,10 +69,19 @@ func Test_Run(t *testing.T) {
}

helmMock.EXPECT().CheckRadiusInstall("test-context").
Return(helm.InstallState{Installed: true, Version: "test-version"}, nil).
Return(helm.InstallState{RadiusInstalled: true, RadiusVersion: "test-version", DaprInstalled: true, DaprVersion: "test-version"}, nil).
Times(1)

helmMock.EXPECT().UninstallRadius(ctx, "test-context").
helmMock.EXPECT().UninstallRadius(ctx, helm.ClusterOptions{
Radius: helm.ChartOptions{
Namespace: "radius-system",
ReleaseName: "radius",
},
Dapr: helm.ChartOptions{
Namespace: "dapr-system",
ReleaseName: "dapr",
},
}, "test-context").
Return(nil).
Times(1)

Expand Down Expand Up @@ -116,7 +126,7 @@ func Test_Run(t *testing.T) {
}
require.Equal(t, expectedWrites, outputMock.Writes)
})
t.Run("Success: Installed -> Uninstalled -> Purge)", func(t *testing.T) {
t.Run("Success: Installed -> Uninstalled -> Purge", func(t *testing.T) {
ctrl := gomock.NewController(t)
helmMock := helm.NewMockInterface(ctrl)
outputMock := &output.MockOutput{}
Expand All @@ -133,10 +143,19 @@ func Test_Run(t *testing.T) {
}

helmMock.EXPECT().CheckRadiusInstall("test-context").
Return(helm.InstallState{Installed: true, Version: "test-version"}, nil).
Return(helm.InstallState{RadiusInstalled: true, RadiusVersion: "test-version", DaprInstalled: true, DaprVersion: "test-version"}, nil).
Times(1)

helmMock.EXPECT().UninstallRadius(ctx, "test-context").
helmMock.EXPECT().UninstallRadius(ctx, helm.ClusterOptions{
Radius: helm.ChartOptions{
Namespace: "radius-system",
ReleaseName: "radius",
},
Dapr: helm.ChartOptions{
Namespace: "dapr-system",
ReleaseName: "dapr",
},
}, "test-context").
Return(nil).
Times(1)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cmd/workspace/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error {
}

state, err := r.HelmInterface.CheckRadiusInstall(context)
if !state.Installed || err != nil {
if !state.RadiusInstalled || err != nil {
return fmt.Errorf("unable to create workspace %q. Radius control plane not installed on target platform. Run 'rad install' and try again", workspaceName)
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/cmd/workspace/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func Test_Validate(t *testing.T) {
ConfigureMocks: func(mocks radcli.ValidateMocks) {
// We have a valid kubernetes context, but Radius is not installed
mocks.Kubernetes.EXPECT().GetKubeContext().Return(getTestKubeConfig(), nil).Times(1)
mocks.Helm.EXPECT().CheckRadiusInstall(gomock.Any()).Return(helm.InstallState{Installed: false}, nil).Times(1)
mocks.Helm.EXPECT().CheckRadiusInstall(gomock.Any()).Return(helm.InstallState{RadiusInstalled: false}, nil).Times(1)
},
},
{
Expand All @@ -84,7 +84,7 @@ func Test_Validate(t *testing.T) {
ConfigureMocks: func(mocks radcli.ValidateMocks) {
// We have a valid kubernetes context with Radius installed
mocks.Kubernetes.EXPECT().GetKubeContext().Return(getTestKubeConfig(), nil).Times(1)
mocks.Helm.EXPECT().CheckRadiusInstall(gomock.Any()).Return(helm.InstallState{Installed: true}, nil).Times(1)
mocks.Helm.EXPECT().CheckRadiusInstall(gomock.Any()).Return(helm.InstallState{RadiusInstalled: true}, nil).Times(1)

// Resource group does not exist
mocks.ApplicationManagementClient.EXPECT().GetResourceGroup(gomock.Any(), "local", "rg1").Return(ucp.ResourceGroupResource{}, errors.New("group does not exist")).Times(1)
Expand All @@ -101,7 +101,7 @@ func Test_Validate(t *testing.T) {
ConfigureMocks: func(mocks radcli.ValidateMocks) {
// We have a valid kubernetes context with Radius installed
mocks.Kubernetes.EXPECT().GetKubeContext().Return(getTestKubeConfig(), nil).Times(1)
mocks.Helm.EXPECT().CheckRadiusInstall(gomock.Any()).Return(helm.InstallState{Installed: true}, nil).Times(1)
mocks.Helm.EXPECT().CheckRadiusInstall(gomock.Any()).Return(helm.InstallState{RadiusInstalled: true}, nil).Times(1)

// Resource group exists but environment does not
mocks.ApplicationManagementClient.EXPECT().GetResourceGroup(gomock.Any(), "local", "rg1").Return(ucp.ResourceGroupResource{}, nil).Times(1)
Expand All @@ -119,7 +119,7 @@ func Test_Validate(t *testing.T) {
ConfigureMocks: func(mocks radcli.ValidateMocks) {
// We have a valid kubernetes context with Radius installed
mocks.Kubernetes.EXPECT().GetKubeContext().Return(getTestKubeConfig(), nil).Times(1)
mocks.Helm.EXPECT().CheckRadiusInstall(gomock.Any()).Return(helm.InstallState{Installed: true}, nil).Times(1)
mocks.Helm.EXPECT().CheckRadiusInstall(gomock.Any()).Return(helm.InstallState{RadiusInstalled: true}, nil).Times(1)

// Resource group and environment exist
mocks.ApplicationManagementClient.EXPECT().GetResourceGroup(gomock.Any(), "local", "rg1").Return(ucp.ResourceGroupResource{}, nil).Times(1)
Expand Down
Loading
Loading