Make node name registered in K8s part of Node type

上级 63aef4ab
......@@ -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: n.InternalName(),
CRISocket: r.SocketPath(),
ImageRepository: k8s.ImageRepository,
ComponentOptions: componentOpts,
......
......@@ -26,7 +26,6 @@ import (
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/cruntime"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/util"
)
......@@ -60,7 +59,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 := nc.InternalName()
if nodeName != "" {
extraOpts["hostname-override"] = nodeName
}
......
......@@ -18,6 +18,7 @@ package config
import (
"net"
"os"
"github.com/blang/semver"
)
......@@ -102,6 +103,17 @@ type Node struct {
Worker bool
}
// returns the name to be registered kubernetes
func (n Node) InternalName() string {
if n.Name == "" {
// Always use hostname for "none" driver
hostname, _ := os.Hostname()
return hostname
}
return n.Name
}
// VersionedExtraOption holds information on flags to apply to a specific range
// of versions
type VersionedExtraOption struct {
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册