mirror of https://github.com/k3s-io/k3s
Add `metrics-port` to kube-proxy cmd flags.
parent
5a708017e9
commit
d52ba6413d
|
@ -111,6 +111,8 @@ type Options struct {
|
||||||
master string
|
master string
|
||||||
// healthzPort is the port to be used by the healthz server.
|
// healthzPort is the port to be used by the healthz server.
|
||||||
healthzPort int32
|
healthzPort int32
|
||||||
|
// metricsPort is the port to be used by the metrics server.
|
||||||
|
metricsPort int32
|
||||||
|
|
||||||
scheme *runtime.Scheme
|
scheme *runtime.Scheme
|
||||||
codecs serializer.CodecFactory
|
codecs serializer.CodecFactory
|
||||||
|
@ -134,8 +136,9 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
|
||||||
fs.Var(utilflag.IPVar{Val: &o.config.BindAddress}, "bind-address", "The IP address for the proxy server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
|
fs.Var(utilflag.IPVar{Val: &o.config.BindAddress}, "bind-address", "The IP address for the proxy server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
|
||||||
fs.StringVar(&o.master, "master", o.master, "The address of the Kubernetes API server (overrides any value in kubeconfig)")
|
fs.StringVar(&o.master, "master", o.master, "The address of the Kubernetes API server (overrides any value in kubeconfig)")
|
||||||
fs.Int32Var(&o.healthzPort, "healthz-port", o.healthzPort, "The port to bind the health check server. Use 0 to disable.")
|
fs.Int32Var(&o.healthzPort, "healthz-port", o.healthzPort, "The port to bind the health check server. Use 0 to disable.")
|
||||||
fs.Var(utilflag.IPVar{Val: &o.config.HealthzBindAddress}, "healthz-bind-address", "The IP address and port for the health check server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
|
fs.Var(utilflag.IPVar{Val: &o.config.HealthzBindAddress}, "healthz-bind-address", "The IP address for the health check server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
|
||||||
fs.Var(utilflag.IPVar{Val: &o.config.MetricsBindAddress}, "metrics-bind-address", "The IP address and port for the metrics server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
|
fs.Int32Var(&o.metricsPort, "metrics-port", o.metricsPort, "The port to bind the metrics server. Use 0 to disable.")
|
||||||
|
fs.Var(utilflag.IPVar{Val: &o.config.MetricsBindAddress}, "metrics-bind-address", "The IP address for the metrics server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
|
||||||
fs.Int32Var(o.config.OOMScoreAdj, "oom-score-adj", utilpointer.Int32PtrDerefOr(o.config.OOMScoreAdj, int32(qos.KubeProxyOOMScoreAdj)), "The oom-score-adj value for kube-proxy process. Values must be within the range [-1000, 1000]")
|
fs.Int32Var(o.config.OOMScoreAdj, "oom-score-adj", utilpointer.Int32PtrDerefOr(o.config.OOMScoreAdj, int32(qos.KubeProxyOOMScoreAdj)), "The oom-score-adj value for kube-proxy process. Values must be within the range [-1000, 1000]")
|
||||||
fs.StringVar(&o.config.ResourceContainer, "resource-container", o.config.ResourceContainer, "Absolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy).")
|
fs.StringVar(&o.config.ResourceContainer, "resource-container", o.config.ResourceContainer, "Absolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy).")
|
||||||
fs.MarkDeprecated("resource-container", "This feature will be removed in a later release.")
|
fs.MarkDeprecated("resource-container", "This feature will be removed in a later release.")
|
||||||
|
@ -183,6 +186,7 @@ func NewOptions() *Options {
|
||||||
return &Options{
|
return &Options{
|
||||||
config: new(kubeproxyconfig.KubeProxyConfiguration),
|
config: new(kubeproxyconfig.KubeProxyConfiguration),
|
||||||
healthzPort: ports.ProxyHealthzPort,
|
healthzPort: ports.ProxyHealthzPort,
|
||||||
|
metricsPort: ports.ProxyStatusPort,
|
||||||
scheme: scheme.Scheme,
|
scheme: scheme.Scheme,
|
||||||
codecs: scheme.Codecs,
|
codecs: scheme.Codecs,
|
||||||
CleanupIPVS: true,
|
CleanupIPVS: true,
|
||||||
|
@ -194,6 +198,7 @@ func (o *Options) Complete() error {
|
||||||
if len(o.ConfigFile) == 0 && len(o.WriteConfigTo) == 0 {
|
if len(o.ConfigFile) == 0 && len(o.WriteConfigTo) == 0 {
|
||||||
klog.Warning("WARNING: all flags other than --config, --write-config-to, and --cleanup are deprecated. Please begin using a config file ASAP.")
|
klog.Warning("WARNING: all flags other than --config, --write-config-to, and --cleanup are deprecated. Please begin using a config file ASAP.")
|
||||||
o.applyDeprecatedHealthzPortToConfig()
|
o.applyDeprecatedHealthzPortToConfig()
|
||||||
|
o.applyDeprecatedMetricsPortToConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the config file here in Complete, so that Validate validates the fully-resolved config.
|
// Load the config file here in Complete, so that Validate validates the fully-resolved config.
|
||||||
|
@ -306,6 +311,20 @@ func (o *Options) applyDeprecatedHealthzPortToConfig() {
|
||||||
o.config.HealthzBindAddress = fmt.Sprintf("%s:%d", o.config.HealthzBindAddress, o.healthzPort)
|
o.config.HealthzBindAddress = fmt.Sprintf("%s:%d", o.config.HealthzBindAddress, o.healthzPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *Options) applyDeprecatedMetricsPortToConfig() {
|
||||||
|
if o.metricsPort == 0 {
|
||||||
|
o.config.MetricsBindAddress = ""
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
index := strings.Index(o.config.MetricsBindAddress, ":")
|
||||||
|
if index != -1 {
|
||||||
|
o.config.MetricsBindAddress = o.config.MetricsBindAddress[0:index]
|
||||||
|
}
|
||||||
|
|
||||||
|
o.config.MetricsBindAddress = fmt.Sprintf("%s:%d", o.config.MetricsBindAddress, o.metricsPort)
|
||||||
|
}
|
||||||
|
|
||||||
// loadConfigFromFile loads the contents of file and decodes it as a
|
// loadConfigFromFile loads the contents of file and decodes it as a
|
||||||
// KubeProxyConfiguration object.
|
// KubeProxyConfiguration object.
|
||||||
func (o *Options) loadConfigFromFile(file string) (*kubeproxyconfig.KubeProxyConfiguration, error) {
|
func (o *Options) loadConfigFromFile(file string) (*kubeproxyconfig.KubeProxyConfiguration, error) {
|
||||||
|
|
Loading…
Reference in New Issue