2016-08-18 12:38:18 +00:00
|
|
|
/*
|
|
|
|
Copyright 2016 The Kubernetes Authors.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/spf13/pflag"
|
|
|
|
|
|
|
|
"k8s.io/kubernetes/pkg/kubeadm/cmd"
|
|
|
|
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
|
|
|
"k8s.io/kubernetes/pkg/util/logs"
|
|
|
|
)
|
|
|
|
|
|
|
|
var CommandLine *pflag.FlagSet
|
|
|
|
|
|
|
|
// TODO(phase2) use componentconfig
|
|
|
|
// we need some params for testing etc, let's keep these hidden for now
|
|
|
|
func getEnvParams() map[string]string {
|
|
|
|
globalPrefix := os.Getenv("KUBE_PREFIX_ALL")
|
|
|
|
if globalPrefix == "" {
|
|
|
|
globalPrefix = "/etc/kubernetes"
|
|
|
|
}
|
|
|
|
|
|
|
|
envParams := map[string]string{
|
2016-09-06 14:30:58 +00:00
|
|
|
"prefix": globalPrefix,
|
|
|
|
"host_pki_path": path.Join(globalPrefix, "pki"),
|
2016-09-11 13:39:35 +00:00
|
|
|
"host_etcd_path": "/var/lib/etcd",
|
2016-09-07 12:53:11 +00:00
|
|
|
"hyperkube_image": "",
|
|
|
|
"discovery_image": "dgoodwin/kubediscovery:latest", // TODO(phase1): fmt.Sprintf("gcr.io/google_containers/kube-discovery-%s:%s", runtime.GOARCH, "1.0"),
|
|
|
|
"etcd_image": "",
|
2016-09-02 09:19:38 +00:00
|
|
|
"component_loglevel": "--v=4",
|
2016-08-18 12:38:18 +00:00
|
|
|
}
|
|
|
|
|
2016-09-02 09:19:38 +00:00
|
|
|
for k := range envParams {
|
2016-08-18 12:38:18 +00:00
|
|
|
if v := os.Getenv(fmt.Sprintf("KUBE_%s", strings.ToUpper(k))); v != "" {
|
|
|
|
envParams[k] = v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return envParams
|
|
|
|
}
|
|
|
|
|
|
|
|
func Run() error {
|
|
|
|
CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ContinueOnError)
|
|
|
|
logs.InitLogs()
|
|
|
|
defer logs.FlushLogs()
|
|
|
|
|
2016-09-07 12:53:11 +00:00
|
|
|
// We do not want these flags to show up in --help
|
|
|
|
pflag.CommandLine.MarkHidden("google-json-key")
|
|
|
|
pflag.CommandLine.MarkHidden("log-flush-frequency")
|
|
|
|
|
2016-08-18 12:38:18 +00:00
|
|
|
cmd := cmd.NewKubeadmCommand(cmdutil.NewFactory(nil), os.Stdin, os.Stdout, os.Stderr, getEnvParams())
|
|
|
|
return cmd.Execute()
|
|
|
|
}
|