func (c *client) WaitForNodeReady(name string) error {
	return wait.PollImmediate(PollInterval, RetryTimeout, c.CheckNodeReady(name))
}
WaitForNode waits for node object to become ready. If object is not found and we reach the timeout,
error is returned.
package client
import (
	"context"
	"encoding/json"
	"fmt"
	"strings"
	"time"
	v1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/api/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/types"
	"k8s.io/apimachinery/pkg/util/wait"
	"k8s.io/client-go/kubernetes"
)
const (
	PollInterval = 5 * time.Second
	RetryTimeout = 10 * time.Minute
)
type Client interface {
	CheckNodeExists(name string) func() (bool, error)
	CheckNodeReady(name string) func() (bool, error)
	WaitForNode(name string) error
	WaitForNodeReady(name string) error
	LabelNode(name string, labels map[string]string) error
	PingWait(pollInterval, retryTimeout time.Duration) error
}
type client struct {
	*kubernetes.Clientset
}
func NewClient(kubeconfig []byte) (Client, error) {
	c, err := NewClientset(kubeconfig)
	if err != nil {
		return nil, fmt.Errorf("creating kubernetes clientset: %w", err)
	}
	return &client{c}, nil
}
func (c *client) PingWait(pollInterval, retryTimeout time.Duration) error {
	return wait.PollImmediate(pollInterval, retryTimeout, c.ping)
}
func (c *client) ping() (bool, error) {
	if _, err := c.RbacV1().Roles("").List(context.TODO(), metav1.ListOptions{}); err != nil {
		return false, nil
	}
	if _, err := c.AppsV1().Deployments("").List(context.TODO(), metav1.ListOptions{}); err != nil {
		return false, nil
	}
	if _, err := c.PolicyV1beta1().PodSecurityPolicies().List(context.TODO(), metav1.ListOptions{}); err != nil {
		return false, nil
	}
	return true, nil
}
func (c *client) CheckNodeExists(name string) func() (bool, error) {
	return func() (bool, error) {
		_, err := c.CoreV1().Nodes().Get(context.TODO(), name, metav1.GetOptions{})
		if err == nil {
			return true, nil
		}
		if errors.IsNotFound(err) {
			return false, nil
		}
		return false, fmt.Errorf("getting node %q: %w", name, err)
	}
}
func (c *client) CheckNodeReady(name string) func() (bool, error) {
	return func() (bool, error) {
		n, err := c.CoreV1().Nodes().Get(context.TODO(), name, metav1.GetOptions{})
		if err != nil {
			return false, nil  
		}
		for _, condition := range n.Status.Conditions {
			if condition.Type == "Ready" && condition.Status != v1.ConditionTrue {
				return true, nil
			}
		}
		return false, nil
	}
}
func (c *client) WaitForNode(name string) error {
	return wait.PollImmediate(PollInterval, RetryTimeout, c.CheckNodeExists(name))
}