Run metrics when using standlone kube-proxy
The metrics server is started as part of kube-proxy startup so we were
accidentally skipping that when using standalone kube-proxy.
@@ -61,6 +61,7 @@ func (sdn *OpenShiftSDN) initProxy() error {
func (sdn *OpenShiftSDN) runProxy(waitChan chan<- bool) {
if string(sdn.ProxyConfig.Mode) == "disabled" {
klog.Warningf("Built-in kube-proxy is disabled")
+ sdn.startMetricsServer()
close(waitChan)
return
}
@@ -227,7 +228,18 @@ func (sdn *OpenShiftSDN) runProxy(waitChan chan<- bool) {
}
// Start up a metrics server if requested
- if len(sdn.ProxyConfig.MetricsBindAddress) > 0 {
+ sdn.startMetricsServer()
+
+ // periodically sync k8s iptables rules
+ go utilwait.Forever(proxier.SyncLoop, 0)
+ klog.Infof("Started Kubernetes Proxy on %s", sdn.ProxyConfig.BindAddress)
+}
+
+func (sdn *OpenShiftSDN) startMetricsServer() {
+ if sdn.ProxyConfig.MetricsBindAddress == "" {
+ return
+ }
+
mux := mux.NewPathRecorderMux("kube-proxy")
mux.HandleFunc("/proxyMode", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s", sdn.ProxyConfig.Mode)
@@ -243,8 +255,3 @@ func (sdn *OpenShiftSDN) runProxy(waitChan chan<- bool) {
}
}, 5*time.Second, utilwait.NeverStop)
}
-
- // periodically sync k8s iptables rules
- go utilwait.Forever(proxier.SyncLoop, 0)
- klog.Infof("Started Kubernetes Proxy on %s", sdn.ProxyConfig.BindAddress)
-}
