workaround for "none" driver and IsPrimaryControlPlane()
parent
99ea346caa
commit
32b2a5fece
|
@ -50,7 +50,7 @@ func enableOrDisableStorageClasses(cc *config.ClusterConfig, name string, val st
|
|||
defer api.Close()
|
||||
|
||||
pcp, err := config.ControlPlane(*cc)
|
||||
if err != nil || !config.IsPrimaryControlPlane(pcp) {
|
||||
if err != nil || !config.IsPrimaryControlPlane(*cc, pcp) {
|
||||
return errors.Wrap(err, "get primary control-plane node")
|
||||
}
|
||||
if !machine.IsRunning(api, config.MachineName(*cc, pcp)) {
|
||||
|
|
|
@ -124,7 +124,7 @@ func SetupCerts(k8s config.ClusterConfig, n config.Node, pcpCmd command.Runner,
|
|||
if n.ControlPlane {
|
||||
// copy essential certs from primary control-plane node to secondaries
|
||||
// ref: https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/high-availability/#manual-certs
|
||||
if !config.IsPrimaryControlPlane(n) {
|
||||
if !config.IsPrimaryControlPlane(k8s, n) {
|
||||
pcpCerts := []struct {
|
||||
srcDir string
|
||||
srcFile string
|
||||
|
|
|
@ -596,7 +596,7 @@ func (k *Bootstrapper) restartPrimaryControlPlane(cfg config.ClusterConfig) erro
|
|||
}
|
||||
|
||||
pcp, err := config.ControlPlane(cfg)
|
||||
if err != nil || !config.IsPrimaryControlPlane(pcp) {
|
||||
if err != nil || !config.IsPrimaryControlPlane(cfg, pcp) {
|
||||
return errors.Wrap(err, "get primary control-plane node")
|
||||
}
|
||||
|
||||
|
@ -911,7 +911,7 @@ func (k *Bootstrapper) UpdateCluster(cfg config.ClusterConfig) error {
|
|||
}
|
||||
|
||||
pcp, err := config.ControlPlane(cfg)
|
||||
if err != nil || !config.IsPrimaryControlPlane(pcp) {
|
||||
if err != nil || !config.IsPrimaryControlPlane(cfg, pcp) {
|
||||
return errors.Wrap(err, "get primary control-plane node")
|
||||
}
|
||||
|
||||
|
@ -947,7 +947,7 @@ func (k *Bootstrapper) UpdateNode(cfg config.ClusterConfig, n config.Node, r cru
|
|||
if n.ControlPlane {
|
||||
// for primary control-plane node only, generate kubeadm config based on current params
|
||||
// on node restart, it will be checked against later if anything needs changing
|
||||
if config.IsPrimaryControlPlane(n) {
|
||||
if config.IsPrimaryControlPlane(cfg, n) {
|
||||
kubeadmCfg, err := bsutil.GenerateKubeadmYAML(cfg, n, r)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "generating kubeadm cfg")
|
||||
|
@ -963,7 +963,7 @@ func (k *Bootstrapper) UpdateNode(cfg config.ClusterConfig, n config.Node, r cru
|
|||
if err != nil {
|
||||
return errors.Wrapf(err, "parsing kubernetes version %q", cfg.KubernetesConfig.KubernetesVersion)
|
||||
}
|
||||
workaround := kv.GTE(semver.Version{Major: 1, Minor: 29}) && config.IsPrimaryControlPlane(n) && len(config.ControlPlanes(cfg)) == 1
|
||||
workaround := kv.GTE(semver.Version{Major: 1, Minor: 29}) && config.IsPrimaryControlPlane(cfg, n) && len(config.ControlPlanes(cfg)) == 1
|
||||
kubevipCfg, err := kubevip.Configure(cfg, workaround)
|
||||
if err != nil {
|
||||
klog.Errorf("couldn't generate kube-vip config, this might cause issues (will continue): %v", err)
|
||||
|
@ -1056,7 +1056,7 @@ func (k *Bootstrapper) labelAndUntaintNode(cfg config.ClusterConfig, n config.No
|
|||
// ensure that "primary" label is applied only to the 1st node in the cluster (used eg for placing ingress there)
|
||||
// this is used to uniquely distinguish that from other nodes in multi-master/multi-control-plane cluster config
|
||||
primaryLbl := "minikube.k8s.io/primary=false"
|
||||
if config.IsPrimaryControlPlane(n) {
|
||||
if config.IsPrimaryControlPlane(cfg, n) {
|
||||
primaryLbl = "minikube.k8s.io/primary=true"
|
||||
}
|
||||
|
||||
|
@ -1083,7 +1083,7 @@ func (k *Bootstrapper) labelAndUntaintNode(cfg config.ClusterConfig, n config.No
|
|||
}
|
||||
|
||||
// primary control-plane and worker nodes should be untainted by default
|
||||
if n.ControlPlane && !config.IsPrimaryControlPlane(n) {
|
||||
if n.ControlPlane && !config.IsPrimaryControlPlane(cfg, n) {
|
||||
// example:
|
||||
// sudo /var/lib/minikube/binaries/<version>/kubectl --kubeconfig=/var/lib/minikube/kubeconfig taint nodes test-357 node-role.kubernetes.io/control-plane:NoSchedule-
|
||||
cmd := exec.CommandContext(ctx, "sudo", kubectlPath(cfg), fmt.Sprintf("--kubeconfig=%s", path.Join(vmpath.GuestPersistentDir, "kubeconfig")),
|
||||
|
|
|
@ -54,8 +54,10 @@ func ControlPlanes(cc ClusterConfig) []Node {
|
|||
}
|
||||
|
||||
// IsPrimaryControlPlane returns if node is primary control-plane node.
|
||||
func IsPrimaryControlPlane(node Node) bool {
|
||||
return node.ControlPlane && node.Name == ""
|
||||
func IsPrimaryControlPlane(cc ClusterConfig, node Node) bool {
|
||||
// TODO (prezha): find where, for "none" driver, we set first (ie, primary control-plane) node name to "m01" - that should not happen but it's happening before pr #17909
|
||||
// return node.ControlPlane && node.Name == ""
|
||||
return cc.Nodes != nil && cc.Nodes[0].Name == node.Name
|
||||
}
|
||||
|
||||
// IsValid checks if the profile has the essential info needed for a profile
|
||||
|
|
|
@ -135,7 +135,7 @@ func Start(starter Starter) (*kubeconfig.Settings, error) { // nolint:gocyclo
|
|||
|
||||
var kcs *kubeconfig.Settings
|
||||
var bs bootstrapper.Bootstrapper
|
||||
if config.IsPrimaryControlPlane(*starter.Node) {
|
||||
if config.IsPrimaryControlPlane(*starter.Cfg, *starter.Node) {
|
||||
// [re]start primary control-plane node
|
||||
kcs, bs, err = startPrimaryControlPlane(starter, cr)
|
||||
if err != nil {
|
||||
|
@ -228,7 +228,7 @@ func Start(starter Starter) (*kubeconfig.Settings, error) { // nolint:gocyclo
|
|||
}
|
||||
|
||||
// for ha cluster, primary control-plane node will not come up alone until secondary joins
|
||||
if config.HA(*starter.Cfg) && config.IsPrimaryControlPlane(*starter.Node) {
|
||||
if config.HA(*starter.Cfg) && config.IsPrimaryControlPlane(*starter.Cfg, *starter.Node) {
|
||||
klog.Infof("HA cluster: will skip waiting for primary control-plane node %+v", starter.Node)
|
||||
} else {
|
||||
klog.Infof("Will wait %s for node %+v", viper.GetDuration(waitTimeout), starter.Node)
|
||||
|
@ -274,7 +274,7 @@ func handleNoKubernetes(starter Starter) (bool, error) {
|
|||
|
||||
// startPrimaryControlPlane starts control-plane node.
|
||||
func startPrimaryControlPlane(starter Starter, cr cruntime.Manager) (*kubeconfig.Settings, bootstrapper.Bootstrapper, error) {
|
||||
if !config.IsPrimaryControlPlane(*starter.Node) {
|
||||
if !config.IsPrimaryControlPlane(*starter.Cfg, *starter.Node) {
|
||||
return nil, nil, fmt.Errorf("node not marked as primary control-plane")
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,7 @@ func Provision(cc *config.ClusterConfig, n *config.Node, delOnFail bool) (comman
|
|||
if n.ControlPlane {
|
||||
role = "control-plane"
|
||||
}
|
||||
if config.IsPrimaryControlPlane(*n) {
|
||||
if config.IsPrimaryControlPlane(*cc, *n) {
|
||||
role = "primary control-plane"
|
||||
}
|
||||
out.Step(style.ThumbsUp, "Starting \"{{.node}}\" {{.role}} node in \"{{.cluster}}\" cluster", out.V{"node": name, "role": role, "cluster": cc.Name})
|
||||
|
|
Loading…
Reference in New Issue