Skip to content

Commit 6a21472

Browse files
qiujian16arturshadnikmikeshngahmad-ibra
authored
🐛 Cherry pick and bump to ocm 0.16.1 (#487)
* ✨ Expose ManagedCluster annotations during join via clusteradm flag (#481) * feat: expose klusterlet/managedcluster annotations via clusteradm flags Signed-off-by: Artur Shad Nik <[email protected]> * feat: improve handling annotations; add e2e test Signed-off-by: Artur Shad Nik <[email protected]> * test: simplify assertion Signed-off-by: Artur Shad Nik <[email protected]> --------- Signed-off-by: Artur Shad Nik <[email protected]> * feat: remove existing application-manager addon and add new argocd pull model addon (#483) Signed-off-by: Mike Ng <[email protected]> * feat: add --managed-cluster-arn flag to clusteradm join command (#486) Signed-off-by: Ahmad Ibrahim <[email protected]> * bump to ocm 0.16.1 Signed-off-by: Jian Qiu <[email protected]> --------- Signed-off-by: Artur Shad Nik <[email protected]> Signed-off-by: Mike Ng <[email protected]> Signed-off-by: Ahmad Ibrahim <[email protected]> Signed-off-by: Jian Qiu <[email protected]> Co-authored-by: Artur Shad Nik <[email protected]> Co-authored-by: Mike Ng <[email protected]> Co-authored-by: Ahmad Malik Ibrahim <[email protected]>
1 parent 73281f6 commit 6a21472

Some content is hidden

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

56 files changed

+325
-2358
lines changed

README.md

Lines changed: 4 additions & 4 deletions
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`

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ require (
2828
k8s.io/klog/v2 v2.130.1
2929
k8s.io/kubectl v0.31.1
3030
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6
31-
open-cluster-management.io/api v0.16.1
31+
open-cluster-management.io/api v0.16.2
3232
open-cluster-management.io/cluster-proxy v0.7.0
3333
open-cluster-management.io/managed-serviceaccount v0.8.0
34-
open-cluster-management.io/ocm v0.16.0
34+
open-cluster-management.io/ocm v0.16.1
3535
open-cluster-management.io/sdk-go v0.16.0
3636
sigs.k8s.io/apiserver-network-proxy v0.29.0
3737
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,14 +563,14 @@ k8s.io/kubectl v0.31.1 h1:ih4JQJHxsEggFqDJEHSOdJ69ZxZftgeZvYo7M/cpp24=
563563
k8s.io/kubectl v0.31.1/go.mod h1:aNuQoR43W6MLAtXQ/Bu4GDmoHlbhHKuyD49lmTC8eJM=
564564
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 h1:MDF6h2H/h4tbzmtIKTuctcwZmY0tY9mD9fNT47QO6HI=
565565
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
566-
open-cluster-management.io/api v0.16.1 h1:mS+4UGxHLPQd7CRM0gdFQdVaz139Lo2bkLfqSE0CDNU=
567-
open-cluster-management.io/api v0.16.1/go.mod h1:9erZEWEn4bEqh0nIX2wA7f/s3KCuFycQdBrPrRzi0QM=
566+
open-cluster-management.io/api v0.16.2 h1:JzpJtgp/qJKjDLEO7o7q5eVLxYkfgxhtagJvWFbaNno=
567+
open-cluster-management.io/api v0.16.2/go.mod h1:9erZEWEn4bEqh0nIX2wA7f/s3KCuFycQdBrPrRzi0QM=
568568
open-cluster-management.io/cluster-proxy v0.7.0 h1:qOok0BIBL6j4mLRArzJdz0gK5nyynGKTwgBvnUHmfkE=
569569
open-cluster-management.io/cluster-proxy v0.7.0/go.mod h1:6cgnExpuprO7Le7aqf7bI3H7Nvu3YnXBJCIbJ7wsC0s=
570570
open-cluster-management.io/managed-serviceaccount v0.8.0 h1:8+Z142IUqVT/enxXkyb0nzLUL7JaR7dBM2fDtlCA4pM=
571571
open-cluster-management.io/managed-serviceaccount v0.8.0/go.mod h1:eTixwpLA6XkPQARDjze3k0KRjwn6N22eFOEFx8CpB0I=
572-
open-cluster-management.io/ocm v0.16.0 h1:oCxhy/Z7Xbzj35p4860dWL2rr7aBk87vSokEeNVFPdk=
573-
open-cluster-management.io/ocm v0.16.0/go.mod h1:M2/9PVwAYtP2Rv9ahsUEcGGXUctPPVlqhzrBKRW4Wzs=
572+
open-cluster-management.io/ocm v0.16.1 h1:OBh0WQ0Ql9TQ5OZfDtmynOk3+aaRBKX8exIVAZQOigA=
573+
open-cluster-management.io/ocm v0.16.1/go.mod h1:yxZYEDhp5JUvRxHNXlBk4Q3yL0+K6pv3BO6kN2uN6s0=
574574
open-cluster-management.io/sdk-go v0.16.0 h1:Ui1jerkeLaNaJPu47xjOJ3lh+rJQgeJHD25ViQMzAMs=
575575
open-cluster-management.io/sdk-go v0.16.0/go.mod h1:TyOjZC5YxyM5BRNgwTmLuTbHXX6xXqzYBXllrfoVp9w=
576576
oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo=

pkg/cmd/addon/disable/cmd.go

Lines changed: 6 additions & 6 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 5 deletions
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

Lines changed: 1 addition & 42 deletions
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)