Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
make k8s restclient cfg configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyan2016 committed Jun 18, 2021
1 parent 9631566 commit 03b75ea
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/controller-manager/app/controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"flag"
"fmt"
"io/ioutil"
"k8s.io/klog"
"net/http"
"os"
"strings"
Expand All @@ -40,7 +41,6 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/component-base/logs"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/metrics"

"sigs.k8s.io/kubefed/cmd/controller-manager/app/leaderelection"
Expand All @@ -64,6 +64,8 @@ const (

var (
kubeconfig, kubeFedConfig, masterURL, metricsAddr, healthzAddr string
restConfigQPS float32
restConfigBurst int
)

// NewControllerManagerCommand creates a *cobra.Command object with default parameters
Expand Down Expand Up @@ -98,6 +100,8 @@ member clusters and do the necessary reconciliation`,
flags.StringVar(&kubeFedConfig, "kubefed-config", "", "Path to a KubeFedConfig yaml file. Test only.")
flags.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
flags.StringVar(&masterURL, "master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
flags.Float32Var(&restConfigQPS, "rest-config-qps", 5.0, "Maximum QPS to the api-server from this client.")
flags.IntVar(&restConfigBurst, "rest-config-burst", 10, "Maximum burst for throttle to the api-server from this client.")

local := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
klog.InitFlags(local)
Expand All @@ -121,6 +125,12 @@ func Run(opts *options.Options, stopChan <-chan struct{}) error {
if err != nil {
panic(err)
}
if restConfigQPS > 0 {
opts.Config.KubeConfig.QPS = restConfigQPS
}
if restConfigBurst > 0 {
opts.Config.KubeConfig.Burst = restConfigBurst
}

runningInCluster := len(masterURL) == 0 && len(kubeconfig) == 0
if runningInCluster && len(opts.Config.KubeFedNamespace) == 0 {
Expand Down

0 comments on commit 03b75ea

Please sign in to comment.