Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using in-cluster kubeconfig #7156

Merged
merged 6 commits into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions cluster-autoscaler/utils/kubernetes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import (
)

const (
failedToBuildConfigErr = "Failed to build config"
failedToParseK8sUrlErr = "Failed to parse Kubernetes url"
failedToBuildClientConfigErr = "Failed to build Kubernetes client configuration"
failedToBuildConfigErr = "Failed to build config"
failedToParseK8sUrlErr = "Failed to parse Kubernetes url"
failedToBuildClientConfigErr = "Failed to build Kubernetes client configuration"
failedToFindInClusterConfigErr = "Failed to find in-cluster config"
)

// CreateKubeClient creates kube client based on AutoscalingOptions.KubeClientOptions
Expand All @@ -50,7 +51,7 @@ func GetKubeConfig(opts config.KubeClientOptions) *rest.Config {
if err != nil {
klog.Fatalf("%v: %v", failedToBuildConfigErr, err)
}
} else {
} else if opts.Master != "" {
url, err := url.Parse(opts.Master)
if err != nil {
klog.Fatalf("%v: %v", failedToParseK8sUrlErr, err)
Expand All @@ -60,8 +61,12 @@ func GetKubeConfig(opts config.KubeClientOptions) *rest.Config {
if err != nil {
klog.Fatalf("%v: %v", failedToBuildClientConfigErr, err)
}
} else {
kubeConfig, err = rest.InClusterConfig()
if err != nil {
klog.Fatalf("%v: %v", failedToFindInClusterConfigErr, err)
}
}

kubeConfig.QPS = opts.KubeClientQPS
kubeConfig.Burst = opts.KubeClientBurst
kubeConfig.ContentType = opts.APIContentType
Expand Down
Loading