Skip to content

Commit

Permalink
add InClusterConfig
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Karpov <pavel.karpov@flant.com>
  • Loading branch information
krpsh123 committed Feb 24, 2025
1 parent 3e9df3f commit 5ae36c4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions images/sds-local-volume-csi/src/pkg/kubutils/kubernetes.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/*
Copyright 2024 Flant JSC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -24,13 +21,18 @@ import (
)

func KubernetesDefaultConfigCreate() (*rest.Config, error) {
config, err := rest.InClusterConfig()
if err == nil {
return config, nil
}

clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
clientcmd.NewDefaultClientConfigLoadingRules(),
&clientcmd.ConfigOverrides{},
)

// Get a config to talk to API server
config, err := clientConfig.ClientConfig()
config, err = clientConfig.ClientConfig()
if err != nil {
return nil, fmt.Errorf("config kubernetes error %w", err)
}
Expand Down

0 comments on commit 5ae36c4

Please sign in to comment.