Convert for util.IP to just use a net.IP
pflag can handle IP addresses so use the pflag code instead of doing it ourselves. This means our code just uses net.IP and we don't have all of the useless casting back and forth!
This commit is contained in:
@@ -62,10 +62,10 @@ const (
|
||||
|
||||
// APIServer runs a kubernetes api server.
|
||||
type APIServer struct {
|
||||
InsecureBindAddress util.IP
|
||||
InsecureBindAddress net.IP
|
||||
InsecurePort int
|
||||
BindAddress util.IP
|
||||
AdvertiseAddress util.IP
|
||||
BindAddress net.IP
|
||||
AdvertiseAddress net.IP
|
||||
SecurePort int
|
||||
ExternalHost string
|
||||
APIRate float32
|
||||
@@ -114,8 +114,8 @@ type APIServer struct {
|
||||
func NewAPIServer() *APIServer {
|
||||
s := APIServer{
|
||||
InsecurePort: 8080,
|
||||
InsecureBindAddress: util.IP(net.ParseIP("127.0.0.1")),
|
||||
BindAddress: util.IP(net.ParseIP("0.0.0.0")),
|
||||
InsecureBindAddress: net.ParseIP("127.0.0.1"),
|
||||
BindAddress: net.ParseIP("0.0.0.0"),
|
||||
SecurePort: 6443,
|
||||
APIRate: 10.0,
|
||||
APIBurst: 200,
|
||||
@@ -151,20 +151,20 @@ func (s *APIServer) AddFlags(fs *pflag.FlagSet) {
|
||||
"the cluster and that port 443 on the cluster's public address is proxied to this "+
|
||||
"port. This is performed by nginx in the default setup.")
|
||||
fs.IntVar(&s.InsecurePort, "port", s.InsecurePort, "DEPRECATED: see --insecure-port instead")
|
||||
fs.Var(&s.InsecureBindAddress, "insecure-bind-address", ""+
|
||||
fs.IPVar(&s.InsecureBindAddress, "insecure-bind-address", s.InsecureBindAddress, ""+
|
||||
"The IP address on which to serve the --insecure-port (set to 0.0.0.0 for all interfaces). "+
|
||||
"Defaults to localhost.")
|
||||
fs.Var(&s.InsecureBindAddress, "address", "DEPRECATED: see --insecure-bind-address instead")
|
||||
fs.Var(&s.BindAddress, "bind-address", ""+
|
||||
fs.IPVar(&s.InsecureBindAddress, "address", s.InsecureBindAddress, "DEPRECATED: see --insecure-bind-address instead")
|
||||
fs.IPVar(&s.BindAddress, "bind-address", s.BindAddress, ""+
|
||||
"The IP address on which to serve the --read-only-port and --secure-port ports. The "+
|
||||
"associated interface(s) must be reachable by the rest of the cluster, and by CLI/web "+
|
||||
"clients. If blank, all interfaces will be used (0.0.0.0).")
|
||||
fs.Var(&s.AdvertiseAddress, "advertise-address", ""+
|
||||
fs.IPVar(&s.AdvertiseAddress, "advertise-address", s.AdvertiseAddress, ""+
|
||||
"The IP address on which to advertise the apiserver to members of the cluster. This "+
|
||||
"address must be reachable by the rest of the cluster. If blank, the --bind-address "+
|
||||
"will be used. If --bind-address is unspecified, the host's default interface will "+
|
||||
"be used.")
|
||||
fs.Var(&s.BindAddress, "public-address-override", "DEPRECATED: see --bind-address instead")
|
||||
fs.IPVar(&s.BindAddress, "public-address-override", s.BindAddress, "DEPRECATED: see --bind-address instead")
|
||||
fs.IntVar(&s.SecurePort, "secure-port", s.SecurePort, ""+
|
||||
"The port on which to serve HTTPS with authentication and authorization. If 0, "+
|
||||
"don't serve HTTPS at all.")
|
||||
@@ -257,7 +257,7 @@ func (s *APIServer) Run(_ []string) error {
|
||||
// If advertise-address is not specified, use bind-address. If bind-address
|
||||
// is also unset (or 0.0.0.0), setDefaults() in pkg/master/master.go will
|
||||
// do the right thing and use the host's default interface.
|
||||
if s.AdvertiseAddress == nil || net.IP(s.AdvertiseAddress).IsUnspecified() {
|
||||
if s.AdvertiseAddress == nil || s.AdvertiseAddress.IsUnspecified() {
|
||||
s.AdvertiseAddress = s.BindAddress
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ func (s *APIServer) Run(_ []string) error {
|
||||
ExpAPIPrefix: s.ExpAPIPrefix,
|
||||
CorsAllowedOriginList: s.CorsAllowedOriginList,
|
||||
ReadWritePort: s.SecurePort,
|
||||
PublicAddress: net.IP(s.AdvertiseAddress),
|
||||
PublicAddress: s.AdvertiseAddress,
|
||||
Authenticator: authenticator,
|
||||
SupportsBasicAuth: len(s.BasicAuthFile) > 0,
|
||||
Authorizer: authorizer,
|
||||
|
@@ -56,7 +56,7 @@ import (
|
||||
// CMServer is the main context object for the controller manager.
|
||||
type CMServer struct {
|
||||
Port int
|
||||
Address util.IP
|
||||
Address net.IP
|
||||
CloudProvider string
|
||||
CloudConfigFile string
|
||||
ConcurrentEndpointSyncs int
|
||||
@@ -90,7 +90,7 @@ type CMServer struct {
|
||||
func NewCMServer() *CMServer {
|
||||
s := CMServer{
|
||||
Port: ports.ControllerManagerPort,
|
||||
Address: util.IP(net.ParseIP("127.0.0.1")),
|
||||
Address: net.ParseIP("127.0.0.1"),
|
||||
ConcurrentEndpointSyncs: 5,
|
||||
ConcurrentRCSyncs: 5,
|
||||
ServiceSyncPeriod: 5 * time.Minute,
|
||||
@@ -108,7 +108,7 @@ func NewCMServer() *CMServer {
|
||||
// AddFlags adds flags for a specific CMServer to the specified FlagSet
|
||||
func (s *CMServer) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.IntVar(&s.Port, "port", s.Port, "The port that the controller-manager's http service runs on")
|
||||
fs.Var(&s.Address, "address", "The IP address to serve on (set to 0.0.0.0 for all interfaces)")
|
||||
fs.IPVar(&s.Address, "address", s.Address, "The IP address to serve on (set to 0.0.0.0 for all interfaces)")
|
||||
fs.StringVar(&s.CloudProvider, "cloud-provider", s.CloudProvider, "The provider for cloud services. Empty string for no provider.")
|
||||
fs.StringVar(&s.CloudConfigFile, "cloud-config", s.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.")
|
||||
fs.IntVar(&s.ConcurrentEndpointSyncs, "concurrent-endpoint-syncs", s.ConcurrentEndpointSyncs, "The number of endpoint syncing operations that will be done concurrently. Larger number = faster endpoint updating, but more CPU (and network) load")
|
||||
|
@@ -42,9 +42,9 @@ import (
|
||||
|
||||
// ProxyServer contains configures and runs a Kubernetes proxy server
|
||||
type ProxyServer struct {
|
||||
BindAddress util.IP
|
||||
BindAddress net.IP
|
||||
HealthzPort int
|
||||
HealthzBindAddress util.IP
|
||||
HealthzBindAddress net.IP
|
||||
OOMScoreAdj int
|
||||
ResourceContainer string
|
||||
Master string
|
||||
@@ -55,9 +55,9 @@ type ProxyServer struct {
|
||||
// NewProxyServer creates a new ProxyServer object with default parameters
|
||||
func NewProxyServer() *ProxyServer {
|
||||
return &ProxyServer{
|
||||
BindAddress: util.IP(net.ParseIP("0.0.0.0")),
|
||||
BindAddress: net.ParseIP("0.0.0.0"),
|
||||
HealthzPort: 10249,
|
||||
HealthzBindAddress: util.IP(net.ParseIP("127.0.0.1")),
|
||||
HealthzBindAddress: net.ParseIP("127.0.0.1"),
|
||||
OOMScoreAdj: qos.KubeProxyOomScoreAdj,
|
||||
ResourceContainer: "/kube-proxy",
|
||||
}
|
||||
@@ -65,10 +65,10 @@ func NewProxyServer() *ProxyServer {
|
||||
|
||||
// AddFlags adds flags for a specific ProxyServer to the specified FlagSet
|
||||
func (s *ProxyServer) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.Var(&s.BindAddress, "bind-address", "The IP address for the proxy server to serve on (set to 0.0.0.0 for all interfaces)")
|
||||
fs.IPVar(&s.BindAddress, "bind-address", s.BindAddress, "The IP address for the proxy server to serve on (set to 0.0.0.0 for all interfaces)")
|
||||
fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)")
|
||||
fs.IntVar(&s.HealthzPort, "healthz-port", s.HealthzPort, "The port to bind the health check server. Use 0 to disable.")
|
||||
fs.Var(&s.HealthzBindAddress, "healthz-bind-address", "The IP address for the health check server to serve on, defaulting to 127.0.0.1 (set to 0.0.0.0 for all interfaces)")
|
||||
fs.IPVar(&s.HealthzBindAddress, "healthz-bind-address", s.HealthzBindAddress, "The IP address for the health check server to serve on, defaulting to 127.0.0.1 (set to 0.0.0.0 for all interfaces)")
|
||||
fs.IntVar(&s.OOMScoreAdj, "oom-score-adj", s.OOMScoreAdj, "The oom_score_adj value for kube-proxy process. Values must be within the range [-1000, 1000]")
|
||||
fs.StringVar(&s.ResourceContainer, "resource-container", s.ResourceContainer, "Absolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy).")
|
||||
fs.StringVar(&s.Kubeconfig, "kubeconfig", s.Kubeconfig, "Path to kubeconfig file with authorization information (the master location is set by the master flag).")
|
||||
@@ -94,11 +94,11 @@ func (s *ProxyServer) Run(_ []string) error {
|
||||
endpointsConfig := config.NewEndpointsConfig()
|
||||
|
||||
protocol := iptables.ProtocolIpv4
|
||||
if net.IP(s.BindAddress).To4() == nil {
|
||||
if s.BindAddress.To4() == nil {
|
||||
protocol = iptables.ProtocolIpv6
|
||||
}
|
||||
loadBalancer := userspace.NewLoadBalancerRR()
|
||||
proxier, err := userspace.NewProxier(loadBalancer, net.IP(s.BindAddress), iptables.New(exec.New(), protocol), s.PortRange)
|
||||
proxier, err := userspace.NewProxier(loadBalancer, s.BindAddress, iptables.New(exec.New(), protocol), s.PortRange)
|
||||
if err != nil {
|
||||
glog.Fatalf("Unable to create proxer: %v", err)
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ type KubeletServer struct {
|
||||
ManifestURL string
|
||||
ManifestURLHeader string
|
||||
EnableServer bool
|
||||
Address util.IP
|
||||
Address net.IP
|
||||
Port uint
|
||||
ReadOnlyPort uint
|
||||
HostnameOverride string
|
||||
@@ -93,14 +93,14 @@ type KubeletServer struct {
|
||||
KubeConfig util.StringFlag
|
||||
CadvisorPort uint
|
||||
HealthzPort int
|
||||
HealthzBindAddress util.IP
|
||||
HealthzBindAddress net.IP
|
||||
OOMScoreAdj int
|
||||
APIServerList []string
|
||||
RegisterNode bool
|
||||
StandaloneMode bool
|
||||
ClusterDomain string
|
||||
MasterServiceNamespace string
|
||||
ClusterDNS util.IP
|
||||
ClusterDNS net.IP
|
||||
StreamingConnectionIdleTimeout time.Duration
|
||||
ImageGCHighThresholdPercent int
|
||||
ImageGCLowThresholdPercent int
|
||||
@@ -153,7 +153,7 @@ func NewKubeletServer() *KubeletServer {
|
||||
FileCheckFrequency: 20 * time.Second,
|
||||
HTTPCheckFrequency: 20 * time.Second,
|
||||
EnableServer: true,
|
||||
Address: util.IP(net.ParseIP("0.0.0.0")),
|
||||
Address: net.ParseIP("0.0.0.0"),
|
||||
Port: ports.KubeletPort,
|
||||
ReadOnlyPort: ports.KubeletReadOnlyPort,
|
||||
PodInfraContainerImage: dockertools.PodInfraContainerImage,
|
||||
@@ -167,7 +167,7 @@ func NewKubeletServer() *KubeletServer {
|
||||
KubeConfig: util.NewStringFlag("/var/lib/kubelet/kubeconfig"),
|
||||
CadvisorPort: 4194,
|
||||
HealthzPort: 10248,
|
||||
HealthzBindAddress: util.IP(net.ParseIP("127.0.0.1")),
|
||||
HealthzBindAddress: net.ParseIP("127.0.0.1"),
|
||||
RegisterNode: true, // will be ignored if no apiserver is configured
|
||||
OOMScoreAdj: qos.KubeletOomScoreAdj,
|
||||
MasterServiceNamespace: api.NamespaceDefault,
|
||||
@@ -198,7 +198,7 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.StringVar(&s.ManifestURL, "manifest-url", s.ManifestURL, "URL for accessing the container manifest")
|
||||
fs.StringVar(&s.ManifestURLHeader, "manifest-url-header", s.ManifestURLHeader, "HTTP header to use when accessing the manifest URL, with the key separated from the value with a ':', as in 'key:value'")
|
||||
fs.BoolVar(&s.EnableServer, "enable-server", s.EnableServer, "Enable the Kubelet's server")
|
||||
fs.Var(&s.Address, "address", "The IP address for the Kubelet to serve on (set to 0.0.0.0 for all interfaces)")
|
||||
fs.IPVar(&s.Address, "address", s.Address, "The IP address for the Kubelet to serve on (set to 0.0.0.0 for all interfaces)")
|
||||
fs.UintVar(&s.Port, "port", s.Port, "The port for the Kubelet to serve on. Note that \"kubectl logs\" will not work if you set this flag.") // see #9325
|
||||
fs.UintVar(&s.ReadOnlyPort, "read-only-port", s.ReadOnlyPort, "The read-only port for the Kubelet to serve on (set to 0 to disable)")
|
||||
fs.StringVar(&s.TLSCertFile, "tls-cert-file", s.TLSCertFile, ""+
|
||||
@@ -226,13 +226,13 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.Var(&s.KubeConfig, "kubeconfig", "Path to a kubeconfig file, specifying how to authenticate to API server (the master location is set by the api-servers flag).")
|
||||
fs.UintVar(&s.CadvisorPort, "cadvisor-port", s.CadvisorPort, "The port of the localhost cAdvisor endpoint")
|
||||
fs.IntVar(&s.HealthzPort, "healthz-port", s.HealthzPort, "The port of the localhost healthz endpoint")
|
||||
fs.Var(&s.HealthzBindAddress, "healthz-bind-address", "The IP address for the healthz server to serve on, defaulting to 127.0.0.1 (set to 0.0.0.0 for all interfaces)")
|
||||
fs.IPVar(&s.HealthzBindAddress, "healthz-bind-address", s.HealthzBindAddress, "The IP address for the healthz server to serve on, defaulting to 127.0.0.1 (set to 0.0.0.0 for all interfaces)")
|
||||
fs.IntVar(&s.OOMScoreAdj, "oom-score-adj", s.OOMScoreAdj, "The oom-score-adj value for kubelet process. Values must be within the range [-1000, 1000]")
|
||||
fs.StringSliceVar(&s.APIServerList, "api-servers", []string{}, "List of Kubernetes API servers for publishing events, and reading pods and services. (ip:port), comma separated.")
|
||||
fs.BoolVar(&s.RegisterNode, "register-node", s.RegisterNode, "Register the node with the apiserver (defaults to true if --api-server is set)")
|
||||
fs.StringVar(&s.ClusterDomain, "cluster-domain", s.ClusterDomain, "Domain for this cluster. If set, kubelet will configure all containers to search this domain in addition to the host's search domains")
|
||||
fs.StringVar(&s.MasterServiceNamespace, "master-service-namespace", s.MasterServiceNamespace, "The namespace from which the kubernetes master services should be injected into pods")
|
||||
fs.Var(&s.ClusterDNS, "cluster-dns", "IP address for a cluster DNS server. If set, kubelet will configure all containers to use this for DNS resolution in addition to the host's DNS servers")
|
||||
fs.IPVar(&s.ClusterDNS, "cluster-dns", s.ClusterDNS, "IP address for a cluster DNS server. If set, kubelet will configure all containers to use this for DNS resolution in addition to the host's DNS servers")
|
||||
fs.DurationVar(&s.StreamingConnectionIdleTimeout, "streaming-connection-idle-timeout", 0, "Maximum time a streaming connection can be idle before the connection is automatically closed. Example: '5m'")
|
||||
fs.DurationVar(&s.NodeStatusUpdateFrequency, "node-status-update-frequency", s.NodeStatusUpdateFrequency, "Specifies how often kubelet posts node status to master. Note: be cautious when changing the constant, it must work with nodeMonitorGracePeriod in nodecontroller. Default: 10s")
|
||||
fs.IntVar(&s.ImageGCHighThresholdPercent, "image-gc-high-threshold", s.ImageGCHighThresholdPercent, "The percent of disk usage after which image garbage collection is always run. Default: 90%%")
|
||||
@@ -568,7 +568,7 @@ func SimpleKubelet(client *client.Client,
|
||||
ManifestURL: manifestURL,
|
||||
PodInfraContainerImage: dockertools.PodInfraContainerImage,
|
||||
Port: port,
|
||||
Address: util.IP(net.ParseIP(address)),
|
||||
Address: net.ParseIP(address),
|
||||
EnableServer: true,
|
||||
EnableDebuggingHandlers: true,
|
||||
HTTPCheckFrequency: 1 * time.Second,
|
||||
@@ -672,12 +672,12 @@ func startKubelet(k KubeletBootstrap, podCfg *config.PodConfig, kc *KubeletConfi
|
||||
// start the kubelet server
|
||||
if kc.EnableServer {
|
||||
go util.Forever(func() {
|
||||
k.ListenAndServe(net.IP(kc.Address), kc.Port, kc.TLSOptions, kc.EnableDebuggingHandlers)
|
||||
k.ListenAndServe(kc.Address, kc.Port, kc.TLSOptions, kc.EnableDebuggingHandlers)
|
||||
}, 0)
|
||||
}
|
||||
if kc.ReadOnlyPort > 0 {
|
||||
go util.Forever(func() {
|
||||
k.ListenAndServeReadOnly(net.IP(kc.Address), kc.ReadOnlyPort)
|
||||
k.ListenAndServeReadOnly(kc.Address, kc.ReadOnlyPort)
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
@@ -710,7 +710,7 @@ type KubeletConfig struct {
|
||||
KubeClient *client.Client
|
||||
DockerClient dockertools.DockerInterface
|
||||
CadvisorInterface cadvisor.Interface
|
||||
Address util.IP
|
||||
Address net.IP
|
||||
AllowPrivileged bool
|
||||
HostNetworkSources []string
|
||||
HostnameOverride string
|
||||
@@ -732,7 +732,7 @@ type KubeletConfig struct {
|
||||
RegisterNode bool
|
||||
StandaloneMode bool
|
||||
ClusterDomain string
|
||||
ClusterDNS util.IP
|
||||
ClusterDNS net.IP
|
||||
EnableServer bool
|
||||
EnableDebuggingHandlers bool
|
||||
Port uint
|
||||
@@ -795,7 +795,7 @@ func createAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod
|
||||
kc.RegisterNode,
|
||||
kc.StandaloneMode,
|
||||
kc.ClusterDomain,
|
||||
net.IP(kc.ClusterDNS),
|
||||
kc.ClusterDNS,
|
||||
kc.MasterServiceNamespace,
|
||||
kc.VolumePlugins,
|
||||
kc.NetworkPlugins,
|
||||
|
Reference in New Issue
Block a user