Make the docker endpoint a flag.

This commit is contained in:
Brendan Burns
2014-06-27 16:07:30 -07:00
parent affaf173bf
commit f8060c5b3d
3 changed files with 31 additions and 12 deletions

View File

@@ -23,6 +23,7 @@ package main
import (
"flag"
"math/rand"
"os"
"os/exec"
"time"
@@ -43,6 +44,7 @@ var (
address = flag.String("address", "127.0.0.1", "The address for the info server to serve on")
port = flag.Uint("port", 10250, "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.")
dockerEndpoint = flag.String("docker_endpoint", "", "If non-empty, use this for the docker endpoint to communicate with")
)
const dockerBinary = "/usr/bin/docker"
@@ -56,7 +58,15 @@ func main() {
// Set up logger for etcd client
etcd.SetLogger(util.NewLogger("etcd "))
endpoint := "unix:///var/run/docker.sock"
var endpoint string
if len(*dockerEndpoint) > 0 {
endpoint = *dockerEndpoint
} else if len(os.Getenv("DOCKER_HOST")) > 0 {
endpoint = os.Getenv("DOCKER_HOST")
} else {
endpoint = "unix:///var/run/docker.sock"
}
glog.Infof("Connecting to docker on %s", endpoint)
dockerClient, err := docker.NewClient(endpoint)
if err != nil {
glog.Fatal("Couldn't connnect to docker.")
@@ -79,5 +89,5 @@ func main() {
SyncFrequency: *syncFrequency,
HTTPCheckFrequency: *httpCheckFrequency,
}
my_kubelet.RunKubelet(*config, *manifestUrl, *etcdServers, *address, *port)
my_kubelet.RunKubelet(*config, *manifestUrl, *etcdServers, *address, *dockerEndpoint, *port)
}