From 6ce0c5bf6043adb64944bf5b5517ae3d8552d5f9 Mon Sep 17 00:00:00 2001 From: Abubakr-Sadik Nii Nai Davis Date: Sun, 15 Oct 2017 11:43:35 +0000 Subject: [PATCH] Add function to get pod specs for kubernetes components. --- cfg/config.yaml | 20 ++++++++++++++++---- cmd/common.go | 2 ++ cmd/util.go | 31 +++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/cfg/config.yaml b/cfg/config.yaml index 8ad2e89..e7c2e4f 100644 --- a/cfg/config.yaml +++ b/cfg/config.yaml @@ -26,42 +26,54 @@ master: - "hyperkube apiserver" - "apiserver" confs: - - /etc/kubernetes/manifests/kube-apiserver.yaml - /etc/kubernetes/apiserver.conf - /etc/kubernetes/apiserver defaultconf: /etc/kubernetes/apiserver + podspecs: + - /etc/kubernetes/manifests/kube-apiserver.yaml + defaultpodspec: /etc/kubernetes/manifests/kube-apiserver.yaml + scheduler: bins: - "kube-scheduler" - "hyperkube scheduler" - "scheduler" confs: - - /etc/kubernetes/manifests/kube-scheduler.yaml - /etc/kubernetes/scheduler.conf - /etc/kubernetes/scheduler defaultconf: /etc/kubernetes/scheduler + podspecs: + - /etc/kubernetes/manifests/kube-scheduler.yaml + defaultpodspec: /etc/kubernetes/manifests/kube-scheduler.yaml + controllermanager: bins: - "kube-controller-manager" - "hyperkube controller-manager" - "controller-manager" confs: - - /etc/kubernetes/manifests/kube-controller-manager.yaml - /etc/kubernetes/controller-manager.conf - /etc/kubernetes/controller-manager defaultconf: /etc/kubernetes/controller-manager + podspecs: + - /etc/kubernetes/manifests/kube-controller-manager.yaml + defaultpodspec: /etc/kubernetes/manifests/kube-controller-manager.yaml + etcd: optional: true bins: - "etcd" confs: - - /etc/kubernetes/manifests/etcd.yaml - /etc/etcd/etcd.conf defaultconf: /etc/etcd/etcd.conf + podspecs: + - /etc/kubernetes/manifests/etcd.yaml + defaultpodspec: /etc/kubernetes/manifests/etcd.yaml + flanneld: optional: true bins: diff --git a/cmd/common.go b/cmd/common.go index b618cff..e9cc610 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -67,6 +67,7 @@ func runChecks(t check.NodeType) { // checks that the executables we need for the node type are running. binmap := getBinaries(typeConf) confmap := getConfigFiles(typeConf) + podspecmap := getPodSpecFiles(typeConf) switch t { case check.MASTER: @@ -88,6 +89,7 @@ func runChecks(t check.NodeType) { s := string(in) s = makeSubstitutions(s, "bin", binmap) s = makeSubstitutions(s, "conf", confmap) + s = makeSubstitutions(s, "podspec", podspecmap) glog.V(1).Info(fmt.Sprintf("Using config file: %s\n", viper.ConfigFileUsed())) glog.V(1).Info(fmt.Sprintf("Using benchmark file: %s\n", path)) diff --git a/cmd/util.go b/cmd/util.go index 7524eaf..5dd2303 100644 --- a/cmd/util.go +++ b/cmd/util.go @@ -147,6 +147,37 @@ func getConfigFiles(v *viper.Viper) map[string]string { return confmap } +// getPodSpecFiles finds which of the set of candidate podspec files exist +func getPodSpecFiles(v *viper.Viper) map[string]string { + podspecmap := make(map[string]string) + + for _, component := range v.GetStringSlice("components") { + s := v.Sub(component) + if s == nil { + continue + } + + // See if any of the candidate podspec files exist + podspec := findConfigFile(s.GetStringSlice("podspecs")) + if podspec == "" { + if s.IsSet("defaultpodspec") { + podspec = s.GetString("defaultpodspec") + glog.V(2).Info(fmt.Sprintf("Using default podspec file name '%s' for component %s", podspec, component)) + } else { + // Default the config file name that we'll substitute to the name of the component + printlnWarn(fmt.Sprintf("Missing podspec file for %s", component)) + podspec = component + } + } else { + glog.V(2).Info(fmt.Sprintf("Component %s uses podspec file '%s'", component, podspec)) + } + + podspecmap[component] = podspec + } + + return podspecmap +} + // verifyBin checks that the binary specified is running func verifyBin(bin string) bool {