From e4651743308e52ac4ca3808d26f2b65b434deb44 Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Mon, 29 May 2023 13:21:34 +0530 Subject: [PATCH] feat(provisioner): Expose Kubernetes client QPS and Burst as flags (#234) (#235) * Expose Kubernetes client QPS and Burst as flags * feat(operator-yaml): add flags for k8s client qps and burst --------- Signed-off-by: Michael Morello Signed-off-by: Niladri Halder Co-authored-by: Michael Morello --- cmd/main.go | 8 ++++++++ deploy/lvm-operator.yaml | 4 ++++ pkg/driver/config/config.go | 6 ++++++ pkg/driver/controller.go | 10 ++++++++++ 4 files changed, 28 insertions(+) diff --git a/cmd/main.go b/cmd/main.go index d3d0e8c4..219a7ed5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -98,6 +98,14 @@ func main() { &config.DisableExporterMetrics, "disable-exporter-metrics", true, "Exclude metrics about the exporter itself (process_*, go_*).", ) + cmd.PersistentFlags().IntVar( + &config.KubeAPIQPS, "kube-api-qps", 0, "QPS to use while talking with Kubernetes API server.", + ) + + cmd.PersistentFlags().IntVar( + &config.KubeAPIBurst, "kube-api-burst", 0, "Burst to allow while talking with Kubernetes API server.", + ) + config.RIopsLimitPerGB = cmd.PersistentFlags().StringSlice( "riops-per-gb", []string{}, "Read IOPS per GB limit to use for each volume group prefix, "+ diff --git a/deploy/lvm-operator.yaml b/deploy/lvm-operator.yaml index 2f3a27ed..f86be38d 100644 --- a/deploy/lvm-operator.yaml +++ b/deploy/lvm-operator.yaml @@ -1273,6 +1273,8 @@ spec: args : - "--endpoint=$(OPENEBS_CSI_ENDPOINT)" - "--plugin=$(OPENEBS_CONTROLLER_DRIVER)" + - "--kube-api-qps=0" + - "--kube-api-burst=0" volumeMounts: - name: socket-dir mountPath: /var/lib/csi/sockets/pluginproxy/ @@ -1460,6 +1462,8 @@ spec: - "--endpoint=$(OPENEBS_CSI_ENDPOINT)" - "--plugin=$(OPENEBS_NODE_DRIVER)" - "--listen-address=$(METRICS_LISTEN_ADDRESS)" + - "--kube-api-qps=0" + - "--kube-api-burst=0" env: - name: OPENEBS_NODE_ID valueFrom: diff --git a/pkg/driver/config/config.go b/pkg/driver/config/config.go index d353e11e..04a7a837 100644 --- a/pkg/driver/config/config.go +++ b/pkg/driver/config/config.go @@ -79,6 +79,12 @@ type Config struct { // Exclude metrics about the exporter itself (process_*, go_*). DisableExporterMetrics bool + + // KubeAPIQPS is the QPS to use while talking with Kubernetes API server. + KubeAPIQPS int + + // KubeAPIBurst is the burst to allow while talking with Kubernetes API server. + KubeAPIBurst int } // Default returns a new instance of config diff --git a/pkg/driver/controller.go b/pkg/driver/controller.go index 7287a3e8..0ce1c8b0 100644 --- a/pkg/driver/controller.go +++ b/pkg/driver/controller.go @@ -181,6 +181,16 @@ func (cs *controller) init() error { return errors.Wrapf(err, "failed to build kubeconfig") } + if cs.driver.config.KubeAPIQPS > 0 { + klog.Infof("setting k8s client qps to %d", cs.driver.config.KubeAPIQPS) + cfg.QPS = float32(cs.driver.config.KubeAPIQPS) + } + + if cs.driver.config.KubeAPIBurst > 0 { + cfg.Burst = cs.driver.config.KubeAPIBurst + klog.Infof("setting k8s client burst to %d", cs.driver.config.KubeAPIBurst) + } + kubeClient, err := kubernetes.NewForConfig(cfg) if err != nil { return errors.Wrap(err, "failed to build k8s clientset")