@@ -28,9 +28,10 @@ import (
28
28
)
29
29
30
30
const (
31
- failedToBuildConfigErr = "Failed to build config"
32
- failedToParseK8sUrlErr = "Failed to parse Kubernetes url"
33
- failedToBuildClientConfigErr = "Failed to build Kubernetes client configuration"
31
+ failedToBuildConfigErr = "Failed to build config"
32
+ failedToParseK8sUrlErr = "Failed to parse Kubernetes url"
33
+ failedToBuildClientConfigErr = "Failed to build Kubernetes client configuration"
34
+ failedToFindInClusterConfigErr = "Failed to find in-cluster config"
34
35
)
35
36
36
37
// CreateKubeClient creates kube client based on AutoscalingOptions.KubeClientOptions
@@ -50,7 +51,7 @@ func GetKubeConfig(opts config.KubeClientOptions) *rest.Config {
50
51
if err != nil {
51
52
klog .Fatalf ("%v: %v" , failedToBuildConfigErr , err )
52
53
}
53
- } else {
54
+ } else if opts . Master != "" {
54
55
url , err := url .Parse (opts .Master )
55
56
if err != nil {
56
57
klog .Fatalf ("%v: %v" , failedToParseK8sUrlErr , err )
@@ -60,8 +61,12 @@ func GetKubeConfig(opts config.KubeClientOptions) *rest.Config {
60
61
if err != nil {
61
62
klog .Fatalf ("%v: %v" , failedToBuildClientConfigErr , err )
62
63
}
64
+ } else {
65
+ kubeConfig , err = rest .InClusterConfig ()
66
+ if err != nil {
67
+ klog .Fatalf ("%v: %v" , failedToFindInClusterConfigErr , err )
68
+ }
63
69
}
64
-
65
70
kubeConfig .QPS = opts .KubeClientQPS
66
71
kubeConfig .Burst = opts .KubeClientBurst
67
72
kubeConfig .ContentType = opts .APIContentType
0 commit comments