Make ks-apiserver be easier to run locally with kube config
Signed-off-by: rick <linuxsuren@users.noreply.github.com>
This commit is contained in:
@@ -18,6 +18,9 @@ package k8s
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"k8s.io/client-go/util/homedir"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
@@ -44,12 +47,18 @@ type KubernetesOptions struct {
|
||||
}
|
||||
|
||||
// NewKubernetesOptions returns a `zero` instance
|
||||
func NewKubernetesOptions() *KubernetesOptions {
|
||||
return &KubernetesOptions{
|
||||
KubeConfig: "",
|
||||
QPS: 1e6,
|
||||
Burst: 1e6,
|
||||
func NewKubernetesOptions() (option *KubernetesOptions) {
|
||||
option = &KubernetesOptions{
|
||||
QPS: 1e6,
|
||||
Burst: 1e6,
|
||||
}
|
||||
|
||||
// make it be easier for those who wants to run api-server locally
|
||||
userHomeConfig := path.Join(homedir.HomeDir(), ".kube/config")
|
||||
if _, err := os.Stat(userHomeConfig); !os.IsNotExist(err) {
|
||||
option.KubeConfig = userHomeConfig
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (k *KubernetesOptions) Validate() []error {
|
||||
|
||||
Reference in New Issue
Block a user