@@ -676,34 +676,6 @@ func (k *Bootstrapper) restartControlPlane(cfg config.ClusterConfig) error {
676676 }
677677 }
678678
679- if cfg .VerifyComponents [kverify .ExtraKey ] {
680- // after kubelet is restarted (with 'kubeadm init phase kubelet-start' above),
681- // it appears as to be immediately Ready as well as all kube-system pods (last observed state),
682- // then (after ~10sec) it realises it has some changes to apply, implying also pods restarts,
683- // and by that time we would exit completely, so we wait until kubelet begins restarting pods
684- klog .Info ("waiting for restarted kubelet to initialise ..." )
685- start := time .Now ()
686- wait := func () error {
687- pods , err := client .CoreV1 ().Pods (meta .NamespaceSystem ).List (context .Background (), meta.ListOptions {LabelSelector : "tier=control-plane" })
688- if err != nil {
689- return err
690- }
691- for _ , pod := range pods .Items {
692- if ready , _ := kverify .IsPodReady (& pod ); ! ready {
693- return nil
694- }
695- }
696- return fmt .Errorf ("kubelet not initialised" )
697- }
698- _ = retry .Expo (wait , 250 * time .Millisecond , 1 * time .Minute )
699- klog .Infof ("kubelet initialised" )
700- klog .Infof ("duration metric: took %s waiting for restarted kubelet to initialise ..." , time .Since (start ))
701-
702- if err := kverify .WaitExtra (client , kverify .CorePodsLabels , kconst .DefaultControlPlaneTimeout ); err != nil {
703- return errors .Wrap (err , "extra" )
704- }
705- }
706-
707679 cr , err := cruntime .New (cruntime.Config {Type : cfg .KubernetesConfig .ContainerRuntime , Runner : k .c })
708680 if err != nil {
709681 return errors .Wrap (err , "runtime" )
@@ -741,6 +713,35 @@ func (k *Bootstrapper) restartControlPlane(cfg config.ClusterConfig) error {
741713 return errors .Wrap (err , "addons" )
742714 }
743715
716+ // must be called after applyCNI and `kubeadm phase addon all` (ie, coredns redeploy)
717+ if cfg .VerifyComponents [kverify .ExtraKey ] {
718+ // after kubelet is restarted (with 'kubeadm init phase kubelet-start' above),
719+ // it appears as to be immediately Ready as well as all kube-system pods (last observed state),
720+ // then (after ~10sec) it realises it has some changes to apply, implying also pods restarts,
721+ // and by that time we would exit completely, so we wait until kubelet begins restarting pods
722+ klog .Info ("waiting for restarted kubelet to initialise ..." )
723+ start := time .Now ()
724+ wait := func () error {
725+ pods , err := client .CoreV1 ().Pods (meta .NamespaceSystem ).List (context .Background (), meta.ListOptions {LabelSelector : "tier=control-plane" })
726+ if err != nil {
727+ return err
728+ }
729+ for _ , pod := range pods .Items {
730+ if ready , _ := kverify .IsPodReady (& pod ); ! ready {
731+ return nil
732+ }
733+ }
734+ return fmt .Errorf ("kubelet not initialised" )
735+ }
736+ _ = retry .Expo (wait , 250 * time .Millisecond , 1 * time .Minute )
737+ klog .Infof ("kubelet initialised" )
738+ klog .Infof ("duration metric: took %s waiting for restarted kubelet to initialise ..." , time .Since (start ))
739+
740+ if err := kverify .WaitExtra (client , kverify .CorePodsLabels , kconst .DefaultControlPlaneTimeout ); err != nil {
741+ return errors .Wrap (err , "extra" )
742+ }
743+ }
744+
744745 if err := bsutil .AdjustResourceLimits (k .c ); err != nil {
745746 klog .Warningf ("unable to adjust resource limits: %v" , err )
746747 }
@@ -776,9 +777,17 @@ func (k *Bootstrapper) GenerateToken(cc config.ClusterConfig) (string, error) {
776777 joinCmd := r .Stdout .String ()
777778 joinCmd = strings .Replace (joinCmd , "kubeadm" , bsutil .InvokeKubeadm (cc .KubernetesConfig .KubernetesVersion ), 1 )
778779 joinCmd = fmt .Sprintf ("%s --ignore-preflight-errors=all" , strings .TrimSpace (joinCmd ))
779- if cc .KubernetesConfig .CRISocket != "" {
780- joinCmd = fmt .Sprintf ("%s --cri-socket %s" , joinCmd , cc .KubernetesConfig .CRISocket )
780+
781+ // avoid "Found multiple CRI sockets, please use --cri-socket to select one: /var/run/dockershim.sock, /var/run/crio/crio.sock" error
782+ cr , err := cruntime .New (cruntime.Config {Type : cc .KubernetesConfig .ContainerRuntime , Runner : k .c , Socket : cc .KubernetesConfig .CRISocket })
783+ if err != nil {
784+ klog .Errorf ("cruntime: %v" , err )
785+ }
786+ sp := cr .SocketPath ()
787+ if sp == "" {
788+ sp = kconst .DefaultDockerCRISocket
781789 }
790+ joinCmd = fmt .Sprintf ("%s --cri-socket %s" , joinCmd , sp )
782791
783792 return joinCmd , nil
784793}
0 commit comments