mirror of https://github.com/k3s-io/k3s
commit
1ff0a1e2a1
|
@ -91,6 +91,7 @@ function verify-prereqs() {
|
|||
gcloud_prompt="-q"
|
||||
fi
|
||||
gcloud ${gcloud_prompt:-} components update preview || true
|
||||
gcloud ${gcloud_prompt:-} components update alpha || true
|
||||
gcloud ${gcloud_prompt:-} components update || true
|
||||
}
|
||||
|
||||
|
@ -128,7 +129,7 @@ function kube-up() {
|
|||
fi
|
||||
|
||||
# Bring up the cluster.
|
||||
"${GCLOUD}" preview container clusters create "${CLUSTER_NAME}" \
|
||||
"${GCLOUD}" alpha container clusters create "${CLUSTER_NAME}" \
|
||||
--zone="${ZONE}" \
|
||||
--project="${PROJECT}" \
|
||||
--cluster-api-version="${CLUSTER_API_VERSION:-}" \
|
||||
|
@ -175,10 +176,10 @@ function test-setup() {
|
|||
function get-password() {
|
||||
echo "... in get-password()" >&2
|
||||
detect-project >&2
|
||||
KUBE_USER=$("${GCLOUD}" preview container clusters describe \
|
||||
KUBE_USER=$("${GCLOUD}" alpha container clusters describe \
|
||||
--project="${PROJECT}" --zone="${ZONE}" "${CLUSTER_NAME}" \
|
||||
| grep user | cut -f 4 -d ' ')
|
||||
KUBE_PASSWORD=$("${GCLOUD}" preview container clusters describe \
|
||||
KUBE_PASSWORD=$("${GCLOUD}" alpha container clusters describe \
|
||||
--project="${PROJECT}" --zone="${ZONE}" "${CLUSTER_NAME}" \
|
||||
| grep password | cut -f 4 -d ' ')
|
||||
}
|
||||
|
@ -195,7 +196,7 @@ function detect-master() {
|
|||
echo "... in detect-master()" >&2
|
||||
detect-project >&2
|
||||
KUBE_MASTER="k8s-${CLUSTER_NAME}-master"
|
||||
KUBE_MASTER_IP=$("${GCLOUD}" preview container clusters describe \
|
||||
KUBE_MASTER_IP=$("${GCLOUD}" alpha container clusters describe \
|
||||
--project="${PROJECT}" --zone="${ZONE}" "${CLUSTER_NAME}" \
|
||||
| grep endpoint | cut -f 2 -d ' ')
|
||||
}
|
||||
|
@ -218,7 +219,7 @@ function detect-minions() {
|
|||
function detect-minion-names {
|
||||
detect-project
|
||||
export MINION_NAMES=""
|
||||
count=$("${GCLOUD}" preview container clusters describe --project="${PROJECT}" --zone="${ZONE}" "${CLUSTER_NAME}" | grep numNodes | cut -f 2 -d ' ')
|
||||
count=$("${GCLOUD}" alpha container clusters describe --project="${PROJECT}" --zone="${ZONE}" "${CLUSTER_NAME}" | grep numNodes | cut -f 2 -d ' ')
|
||||
for x in $(seq 1 $count); do
|
||||
export MINION_NAMES="${MINION_NAMES} k8s-${CLUSTER_NAME}-node-${x} ";
|
||||
done
|
||||
|
@ -286,6 +287,6 @@ function test-teardown() {
|
|||
function kube-down() {
|
||||
echo "... in kube-down()" >&2
|
||||
detect-project >&2
|
||||
"${GCLOUD}" preview container clusters delete --project="${PROJECT}" \
|
||||
"${GCLOUD}" alpha container clusters delete --project="${PROJECT}" \
|
||||
--zone="${ZONE}" "${CLUSTER_NAME}"
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ if [[ "$KUBERNETES_PROVIDER" == "gke" ]]; then
|
|||
kubectl="${GCLOUD}"
|
||||
# GKE runs kubectl through gcloud.
|
||||
config=(
|
||||
"preview"
|
||||
"alpha"
|
||||
"container"
|
||||
"kubectl"
|
||||
"--project=${PROJECT}"
|
||||
|
|
|
@ -28,29 +28,34 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
kubeConfig = flag.String(clientcmd.RecommendedConfigPathFlag, "", "Path to kubeconfig containing embeded authinfo. Will use cluster/user info from 'current-context'")
|
||||
authConfig = flag.String("auth_config", "", "Path to the auth info file.")
|
||||
certDir = flag.String("cert_dir", "", "Path to the directory containing the certs. Default is empty, which doesn't use certs.")
|
||||
gceProject = flag.String("gce_project", "", "The GCE project being used, if applicable")
|
||||
gceZone = flag.String("gce_zone", "", "GCE zone being used, if applicable")
|
||||
host = flag.String("host", "", "The host to connect to")
|
||||
masterName = flag.String("kube_master", "", "Name of the kubernetes master. Only required if provider is gce or gke")
|
||||
provider = flag.String("provider", "", "The name of the Kubernetes provider")
|
||||
orderseed = flag.Int64("orderseed", 0, "If non-zero, seed of random test shuffle order. (Otherwise random.)")
|
||||
repoRoot = flag.String("repo_root", "./", "Root directory of kubernetes repository, for finding test files. Default assumes working directory is repository root")
|
||||
reportDir = flag.String("report_dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.")
|
||||
times = flag.Int("times", 1, "Number of times each test is eligible to be run. Individual order is determined by shuffling --times instances of each test using --orderseed (like a multi-deck shoe of cards).")
|
||||
testList util.StringList
|
||||
context = &e2e.TestContextType{}
|
||||
gceConfig = &context.GCEConfig
|
||||
|
||||
orderseed = flag.Int64("orderseed", 0, "If non-zero, seed of random test shuffle order. (Otherwise random.)")
|
||||
reportDir = flag.String("report_dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.")
|
||||
times = flag.Int("times", 1, "Number of times each test is eligible to be run. Individual order is determined by shuffling --times instances of each test using --orderseed (like a multi-deck shoe of cards).")
|
||||
testList util.StringList
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.VarP(&testList, "test", "t", "Test to execute (may be repeated or comma separated list of tests.) Defaults to running all tests.")
|
||||
|
||||
flag.StringVar(&context.KubeConfig, clientcmd.RecommendedConfigPathFlag, "", "Path to kubeconfig containing embeded authinfo.")
|
||||
flag.StringVar(&context.KubeContext, clientcmd.FlagContext, "", "kubeconfig context to use/override. If unset, will use value from 'current-context'")
|
||||
flag.StringVar(&context.AuthConfig, "auth_config", "", "Path to the auth info file.")
|
||||
flag.StringVar(&context.CertDir, "cert_dir", "", "Path to the directory containing the certs. Default is empty, which doesn't use certs.")
|
||||
flag.StringVar(&context.Host, "host", "", "The host to connect to")
|
||||
flag.StringVar(&context.RepoRoot, "repo_root", "./", "Root directory of kubernetes repository, for finding test files. Default assumes working directory is repository root")
|
||||
flag.StringVar(&context.Provider, "provider", "", "The name of the Kubernetes provider")
|
||||
flag.StringVar(&gceConfig.MasterName, "kube_master", "", "Name of the kubernetes master. Only required if provider is gce or gke")
|
||||
flag.StringVar(&gceConfig.ProjectID, "gce_project", "", "The GCE project being used, if applicable")
|
||||
flag.StringVar(&gceConfig.Zone, "gce_zone", "", "GCE zone being used, if applicable")
|
||||
}
|
||||
|
||||
func main() {
|
||||
util.InitFlags()
|
||||
goruntime.GOMAXPROCS(goruntime.NumCPU())
|
||||
if *provider == "" {
|
||||
if context.Provider == "" {
|
||||
glog.Info("The --provider flag is not set. Treating as a conformance test. Some tests may not be run.")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
@ -58,10 +63,5 @@ func main() {
|
|||
glog.Error("Invalid --times (negative or no testing requested)!")
|
||||
os.Exit(1)
|
||||
}
|
||||
gceConfig := &e2e.GCEConfig{
|
||||
ProjectID: *gceProject,
|
||||
Zone: *gceZone,
|
||||
MasterName: *masterName,
|
||||
}
|
||||
e2e.RunE2ETests(*kubeConfig, *authConfig, *certDir, *host, *repoRoot, *provider, gceConfig, *orderseed, *times, *reportDir, testList)
|
||||
e2e.RunE2ETests(context, *orderseed, *times, *reportDir, testList)
|
||||
}
|
||||
|
|
|
@ -95,12 +95,12 @@ if [[ -z "${AUTH_CONFIG:-}" ]]; then
|
|||
"--kubeconfig=${HOME}/.kubernetes_vagrant_kubeconfig"
|
||||
)
|
||||
elif [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
|
||||
# With GKE, our auth and certs are in gcloud's config directory.
|
||||
# GKE stores its own kubeconfig in gcloud's config directory.
|
||||
detect-project &> /dev/null
|
||||
cfg_dir="${GCLOUD_CONFIG_DIR}/${PROJECT}.${ZONE}.${CLUSTER_NAME}"
|
||||
auth_config=(
|
||||
"--auth_config=${cfg_dir}/kubernetes_auth"
|
||||
"--cert_dir=${cfg_dir}"
|
||||
"--kubeconfig=${GCLOUD_CONFIG_DIR}/kubeconfig"
|
||||
# gcloud doesn't set the current-context, so we have to set it
|
||||
"--context=gke_${PROJECT}_${ZONE}_${CLUSTER_NAME}"
|
||||
)
|
||||
elif [[ "${KUBERNETES_PROVIDER}" == "gce" ]]; then
|
||||
auth_config=(
|
||||
|
|
|
@ -32,14 +32,14 @@ var _ = Describe("MasterCerts", func() {
|
|||
})
|
||||
|
||||
It("should have all expected certs on the master", func() {
|
||||
if testContext.provider != "gce" && testContext.provider != "gke" {
|
||||
By(fmt.Sprintf("Skipping MasterCerts test for cloud provider %s (only supported for gce and gke)", testContext.provider))
|
||||
if testContext.Provider != "gce" && testContext.Provider != "gke" {
|
||||
By(fmt.Sprintf("Skipping MasterCerts test for cloud provider %s (only supported for gce and gke)", testContext.Provider))
|
||||
return
|
||||
}
|
||||
|
||||
for _, certFile := range []string{"kubecfg.key", "kubecfg.crt", "ca.crt"} {
|
||||
cmd := exec.Command("gcloud", "compute", "ssh", "--project", testContext.gceConfig.ProjectID,
|
||||
"--zone", testContext.gceConfig.Zone, testContext.gceConfig.MasterName,
|
||||
cmd := exec.Command("gcloud", "compute", "ssh", "--project", testContext.GCEConfig.ProjectID,
|
||||
"--zone", testContext.GCEConfig.Zone, testContext.GCEConfig.MasterName,
|
||||
"--command", fmt.Sprintf("ls /srv/kubernetes/%s", certFile))
|
||||
if _, err := cmd.CombinedOutput(); err != nil {
|
||||
Fail(fmt.Sprintf("Error checking for cert file %s on master: %v", certFile, err))
|
||||
|
|
|
@ -53,8 +53,8 @@ func (t *testResult) Fail() { *t = false }
|
|||
|
||||
// Run each Go end-to-end-test. This function assumes the
|
||||
// creation of a test cluster.
|
||||
func RunE2ETests(kubeConfig, authConfig, certDir, host, repoRoot, provider string, gceConfig *GCEConfig, orderseed int64, times int, reportDir string, testList []string) {
|
||||
testContext = testContextType{kubeConfig, authConfig, certDir, host, repoRoot, provider, *gceConfig}
|
||||
func RunE2ETests(context *TestContextType, orderseed int64, times int, reportDir string, testList []string) {
|
||||
testContext = *context
|
||||
util.ReallyCrash = true
|
||||
util.InitLogs()
|
||||
defer util.FlushLogs()
|
||||
|
|
|
@ -60,8 +60,8 @@ func ClusterLevelLoggingWithElasticsearch(c *client.Client) {
|
|||
// TODO: For now assume we are only testing cluster logging with Elasticsearch
|
||||
// on GCE. Once we are sure that Elasticsearch cluster level logging
|
||||
// works for other providers we should widen this scope of this test.
|
||||
if testContext.provider != "gce" {
|
||||
Logf("Skipping cluster level logging test for provider %s", testContext.provider)
|
||||
if testContext.Provider != "gce" {
|
||||
Logf("Skipping cluster level logging test for provider %s", testContext.Provider)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ var _ = Describe("Events", func() {
|
|||
})
|
||||
|
||||
It("should be sent by kubelets and the scheduler about pods scheduling and running", func() {
|
||||
provider := testContext.provider
|
||||
provider := testContext.Provider
|
||||
if len(provider) > 0 && provider != "gce" && provider != "gke" && provider != "aws" {
|
||||
By(fmt.Sprintf("skipping TestKubeletSendsEvent on cloud provider %s", provider))
|
||||
return
|
||||
|
|
|
@ -53,7 +53,7 @@ var _ = Describe("kubectl", func() {
|
|||
|
||||
Describe("update-demo", func() {
|
||||
var (
|
||||
updateDemoRoot = filepath.Join(testContext.repoRoot, "examples/update-demo/v1beta1")
|
||||
updateDemoRoot = filepath.Join(testContext.RepoRoot, "examples/update-demo/v1beta1")
|
||||
nautilusPath = filepath.Join(updateDemoRoot, "nautilus-rc.yaml")
|
||||
kittenPath = filepath.Join(updateDemoRoot, "kitten-rc.yaml")
|
||||
)
|
||||
|
@ -94,7 +94,7 @@ var _ = Describe("kubectl", func() {
|
|||
})
|
||||
|
||||
Describe("guestbook", func() {
|
||||
var guestbookPath = filepath.Join(testContext.repoRoot, "examples/guestbook")
|
||||
var guestbookPath = filepath.Join(testContext.RepoRoot, "examples/guestbook")
|
||||
|
||||
It("should create and stop a working application", func() {
|
||||
defer cleanup(guestbookPath, frontendSelector, redisMasterSelector, redisSlaveSelector)
|
||||
|
|
|
@ -40,9 +40,9 @@ var _ = Describe("Monitoring", func() {
|
|||
})
|
||||
|
||||
It("verify monitoring pods and all cluster nodes are available on influxdb using heapster.", func() {
|
||||
if testContext.provider != "gce" {
|
||||
if testContext.Provider != "gce" {
|
||||
By(fmt.Sprintf("Skipping Monitoring test, which is only supported for provider gce (not %s)",
|
||||
testContext.provider))
|
||||
testContext.Provider))
|
||||
return
|
||||
}
|
||||
testMonitoringUsingHeapsterInfluxdb(c)
|
||||
|
@ -192,7 +192,7 @@ func validatePodsAndNodes(influxdbClient *influxdb.Client, expectedPods, expecte
|
|||
}
|
||||
|
||||
func getMasterHost() string {
|
||||
masterUrl, err := url.Parse(testContext.host)
|
||||
masterUrl, err := url.Parse(testContext.Host)
|
||||
expectNoError(err)
|
||||
return masterUrl.Host
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ var _ = Describe("Networking", func() {
|
|||
ns := "nettest-" + randomSuffix()
|
||||
|
||||
It("should function for pods", func() {
|
||||
if testContext.provider == "vagrant" {
|
||||
if testContext.Provider == "vagrant" {
|
||||
By("Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -55,9 +55,9 @@ var _ = Describe("PD", func() {
|
|||
})
|
||||
|
||||
It("should schedule a pod w/ a RW PD, remove it, then schedule it on another host", func() {
|
||||
if testContext.provider != "gce" {
|
||||
if testContext.Provider != "gce" {
|
||||
By(fmt.Sprintf("Skipping PD test, which is only supported for provider gce (not %s)",
|
||||
testContext.provider))
|
||||
testContext.Provider))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ var _ = Describe("PD", func() {
|
|||
host1Pod := testPDPod(diskName, host1Name, false)
|
||||
|
||||
By(fmt.Sprintf("creating PD %q", diskName))
|
||||
expectNoError(createPD(diskName, testContext.gceConfig.Zone), "Error creating PD")
|
||||
expectNoError(createPD(diskName, testContext.GCEConfig.Zone), "Error creating PD")
|
||||
|
||||
defer func() {
|
||||
By("cleaning up PD-RW test environment")
|
||||
|
@ -73,9 +73,9 @@ var _ = Describe("PD", func() {
|
|||
// Teardown should do nothing unless test failed.
|
||||
podClient.Delete(host0Pod.Name)
|
||||
podClient.Delete(host1Pod.Name)
|
||||
detachPD(host0Name, diskName, testContext.gceConfig.Zone)
|
||||
detachPD(host1Name, diskName, testContext.gceConfig.Zone)
|
||||
deletePD(diskName, testContext.gceConfig.Zone)
|
||||
detachPD(host0Name, diskName, testContext.GCEConfig.Zone)
|
||||
detachPD(host1Name, diskName, testContext.GCEConfig.Zone)
|
||||
deletePD(diskName, testContext.GCEConfig.Zone)
|
||||
}()
|
||||
|
||||
By("submitting host0Pod to kubernetes")
|
||||
|
@ -98,7 +98,7 @@ var _ = Describe("PD", func() {
|
|||
|
||||
By(fmt.Sprintf("deleting PD %q", diskName))
|
||||
for start := time.Now(); time.Since(start) < 180*time.Second; time.Sleep(5 * time.Second) {
|
||||
if err = deletePD(diskName, testContext.gceConfig.Zone); err != nil {
|
||||
if err = deletePD(diskName, testContext.GCEConfig.Zone); err != nil {
|
||||
Logf("Couldn't delete PD. Sleeping 5 seconds")
|
||||
continue
|
||||
}
|
||||
|
@ -110,9 +110,9 @@ var _ = Describe("PD", func() {
|
|||
})
|
||||
|
||||
It("should schedule a pod w/ a readonly PD on two hosts, then remove both.", func() {
|
||||
if testContext.provider != "gce" {
|
||||
if testContext.Provider != "gce" {
|
||||
By(fmt.Sprintf("Skipping PD test, which is only supported for provider gce (not %s)",
|
||||
testContext.provider))
|
||||
testContext.Provider))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -127,13 +127,13 @@ var _ = Describe("PD", func() {
|
|||
podClient.Delete(rwPod.Name)
|
||||
podClient.Delete(host0ROPod.Name)
|
||||
podClient.Delete(host1ROPod.Name)
|
||||
detachPD(host0Name, diskName, testContext.gceConfig.Zone)
|
||||
detachPD(host1Name, diskName, testContext.gceConfig.Zone)
|
||||
deletePD(diskName, testContext.gceConfig.Zone)
|
||||
detachPD(host0Name, diskName, testContext.GCEConfig.Zone)
|
||||
detachPD(host1Name, diskName, testContext.GCEConfig.Zone)
|
||||
deletePD(diskName, testContext.GCEConfig.Zone)
|
||||
}()
|
||||
|
||||
By(fmt.Sprintf("creating PD %q", diskName))
|
||||
expectNoError(createPD(diskName, testContext.gceConfig.Zone), "Error creating PD")
|
||||
expectNoError(createPD(diskName, testContext.GCEConfig.Zone), "Error creating PD")
|
||||
|
||||
By("submitting rwPod to ensure PD is formatted")
|
||||
_, err := podClient.Create(rwPod)
|
||||
|
@ -161,7 +161,7 @@ var _ = Describe("PD", func() {
|
|||
|
||||
By(fmt.Sprintf("deleting PD %q", diskName))
|
||||
for start := time.Now(); time.Since(start) < 180*time.Second; time.Sleep(5 * time.Second) {
|
||||
if err = deletePD(diskName, testContext.gceConfig.Zone); err != nil {
|
||||
if err = deletePD(diskName, testContext.GCEConfig.Zone); err != nil {
|
||||
Logf("Couldn't delete PD. Sleeping 5 seconds")
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -44,12 +44,12 @@ var _ = Describe("ReplicationController", func() {
|
|||
})
|
||||
|
||||
It("should serve a basic image on each replica with a private image", func() {
|
||||
switch testContext.provider {
|
||||
switch testContext.Provider {
|
||||
case "gce", "gke":
|
||||
ServeImageOrFail(c, "private", "gcr.io/_b_k8s_authenticated_test/serve_hostname:1.1")
|
||||
default:
|
||||
By(fmt.Sprintf("Skipping private variant, which is only supported for providers gce and gke (not %s)",
|
||||
testContext.provider))
|
||||
testContext.Provider))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -46,7 +46,7 @@ var _ = Describe("Services", func() {
|
|||
})
|
||||
|
||||
It("should provide DNS for the cluster", func() {
|
||||
if testContext.provider == "vagrant" {
|
||||
if testContext.Provider == "vagrant" {
|
||||
By("Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -41,17 +41,18 @@ const (
|
|||
podStartTimeout = 5 * time.Minute
|
||||
)
|
||||
|
||||
type testContextType struct {
|
||||
kubeConfig string
|
||||
authConfig string
|
||||
certDir string
|
||||
host string
|
||||
repoRoot string
|
||||
provider string
|
||||
gceConfig GCEConfig
|
||||
type TestContextType struct {
|
||||
KubeConfig string
|
||||
KubeContext string
|
||||
AuthConfig string
|
||||
CertDir string
|
||||
Host string
|
||||
RepoRoot string
|
||||
Provider string
|
||||
GCEConfig GCEConfig
|
||||
}
|
||||
|
||||
var testContext testContextType
|
||||
var testContext TestContextType
|
||||
|
||||
func Logf(format string, a ...interface{}) {
|
||||
fmt.Fprintf(GinkgoWriter, "INFO: "+format+"\n", a...)
|
||||
|
@ -133,32 +134,37 @@ func waitForPodSuccess(c *client.Client, podName string, contName string) error
|
|||
|
||||
func loadConfig() (*client.Config, error) {
|
||||
switch {
|
||||
case testContext.kubeConfig != "":
|
||||
fmt.Printf(">>> testContext.kubeConfig: %s\n", testContext.kubeConfig)
|
||||
c, err := clientcmd.LoadFromFile(testContext.kubeConfig)
|
||||
case testContext.KubeConfig != "":
|
||||
fmt.Printf(">>> testContext.KubeConfig: %s\n", testContext.KubeConfig)
|
||||
c, err := clientcmd.LoadFromFile(testContext.KubeConfig)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error loading kubeConfig: %v", err.Error())
|
||||
return nil, fmt.Errorf("error loading KubeConfig: %v", err.Error())
|
||||
}
|
||||
if testContext.KubeContext != "" {
|
||||
fmt.Printf(">>> testContext.KubeContext: %s\n", testContext.KubeContext)
|
||||
c.CurrentContext = testContext.KubeContext
|
||||
}
|
||||
return clientcmd.NewDefaultClientConfig(*c, &clientcmd.ConfigOverrides{}).ClientConfig()
|
||||
case testContext.authConfig != "":
|
||||
case testContext.AuthConfig != "":
|
||||
fmt.Printf(">>> testContext.AuthConfig: %s\n", testContext.AuthConfig)
|
||||
config := &client.Config{
|
||||
Host: testContext.host,
|
||||
Host: testContext.Host,
|
||||
}
|
||||
info, err := clientauth.LoadFromFile(testContext.authConfig)
|
||||
info, err := clientauth.LoadFromFile(testContext.AuthConfig)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error loading authConfig: %v", err.Error())
|
||||
return nil, fmt.Errorf("error loading AuthConfig: %v", err.Error())
|
||||
}
|
||||
// If the certificate directory is provided, set the cert paths to be there.
|
||||
if testContext.certDir != "" {
|
||||
Logf("Expecting certs in %v.", testContext.certDir)
|
||||
info.CAFile = filepath.Join(testContext.certDir, "ca.crt")
|
||||
info.CertFile = filepath.Join(testContext.certDir, "kubecfg.crt")
|
||||
info.KeyFile = filepath.Join(testContext.certDir, "kubecfg.key")
|
||||
if testContext.CertDir != "" {
|
||||
Logf("Expecting certs in %v.", testContext.CertDir)
|
||||
info.CAFile = filepath.Join(testContext.CertDir, "ca.crt")
|
||||
info.CertFile = filepath.Join(testContext.CertDir, "kubecfg.crt")
|
||||
info.KeyFile = filepath.Join(testContext.CertDir, "kubecfg.key")
|
||||
}
|
||||
mergedConfig, err := info.MergeWithConfig(*config)
|
||||
return &mergedConfig, err
|
||||
default:
|
||||
return nil, fmt.Errorf("either kubeConfig or authConfig must be specified to load client config")
|
||||
return nil, fmt.Errorf("either KubeConfig or AuthConfig must be specified to load client config")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,21 +273,21 @@ func validateController(c *client.Client, containerImage string, replicas int, c
|
|||
// kubectlCmd runs the kubectl executable.
|
||||
func kubectlCmd(args ...string) *exec.Cmd {
|
||||
defaultArgs := []string{}
|
||||
if testContext.kubeConfig != "" {
|
||||
defaultArgs = append(defaultArgs, "--"+clientcmd.RecommendedConfigPathFlag+"="+testContext.kubeConfig)
|
||||
if testContext.KubeConfig != "" {
|
||||
defaultArgs = append(defaultArgs, "--"+clientcmd.RecommendedConfigPathFlag+"="+testContext.KubeConfig)
|
||||
} else {
|
||||
defaultArgs = append(defaultArgs, "--"+clientcmd.FlagAuthPath+"="+testContext.authConfig)
|
||||
if testContext.certDir != "" {
|
||||
defaultArgs = append(defaultArgs, "--"+clientcmd.FlagAuthPath+"="+testContext.AuthConfig)
|
||||
if testContext.CertDir != "" {
|
||||
defaultArgs = append(defaultArgs,
|
||||
fmt.Sprintf("--certificate-authority=%s", filepath.Join(testContext.certDir, "ca.crt")),
|
||||
fmt.Sprintf("--client-certificate=%s", filepath.Join(testContext.certDir, "kubecfg.crt")),
|
||||
fmt.Sprintf("--client-key=%s", filepath.Join(testContext.certDir, "kubecfg.key")))
|
||||
fmt.Sprintf("--certificate-authority=%s", filepath.Join(testContext.CertDir, "ca.crt")),
|
||||
fmt.Sprintf("--client-certificate=%s", filepath.Join(testContext.CertDir, "kubecfg.crt")),
|
||||
fmt.Sprintf("--client-key=%s", filepath.Join(testContext.CertDir, "kubecfg.key")))
|
||||
}
|
||||
}
|
||||
kubectlArgs := append(defaultArgs, args...)
|
||||
// TODO: Remove this once gcloud writes a proper entry in the kubeconfig file.
|
||||
if testContext.provider == "gke" {
|
||||
kubectlArgs = append(kubectlArgs, "--server="+testContext.host)
|
||||
if testContext.Provider == "gke" {
|
||||
kubectlArgs = append(kubectlArgs, "--server="+testContext.Host)
|
||||
}
|
||||
//TODO: the "kubectl" path string might be worth externalizing into an (optional) ginko arg.
|
||||
cmd := exec.Command("kubectl", kubectlArgs...)
|
||||
|
|
Loading…
Reference in New Issue