Move KubeNodeName out of driver package

上级 15b1647b
......@@ -29,7 +29,6 @@ import (
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/cruntime"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/vmpath"
"k8s.io/minikube/pkg/util"
)
......@@ -94,7 +93,7 @@ func GenerateKubeadmYAML(cc config.ClusterConfig, n config.Node, r cruntime.Mana
EtcdDataDir: EtcdDataDir(),
ClusterName: cc.Name,
//kubeadm uses NodeName as the --hostname-override parameter, so this needs to be the name of the machine
NodeName: driver.KubeNodeName(cc, n),
NodeName: KubeNodeName(cc, n),
CRISocket: r.SocketPath(),
ImageRepository: k8s.ImageRepository,
ComponentOptions: componentOpts,
......
......@@ -19,6 +19,7 @@ package bsutil
import (
"bytes"
"os"
"path"
"github.com/pkg/errors"
......@@ -60,7 +61,7 @@ func extraKubeletOpts(mc config.ClusterConfig, nc config.Node, r cruntime.Manage
if _, ok := extraOpts["node-ip"]; !ok {
extraOpts["node-ip"] = cp.IP
}
nodeName := driver.KubeNodeName(mc, nc)
nodeName := KubeNodeName(mc, nc)
if nodeName != "" {
extraOpts["hostname-override"] = nodeName
}
......@@ -117,3 +118,13 @@ func NewKubeletService(cfg config.KubernetesConfig) ([]byte, error) {
}
return b.Bytes(), nil
}
// KubeNodeName returns the node name registered in Kubernetes
func KubeNodeName(cc config.ClusterConfig, n config.Node) string {
if cc.Driver == driver.None {
// Always use hostname for "none" driver
hostname, _ := os.Hostname()
return hostname
}
return driver.MachineName(cc, n)
}
......@@ -237,16 +237,6 @@ func MachineName(cc config.ClusterConfig, n config.Node) string {
return fmt.Sprintf("%s---%s", cc.Name, n.Name)
}
// KubeNodeName returns the node name registered in Kubernetes
func KubeNodeName(cc config.ClusterConfig, n config.Node) string {
if cc.Driver == None {
// Always use hostname for "none" driver
hostname, _ := os.Hostname()
return hostname
}
return MachineName(cc, n)
}
// ClusterNameFromMachine retrieves the cluster name embedded in the machine name
func ClusterNameFromMachine(name string) (string, string) {
if strings.Contains(name, "---") {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册