Remove BindAddress & SecurePort of karmada-agent

Signed-off-by: whitewindmills <jayfantasyhjh@gmail.com>
This commit is contained in:
whitewindmills 2024-09-14 10:44:27 +08:00
parent e76ce6355b
commit f33bc3820f
2 changed files with 3 additions and 34 deletions

View File

@ -78,10 +78,6 @@ func NewAgentCommand(ctx context.Context) *cobra.Command {
plane and sync manifests from the Karmada control plane to the member cluster. In addition, it also syncs the status of member plane and sync manifests from the Karmada control plane to the member cluster. In addition, it also syncs the status of member
cluster and manifests to the Karmada control plane.`, cluster and manifests to the Karmada control plane.`,
RunE: func(_ *cobra.Command, _ []string) error { RunE: func(_ *cobra.Command, _ []string) error {
// complete options
if err := opts.Complete(); err != nil {
return err
}
// validate options // validate options
if errs := opts.Validate(); len(errs) != 0 { if errs := opts.Validate(); len(errs) != 0 {
return errs.ToAggregate() return errs.ToAggregate()

View File

@ -18,8 +18,6 @@ package options
import ( import (
"fmt" "fmt"
"net"
"strconv"
"strings" "strings"
"time" "time"
@ -37,8 +35,6 @@ import (
const ( const (
// DefaultKarmadaClusterNamespace defines the default namespace where the member cluster secrets are stored. // DefaultKarmadaClusterNamespace defines the default namespace where the member cluster secrets are stored.
DefaultKarmadaClusterNamespace = "karmada-cluster" DefaultKarmadaClusterNamespace = "karmada-cluster"
defaultBindAddress = "0.0.0.0"
defaultPort = 10357
) )
var ( var (
@ -50,15 +46,8 @@ var (
// Options contains everything necessary to create and run controller-manager. // Options contains everything necessary to create and run controller-manager.
type Options struct { type Options struct {
// Controllers contains all controller names. // Controllers contains all controller names.
Controllers []string Controllers []string
LeaderElection componentbaseconfig.LeaderElectionConfiguration LeaderElection componentbaseconfig.LeaderElectionConfiguration
// BindAddress is the IP address on which to listen for the --secure-port port.
// Deprecated: Use HealthProbeBindAddress instead. And will be removed in release 1.12+.
BindAddress string
// SecurePort is the port that the the server serves at.
// Note: We hope support https in the future once controller-runtime provides the functionality.
// Deprecated: Use HealthProbeBindAddress instead. And will be removed in release 1.12+.
SecurePort int
KarmadaKubeConfig string KarmadaKubeConfig string
// ClusterContext is the name of the cluster context in control plane KUBECONFIG file. // ClusterContext is the name of the cluster context in control plane KUBECONFIG file.
// Default value is the current-context. // Default value is the current-context.
@ -173,14 +162,6 @@ func (o *Options) AddFlags(fs *pflag.FlagSet, allControllers []string) {
"A list of controllers to enable. '*' enables all on-by-default controllers, 'foo' enables the controller named 'foo', '-foo' disables the controller named 'foo'. All controllers: %s.", "A list of controllers to enable. '*' enables all on-by-default controllers, 'foo' enables the controller named 'foo', '-foo' disables the controller named 'foo'. All controllers: %s.",
strings.Join(allControllers, ", "), strings.Join(allControllers, ", "),
)) ))
fs.StringVar(&o.BindAddress, "bind-address", defaultBindAddress,
"The IP address on which to listen for the --secure-port port.")
fs.IntVar(&o.SecurePort, "secure-port", defaultPort,
"The secure port on which to serve HTTPS.")
// nolint: errcheck
fs.MarkDeprecated("bind-address", "This flag is deprecated and will be removed in release 1.12+. Use --health-probe-bind-address instead.")
// nolint: errcheck
fs.MarkDeprecated("secure-port", "This flag is deprecated and will be removed in release 1.12+. Use --health-probe-bind-address instead.")
fs.BoolVar(&o.LeaderElection.LeaderElect, "leader-elect", true, "Start a leader election client and gain leadership before executing the main loop. Enable this when running replicated components for high availability.") fs.BoolVar(&o.LeaderElection.LeaderElect, "leader-elect", true, "Start a leader election client and gain leadership before executing the main loop. Enable this when running replicated components for high availability.")
fs.StringVar(&o.LeaderElection.ResourceNamespace, "leader-elect-resource-namespace", util.NamespaceKarmadaSystem, "The namespace of resource object that is used for locking during leader election.") fs.StringVar(&o.LeaderElection.ResourceNamespace, "leader-elect-resource-namespace", util.NamespaceKarmadaSystem, "The namespace of resource object that is used for locking during leader election.")
fs.DurationVar(&o.LeaderElection.LeaseDuration.Duration, "leader-elect-lease-duration", defaultElectionLeaseDuration.Duration, ""+ fs.DurationVar(&o.LeaderElection.LeaseDuration.Duration, "leader-elect-lease-duration", defaultElectionLeaseDuration.Duration, ""+
@ -219,7 +200,7 @@ func (o *Options) AddFlags(fs *pflag.FlagSet, allControllers []string) {
fs.IntVar(&o.ConcurrentWorkSyncs, "concurrent-work-syncs", 5, "The number of Works that are allowed to sync concurrently.") fs.IntVar(&o.ConcurrentWorkSyncs, "concurrent-work-syncs", 5, "The number of Works that are allowed to sync concurrently.")
fs.StringSliceVar(&o.ReportSecrets, "report-secrets", []string{"KubeCredentials", "KubeImpersonator"}, "The secrets that are allowed to be reported to the Karmada control plane during registering. Valid values are 'KubeCredentials', 'KubeImpersonator' and 'None'. e.g 'KubeCredentials,KubeImpersonator' or 'None'.") fs.StringSliceVar(&o.ReportSecrets, "report-secrets", []string{"KubeCredentials", "KubeImpersonator"}, "The secrets that are allowed to be reported to the Karmada control plane during registering. Valid values are 'KubeCredentials', 'KubeImpersonator' and 'None'. e.g 'KubeCredentials,KubeImpersonator' or 'None'.")
fs.StringVar(&o.MetricsBindAddress, "metrics-bind-address", ":8080", "The TCP address that the controller should bind to for serving prometheus metrics(e.g. 127.0.0.1:8080, :8080). It can be set to \"0\" to disable the metrics serving.") fs.StringVar(&o.MetricsBindAddress, "metrics-bind-address", ":8080", "The TCP address that the controller should bind to for serving prometheus metrics(e.g. 127.0.0.1:8080, :8080). It can be set to \"0\" to disable the metrics serving.")
fs.StringVar(&o.HealthProbeBindAddress, "health-probe-bind-address", "", "The TCP address that the controller should bind to for serving health probes(e.g. 127.0.0.1:10357, :10357). It can be set to \"0\" to disable serving the health probe. Defaults to 0.0.0.0:10357.") fs.StringVar(&o.HealthProbeBindAddress, "health-probe-bind-address", ":10357", "The TCP address that the controller should bind to for serving health probes(e.g. 127.0.0.1:10357, :10357). It can be set to \"0\" to disable serving the health probe. Defaults to 0.0.0.0:10357.")
fs.StringVar(&o.ClusterProvider, "cluster-provider", "", "Provider of the joining cluster. The Karmada scheduler can use this information to spread workloads across providers for higher availability.") fs.StringVar(&o.ClusterProvider, "cluster-provider", "", "Provider of the joining cluster. The Karmada scheduler can use this information to spread workloads across providers for higher availability.")
fs.StringVar(&o.ClusterRegion, "cluster-region", "", "The region of the joining cluster. The Karmada scheduler can use this information to spread workloads across regions for higher availability.") fs.StringVar(&o.ClusterRegion, "cluster-region", "", "The region of the joining cluster. The Karmada scheduler can use this information to spread workloads across regions for higher availability.")
fs.StringSliceVar(&o.ClusterZones, "cluster-zones", []string{}, "The zones of the joining cluster. The Karmada scheduler can use this information to spread workloads across zones for higher availability.") fs.StringSliceVar(&o.ClusterZones, "cluster-zones", []string{}, "The zones of the joining cluster. The Karmada scheduler can use this information to spread workloads across zones for higher availability.")
@ -233,11 +214,3 @@ func (o *Options) AddFlags(fs *pflag.FlagSet, allControllers []string) {
features.FeatureGate.AddFlag(fs) features.FeatureGate.AddFlag(fs)
o.ProfileOpts.AddFlags(fs) o.ProfileOpts.AddFlags(fs)
} }
// Complete ensures that options are valid and marshals them if necessary.
func (o *Options) Complete() error {
if len(o.HealthProbeBindAddress) == 0 {
o.HealthProbeBindAddress = net.JoinHostPort(o.BindAddress, strconv.Itoa(o.SecurePort))
}
return nil
}