| ... | ... |
@@ -23,6 +23,7 @@ import ( |
| 23 | 23 |
utildbus "k8s.io/kubernetes/pkg/util/dbus" |
| 24 | 24 |
kexec "k8s.io/kubernetes/pkg/util/exec" |
| 25 | 25 |
utiliptables "k8s.io/kubernetes/pkg/util/iptables" |
| 26 |
+ utilnet "k8s.io/kubernetes/pkg/util/net" |
|
| 26 | 27 |
|
| 27 | 28 |
cmdutil "github.com/openshift/origin/pkg/cmd/util" |
| 28 | 29 |
dockerutil "github.com/openshift/origin/pkg/cmd/util/docker" |
| ... | ... |
@@ -193,10 +194,13 @@ func (c *NodeConfig) RunSDN() {
|
| 193 | 193 |
// RunProxy starts the proxy |
| 194 | 194 |
func (c *NodeConfig) RunProxy() {
|
| 195 | 195 |
protocol := utiliptables.ProtocolIpv4 |
| 196 |
- if c.ProxyConfig.BindAddress.To4() == nil {
|
|
| 196 |
+ bindAddr := net.ParseIP(c.ProxyConfig.BindAddress) |
|
| 197 |
+ if bindAddr.To4() == nil {
|
|
| 197 | 198 |
protocol = utiliptables.ProtocolIpv6 |
| 198 | 199 |
} |
| 199 | 200 |
|
| 201 |
+ portRange := utilnet.ParsePortRangeOrDie(c.ProxyConfig.PortRange) |
|
| 202 |
+ |
|
| 200 | 203 |
eventBroadcaster := record.NewBroadcaster() |
| 201 | 204 |
eventBroadcaster.StartRecordingToSink(c.Client.Events(""))
|
| 202 | 205 |
recorder := eventBroadcaster.NewRecorder(kapi.EventSource{Component: "kube-proxy", Host: c.KubeletConfig.NodeName})
|
| ... | ... |
@@ -208,10 +212,10 @@ func (c *NodeConfig) RunProxy() {
|
| 208 | 208 |
var proxier proxy.ProxyProvider |
| 209 | 209 |
var endpointsHandler pconfig.EndpointsConfigHandler |
| 210 | 210 |
|
| 211 |
- switch c.ProxyConfig.ProxyMode {
|
|
| 211 |
+ switch c.ProxyConfig.Mode {
|
|
| 212 | 212 |
case "iptables": |
| 213 | 213 |
glog.V(0).Info("Using iptables Proxier.")
|
| 214 |
- proxierIptables, err := iptables.NewProxier(iptInterface, exec, c.ProxyConfig.IptablesSyncPeriod, c.ProxyConfig.MasqueradeAll) |
|
| 214 |
+ proxierIptables, err := iptables.NewProxier(iptInterface, exec, c.ProxyConfig.IPTablesSyncPeriod.Duration, c.ProxyConfig.MasqueradeAll, *c.ProxyConfig.IPTablesMasqueradeBit) |
|
| 215 | 215 |
if err != nil {
|
| 216 | 216 |
// This should be fatal, but that would break the integration tests |
| 217 | 217 |
glog.Warningf("WARNING: Could not initialize Kubernetes Proxy. You must run this process as root to use the service proxy: %v", err)
|
| ... | ... |
@@ -226,7 +230,7 @@ func (c *NodeConfig) RunProxy() {
|
| 226 | 226 |
glog.V(0).Info("Using userspace Proxier.")
|
| 227 | 227 |
loadBalancer := userspace.NewLoadBalancerRR() |
| 228 | 228 |
endpointsHandler = loadBalancer |
| 229 |
- proxierUserspace, err := userspace.NewProxier(loadBalancer, c.ProxyConfig.BindAddress, iptInterface, c.ProxyConfig.PortRange, c.ProxyConfig.IptablesSyncPeriod, c.ProxyConfig.UDPIdleTimeout) |
|
| 229 |
+ proxierUserspace, err := userspace.NewProxier(loadBalancer, bindAddr, iptInterface, *portRange, c.ProxyConfig.IPTablesSyncPeriod.Duration, c.ProxyConfig.UDPIdleTimeout.Duration) |
|
| 230 | 230 |
if err != nil {
|
| 231 | 231 |
// This should be fatal, but that would break the integration tests |
| 232 | 232 |
glog.Warningf("WARNING: Could not initialize Kubernetes Proxy. You must run this process as root to use the service proxy: %v", err)
|
| ... | ... |
@@ -237,7 +241,7 @@ func (c *NodeConfig) RunProxy() {
|
| 237 | 237 |
glog.V(0).Info("Tearing down pure-iptables proxy rules. Errors here are acceptable.")
|
| 238 | 238 |
iptables.CleanupLeftovers(iptInterface) |
| 239 | 239 |
default: |
| 240 |
- glog.Fatalf("Unknown proxy mode %q", c.ProxyConfig.ProxyMode)
|
|
| 240 |
+ glog.Fatalf("Unknown proxy mode %q", c.ProxyConfig.Mode)
|
|
| 241 | 241 |
} |
| 242 | 242 |
iptInterface.AddReloadFunc(proxier.Sync) |
| 243 | 243 |
|
| ... | ... |
@@ -262,7 +266,7 @@ func (c *NodeConfig) RunProxy() {
|
| 262 | 262 |
endpointsConfig.Channel("api"))
|
| 263 | 263 |
|
| 264 | 264 |
recorder.Eventf(c.ProxyConfig.NodeRef, kapi.EventTypeNormal, "Starting", "Starting kube-proxy.") |
| 265 |
- glog.Infof("Started Kubernetes Proxy on %s", c.ProxyConfig.BindAddress.String())
|
|
| 265 |
+ glog.Infof("Started Kubernetes Proxy on %s", c.ProxyConfig.BindAddress)
|
|
| 266 | 266 |
} |
| 267 | 267 |
|
| 268 | 268 |
// TODO: more generic location |
| ... | ... |
@@ -31,6 +31,7 @@ import ( |
| 31 | 31 |
"github.com/openshift/origin/pkg/cmd/util/clientcmd" |
| 32 | 32 |
cmdflags "github.com/openshift/origin/pkg/cmd/util/flags" |
| 33 | 33 |
"github.com/openshift/origin/pkg/cmd/util/variable" |
| 34 |
+ "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" |
|
| 34 | 35 |
) |
| 35 | 36 |
|
| 36 | 37 |
// NodeConfig represents the required parameters to start the OpenShift node |
| ... | ... |
@@ -167,8 +168,8 @@ func BuildKubernetesNodeConfig(options configapi.NodeConfig) (*NodeConfig, error |
| 167 | 167 |
|
| 168 | 168 |
// provide any config overrides |
| 169 | 169 |
cfg.NodeName = options.NodeName |
| 170 |
- cfg.KubeClient = kubeClient |
|
| 171 |
- cfg.EventClient = eventClient |
|
| 170 |
+ cfg.KubeClient = internalclientset.FromUnversionedClient(kubeClient) |
|
| 171 |
+ cfg.EventClient = internalclientset.FromUnversionedClient(eventClient) |
|
| 172 | 172 |
cfg.DockerExecHandler = dockerExecHandler |
| 173 | 173 |
|
| 174 | 174 |
// docker-in-docker (dind) deployments are used for testing |
| ... | ... |
@@ -299,14 +300,15 @@ func buildKubeProxyConfig(options configapi.NodeConfig) (*proxyoptions.ProxyServ |
| 299 | 299 |
if ip == nil {
|
| 300 | 300 |
return nil, fmt.Errorf("The provided value to bind to must be an ip:port: %q", addr)
|
| 301 | 301 |
} |
| 302 |
- proxyconfig.BindAddress = ip |
|
| 302 |
+ proxyconfig.BindAddress = ip.String() |
|
| 303 | 303 |
|
| 304 | 304 |
// HealthzPort, HealthzBindAddress - disable |
| 305 | 305 |
proxyconfig.HealthzPort = 0 |
| 306 |
- proxyconfig.HealthzBindAddress = nil |
|
| 306 |
+ proxyconfig.HealthzBindAddress = "" |
|
| 307 | 307 |
|
| 308 | 308 |
// OOMScoreAdj, ResourceContainer - clear, we don't run in a container |
| 309 |
- proxyconfig.OOMScoreAdj = 0 |
|
| 309 |
+ oomScoreAdj := 0 |
|
| 310 |
+ proxyconfig.OOMScoreAdj = &oomScoreAdj |
|
| 310 | 311 |
proxyconfig.ResourceContainer = "" |
| 311 | 312 |
|
| 312 | 313 |
// use the same client as the node |
| ... | ... |
@@ -317,14 +319,16 @@ func buildKubeProxyConfig(options configapi.NodeConfig) (*proxyoptions.ProxyServ |
| 317 | 317 |
// HostnameOverride, use default |
| 318 | 318 |
|
| 319 | 319 |
// ProxyMode, set to iptables |
| 320 |
- proxyconfig.ProxyMode = "iptables" |
|
| 320 |
+ proxyconfig.Mode = "iptables" |
|
| 321 | 321 |
|
| 322 | 322 |
// IptablesSyncPeriod, set to our config value |
| 323 | 323 |
syncPeriod, err := time.ParseDuration(options.IPTablesSyncPeriod) |
| 324 | 324 |
if err != nil {
|
| 325 | 325 |
return nil, fmt.Errorf("Cannot parse the provided ip-tables sync period (%s) : %v", options.IPTablesSyncPeriod, err)
|
| 326 | 326 |
} |
| 327 |
- proxyconfig.IptablesSyncPeriod = syncPeriod |
|
| 327 |
+ proxyconfig.IPTablesSyncPeriod = unversioned.Duration{
|
|
| 328 |
+ Duration: syncPeriod, |
|
| 329 |
+ } |
|
| 328 | 330 |
|
| 329 | 331 |
// ConfigSyncPeriod, use default |
| 330 | 332 |
|
| ... | ... |
@@ -1,12 +1,13 @@ |
| 1 | 1 |
package kubernetes |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "net" |
|
| 5 | 4 |
"reflect" |
| 6 | 5 |
"testing" |
| 7 | 6 |
"time" |
| 8 | 7 |
|
| 9 | 8 |
proxyoptions "k8s.io/kubernetes/cmd/kube-proxy/app/options" |
| 9 |
+ "k8s.io/kubernetes/pkg/api/unversioned" |
|
| 10 |
+ "k8s.io/kubernetes/pkg/apis/componentconfig" |
|
| 10 | 11 |
"k8s.io/kubernetes/pkg/kubelet/qos" |
| 11 | 12 |
) |
| 12 | 13 |
|
| ... | ... |
@@ -14,19 +15,26 @@ func TestProxyConfig(t *testing.T) {
|
| 14 | 14 |
// This is a snapshot of the default config |
| 15 | 15 |
// If the default changes (new fields are added, or default values change), we want to know |
| 16 | 16 |
// Once we've reacted to the changes appropriately in buildKubeProxyConfig(), update this expected default to match the new upstream defaults |
| 17 |
+ oomScoreAdj := qos.KubeProxyOOMScoreAdj |
|
| 18 |
+ ipTablesMasqueratebit := 14 |
|
| 17 | 19 |
expectedDefaultConfig := &proxyoptions.ProxyServerConfig{
|
| 18 |
- BindAddress: net.ParseIP("0.0.0.0"),
|
|
| 19 |
- HealthzPort: 10249, |
|
| 20 |
- HealthzBindAddress: net.ParseIP("127.0.0.1"),
|
|
| 21 |
- OOMScoreAdj: qos.KubeProxyOOMScoreAdj, |
|
| 22 |
- ResourceContainer: "/kube-proxy", |
|
| 23 |
- IptablesSyncPeriod: 30 * time.Second, |
|
| 24 |
- ConfigSyncPeriod: 15 * time.Minute, |
|
| 25 |
- KubeAPIQPS: 5.0, |
|
| 26 |
- KubeAPIBurst: 10, |
|
| 27 |
- UDPIdleTimeout: 250 * time.Millisecond, |
|
| 28 |
- ConntrackMax: 256 * 1024, // 4x default (64k) |
|
| 29 |
- ConntrackTCPTimeoutEstablished: 86400, // 1 day (1/5 default) |
|
| 20 |
+ KubeProxyConfiguration: componentconfig.KubeProxyConfiguration{
|
|
| 21 |
+ BindAddress: "0.0.0.0", |
|
| 22 |
+ HealthzPort: 10249, |
|
| 23 |
+ HealthzBindAddress: "127.0.0.1", |
|
| 24 |
+ OOMScoreAdj: &oomScoreAdj, |
|
| 25 |
+ ResourceContainer: "/kube-proxy", |
|
| 26 |
+ IPTablesSyncPeriod: unversioned.Duration{Duration: 30 * time.Second},
|
|
| 27 |
+ // from k8s.io/kubernetes/cmd/kube-proxy/app/options/options.go |
|
| 28 |
+ // defaults to 14. |
|
| 29 |
+ IPTablesMasqueradeBit: &ipTablesMasqueratebit, |
|
| 30 |
+ UDPIdleTimeout: unversioned.Duration{Duration: 250 * time.Millisecond},
|
|
| 31 |
+ ConntrackMax: 256 * 1024, // 4x default (64k) |
|
| 32 |
+ ConntrackTCPEstablishedTimeout: unversioned.Duration{Duration: 86400 * time.Second}, // 1 day (1/5 default)
|
|
| 33 |
+ }, |
|
| 34 |
+ ConfigSyncPeriod: 15 * time.Minute, |
|
| 35 |
+ KubeAPIQPS: 5.0, |
|
| 36 |
+ KubeAPIBurst: 10, |
|
| 30 | 37 |
} |
| 31 | 38 |
|
| 32 | 39 |
actualDefaultConfig := proxyoptions.NewProxyConfig() |