...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/dtest/k8sapply.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/dtest

     1  package dtest
     2  
     3  import (
     4  	"context"
     5  	"os"
     6  	"time"
     7  
     8  	"github.com/datawire/dlib/dexec"
     9  	"github.com/datawire/dlib/dlog"
    10  	"github.com/emissary-ingress/emissary/v3/pkg/k8s"
    11  	"github.com/emissary-ingress/emissary/v3/pkg/kubeapply"
    12  )
    13  
    14  // K8sApply applies the supplied manifests to the cluster indicated by
    15  // the supplied kubeconfig.
    16  func K8sApply(ctx context.Context, ver KubeVersion, files ...string) {
    17  	if os.Getenv("DOCKER_REGISTRY") == "" {
    18  		os.Setenv("DOCKER_REGISTRY", DockerRegistry(ctx))
    19  	}
    20  	kubeconfig := KubeVersionConfig(ctx, ver)
    21  	err := kubeapply.Kubeapply(ctx, k8s.NewKubeInfo(kubeconfig, "", ""), 300*time.Second, false, false, files...)
    22  	if err != nil {
    23  		dlog.Println(ctx)
    24  		dlog.Println(ctx, err)
    25  		dlog.Printf(ctx,
    26  			"Please note, if this is a timeout, then your kubernetes cluster may not "+
    27  				"exist or may be unreachable. Check access to your cluster with \"kubectl --kubeconfig %s\".",
    28  			kubeconfig)
    29  		dlog.Println(ctx)
    30  		cmd := dexec.CommandContext(ctx,
    31  			"kubectl", "--kubeconfig", kubeconfig,
    32  			"get", "--all-namespaces", "ns,svc,deploy,po",
    33  		)
    34  		_ = cmd.Run() // Command output and any error will be logged
    35  
    36  		os.Exit(1)
    37  	}
    38  }
    39  

View as plain text