func (ncc *Checker) Run(ctx context.Context, cancel context.CancelFunc, client *kubernetes.Clientset) error {
	log.Infoln("Running network connection checker")
	doneChan := make(chan error)
	runTimeout := time.After(checkTimeout)
	ncc.client = client
	go func(doneChan chan error) {
		err := ncc.doChecks()
		doneChan <- err
	}(doneChan)
	select {
	case <-ctx.Done():
		log.Println("Cancelling check and shutting down due to interrupt.")
		return reportKHFailure("Cancelling check and shutting down due to interrupt.")
	case <-runTimeout:
		cancel()
		log.Println("Cancelling check and shutting down due to timeout.")
		return reportKHFailure("Failed to complete network connection check in time! Timeout was reached.")
	case err := <-doneChan:
		cancel()
		if err != nil && ncc.targetUnreachable != true {
			return reportKHFailure(err.Error())
		}
		return reportKHSuccess()
	}
}
Run implements the entrypoint for check execution
package main
import (
	"context"
	"errors"
	"io/ioutil"
	"net"
	"os"
	"strconv"
	"strings"
	"time"
	log "github.com/sirupsen/logrus"
	_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
	"k8s.io/client-go/kubernetes"
	checkclient "github.com/kuberhealthy/kuberhealthy/v2/pkg/checks/external/checkclient"
	"github.com/kuberhealthy/kuberhealthy/v2/pkg/checks/external/nodeCheck"
	"github.com/kuberhealthy/kuberhealthy/v2/pkg/kubeClient"
)
var (
	kubeConfigFile    = os.Getenv("KUBECONFIG")
	checkTimeout      time.Duration
	connectionTarget  string
	targetUnreachable bool
	checkNamespace    string
	ctx               context.Context
)
const (
	errorMessage = "Failed to complete network connection check in time! Timeout was reached."
)
type Checker struct {
	client            *kubernetes.Clientset
	connectionTarget  string
	targetUnreachable bool
}
func init() {
	var err error
	checkTimeout = time.Duration(time.Second * 20)
	timeDeadline, err := checkclient.GetDeadline()
	if err != nil {
		log.Infoln("There was an issue getting the check deadline:", err.Error())
	}
	checkTimeout = timeDeadline.Sub(time.Now().Add(time.Second * 5))
	log.Infoln("Check time limit set to:", checkTimeout)
	connectionTarget = os.Getenv("CONNECTION_TARGET")
	if len(connectionTarget) == 0 {
		log.Errorln("CONNECTION_TARGET environment variable has not been set.")
		return
	}
	targetUnreachable, err = strconv.ParseBool(os.Getenv("CONNECTION_TARGET_UNREACHABLE"))
	if err != nil {
		log.Infoln("CONNECTION_TARGET_UNREACHABLE could not be parsed.")
		return
	}
	data, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
	if err != nil {
		log.Warnln("Failed to open namespace file:", err.Error())
	}
	if len(data) != 0 {
		log.Infoln("Found pod namespace:", string(data))
		checkNamespace = string(data)
	}
	nodeCheck.EnableDebugOutput()
}
func main() {
	client, err := kubeClient.Create(kubeConfigFile)
	if err != nil {
		log.Fatalln("Unable to create kubernetes client", err)
	}
	ncc := New()
	var cancelFunc context.CancelFunc
	ctx, cancelFunc = context.WithTimeout(context.Background(), checkTimeout)
	waitForNodeToJoin(ctx)
	err = ncc.Run(ctx, cancelFunc, client)
	if err != nil {
		log.Errorln("Error running network connection check for:", connectionTarget)
	}
	log.Infoln("Done running network connection check for:", connectionTarget)
}
func New() *Checker {
	return &Checker{
		connectionTarget:  connectionTarget,
		targetUnreachable: targetUnreachable,
	}
}