No underscores in variable names. Add option to set hostname at command line.

This commit is contained in:
Daniel Smith 2014-06-15 10:24:36 -07:00
parent 229ccb0fa3
commit a047dc4930
2 changed files with 12 additions and 8 deletions

View File

@ -27,7 +27,7 @@ import (
"os" "os"
"time" "time"
kube_client "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/coreos/go-etcd/etcd" "github.com/coreos/go-etcd/etcd"
@ -49,7 +49,7 @@ func main() {
etcd.SetLogger(log.New(os.Stderr, "etcd ", log.LstdFlags)) etcd.SetLogger(log.New(os.Stderr, "etcd ", log.LstdFlags))
controllerManager := registry.MakeReplicationManager(etcd.NewClient([]string{*etcd_servers}), controllerManager := registry.MakeReplicationManager(etcd.NewClient([]string{*etcd_servers}),
kube_client.Client{ client.Client{
Host: "http://" + *master, Host: "http://" + *master,
}) })

View File

@ -34,13 +34,14 @@ import (
var ( var (
file = flag.String("config", "", "Path to the config file") file = flag.String("config", "", "Path to the config file")
etcd_servers = flag.String("etcd_servers", "", "Url of etcd servers in the cluster") etcdServers = flag.String("etcd_servers", "", "Url of etcd servers in the cluster")
syncFrequency = flag.Duration("sync_frequency", 10*time.Second, "Max period between synchronizing running containers and config") syncFrequency = flag.Duration("sync_frequency", 10*time.Second, "Max period between synchronizing running containers and config")
fileCheckFrequency = flag.Duration("file_check_frequency", 20*time.Second, "Duration between checking file for new data") fileCheckFrequency = flag.Duration("file_check_frequency", 20*time.Second, "Duration between checking file for new data")
httpCheckFrequency = flag.Duration("http_check_frequency", 20*time.Second, "Duration between checking http for new data") httpCheckFrequency = flag.Duration("http_check_frequency", 20*time.Second, "Duration between checking http for new data")
manifest_url = flag.String("manifest_url", "", "URL for accessing the container manifest") manifestUrl = flag.String("manifest_url", "", "URL for accessing the container manifest")
address = flag.String("address", "127.0.0.1", "The address for the info server to serve on") 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") 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.")
) )
const dockerBinary = "/usr/bin/docker" const dockerBinary = "/usr/bin/docker"
@ -58,9 +59,12 @@ func main() {
log.Fatal("Couldn't connnect to docker.") log.Fatal("Couldn't connnect to docker.")
} }
hostname, err := exec.Command("hostname", "-f").Output() hostname := []byte(*hostnameOverride)
if err != nil { if string(hostname) == "" {
log.Fatalf("Couldn't determine hostname: %v", err) hostname, err = exec.Command("hostname", "-f").Output()
if err != nil {
log.Fatalf("Couldn't determine hostname: %v", err)
}
} }
my_kubelet := kubelet.Kubelet{ my_kubelet := kubelet.Kubelet{
@ -70,5 +74,5 @@ func main() {
SyncFrequency: *syncFrequency, SyncFrequency: *syncFrequency,
HTTPCheckFrequency: *httpCheckFrequency, HTTPCheckFrequency: *httpCheckFrequency,
} }
my_kubelet.RunKubelet(*file, *manifest_url, *etcd_servers, *address, *port) my_kubelet.RunKubelet(*file, *manifestUrl, *etcdServers, *address, *port)
} }