Skip to content

Commit 3d8291d

Browse files
authored
feat: remove existing application-manager addon and add new argocd pull model addon (#483)
Signed-off-by: Mike Ng <[email protected]>
1 parent b094f73 commit 3d8291d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+171
-2338
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,22 @@ Clean up the multicluster hub control plane and other initialized resources on t
127127

128128
Install specific built-in add-on(s) to the hub cluster.
129129

130-
`clusteradm install hub-addon --names application-manager`
130+
`clusteradm install hub-addon --names argocd`
131131

132132
`clusteradm install hub-addon --names governance-policy-framework`
133133

134134
### enable addons
135135

136136
Enable specific add-on(s) agent deployment to the given managed clusters of the specified namespace
137137

138-
`clusteradm addon enable --names application-manager --namespace <namespace> --clusters <cluster1>,<cluster2>,....`
138+
`clusteradm addon enable --names argocd --namespace <namespace> --clusters <cluster1>,<cluster2>,....`
139139

140140
`clusteradm addon enable --names governance-policy-framework --namespace <namespace> --clusters <cluster1>,<cluster2>,....`
141141

142142
`clusteradm addon enable --names config-policy-controller --namespace <namespace> --clusters <cluster1>,<cluster2>,....`
143143

144144
### create sample application
145145

146-
Create and Deploy a Sample Subscription Application
146+
Create and deploy a sample Argo CD ApplicationSet
147147

148-
`clusteradm create sampleapp sampleapp1`
148+
`clusteradm create sampleapp sample-appset`

pkg/cmd/addon/disable/cmd.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import (
1212
)
1313

1414
var example = `
15-
# Disable application-manager addon on specified clusters
16-
%[1]s addon disable --names application-manager --clusters cluster1,cluster2
17-
# Disable application-manager addon on all clusters
18-
%[1]s addon disable --names application-manager --all-clusters
19-
# Disable application-manager addon to the given managed clusters in the specified namespace
20-
%[1]s addon disable --names application-manager --namespace <namespace> --clusters <cluster1>
15+
# Disable argocd addon on specified clusters
16+
%[1]s addon disable --names argocd --clusters cluster1,cluster2
17+
# Disable argocd addon on all clusters
18+
%[1]s addon disable --names argocd --all-clusters
19+
# Disable argocd addon to the given managed clusters in the specified namespace
20+
%[1]s addon disable --names argocd --namespace <namespace> --clusters <cluster1>
2121
2222
## Policy Framework
2323

pkg/cmd/addon/disable/exec_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var _ = ginkgo.Describe("addon disable", func() {
2323
var cluster2Name string
2424
var err error
2525

26-
appMgrAddonName := "application-manager"
26+
appMgrAddonName := "argocd"
2727

2828
ginkgo.BeforeEach(func() {
2929
cluster1Name = fmt.Sprintf("cluster-%s", rand.String(5))
@@ -71,7 +71,7 @@ var _ = ginkgo.Describe("addon disable", func() {
7171

7272
ginkgo.Context("runWithClient", func() {
7373

74-
ginkgo.It("Should disable application-manager ManagedClusterAddOn in ManagedCluster namespace successfully", func() {
74+
ginkgo.It("Should disable argocd ManagedClusterAddOn in ManagedCluster namespace successfully", func() {
7575
assertCreatingClusters(cluster1Name)
7676

7777
addons := []string{appMgrAddonName}
@@ -86,7 +86,7 @@ var _ = ginkgo.Describe("addon disable", func() {
8686
gomega.Expect(err).ToNot(gomega.HaveOccurred())
8787
})
8888

89-
ginkgo.It("Should disable application-manager ManagedClusterAddOns in each ManagedCluster namespace successfully", func() {
89+
ginkgo.It("Should disable argocd ManagedClusterAddOns in each ManagedCluster namespace successfully", func() {
9090
assertCreatingClusters(cluster1Name)
9191
assertCreatingClusters(cluster2Name)
9292

pkg/cmd/addon/enable/cmd.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import (
1414
var example = `
1515
## Application Manager
1616
17-
# Enable application-manager addon on the given managed clusters in the specified namespace
18-
%[1]s addon enable --names application-manager --namespace namespace --clusters cluster1,cluster2
19-
# Enable application-manager addon for specified clusters
20-
%[1]s addon enable --names application-manager --clusters cluster1,cluster2
17+
# Enable argocd addon on the given managed clusters in the specified namespace
18+
%[1]s addon enable --names argocd --namespace namespace --clusters cluster1,cluster2
19+
# Enable argocd addon for specified clusters
20+
%[1]s addon enable --names argocd --clusters cluster1,cluster2
2121
2222
## Policy Framework
2323

pkg/cmd/addon/enable/exec_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var _ = ginkgo.Describe("addon enable", func() {
2222

2323
// Array of addons to check
2424
var addons = []string{
25-
"application-manager",
25+
"argocd",
2626
"governance-policy-framework",
2727
"config-policy-controller",
2828
}

pkg/cmd/create/sampleapp/cmd.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515
var example = `
1616
# Create a sample app
1717
%[1]s create sampleapp sampleapp1
18-
# Create a sample app on specified namespace
19-
%[1]s create sampleapp sampleapp1 --namespace namespace1
2018
`
2119

2220
// NewCmd...
@@ -25,8 +23,8 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream
2523

2624
cmd := &cobra.Command{
2725
Use: "sampleapp",
28-
Short: "Create a sample app",
29-
Long: "Create a sample app, by generating Helm ngix deployment yamls",
26+
Short: "Create a sample Argo CD ApplicationSet",
27+
Long: "Create a sample Argo CD ApplicationSet",
3028
Example: fmt.Sprintf(example, clusteradmhelpers.GetExampleHeader()),
3129
SilenceUsage: true,
3230
PreRunE: func(c *cobra.Command, args []string) error {
@@ -50,7 +48,6 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream
5048
}
5149

5250
cmd.Flags().StringVar(&o.OutputFile, "output-file", "", "The generated resources will be copied in the specified file")
53-
cmd.Flags().StringVarP(&o.Namespace, "namespace", "n", "default", "Specified namespace to deploy sample app")
5451

5552
return cmd
5653
}

pkg/cmd/create/sampleapp/exec.go

+1-42
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package sampleapp
44

55
import (
6-
"context"
76
"errors"
87
"fmt"
98
"os"
@@ -13,17 +12,13 @@ import (
1312
"open-cluster-management.io/clusteradm/pkg/helpers/reader"
1413

1514
"github.com/spf13/cobra"
16-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1715
clusterclientset "open-cluster-management.io/api/client/cluster/clientset/versioned"
1816
"open-cluster-management.io/clusteradm/pkg/cmd/create/sampleapp/scenario"
1917
)
2018

2119
const (
2220
defaultSampleAppName = "sampleapp"
2321
pathToAppManifests = "scenario/sampleapp"
24-
clusterSetLabel = "cluster.open-cluster-management.io/clusterset"
25-
placementLabel = "placement"
26-
placementLabelValue = "sampleapp"
2722
)
2823

2924
func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
@@ -67,48 +62,12 @@ func (o *Options) Run() (err error) {
6762

6863
func (o *Options) runWithClient(clusterClient clusterclientset.Interface, dryRun bool) error {
6964

70-
// Label all managed clusters with clusterset and placement labels
71-
err := o.checkManagedClusterBinding(clusterClient, dryRun)
72-
if err != nil {
73-
return err
74-
}
75-
7665
// Apply sample application manifest to hub cluster
77-
err = o.deployApp()
78-
if err != nil {
79-
return err
80-
}
81-
82-
return nil
83-
}
84-
85-
func (o *Options) checkManagedClusterBinding(clusterClient clusterclientset.Interface, dryRun bool) error {
86-
87-
// Skip if dryRun
88-
if dryRun {
89-
return nil
90-
}
91-
92-
// Get managed clusters
93-
clusters, err := clusterClient.ClusterV1().ManagedClusters().List(context.TODO(), metav1.ListOptions{})
66+
err := o.deployApp()
9467
if err != nil {
9568
return err
9669
}
9770

98-
// Check for binding labels in managed clusters
99-
for _, cluster := range clusters.Items {
100-
managedCluster, err := clusterClient.ClusterV1().ManagedClusters().Get(context.TODO(), cluster.Name, metav1.GetOptions{})
101-
if err != nil {
102-
return err
103-
}
104-
if cs, ok := managedCluster.Labels[clusterSetLabel]; !ok || (cs != fmt.Sprintf("app-%s", o.SampleAppName)) {
105-
fmt.Fprintf(o.Streams.Out, "[WARNING] Label \"%s=%s\" has not been found in ManagedCluster %s, could not establish binding.\n", clusterSetLabel, fmt.Sprintf("app-%s", o.SampleAppName), cluster.Name)
106-
}
107-
if p, ok := managedCluster.Labels[placementLabel]; !ok || (p != placementLabelValue) {
108-
fmt.Fprintf(o.Streams.Out, "[WARNING] Label \"%s=%s\" has not been found in ManagedCluster %s, could not establish binding.\n", placementLabel, placementLabelValue, cluster.Name)
109-
}
110-
}
111-
11271
return nil
11372
}
11473

0 commit comments

Comments
 (0)