Change:
Whenever I try to change kube proxy metrics bind using flag , it gives me: Then, I the port , the error changes. I expect the metrics server to listen to 0.0.0.0:. Do I miss something? Environment: Kubernetes version: v1.7.8 Cloud provider or hardware configuration**: on-premise OS (e.g. from /etc/os-release): debian/stretch Kernel (e.g. ): Linux R11U2-7U20N-1 4.9.0-3-amd64 SMP Debian 4.9.30-2+deb9u3 (2017-08-06) x86_64 GNU/Linux Install tools: Others:
/sig network /area kube-proxy
The is being and does NOT allow specifying a port. Have you tried using a config file? The field allows you to specify a port (an example ).
/assign
Turned out we use a wrong type when validating and . Sent for fixing this. Will try to cherrypick the fix as well.
New finding, is broken on HEAD in a different way: Seems to be introduced by
Humm..We have some default logic for : Seems like for some reason it does not auto append the default port number OR the validation happens before defaulting.
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. Prevent issues from auto-closing with an comment. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale
Stale issues rot after 30d of inactivity. Mark the issue as fresh with . Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle rotten /remove-lifecycle stale
/remove-lifecycle rotten
I got the same issue 0.0.0.0 0.0.0.0: both not work with kube-proxy 1.9.3 amd64
It is a BUG. Conflict between componentconfig.IPVar.Set(s string) and validation.validateHostPort.
Could you elaborate the issue a bit more? Which k8s version are you on?
I also meet the same issue with kubernetes 1.8. It's impossibe for Prometheus to fetch metrics from 127.0.0.1: in my case, any workaround? I think we'd better reopen this issue.
metrics binds to by default, are you trying to modify port as well? Thanks for reporting, I confirm the issue is remaining. (or any ip:port) does not work as intended even after the fix. Reopening this and filed a new issue for conflict kubeproxyconfig validation. /reopen
Thanks for reopening the issue. I want to bind metrics to 0.0.0.0: as well. With address 127.0.0.1:, Prometheus cannot pull metrics from this address unless they are on the same node.
is fixing this.
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale
/remove-lifecycle stale
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale
/remove-lifecycle stale (I just got bitten by this on kube-proxy v1.9.10)
should fix this.
Closing this as is merged. /close
Closing this issue. <detailsIn response to : Closing this as is merged. /close Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details

Discussion:
fs.Var(componentconfig.IPVar{Val: &options.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(&options.master, "master", options.master, "The address of the Kubernetes API server (overrides any value in kubeconfig)") fs.Int32Var(&options.healthzPort, "healthz-port", options.healthzPort, "The port to bind the health check server. Use 0 to disable.") <del> fs.Var(componentconfig.IPVar{Val: &options.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(componentconfig.IPVar{Val: &options.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)") </del> <ins> fs.Var(componentconfig.IPPortVar{Val: &options.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(componentconfig.IPPortVar{Val: &options.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)") </ins> fs.Int32Var(options.config.OOMScoreAdj, "oom-score-adj", utilpointer.Int32PtrDerefOr(options.config.OOMScoreAdj, int32(qos.KubeProxyOOMScoreAdj)), "The oom-score-adj value for kube-proxy process. Values must be within the range [-1000, 1000]") fs.StringVar(&options.config.ResourceContainer, "resource-container", options.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.")

"encoding/json" "fmt" "net" <ins> "strconv" </ins> "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

return "ip" } <ins> // IPPortVar allows IP or IP:port formats. type IPPortVar struct { Val *string } func (v IPPortVar) Set(s string) error { if len(s) == 0 { v.Val = nil return nil } if v.Val == nil { // it's okay to panic here since this is programmer error panic("the string pointer passed into IPPortVar should not be nil") } // Both IP and IP:port are valid. // Attempt to parse into IP first. if net.ParseIP(s) != nil { *v.Val = s return nil } // Can not parse into IP, now assume IP:port. host, port, err := net.SplitHostPort(s) if err != nil { return fmt.Errorf("%q is not in a valid format (ip or ip:port): %v", s, err) } if net.ParseIP(host) == nil { return fmt.Errorf("%q is not a valid IP address", host) } if _, err := strconv.Atoi(port); err != nil { return fmt.Errorf("%q is not a valid number", port) } *v.Val = s return nil } func (v IPPortVar) String() string { if v.Val == nil { return "" } return *v.Val } func (v IPPortVar) Type() string { return "ipport" } </ins> type PortRangeVar struct { Val *string }

func TestIPVar(t *testing.T) { defaultIP := "0.0.0.0" <del> cases := []struct { </del> <ins> testCases := []struct { </ins> argc      string expectErr bool expectVal string

expectVal: defaultIP, }, } <del> for _, c := range cases { </del> <ins> for _, tc := range testCases { </ins> fs := pflag.NewFlagSet("blah", pflag.PanicOnError) ip := defaultIP fs.Var(IPVar{&ip}, "ip", "the ip")

err = r.(error) } }() <del> fs.Parse(strings.Split(c.argc, " ")) </del> <ins> fs.Parse(strings.Split(tc.argc, " ")) </ins> }() <del> if c.expectErr && err == nil { </del> <ins> if tc.expectErr && err == nil { </ins> t.Errorf("did not observe an expected error") continue } <del> if !c.expectErr && err != nil { t.Errorf("observed an unexpected error") </del> <ins> if !tc.expectErr && err != nil { t.Errorf("observed an unexpected error: %v", err) </ins> continue } <del> if c.expectVal != ip { t.Errorf("unexpected ip: expected %q, saw %q", c.expectVal, ip) </del> <ins> if tc.expectVal != ip { t.Errorf("unexpected ip: expected %q, saw %q", tc.expectVal, ip) } } } func TestIPPortVar(t *testing.T) { defaultIPPort := "0.0.0.0:8080" testCases := []struct { desc      string argc      string expectErr bool expectVal string }{ { desc:      "valid ipv4 1", argc:      "blah --ipport=0.0.0.0", expectVal: "0.0.0.0", }, { desc:      "valid ipv4 2", argc:      "blah --ipport=127.0.0.1", expectVal: "127.0.0.1", }, { desc:      "invalid IP", argc:      "blah --ipport=invalidip", expectErr: true, expectVal: defaultIPPort, }, { desc:      "valid ipv4 with port", argc:      "blah --ipport=0.0.0.0:8080", expectVal: "0.0.0.0:8080", }, { desc:      "invalid ipv4 with invalid port", argc:      "blah --ipport=0.0.0.0:invalidport", expectErr: true, expectVal: defaultIPPort, }, { desc:      "invalid IP with port", argc:      "blah --ipport=invalidip:8080", expectErr: true, expectVal: defaultIPPort, }, { desc:      "valid ipv6 1", argc:      "blah --ipport=::1", expectVal: "::1", }, { desc:      "valid ipv6 2", argc:      "blah --ipport=::", expectVal: "::", }, { desc:      "valid ipv6 with port", argc:      "blah --ipport=[::1]:8080", expectVal: "[::1]:8080", }, { desc:      "invalid ipv6 with port without bracket", argc:      "blah --ipport=fd00:f00d:600d:f00d:8080", expectErr: true, expectVal: defaultIPPort, }, } for _, tc := range testCases { fs := pflag.NewFlagSet("blah", pflag.PanicOnError) ipport := defaultIPPort fs.Var(IPPortVar{&ipport}, "ipport", "the ip:port") var err error func() { defer func() { if r := recover(); r != nil { err = r.(error) } }() fs.Parse(strings.Split(tc.argc, " ")) }() if tc.expectErr && err == nil { t.Errorf("%q: Did not observe an expected error", tc.desc) continue } if !tc.expectErr && err != nil { t.Errorf("%q: Observed an unexpected error: %v", tc.desc, err) continue } if tc.expectVal != ipport { t.Errorf("%q: Unexpected ipport: expected %q, saw %q", tc.desc, tc.expectVal, ipport) </ins> } } }

} // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. <ins> func (in *IPPortVar) DeepCopyInto(out *IPPortVar) { *out = *in if in.Val != nil { in, out := &in.Val, &out.Val if *in == nil { *out = nil } else { *out = new(string) **out = **in } } return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPortVar. func (in *IPPortVar) DeepCopy() *IPPortVar { if in == nil { return nil } out := new(IPPortVar) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. </ins> func (in *IPVar) DeepCopyInto(out *IPVar) { *out = *in if in.Val != nil {