Skip to content

Commit

Permalink
master is no longer a thing
Browse files Browse the repository at this point in the history
  • Loading branch information
sharifelgamal committed Jan 24, 2020
1 parent 0681830 commit 0b460e6
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/config/profile_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var printProfilesTable = func() {
if err != nil {
glog.Infof("error getting host status for %v", err)
}
master, err := config.MasterNode(*p.Config)
master, err := config.PrimaryControlPlane(*p.Config)
if err != nil {
exit.WithError("profile has no master node", err)
}
Expand Down
9 changes: 5 additions & 4 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -937,11 +937,12 @@ func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string, drvName string)
out.T(out.SuccessType, "Using image repository {{.name}}", out.V{"name": repository})
}

masterNode := config.Node{
// Create the initial node, which will necessarily be a control plane
cp := config.Node{
Port: viper.GetInt(apiServerPort),
KubernetesVersion: k8sVersion,
Name: constants.DefaultNodeName,
Type: config.Master,
Type: config.ControlPlane,
}

cfg := config.MachineConfig{
Expand Down Expand Up @@ -991,9 +992,9 @@ func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string, drvName string)
ShouldLoadCachedImages: viper.GetBool(cacheImages),
EnableDefaultCNI: selectedEnableDefaultCNI,
},
Nodes: []config.Node{masterNode},
Nodes: []config.Node{cp},
}
return cfg, masterNode, nil
return cfg, cp, nil
}

// setDockerProxy sets the proxy environment variables in the docker environment.
Expand Down
10 changes: 5 additions & 5 deletions pkg/minikube/bootstrapper/bsutil/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ func GenerateKubeadmYAML(mc config.MachineConfig, r cruntime.Manager) ([]byte, e
}

// In case of no port assigned, use default
master, err := config.MasterNode(mc)
cp, err := config.PrimaryControlPlane(mc)
if err != nil {
return nil, errors.Wrap(err, "getting master node")
return nil, errors.Wrap(err, "getting control plane")
}
nodePort := master.Port
nodePort := cp.Port
if nodePort <= 0 {
nodePort = constants.APIServerPort
}
Expand All @@ -82,11 +82,11 @@ func GenerateKubeadmYAML(mc config.MachineConfig, r cruntime.Manager) ([]byte, e
CertDir: vmpath.GuestCertsDir,
ServiceCIDR: constants.DefaultServiceCIDR,
PodSubnet: k8s.ExtraOptions.Get("pod-network-cidr", Kubeadm),
AdvertiseAddress: master.IP,
AdvertiseAddress: cp.IP,
APIServerPort: nodePort,
KubernetesVersion: k8s.KubernetesVersion,
EtcdDataDir: EtcdDataDir(),
NodeName: master.Name,
NodeName: cp.Name,
CRISocket: r.SocketPath(),
ImageRepository: k8s.ImageRepository,
ExtraArgs: extraComponentConfig,
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/bootstrapper/bsutil/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ func NewKubeletConfig(mc config.MachineConfig, r cruntime.Manager) ([]byte, erro
if k8s.NetworkPlugin != "" {
extraOpts["network-plugin"] = k8s.NetworkPlugin
}
master, err := config.MasterNode(mc)
cp, err := config.PrimaryControlPlane(mc)
if err != nil {
return nil, errors.Wrap(err, "getting master node")
}
if _, ok := extraOpts["node-ip"]; !ok {
extraOpts["node-ip"] = master.IP
extraOpts["node-ip"] = cp.IP
}

pauseImage := images.Pause(k8s.ImageRepository)
Expand Down
10 changes: 5 additions & 5 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (k *Bootstrapper) StartCluster(cfg config.MachineConfig) error {
return err
}

master, err := config.MasterNode(cfg)
cp, err := config.PrimaryControlPlane(cfg)
if err != nil {
return err
}
Expand Down Expand Up @@ -249,7 +249,7 @@ func (k *Bootstrapper) StartCluster(cfg config.MachineConfig) error {
if !driver.IsKIC(cfg.VMDriver) { // TODO: skip for both after verifications https://github.com/kubernetes/minikube/issues/6239
glog.Infof("Configuring cluster permissions ...")
elevate := func() error {
client, err := k.client(master)
client, err := k.client(cp)
if err != nil {
return err
}
Expand Down Expand Up @@ -295,18 +295,18 @@ func (k *Bootstrapper) client(n config.Node) (*kubernetes.Clientset, error) {
func (k *Bootstrapper) WaitForCluster(cfg config.MachineConfig, timeout time.Duration) error {
start := time.Now()
out.T(out.Waiting, "Waiting for cluster to come online ...")
master, err := config.MasterNode(cfg)
cp, err := config.PrimaryControlPlane(cfg)
if err != nil {
return err
}
if err := kverify.APIServerProcess(k.c, start, timeout); err != nil {
return err
}
if err := kverify.APIServerIsRunning(start, master.IP, master.Port, timeout); err != nil {
if err := kverify.APIServerIsRunning(start, cp.IP, cp.Port, timeout); err != nil {
return err
}

c, err := k.client(master)
c, err := k.client(cp)
if err != nil {
return errors.Wrap(err, "get k8s client")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/config/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package config
func AddNode(cc *MachineConfig, name string, controlPlane bool, k8sVersion string, profileName string) error {
t := Worker
if controlPlane {
t = Master
t = ControlPlane
}
node := Node{
Name: name,
Expand Down
6 changes: 3 additions & 3 deletions pkg/minikube/config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ func (p *Profile) IsValid() bool {
return true
}

// MasterNode gets the node specific config for the control plane
func MasterNode(cc MachineConfig) (Node, error) {
// PrimaryControlPlane gets the node specific config for the first created control plane
func PrimaryControlPlane(cc MachineConfig) (Node, error) {
for _, n := range cc.Nodes {
if n.Type == Master {
if n.Type == ControlPlane {
return n, nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ type Node struct {
type NodeType int

const (
// Master is the control plane.
Master NodeType = iota
// ControlPlane is the control plane.
ControlPlane NodeType = iota
// Worker is a... worker.
Worker
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/registry/drvs/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ func init() {
}

func configure(mc config.MachineConfig) interface{} {
master, _ := config.MasterNode(mc)
cp, _ := config.PrimaryControlPlane(mc)
return kic.NewDriver(kic.Config{
MachineName: mc.Name,
StorePath: localpath.MiniPath(),
ImageDigest: kic.BaseImage,
CPU: mc.CPUs,
Memory: mc.Memory,
HostBindPort: master.Port,
HostBindPort: cp.Port,
OCIBinary: oci.Docker,
})

Expand Down

0 comments on commit 0b460e6

Please sign in to comment.