Skip to content

Commit

Permalink
deprecate cluster-zone flag and introduce cluster-zones flag
Browse files Browse the repository at this point in the history
Signed-off-by: whitewindmills <[email protected]>
  • Loading branch information
whitewindmills committed Aug 24, 2023
1 parent 5e8a765 commit 5237523
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/agent/app/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
18 changes: 17 additions & 1 deletion pkg/karmadactl/join/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -128,7 +136,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.")
}

Expand Down Expand Up @@ -168,6 +179,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,
Expand Down Expand Up @@ -231,6 +243,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
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/util/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ type ClusterRegisterOption struct {
ProxyServerAddress string
ClusterProvider string
ClusterRegion string
ClusterZone string
DryRun bool
// Deprecated: Use ClusterZones instead.
ClusterZone string
ClusterZones []string
DryRun bool

ControlPlaneConfig *rest.Config
ClusterConfig *rest.Config
Expand Down

0 comments on commit 5237523

Please sign in to comment.