@@ -19,7 +19,7 @@ import (
19
19
// - pluginDefaults
20
20
// - conf.KubeProxyConfig.ProxyArguments
21
21
// - pluginOverrides
22
- func kubeProxyConfiguration (pluginDefaults map [string ]operv1.ProxyArgumentList , conf * operv1.NetworkSpec , pluginOverrides map [string ]operv1.ProxyArgumentList ) (jsonConf , metricsPort , healthzPort string , err error ) {
22
+ func kubeProxyConfiguration (pluginDefaults map [string ]operv1.ProxyArgumentList , conf * operv1.NetworkSpec , pluginOverrides map [string ]operv1.ProxyArgumentList ) (string , error ) {
23
23
p := conf .KubeProxyConfig
24
24
25
25
args := map [string ]operv1.ProxyArgumentList {}
@@ -33,14 +33,7 @@ func kubeProxyConfiguration(pluginDefaults map[string]operv1.ProxyArgumentList,
33
33
args = k8sutil .MergeKubeProxyArguments (args , p .ProxyArguments )
34
34
args = k8sutil .MergeKubeProxyArguments (args , pluginOverrides )
35
35
36
- if len (args ["metrics-port" ]) == 1 {
37
- metricsPort = args ["metrics-port" ][0 ]
38
- }
39
- if len (args ["healthz-port" ]) == 1 {
40
- healthzPort = args ["healthz-port" ][0 ]
41
- }
42
- jsonConf , err = k8sutil .GenerateKubeProxyConfiguration (args )
43
- return
36
+ return k8sutil .GenerateKubeProxyConfiguration (args )
44
37
}
45
38
46
39
// acceptsKubeProxyConfig determines if the desired network type allows
@@ -103,20 +96,18 @@ func validateKubeProxy(conf *operv1.NetworkSpec) []error {
103
96
}
104
97
}
105
98
106
- // Don't allow ports to be overridden. Before 4.7, standalone kube-proxy used the
107
- // same ports as openshift-sdn (metrics 9101, healthz 10256). In 4.7 and later,
108
- // the defaults are 9102 and 10255 to allow openshift-sdn and kube-proxy to be run
109
- // together, but we still allow the old values to avoid breaking old clusters.
99
+ // Don't allow ports to be overridden. For backward compatibility, we allow
100
+ // explicitly specifying the (old) default values, though we prefer for them to be
101
+ // left blank.
110
102
if p .ProxyArguments != nil {
111
103
if val , ok := p .ProxyArguments ["metrics-port" ]; ok {
112
- if len (val ) != 1 || ( val [0 ] != "9102" && val [ 0 ] != " 9101") {
113
- out = append (out , errors .Errorf ("kube-proxy --metrics-port must be 9102 or 9101 " ))
104
+ if len (val ) != 1 || val [0 ] != "9101" {
105
+ out = append (out , errors .Errorf ("kube-proxy --metrics-port cannot be overridden " ))
114
106
}
115
107
}
116
-
117
108
if val , ok := p .ProxyArguments ["healthz-port" ]; ok {
118
- if len (val ) != 1 || ( val [0 ] != "10255" && val [ 0 ] != " 10256") {
119
- out = append (out , errors .Errorf ("kube-proxy --healthz-port must be 10255 or 10256 " ))
109
+ if len (val ) != 1 || val [0 ] != "10256" {
110
+ out = append (out , errors .Errorf ("kube-proxy --healthz-port cannot be overridden " ))
120
111
}
121
112
}
122
113
}
@@ -187,21 +178,34 @@ func renderStandaloneKubeProxy(conf *operv1.NetworkSpec, manifestDir string) ([]
187
178
return nil , nil
188
179
}
189
180
181
+ metricsPort := "9102"
182
+ healthzPort := "10255"
183
+ if val , ok := conf .KubeProxyConfig .ProxyArguments ["metrics-port" ]; ok {
184
+ metricsPort = val [0 ]
185
+ }
186
+ if val , ok := conf .KubeProxyConfig .ProxyArguments ["healthz-port" ]; ok {
187
+ healthzPort = val [0 ]
188
+ }
189
+
190
190
kpcDefaults := map [string ]operv1.ProxyArgumentList {
191
191
"metrics-bind-address" : {"0.0.0.0" },
192
- "metrics-port" : {"9102" },
193
192
"healthz-port" : {"10255" },
194
193
"proxy-mode" : {"iptables" },
195
194
}
196
-
197
- kpc , metricsPort , healthzPort , err := kubeProxyConfiguration (kpcDefaults , conf , nil )
195
+ // Regardless of the public metrics port, kube-proxy itself must publish metrics on
196
+ // port 29102.
197
+ kpcOverrides := map [string ]operv1.ProxyArgumentList {
198
+ "metrics-port" : {"29102" },
199
+ }
200
+ kpc , err := kubeProxyConfiguration (kpcDefaults , conf , kpcOverrides )
198
201
if err != nil {
199
202
return nil , errors .Wrapf (err , "failed to generate kube-proxy configuration file" )
200
203
}
201
204
202
205
data := render .MakeRenderData ()
203
206
data .Data ["ReleaseVersion" ] = os .Getenv ("RELEASE_VERSION" )
204
207
data .Data ["KubeProxyImage" ] = os .Getenv ("KUBE_PROXY_IMAGE" )
208
+ data .Data ["KubeRBACProxyImage" ] = os .Getenv ("KUBE_RBAC_PROXY_IMAGE" )
205
209
data .Data ["KUBERNETES_SERVICE_HOST" ] = os .Getenv ("KUBERNETES_SERVICE_HOST" )
206
210
data .Data ["KUBERNETES_SERVICE_PORT" ] = os .Getenv ("KUBERNETES_SERVICE_PORT" )
207
211
data .Data ["KubeProxyConfig" ] = kpc
0 commit comments