diff --git a/go.mod b/go.mod index 6d00a63eb..9278ac5df 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( open-cluster-management.io/api v0.15.1-0.20241106012558-db876bf4ff8a open-cluster-management.io/cluster-proxy v0.4.0 open-cluster-management.io/managed-serviceaccount v0.6.0 - open-cluster-management.io/ocm v0.15.0 + open-cluster-management.io/ocm v0.15.2 open-cluster-management.io/sdk-go v0.15.0 sigs.k8s.io/apiserver-network-proxy v0.29.0 sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0 diff --git a/go.sum b/go.sum index dd32f79f2..7c44895ed 100644 --- a/go.sum +++ b/go.sum @@ -578,8 +578,8 @@ open-cluster-management.io/cluster-proxy v0.4.0 h1:rm0UDaDWe3/P3xLzwqdHtqNksKwSz open-cluster-management.io/cluster-proxy v0.4.0/go.mod h1:gTvfDHAhGezhdg4BD3ECBn6jbg2Y5PbHhV2ceW5nrB0= open-cluster-management.io/managed-serviceaccount v0.6.0 h1:qIi5T9WQJBuoGqnYGIktXbtqfQoiN2H9XU2P/6lAQiw= open-cluster-management.io/managed-serviceaccount v0.6.0/go.mod h1:G4LUTbZiyrB8c0+rqi/xnDmGlsg7Rdr4T7MPLCWhyQI= -open-cluster-management.io/ocm v0.15.0 h1:anXQzvQUhM/DT8FcKVi4n8AY97IA5DVI0mb8R1wsvbs= -open-cluster-management.io/ocm v0.15.0/go.mod h1:d6ubRiBaouiQ+yV+wFAmarpU7I77nXhkJnQJf8gLZC4= +open-cluster-management.io/ocm v0.15.2 h1:i1b3a7mRrRVJlw9rooEFmZuHdaRVrmfoBOuEDfyxklI= +open-cluster-management.io/ocm v0.15.2/go.mod h1:d6ubRiBaouiQ+yV+wFAmarpU7I77nXhkJnQJf8gLZC4= open-cluster-management.io/sdk-go v0.15.0 h1:2IAJnPfUoY6rPC5w7LhqAnvIlgekPoVW03LdZO1unIM= open-cluster-management.io/sdk-go v0.15.0/go.mod h1:fi5WBsbC5K3txKb8eRLuP0Sim/Oqz/PHX18skAEyjiA= oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo= diff --git a/pkg/cmd/init/exec.go b/pkg/cmd/init/exec.go index e08c1b718..1040c47f4 100644 --- a/pkg/cmd/init/exec.go +++ b/pkg/cmd/init/exec.go @@ -188,12 +188,14 @@ func (o *Options) run() error { } if !o.ClusteradmFlags.DryRun { - if err := helperwait.WaitUntilCRDReady(apiExtensionsClient, "clustermanagers.operator.open-cluster-management.io", o.wait); err != nil { + if err := helperwait.WaitUntilCRDReady( + o.Streams.Out, apiExtensionsClient, "clustermanagers.operator.open-cluster-management.io", o.wait); err != nil { return err } } if o.wait && !o.ClusteradmFlags.DryRun { if err := helperwait.WaitUntilRegistrationOperatorReady( + o.Streams.Out, o.ClusteradmFlags.KubectlFactory, int64(o.ClusteradmFlags.Timeout)); err != nil { return err @@ -202,6 +204,7 @@ func (o *Options) run() error { if o.wait && !o.ClusteradmFlags.DryRun { if err := helperwait.WaitUntilClusterManagerRegistrationReady( + o.Streams.Out, o.ClusteradmFlags.KubectlFactory, int64(o.ClusteradmFlags.Timeout)); err != nil { return err @@ -318,6 +321,7 @@ func (o *Options) deploySingletonControlplane(kubeClient kubernetes.Interface) e // fetch the kubeconfig and get the token if o.wait && !o.ClusteradmFlags.DryRun { if err := helperwait.WaitUntilMulticlusterControlplaneReady( + o.Streams.Out, o.ClusteradmFlags.KubectlFactory, o.SingletonName, int64(o.ClusteradmFlags.Timeout)); err != nil { diff --git a/pkg/cmd/join/exec.go b/pkg/cmd/join/exec.go index e571ad425..bd89d6426 100644 --- a/pkg/cmd/join/exec.go +++ b/pkg/cmd/join/exec.go @@ -8,6 +8,7 @@ import ( "encoding/pem" "fmt" gherrors "github.com/pkg/errors" + "io" "os" "reflect" "strings" @@ -395,13 +396,15 @@ func (o *Options) applyKlusterlet(r *reader.ResourceReader, operatorClient opera } if !o.ClusteradmFlags.DryRun { - if err := wait.WaitUntilCRDReady(apiExtensionsClient, "klusterlets.operator.open-cluster-management.io", o.wait); err != nil { + if err := wait.WaitUntilCRDReady( + o.Streams.Out, apiExtensionsClient, "klusterlets.operator.open-cluster-management.io", o.wait); err != nil { return err } } if !available && o.wait && !o.ClusteradmFlags.DryRun { - err = waitUntilRegistrationOperatorConditionIsTrue(o.ClusteradmFlags.KubectlFactory, int64(o.ClusteradmFlags.Timeout)) + err = waitUntilRegistrationOperatorConditionIsTrue( + o.Streams.Out, o.ClusteradmFlags.KubectlFactory, int64(o.ClusteradmFlags.Timeout)) if err != nil { return err } @@ -409,12 +412,14 @@ func (o *Options) applyKlusterlet(r *reader.ResourceReader, operatorClient opera if o.wait && !o.ClusteradmFlags.DryRun { if o.mode == string(operatorv1.InstallModeHosted) { - err = waitUntilKlusterletConditionIsTrue(operatorClient, int64(o.ClusteradmFlags.Timeout), o.klusterletChartConfig.Klusterlet.Name) + err = waitUntilKlusterletConditionIsTrue( + o.Streams.Out, operatorClient, int64(o.ClusteradmFlags.Timeout), o.klusterletChartConfig.Klusterlet.Name) if err != nil { return err } } else { - err = waitUntilKlusterletConditionIsTrue(operatorClient, int64(o.ClusteradmFlags.Timeout), o.klusterletChartConfig.Klusterlet.Name) + err = waitUntilKlusterletConditionIsTrue( + o.Streams.Out, operatorClient, int64(o.ClusteradmFlags.Timeout), o.klusterletChartConfig.Klusterlet.Name) if err != nil { return err } @@ -475,6 +480,7 @@ func (o *Options) waitUntilManagedClusterIsCreated(timeout int64, clusterName st phase := &atomic.Value{} phase.Store("") operatorSpinner := printer.NewSpinnerWithStatus( + o.Streams.Out, "Waiting for managed cluster to be created...", time.Millisecond*500, "Managed cluster is created.\n", @@ -505,7 +511,7 @@ func (o *Options) waitUntilManagedClusterIsCreated(timeout int64, clusterName st }) } -func waitUntilRegistrationOperatorConditionIsTrue(f util.Factory, timeout int64) error { +func waitUntilRegistrationOperatorConditionIsTrue(w io.Writer, f util.Factory, timeout int64) error { var restConfig *rest.Config restConfig, err := f.ToRESTConfig() if err != nil { @@ -519,6 +525,7 @@ func waitUntilRegistrationOperatorConditionIsTrue(f util.Factory, timeout int64) phase := &atomic.Value{} phase.Store("") operatorSpinner := printer.NewSpinnerWithStatus( + w, "Waiting for registration operator to become ready...", time.Millisecond*500, "Registration operator is now available.\n", @@ -556,10 +563,12 @@ func waitUntilRegistrationOperatorConditionIsTrue(f util.Factory, timeout int64) } // Wait until the klusterlet condition available=true, or timeout in $timeout seconds -func waitUntilKlusterletConditionIsTrue(client operatorclient.Interface, timeout int64, klusterletName string) error { +func waitUntilKlusterletConditionIsTrue( + w io.Writer, client operatorclient.Interface, timeout int64, klusterletName string) error { phase := &atomic.Value{} phase.Store("") klusterletSpinner := printer.NewSpinnerWithStatus( + w, "Waiting for klusterlet agent to become ready...", time.Millisecond*500, "Klusterlet is now available.\n", diff --git a/pkg/cmd/upgrade/clustermanager/exec.go b/pkg/cmd/upgrade/clustermanager/exec.go index c2a16fa56..0c630818c 100644 --- a/pkg/cmd/upgrade/clustermanager/exec.go +++ b/pkg/cmd/upgrade/clustermanager/exec.go @@ -102,12 +102,14 @@ func (o *Options) run() error { } if !o.ClusteradmFlags.DryRun { - if err := wait.WaitUntilCRDReady(apiExtensionsClient, "clustermanagers.operator.open-cluster-management.io", o.wait); err != nil { + if err := wait.WaitUntilCRDReady( + o.Streams.Out, apiExtensionsClient, "clustermanagers.operator.open-cluster-management.io", o.wait); err != nil { return err } } if o.wait && !o.ClusteradmFlags.DryRun { if err := wait.WaitUntilRegistrationOperatorReady( + o.Streams.Out, o.ClusteradmFlags.KubectlFactory, int64(o.ClusteradmFlags.Timeout)); err != nil { return err diff --git a/pkg/cmd/upgrade/klusterlet/exec.go b/pkg/cmd/upgrade/klusterlet/exec.go index 190efee24..dfc3f6e98 100644 --- a/pkg/cmd/upgrade/klusterlet/exec.go +++ b/pkg/cmd/upgrade/klusterlet/exec.go @@ -118,12 +118,14 @@ func (o *Options) run() error { } if !o.ClusteradmFlags.DryRun { - if err := wait.WaitUntilCRDReady(apiExtensionsClient, "klusterlets.operator.open-cluster-management.io", o.wait); err != nil { + if err := wait.WaitUntilCRDReady( + o.Streams.Out, apiExtensionsClient, "klusterlets.operator.open-cluster-management.io", o.wait); err != nil { return err } } if o.wait && !o.ClusteradmFlags.DryRun { if err := wait.WaitUntilRegistrationOperatorReady( + o.Streams.Out, o.ClusteradmFlags.KubectlFactory, int64(o.ClusteradmFlags.Timeout)); err != nil { return err diff --git a/pkg/helpers/printer/prefixwriter.go b/pkg/helpers/printer/prefixwriter.go index 5a82a1c49..209ac6c90 100644 --- a/pkg/helpers/printer/prefixwriter.go +++ b/pkg/helpers/printer/prefixwriter.go @@ -69,17 +69,19 @@ type flusher interface { Flush() } -func NewSpinner(suffix string, interval time.Duration) *spinner.Spinner { +func NewSpinner(w io.Writer, suffix string, interval time.Duration) *spinner.Spinner { return spinner.New( spinner.CharSets[14], interval, + spinner.WithWriter(w), spinner.WithColor("green"), spinner.WithHiddenCursor(true), spinner.WithSuffix(suffixColor.Sprintf(" %s", suffix))) } -func NewSpinnerWithStatus(suffix string, interval time.Duration, final string, statusFunc func() string) *spinner.Spinner { - s := NewSpinner(suffix, interval) +func NewSpinnerWithStatus( + w io.Writer, suffix string, interval time.Duration, final string, statusFunc func() string) *spinner.Spinner { + s := NewSpinner(w, suffix, interval) s.FinalMSG = final s.PreUpdate = func(s *spinner.Spinner) { status := statusFunc() diff --git a/pkg/helpers/wait/wait.go b/pkg/helpers/wait/wait.go index 84d142f2b..78aacf82a 100644 --- a/pkg/helpers/wait/wait.go +++ b/pkg/helpers/wait/wait.go @@ -4,6 +4,7 @@ package wait import ( "context" "fmt" + "io" "sync/atomic" "time" @@ -21,12 +22,12 @@ import ( "open-cluster-management.io/clusteradm/pkg/helpers/printer" ) -func WaitUntilCRDReady(apiExtensionsClient apiextensionsclient.Interface, crdName string, wait bool) error { +func WaitUntilCRDReady(w io.Writer, apiExtensionsClient apiextensionsclient.Interface, crdName string, wait bool) error { b := retry.DefaultBackoff b.Duration = 200 * time.Millisecond if wait { - crdSpinner := printer.NewSpinner("Waiting for CRD to be ready...", time.Second) + crdSpinner := printer.NewSpinner(w, "Waiting for CRD to be ready...", time.Second) crdSpinner.FinalMSG = "CRD successfully registered.\n" crdSpinner.Start() defer crdSpinner.Stop() @@ -34,7 +35,7 @@ func WaitUntilCRDReady(apiExtensionsClient apiextensionsclient.Interface, crdNam return helpers.WaitCRDToBeReady(apiExtensionsClient, crdName, b, wait) } -func WaitUntilRegistrationOperatorReady(f util.Factory, timeout int64) error { +func WaitUntilRegistrationOperatorReady(w io.Writer, f util.Factory, timeout int64) error { var restConfig *rest.Config restConfig, err := f.ToRESTConfig() if err != nil { @@ -49,6 +50,7 @@ func WaitUntilRegistrationOperatorReady(f util.Factory, timeout int64) error { phase.Store("") text := "Waiting for registration operator to become ready..." operatorSpinner := printer.NewSpinnerWithStatus( + w, text, time.Second, "Registration operator is now available.\n", @@ -85,7 +87,7 @@ func WaitUntilRegistrationOperatorReady(f util.Factory, timeout int64) error { }) } -func WaitUntilClusterManagerRegistrationReady(f util.Factory, timeout int64) error { +func WaitUntilClusterManagerRegistrationReady(w io.Writer, f util.Factory, timeout int64) error { var restConfig *rest.Config restConfig, err := f.ToRESTConfig() if err != nil { @@ -100,6 +102,7 @@ func WaitUntilClusterManagerRegistrationReady(f util.Factory, timeout int64) err phase.Store("") text := "Waiting for cluster manager registration to become ready..." clusterManagerSpinner := printer.NewSpinnerWithStatus( + w, text, time.Second, "ClusterManager registration is now available.\n", @@ -136,7 +139,7 @@ func WaitUntilClusterManagerRegistrationReady(f util.Factory, timeout int64) err }) } -func WaitUntilMulticlusterControlplaneReady(f util.Factory, ns string, timeout int64) error { +func WaitUntilMulticlusterControlplaneReady(w io.Writer, f util.Factory, ns string, timeout int64) error { var restConfig *rest.Config restConfig, err := f.ToRESTConfig() if err != nil { @@ -151,6 +154,7 @@ func WaitUntilMulticlusterControlplaneReady(f util.Factory, ns string, timeout i phase.Store("") text := "Waiting for multicluster controlplane to become ready..." clusterManagerSpinner := printer.NewSpinnerWithStatus( + w, text, time.Second, "Multicluster controlplane is now available.\n", diff --git a/pkg/version/version.go b/pkg/version/version.go index 39c2f9c04..0c69b60b7 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -42,7 +42,7 @@ type VersionBundle struct { MulticlusterControlplane string } -var defaultBundleVersion = "0.15.0" +var defaultBundleVersion = "0.15.2" func GetDefaultBundleVersion() string { return defaultBundleVersion @@ -106,6 +106,13 @@ func GetVersionBundle(version string) (VersionBundle, error) { MulticlusterControlplane: "v0.6.0", } + versionBundleList["0.15.2"] = VersionBundle{ + OCM: "v0.15.2", + AppAddon: "v0.15.0", + PolicyAddon: "v0.15.0", + MulticlusterControlplane: "v0.6.0", + } + // default versionBundleList["default"] = versionBundleList[defaultBundleVersion] diff --git a/vendor/modules.txt b/vendor/modules.txt index 1a61b6001..fae92f310 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1261,7 +1261,7 @@ open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versio open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versioned/scheme open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versioned/typed/authentication/v1alpha1 open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versioned/typed/authentication/v1beta1 -# open-cluster-management.io/ocm v0.15.0 +# open-cluster-management.io/ocm v0.15.2 ## explicit; go 1.22.5 open-cluster-management.io/ocm/deploy/cluster-manager/chart open-cluster-management.io/ocm/deploy/klusterlet/chart diff --git a/vendor/open-cluster-management.io/ocm/deploy/cluster-manager/chart/cluster-manager/README.md b/vendor/open-cluster-management.io/ocm/deploy/cluster-manager/chart/cluster-manager/README.md index c93702b91..8c5ee471a 100644 --- a/vendor/open-cluster-management.io/ocm/deploy/cluster-manager/chart/cluster-manager/README.md +++ b/vendor/open-cluster-management.io/ocm/deploy/cluster-manager/chart/cluster-manager/README.md @@ -3,7 +3,7 @@ The cluster-manager provides the multicluster hub, which can manage Kubernetes-based clusters across data centers, public clouds, and private clouds. This operator supports the installation and upgrade of ClusterManager. -# Get Repo Info +## Get Repo Info ```bash helm repo add ocm https://open-cluster-management.io/helm-charts @@ -11,31 +11,30 @@ helm repo update helm search repo ocm ``` -# Install the Chart +## Install the Chart For example, install the chart into `open-cluster-management` namespace. ```bash -$ helm install cluster-manager --version ocm/cluster-manager --namespace=open-cluster-management --create-namespace +helm install cluster-manager --version ocm/cluster-manager --namespace=open-cluster-management --create-namespace ``` -# Uninstall the Chart +## Uninstall -## Delete all managedClusters before uninstall the Chart. +### Delete all managedClusters before uninstall the Chart ```bash kubectl get managedcluster | awk '{print $1}' | xargs kubectl delete managedcluster ``` -## And then delete the clusterManager CR. +### And then delete the clusterManager CR ``` bash kubectl delete clustermanagers cluster-manager ``` -## Uninstall the Chart +### Uninstall the Chart ```bash -helm uninstall cluster-manager +helm uninstall cluster-manager --namespace=open-cluster-management ``` - diff --git a/vendor/open-cluster-management.io/ocm/deploy/klusterlet/chart/klusterlet/README.md b/vendor/open-cluster-management.io/ocm/deploy/klusterlet/chart/klusterlet/README.md index aebada2ec..6b2168d33 100644 --- a/vendor/open-cluster-management.io/ocm/deploy/klusterlet/chart/klusterlet/README.md +++ b/vendor/open-cluster-management.io/ocm/deploy/klusterlet/chart/klusterlet/README.md @@ -3,11 +3,11 @@ The klusterlet provides the registration to the Hub clusters as a managed cluster. This operator supports the installation and upgrade of klusterlet. -# Prerequisites +## Prerequisites You need a Hub cluster which has installed clusterManager operator. -# Get Repo Info +## Get Repo Info ```bash helm repo add ocm https://open-cluster-management.io/helm-charts @@ -15,9 +15,9 @@ helm repo update helm search repo ocm ``` -# Install the Chart +## Install the Chart -### Run klusterlet on Default mode. +### Run klusterlet on Default mode Install the Chart on the managed cluster: @@ -43,7 +43,7 @@ helm install klusterlet --version ocm/klusterlet \ > You can create the `bootstrap-hub-kubeconfig` secret in the `open-cluster-management-agent` namespace > after install the chart without setting `bootstrapHubKubeConfig`. -### Run klusterlet on Hosted mode. +### Run klusterlet on Hosted mode Install the Chart on the hosting cluster without installing operator: @@ -68,17 +68,16 @@ helm install --version ocm/klusterlet \ > You can create the `bootstrap-hub-kubeconfig` and `externalManagedKubeConfig` secrets in the `klusterlet-` namespace > after install the chart without setting `bootstrapHubKubeConfig` and `externalManagedKubeConfig`. +## Uninstall -# Uninstall the Chart - -## Delete the klusterlet CR. +### Delete the klusterlet CR ``` bash kubectl delete klusterlet ``` -## Uninstall the Chart +### Uninstall the Chart ```bash -helm uninstall +helm uninstall klusterlet --namespace=open-cluster-management ```