Skip to content

Commit 2173faf

Browse files
authored
Merge pull request #149 from jsturtevant/qps-burst
Add ability to configure QPS and Burst for go-client
2 parents 795e1c7 + d949ba6 commit 2173faf

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

admission-webhook/main.go

+27-11
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ func main() {
2929
keyPath: env("TLS_KEY"),
3030
}
3131

32-
port, err := port("HTTPS_PORT")
33-
if err != nil {
34-
panic(err)
35-
}
32+
port := env_int("HTTPS_PORT", 443)
3633

3734
if err = webhook.start(port, tlsConfig, nil); err != nil {
3835
panic(err)
@@ -83,19 +80,38 @@ func createKubeClient() (*kubeClient, error) {
8380
return nil, err
8481
}
8582

83+
config.QPS = env_float("QPS", rest.DefaultQPS)
84+
config.Burst = env_int("BURST", rest.DefaultBurst)
85+
logrus.Infof("QPS: %f, Burst: %d", config.QPS, config.Burst)
86+
8687
return newKubeClient(config)
8788
}
8889

90+
func env_float(key string, defaultFloat float32) float32 {
91+
if v, found := os.LookupEnv(key); found {
92+
if i, err := strconv.ParseFloat(v, 32); err != nil {
93+
return float32(i)
94+
}
95+
logrus.Warningf("unable to parse environment variable %s; using default value %f", key, defaultFloat)
96+
}
97+
98+
return defaultFloat
99+
}
100+
101+
func env_int(key string, defaultInt int) int {
102+
if v, found := os.LookupEnv(key); found {
103+
if i, err := strconv.Atoi(v); err != nil {
104+
return i
105+
}
106+
logrus.Warningf("unable to parse environment variable %s; using default value %d", key, defaultInt)
107+
}
108+
109+
return defaultInt
110+
}
111+
89112
func env(key string) string {
90113
if value, found := os.LookupEnv(key); found {
91114
return value
92115
}
93116
panic(fmt.Errorf("%s env var not found", key))
94117
}
95-
96-
func port(key string) (int, error) {
97-
if port, found := os.LookupEnv(key); found {
98-
return strconv.Atoi(port)
99-
}
100-
return 443, nil
101-
}

charts/gmsa/templates/deployment.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ spec:
5353
value: /tls/crt
5454
- name: HTTPS_PORT
5555
value: "{{ .Values.containerPort }}"
56+
- name: BURST
57+
value: "{{ .Values.burst }}"
58+
- name: QPS
59+
value: "{{ .Values.qps }}"
5660
{{- if .Values.securityContext }}
5761
securityContext: {{ toYaml .Values.securityContext | nindent 12 }}
5862
{{- end }}

charts/gmsa/values.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ podSecurityContext: {}
4949
replicaCount: 2
5050
securityContext: {}
5151
tolerations: []
52+
qps: 30
53+
burst: 50

0 commit comments

Comments
 (0)