-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure openshift start network can run in a pod
Need to be able to take node-config from bootstrap node. For openshift start network the --kubeconfig flag from the CLI overrides the value of masterKubeConfig in the provided node config. If the value is empty (like it is by default) the in-cluster-config is used. Reorganize the node startup slightly so there is even less overlap between kubelet and network. A future change will completely separate these two initialization paths.
- Loading branch information
1 parent
ac98451
commit d349f9b
Showing
9 changed files
with
166 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package node | ||
|
||
import ( | ||
"fmt" | ||
"net" | ||
"time" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
kerrors "k8s.io/apimachinery/pkg/util/errors" | ||
kubeproxyoptions "k8s.io/kubernetes/cmd/kube-proxy/app" | ||
"k8s.io/kubernetes/pkg/apis/componentconfig" | ||
|
||
configapi "github.com/openshift/origin/pkg/cmd/server/api" | ||
cmdflags "github.com/openshift/origin/pkg/cmd/util/flags" | ||
) | ||
|
||
// Build creates the network Kubernetes component configs for a given NodeConfig, or returns | ||
// an error | ||
func Build(options configapi.NodeConfig) (*componentconfig.KubeProxyConfiguration, error) { | ||
proxyOptions, err := kubeproxyoptions.NewOptions() | ||
if err != nil { | ||
return nil, err | ||
} | ||
// get default config | ||
proxyconfig := proxyOptions.GetConfig() | ||
|
||
proxyconfig.HostnameOverride = options.NodeName | ||
|
||
// BindAddress - Override default bind address from our config | ||
addr := options.ServingInfo.BindAddress | ||
host, _, err := net.SplitHostPort(addr) | ||
if err != nil { | ||
return nil, fmt.Errorf("The provided value to bind to must be an ip:port %q", addr) | ||
} | ||
ip := net.ParseIP(host) | ||
if ip == nil { | ||
return nil, fmt.Errorf("The provided value to bind to must be an ip:port: %q", addr) | ||
} | ||
proxyconfig.BindAddress = ip.String() | ||
// MetricsBindAddress - disable by default but allow enablement until we switch to | ||
// reading proxy config directly | ||
proxyconfig.MetricsBindAddress = "" | ||
if arg := options.ProxyArguments["metrics-bind-address"]; len(arg) > 0 { | ||
proxyconfig.MetricsBindAddress = arg[0] | ||
} | ||
delete(options.ProxyArguments, "metrics-bind-address") | ||
|
||
// OOMScoreAdj, ResourceContainer - clear, we don't run in a container | ||
oomScoreAdj := int32(0) | ||
proxyconfig.OOMScoreAdj = &oomScoreAdj | ||
proxyconfig.ResourceContainer = "" | ||
|
||
// use the same client as the node | ||
proxyconfig.ClientConnection.KubeConfigFile = options.MasterKubeConfig | ||
|
||
// ProxyMode, set to iptables | ||
proxyconfig.Mode = "iptables" | ||
|
||
// IptablesSyncPeriod, set to our config value | ||
syncPeriod, err := time.ParseDuration(options.IPTablesSyncPeriod) | ||
if err != nil { | ||
return nil, fmt.Errorf("Cannot parse the provided ip-tables sync period (%s) : %v", options.IPTablesSyncPeriod, err) | ||
} | ||
proxyconfig.IPTables.SyncPeriod = metav1.Duration{ | ||
Duration: syncPeriod, | ||
} | ||
masqueradeBit := int32(0) | ||
proxyconfig.IPTables.MasqueradeBit = &masqueradeBit | ||
|
||
// PortRange, use default | ||
// HostnameOverride, use default | ||
// ConfigSyncPeriod, use default | ||
// MasqueradeAll, use default | ||
// CleanupAndExit, use default | ||
// KubeAPIQPS, use default, doesn't apply until we build a separate client | ||
// KubeAPIBurst, use default, doesn't apply until we build a separate client | ||
// UDPIdleTimeout, use default | ||
|
||
// Resolve cmd flags to add any user overrides | ||
if err := cmdflags.Resolve(options.ProxyArguments, proxyOptions.AddFlags); len(err) > 0 { | ||
return nil, kerrors.NewAggregate(err) | ||
} | ||
|
||
if err := proxyOptions.Complete(); err != nil { | ||
return nil, err | ||
} | ||
|
||
return proxyconfig, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.