Skip to content

Commit 6c93862

Browse files
committed
pkg/k8s-client: fix client creation
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
1 parent 6737e2c commit 6c93862

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/k8s-client/eks.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,19 +242,25 @@ func createClient(cfg *EKSConfig) (cli *kubernetes.Clientset, err error) {
242242
ClusterInfo: clientcmdapi.Cluster{Server: ""},
243243
},
244244
).ClientConfig()
245+
245246
case cfg.KubeConfigContext == "":
246247
cfg.Logger.Info("creating k8s client using KUBECONFIG",
247248
zap.String("kubeconfig", cfg.KubeConfigPath),
248249
)
249250
kcfg, err = clientcmd.BuildConfigFromFlags("", cfg.KubeConfigPath)
250251
}
252+
251253
if err != nil {
252254
cfg.Logger.Warn("failed to read kubeconfig", zap.Error(err))
253255
}
254256
}
255257
if kcfg == nil {
256258
kcfg = createClientConfigEKS(cfg)
257259
}
260+
if kcfg == nil {
261+
defaultConfig := clientcmd.DefaultClientConfig
262+
kcfg, _ = defaultConfig.ClientConfig()
263+
}
258264
if kcfg == nil {
259265
cfg.Logger.Warn("failed to create k8s client config")
260266
return nil, errors.New("failed to create k8s client config")
@@ -289,7 +295,7 @@ func createClient(cfg *EKSConfig) (cli *kubernetes.Clientset, err error) {
289295
)
290296
}
291297
if cfg.ClusterCADecoded == "" {
292-
return nil, errors.New("empty ClusterCADecoded")
298+
cfg.Logger.Warn("no cluster CA found in k8s client")
293299
}
294300

295301
if kcfg.AuthProvider != nil {

0 commit comments

Comments
 (0)