func (w *KubeWaiter) WaitForPodsWithLabel(kvLabel string) error {

	lastKnownPodNumber := -1
	return wait.PollImmediate(kubeadmconstants.APICallRetryInterval, w.timeout, func() (bool, error) {
		listOpts := metav1.ListOptions{LabelSelector: kvLabel}
		pods, err := w.client.CoreV1().Pods(metav1.NamespaceSystem).List(context.TODO(), listOpts)
		if err != nil {
			fmt.Fprintf(w.writer, "[apiclient] Error getting Pods with label selector %q [%v]\n", kvLabel, err)
			return false, nil
		}

		if lastKnownPodNumber != len(pods.Items) {
			fmt.Fprintf(w.writer, "[apiclient] Found %d Pods for label selector %s\n", len(pods.Items), kvLabel)
			lastKnownPodNumber = len(pods.Items)
		}

		if len(pods.Items) == 0 {
			return false, nil
		}

		for _, pod := range pods.Items {
			if pod.Status.Phase != v1.PodRunning {
				return false, nil
			}
		}

		return true, nil
	})
}
// WaitForPodsWithLabel will lookup pods with the given label and wait until they are all
// reporting status as running.
WaitForPodsWithLabel will lookup pods with the given label and wait until they are all
reporting status as running.
// WaitForPodsWithLabel will lookup pods with the given label and wait until they are all // reporting status as running .
func (w *KubeWaiter) WaitForPodsWithLabel(kvLabel string) error {
	lastKnownPodNumber := -1
	return wait.PollImmediate(kubeadmconstants.APICallRetryInterval, w.timeout, func() (bool, error) {
		listOpts := metav1.ListOptions{LabelSelector: kvLabel}
		pods, err := w.client.CoreV1().Pods(metav1.NamespaceSystem).List(context.TODO(), listOpts)
		if err != nil {
			fmt.Fprintf(w.writer, "[apiclient] Error getting Pods with label selector %q [%v]\n", kvLabel, err)
			return false, nil
		}
		if lastKnownPodNumber != len(pods.Items) {
			fmt.Fprintf(w.writer, "[apiclient] Found %d Pods for label selector %s\n", len(pods.Items), kvLabel)
			lastKnownPodNumber = len(pods.Items)
		}
		if len(pods.Items) == 0 {
			return false, nil
		}
		for _, pod := range pods.Items {
			if pod.Status.Phase != v1.PodRunning {
				return false, nil
			}
		}
		return true, nil
	})
}
func ( w * KubeWaiter ) WaitForPodsWithLabel ( kvLabel string ) error { lastKnownPodNumber := - 1 return wait . PollImmediate ( kubeadmconstants . APICallRetryInterval , w . timeout , func ( ) ( bool , error ) { listOpts := metav1 . ListOptions { LabelSelector : kvLabel } pods , err := w . client . CoreV1 ( ) . Pods ( metav1 . NamespaceSystem ) . List ( context . TODO ( ) , listOpts ) if err != nil { fmt . Fprintf ( w . writer , " \n " , kvLabel , err ) return false , nil } if lastKnownPodNumber != len ( pods . Items ) { fmt . Fprintf ( w . writer , " \n " , len ( pods . Items ) , kvLabel ) lastKnownPodNumber = len ( pods . Items ) } if len ( pods . Items ) == 0 { return false , nil } for _ , pod := range pods . Items { if pod . Status . Phase != v1 . PodRunning { return false , nil } } return true , nil } ) }
WaitForPodsWithLabel will lookup pods with the given label and wait until they are all
reporting status as running.
WaitForPodsWithLabel will lookup pods with the given label and wait until they are all reporting status as running .