Merge pull request #3995 from whitewindmills/deprecated-zone-flag
feat: deprecate cluster-zone flag and introduce cluster-zones flag
This commit is contained in:
commit
4642d9e781
|
@ -405,8 +405,8 @@ func generateClusterInControllerPlane(opts util.ClusterRegisterOption) (*cluster
|
|||
cluster.Spec.Provider = opts.ClusterProvider
|
||||
}
|
||||
|
||||
if opts.ClusterZone != "" {
|
||||
cluster.Spec.Zone = opts.ClusterZone
|
||||
if len(opts.ClusterZones) > 0 {
|
||||
cluster.Spec.Zones = opts.ClusterZones
|
||||
}
|
||||
|
||||
if opts.ClusterRegion != "" {
|
||||
|
|
|
@ -85,8 +85,16 @@ type CommandJoinOption struct {
|
|||
ClusterRegion string
|
||||
|
||||
// ClusterZone represents the zone of the cluster locate in.
|
||||
// Deprecated: Use ClusterZones instead.
|
||||
ClusterZone string
|
||||
|
||||
// ClusterZones represents the failure zones(also called availability zones) of the
|
||||
// member cluster. The zones are presented as a slice to support the case
|
||||
// that cluster runs across multiple failure zones.
|
||||
// Refer https://kubernetes.io/docs/setup/best-practices/multiple-zones/ for
|
||||
// more details about running Kubernetes in multiple zones.
|
||||
ClusterZones []string
|
||||
|
||||
// DryRun tells if run the command in dry-run mode, without making any server requests.
|
||||
DryRun bool
|
||||
}
|
||||
|
@ -116,6 +124,10 @@ func (j *CommandJoinOption) Validate(args []string) error {
|
|||
if j.ClusterNamespace == util.NamespaceKarmadaSystem {
|
||||
klog.Warningf("karmada-system is always reserved for Karmada control plane. We do not recommend using karmada-system to store secrets of member clusters. It may cause mistaken cleanup of resources.")
|
||||
}
|
||||
|
||||
if j.ClusterZone != "" && len(j.ClusterZones) > 0 {
|
||||
return fmt.Errorf("--cluster-zone and --cluster-zones can not co-exist")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -128,7 +140,10 @@ func (j *CommandJoinOption) AddFlags(flags *pflag.FlagSet) {
|
|||
"Path of the cluster's kubeconfig.")
|
||||
flags.StringVar(&j.ClusterProvider, "cluster-provider", "", "Provider of the joining cluster. The Karmada scheduler can use this information to spread workloads across providers for higher availability.")
|
||||
flags.StringVar(&j.ClusterRegion, "cluster-region", "", "The region of the joining cluster. The Karmada scheduler can use this information to spread workloads across regions for higher availability.")
|
||||
flags.StringVar(&j.ClusterZone, "cluster-zone", "", "The zone of the joining cluster")
|
||||
flags.StringVar(&j.ClusterZone, "cluster-zone", "", "The zone of the joining cluster.")
|
||||
// nolint: errcheck
|
||||
flags.MarkDeprecated("cluster-zone", "This flag is deprecated and will be removed in future releases. Use --cluster-zones instead.")
|
||||
flags.StringSliceVar(&j.ClusterZones, "cluster-zones", nil, "The zones of the joining cluster. The Karmada scheduler can use this information to spread workloads across zones for higher availability.")
|
||||
flags.BoolVar(&j.DryRun, "dry-run", false, "Run the command in dry-run mode, without making any server requests.")
|
||||
}
|
||||
|
||||
|
@ -168,6 +183,7 @@ func (j *CommandJoinOption) RunJoinCluster(controlPlaneRestConfig, clusterConfig
|
|||
ClusterProvider: j.ClusterProvider,
|
||||
ClusterRegion: j.ClusterRegion,
|
||||
ClusterZone: j.ClusterZone,
|
||||
ClusterZones: j.ClusterZones,
|
||||
DryRun: j.DryRun,
|
||||
ControlPlaneConfig: controlPlaneRestConfig,
|
||||
ClusterConfig: clusterConfig,
|
||||
|
@ -231,6 +247,10 @@ func generateClusterInControllerPlane(opts util.ClusterRegisterOption) (*cluster
|
|||
clusterObj.Spec.Zone = opts.ClusterZone
|
||||
}
|
||||
|
||||
if len(opts.ClusterZones) > 0 {
|
||||
clusterObj.Spec.Zones = opts.ClusterZones
|
||||
}
|
||||
|
||||
if opts.ClusterRegion != "" {
|
||||
clusterObj.Spec.Region = opts.ClusterRegion
|
||||
}
|
||||
|
|
|
@ -40,7 +40,9 @@ type ClusterRegisterOption struct {
|
|||
ProxyServerAddress string
|
||||
ClusterProvider string
|
||||
ClusterRegion string
|
||||
// Deprecated: Use ClusterZones instead.
|
||||
ClusterZone string
|
||||
ClusterZones []string
|
||||
DryRun bool
|
||||
|
||||
ControlPlaneConfig *rest.Config
|
||||
|
|
Loading…
Reference in New Issue