mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Cleanup some todos for gke + rip out dead AuthConfig code
This commit is contained in:
parent
ad83197c63
commit
3f3760a14a
@ -105,15 +105,6 @@ if [[ "$KUBERNETES_PROVIDER" == "gke" ]]; then
|
|||||||
config=(
|
config=(
|
||||||
"--context=gke_${PROJECT}_${ZONE}_${CLUSTER_NAME}"
|
"--context=gke_${PROJECT}_${ZONE}_${CLUSTER_NAME}"
|
||||||
)
|
)
|
||||||
# In gcloud versions prior to 0.9.59, GKE stores its kubeconfig
|
|
||||||
# in a separate location. If the file doesn't exist, then use
|
|
||||||
# the default kubeconfig file.
|
|
||||||
# TODO(roberthbailey): Remove this once gcloud 0.9.59 or above is released.
|
|
||||||
if [[ -e "${HOME}/.config/gcloud/kubernetes/kubeconfig" ]]; then
|
|
||||||
config+=(
|
|
||||||
"--kubeconfig=${HOME}/.config/gcloud/kubernetes/kubeconfig"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
elif [[ "$KUBERNETES_PROVIDER" == "ubuntu" ]]; then
|
elif [[ "$KUBERNETES_PROVIDER" == "ubuntu" ]]; then
|
||||||
detect-master > /dev/null
|
detect-master > /dev/null
|
||||||
config=(
|
config=(
|
||||||
|
@ -45,7 +45,6 @@ func init() {
|
|||||||
|
|
||||||
flag.StringVar(&context.KubeConfig, clientcmd.RecommendedConfigPathFlag, "", "Path to kubeconfig containing embeded authinfo.")
|
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.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.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, or apiserver, to connect to")
|
flag.StringVar(&context.Host, "host", "", "The host, or apiserver, 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.RepoRoot, "repo-root", "./", "Root directory of kubernetes repository, for finding test files. Default assumes working directory is repository root")
|
||||||
|
@ -87,18 +87,7 @@ if [[ -z "${AUTH_CONFIG:-}" ]]; then
|
|||||||
|
|
||||||
detect-master >/dev/null
|
detect-master >/dev/null
|
||||||
|
|
||||||
# In gcloud versions < 0.9.59, GKE stores its kubeconfig in a separate
|
if [[ "${KUBERNETES_PROVIDER}" == "conformance_test" ]]; then
|
||||||
# location.
|
|
||||||
# TODO: Remove this once gcloud 0.9.59 or above is released.
|
|
||||||
if [[ "${KUBERNETES_PROVIDER}" == "gke" && -e "${GCLOUD_CONFIG_DIR}/kubeconfig" ]]; then
|
|
||||||
# GKE stores its own kubeconfig in gcloud's config directory.
|
|
||||||
detect-project &> /dev/null
|
|
||||||
auth_config=(
|
|
||||||
"--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}" == "conformance_test" ]]; then
|
|
||||||
auth_config=(
|
auth_config=(
|
||||||
"--auth_config=${KUBERNETES_CONFORMANCE_TEST_AUTH_CONFIG:-}"
|
"--auth_config=${KUBERNETES_CONFORMANCE_TEST_AUTH_CONFIG:-}"
|
||||||
"--cert_dir=${KUBERNETES_CONFORMANCE_TEST_CERT_DIR:-}"
|
"--cert_dir=${KUBERNETES_CONFORMANCE_TEST_CERT_DIR:-}"
|
||||||
@ -106,7 +95,14 @@ if [[ -z "${AUTH_CONFIG:-}" ]]; then
|
|||||||
else
|
else
|
||||||
auth_config=(
|
auth_config=(
|
||||||
"--kubeconfig=${KUBECONFIG:-$DEFAULT_KUBECONFIG}"
|
"--kubeconfig=${KUBECONFIG:-$DEFAULT_KUBECONFIG}"
|
||||||
)
|
)
|
||||||
|
if [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
|
||||||
|
# gcloud doesn't override the current-context, so we explicitly set it
|
||||||
|
detect-project &> /dev/null
|
||||||
|
auth_config+=(
|
||||||
|
"--context=gke_${PROJECT}_${ZONE}_${CLUSTER_NAME}"
|
||||||
|
)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Conformance Test. No cloud-provider-specific preparation."
|
echo "Conformance Test. No cloud-provider-specific preparation."
|
||||||
|
@ -34,7 +34,6 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/clientauth"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
@ -55,7 +54,6 @@ const (
|
|||||||
type TestContextType struct {
|
type TestContextType struct {
|
||||||
KubeConfig string
|
KubeConfig string
|
||||||
KubeContext string
|
KubeContext string
|
||||||
AuthConfig string
|
|
||||||
CertDir string
|
CertDir string
|
||||||
Host string
|
Host string
|
||||||
RepoRoot string
|
RepoRoot string
|
||||||
@ -180,26 +178,8 @@ func loadConfig() (*client.Config, error) {
|
|||||||
c.CurrentContext = testContext.KubeContext
|
c.CurrentContext = testContext.KubeContext
|
||||||
}
|
}
|
||||||
return clientcmd.NewDefaultClientConfig(*c, &clientcmd.ConfigOverrides{}).ClientConfig()
|
return clientcmd.NewDefaultClientConfig(*c, &clientcmd.ConfigOverrides{}).ClientConfig()
|
||||||
case testContext.AuthConfig != "":
|
|
||||||
fmt.Printf(">>> testContext.AuthConfig: %s\n", testContext.AuthConfig)
|
|
||||||
config := &client.Config{
|
|
||||||
Host: testContext.Host,
|
|
||||||
}
|
|
||||||
info, err := clientauth.LoadFromFile(testContext.AuthConfig)
|
|
||||||
if err != nil {
|
|
||||||
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")
|
|
||||||
}
|
|
||||||
mergedConfig, err := info.MergeWithConfig(*config)
|
|
||||||
return &mergedConfig, err
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("either KubeConfig or AuthConfig must be specified to load client config")
|
return nil, fmt.Errorf("KubeConfig must be specified to load client config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user