Skip to content

Commit

Permalink
feat(provisioner): Expose Kubernetes client QPS and Burst as flags (#234
Browse files Browse the repository at this point in the history
) (#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 <[email protected]>
Signed-off-by: Niladri Halder <[email protected]>
Co-authored-by: Michael Morello <[email protected]>
  • Loading branch information
niladrih and barkbay authored May 29, 2023
1 parent 6ee366c commit e465174
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "+
Expand Down
4 changes: 4 additions & 0 deletions deploy/lvm-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions pkg/driver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit e465174

Please sign in to comment.