mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 22:20:51 +00:00
Flag-compatible IP type
This commit is contained in:
@@ -41,7 +41,7 @@ import (
|
||||
|
||||
var (
|
||||
port = flag.Uint("port", 8080, "The port to listen on. Default 8080")
|
||||
address = flag.String("address", "127.0.0.1", "The address on the local server to listen to. Default 127.0.0.1")
|
||||
address = util.IP(net.ParseIP("127.0.0.1"))
|
||||
apiPrefix = flag.String("api_prefix", "/api", "The prefix for API requests on the server. Default '/api'")
|
||||
storageVersion = flag.String("storage_version", "", "The version to store resources with. Defaults to server preferred")
|
||||
cloudProvider = flag.String("cloud_provider", "", "The provider for cloud services. Empty string for no provider.")
|
||||
@@ -60,6 +60,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.Var(&address, "address", "The IP address on to serve on (set to 0.0.0.0 for all interfaces)")
|
||||
flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated")
|
||||
flag.Var(&machineList, "machines", "List of machines to schedule onto, comma separated.")
|
||||
flag.Var(&corsAllowedOriginList, "cors_allowed_origins", "List of allowed origins for CORS, comma separated. An allowed origin can be a regular expression to support subdomain matching. If this list is empty CORS will not be enabled.")
|
||||
@@ -133,7 +134,7 @@ func main() {
|
||||
|
||||
// TODO: expose same flags as client.BindClientConfigFlags but for a server
|
||||
clientConfig := &client.Config{
|
||||
Host: net.JoinHostPort(*address, strconv.Itoa(int(*port))),
|
||||
Host: net.JoinHostPort(address.String(), strconv.Itoa(int(*port))),
|
||||
Version: *storageVersion,
|
||||
}
|
||||
client, err := client.New(clientConfig)
|
||||
@@ -179,7 +180,7 @@ func main() {
|
||||
handler = apiserver.RecoverPanics(handler)
|
||||
|
||||
s := &http.Server{
|
||||
Addr: net.JoinHostPort(*address, strconv.Itoa(int(*port))),
|
||||
Addr: net.JoinHostPort(address.String(), strconv.Itoa(int(*port))),
|
||||
Handler: handler,
|
||||
ReadTimeout: 5 * time.Minute,
|
||||
WriteTimeout: 5 * time.Minute,
|
||||
|
@@ -38,11 +38,12 @@ import (
|
||||
|
||||
var (
|
||||
port = flag.Int("port", masterPkg.ControllerManagerPort, "The port that the controller-manager's http service runs on")
|
||||
address = flag.String("address", "127.0.0.1", "The address to serve from")
|
||||
address = util.IP(net.ParseIP("127.0.0.1"))
|
||||
clientConfig = &client.Config{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.Var(&address, "address", "The IP address to serve on (set to 0.0.0.0 for all interfaces)")
|
||||
client.BindClientConfigFlags(flag.CommandLine, clientConfig)
|
||||
}
|
||||
|
||||
@@ -62,7 +63,7 @@ func main() {
|
||||
glog.Fatalf("Invalid API configuration: %v", err)
|
||||
}
|
||||
|
||||
go http.ListenAndServe(net.JoinHostPort(*address, strconv.Itoa(*port)), nil)
|
||||
go http.ListenAndServe(net.JoinHostPort(address.String(), strconv.Itoa(*port)), nil)
|
||||
|
||||
controllerManager := controller.NewReplicationManager(kubeClient)
|
||||
controllerManager.Run(10 * time.Second)
|
||||
|
@@ -21,6 +21,7 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
@@ -150,7 +151,7 @@ func startComponents(manifestURL string) (apiServerURL string) {
|
||||
myKubelet := kubelet.NewIntegrationTestKubelet(machineList[0], testRootDir, &fakeDocker1)
|
||||
go util.Forever(func() { myKubelet.Run(cfg1.Updates()) }, 0)
|
||||
go util.Forever(func() {
|
||||
kubelet.ListenAndServeKubeletServer(myKubelet, cfg1.Channel("http"), "localhost", 10250)
|
||||
kubelet.ListenAndServeKubeletServer(myKubelet, cfg1.Channel("http"), net.ParseIP("127.0.0.1"), 10250)
|
||||
}, 0)
|
||||
|
||||
// Kubelet (machine)
|
||||
@@ -161,7 +162,7 @@ func startComponents(manifestURL string) (apiServerURL string) {
|
||||
otherKubelet := kubelet.NewIntegrationTestKubelet(machineList[1], testRootDir, &fakeDocker2)
|
||||
go util.Forever(func() { otherKubelet.Run(cfg2.Updates()) }, 0)
|
||||
go util.Forever(func() {
|
||||
kubelet.ListenAndServeKubeletServer(otherKubelet, cfg2.Channel("http"), "localhost", 10251)
|
||||
kubelet.ListenAndServeKubeletServer(otherKubelet, cfg2.Channel("http"), net.ParseIP("127.0.0.1"), 10251)
|
||||
}, 0)
|
||||
|
||||
return apiServer.URL
|
||||
|
@@ -23,6 +23,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -54,7 +55,7 @@ var (
|
||||
httpCheckFrequency = flag.Duration("http_check_frequency", 20*time.Second, "Duration between checking http for new data")
|
||||
manifestURL = flag.String("manifest_url", "", "URL for accessing the container manifest")
|
||||
enableServer = flag.Bool("enable_server", true, "Enable the info server")
|
||||
address = flag.String("address", "127.0.0.1", "The address for the info server to serve on (set to 0.0.0.0 or \"\" for all interfaces)")
|
||||
address = util.IP(net.ParseIP("127.0.0.1"))
|
||||
port = flag.Uint("port", master.KubeletPort, "The port for the info server to serve on")
|
||||
hostnameOverride = flag.String("hostname_override", "", "If non-empty, will use this string as identification instead of the actual hostname.")
|
||||
networkContainerImage = flag.String("network_container_image", kubelet.NetworkContainerImage, "The image that network containers in each pod will use.")
|
||||
@@ -69,6 +70,7 @@ var (
|
||||
|
||||
func init() {
|
||||
flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated")
|
||||
flag.Var(&address, "address", "The IP address for the info server to serve on (set to 0.0.0.0 for all interfaces)")
|
||||
}
|
||||
|
||||
func getDockerEndpoint() string {
|
||||
@@ -199,7 +201,7 @@ func main() {
|
||||
// start the kubelet server
|
||||
if *enableServer {
|
||||
go util.Forever(func() {
|
||||
kubelet.ListenAndServeKubeletServer(k, cfg.Channel("http"), *address, *port)
|
||||
kubelet.ListenAndServeKubeletServer(k, cfg.Channel("http"), net.IP(address), *port)
|
||||
}, 0)
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
@@ -32,13 +33,14 @@ import (
|
||||
var (
|
||||
configFile = flag.String("configfile", "/tmp/proxy_config", "Configuration file for the proxy")
|
||||
etcdServerList util.StringList
|
||||
bindAddress = flag.String("bindaddress", "0.0.0.0", "The address for the proxy server to serve on (set to 0.0.0.0 or \"\" for all interfaces)")
|
||||
bindAddress = util.IP(net.ParseIP("0.0.0.0"))
|
||||
clientConfig = &client.Config{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
client.BindClientConfigFlags(flag.CommandLine, clientConfig)
|
||||
flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated (optional)")
|
||||
flag.Var(&bindAddress, "bind_address", "The address for the proxy server to serve on (set to 0.0.0.0 for all interfaces)")
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -85,7 +87,7 @@ func main() {
|
||||
glog.Infof("Using configuration file %s", *configFile)
|
||||
|
||||
loadBalancer := proxy.NewLoadBalancerRR()
|
||||
proxier := proxy.NewProxier(loadBalancer, *bindAddress)
|
||||
proxier := proxy.NewProxier(loadBalancer, net.IP(bindAddress))
|
||||
// Wire proxier to handle changes to services
|
||||
serviceConfig.RegisterHandler(proxier)
|
||||
// And wire loadBalancer to handle changes to endpoints to services
|
||||
|
Reference in New Issue
Block a user