Add kubernetes QPS and Burst limit configuration (#2899)
Added configurable kubernetes client limits burst and QPS Default QPS 200 and burst 500. Configurable via helm chart values. Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -103,6 +103,13 @@ This template generates the image name for the deployment depending on the value
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
{{- define "kube_client.envs" }}
|
||||||
|
- name: KUBE_CLIENT_QPS
|
||||||
|
value: "{{ .Values.kubernetesClientQPS }}"
|
||||||
|
- name: KUBE_CLIENT_BURST
|
||||||
|
value: "{{ .Values.kubernetesClientBurst }}"
|
||||||
|
{{- end}}
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
Define the svc's name
|
Define the svc's name
|
||||||
*/}}
|
*/}}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ spec:
|
|||||||
- name: HELM_RELEASE_NAME
|
- name: HELM_RELEASE_NAME
|
||||||
value: {{ .Release.Name | quote }}
|
value: {{ .Release.Name | quote }}
|
||||||
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
||||||
|
{{- include "kube_client.envs" . | indent 8 }}
|
||||||
{{- include "opentelemtry.envs" . | indent 8 }}
|
{{- include "opentelemtry.envs" . | indent 8 }}
|
||||||
{{- if .Values.builderPodSpec.enabled }}
|
{{- if .Values.builderPodSpec.enabled }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ spec:
|
|||||||
value: {{ .Values.debugEnv | quote }}
|
value: {{ .Values.debugEnv | quote }}
|
||||||
- name: PPROF_ENABLED
|
- name: PPROF_ENABLED
|
||||||
value: {{ .Values.pprof.enabled | quote }}
|
value: {{ .Values.pprof.enabled | quote }}
|
||||||
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
||||||
|
{{- include "kube_client.envs" . | indent 8 }}
|
||||||
- name: POD_NAMESPACE
|
- name: POD_NAMESPACE
|
||||||
valueFrom:
|
valueFrom:
|
||||||
fieldRef:
|
fieldRef:
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ spec:
|
|||||||
value: {{ .Values.executor.serviceAccountCheck.interval | quote }}
|
value: {{ .Values.executor.serviceAccountCheck.interval | quote }}
|
||||||
{{- end}}
|
{{- end}}
|
||||||
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
||||||
|
{{- include "kube_client.envs" . | indent 8 }}
|
||||||
- name: HELM_RELEASE_NAME
|
- name: HELM_RELEASE_NAME
|
||||||
value: {{ .Release.Name | quote }}
|
value: {{ .Release.Name | quote }}
|
||||||
{{- include "opentelemtry.envs" . | indent 8 }}
|
{{- include "opentelemtry.envs" . | indent 8 }}
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ spec:
|
|||||||
value: {{ .Values.debugEnv | quote }}
|
value: {{ .Values.debugEnv | quote }}
|
||||||
- name: PPROF_ENABLED
|
- name: PPROF_ENABLED
|
||||||
value: {{ .Values.pprof.enabled | quote }}
|
value: {{ .Values.pprof.enabled | quote }}
|
||||||
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
||||||
|
{{- include "kube_client.envs" . | indent 8 }}
|
||||||
{{- include "opentelemtry.envs" . | indent 8 }}
|
{{- include "opentelemtry.envs" . | indent 8 }}
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.kubewatcher.resources | nindent 10 }}
|
{{- toYaml .Values.kubewatcher.resources | nindent 10 }}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ spec:
|
|||||||
- name: REDIS_IMAGE
|
- name: REDIS_IMAGE
|
||||||
value: "{{ .Values.mqt_keda.connector_images.redis.image }}:{{ .Values.mqt_keda.connector_images.redis.tag }}"
|
value: "{{ .Values.mqt_keda.connector_images.redis.image }}:{{ .Values.mqt_keda.connector_images.redis.tag }}"
|
||||||
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
||||||
|
{{- include "kube_client.envs" . | indent 8 }}
|
||||||
{{- include "opentelemtry.envs" . | indent 8 }}
|
{{- include "opentelemtry.envs" . | indent 8 }}
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.mqt_keda.resources | nindent 10 }}
|
{{- toYaml .Values.mqt_keda.resources | nindent 10 }}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ spec:
|
|||||||
command: [ "/pre-upgrade-checks" ]
|
command: [ "/pre-upgrade-checks" ]
|
||||||
env:
|
env:
|
||||||
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
||||||
|
{{- include "kube_client.envs" . | indent 8 }}
|
||||||
{{- if .Values.terminationMessagePath }}
|
{{- if .Values.terminationMessagePath }}
|
||||||
terminationMessagePath: {{ .Values.terminationMessagePath }}
|
terminationMessagePath: {{ .Values.terminationMessagePath }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ spec:
|
|||||||
value: {{ .Values.pprof.enabled | quote }}
|
value: {{ .Values.pprof.enabled | quote }}
|
||||||
- name: DISPLAY_ACCESS_LOG
|
- name: DISPLAY_ACCESS_LOG
|
||||||
value: {{ .Values.router.displayAccessLog | default false | quote }}
|
value: {{ .Values.router.displayAccessLog | default false | quote }}
|
||||||
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
||||||
|
{{- include "kube_client.envs" . | indent 8 }}
|
||||||
{{- include "opentelemtry.envs" . | indent 8 }}
|
{{- include "opentelemtry.envs" . | indent 8 }}
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.router.resources | nindent 10 }}
|
{{- toYaml .Values.router.resources | nindent 10 }}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ spec:
|
|||||||
value: {{ .Values.persistence.s3.region }}
|
value: {{ .Values.persistence.s3.region }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
||||||
|
{{- include "kube_client.envs" . | indent 8 }}
|
||||||
{{- include "opentelemtry.envs" . | indent 8 }}
|
{{- include "opentelemtry.envs" . | indent 8 }}
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.storagesvc.resources | nindent 10 }}
|
{{- toYaml .Values.storagesvc.resources | nindent 10 }}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ spec:
|
|||||||
- name: PPROF_ENABLED
|
- name: PPROF_ENABLED
|
||||||
value: {{ .Values.pprof.enabled | quote }}
|
value: {{ .Values.pprof.enabled | quote }}
|
||||||
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
{{- include "fission-resource-namespace.envs" . | indent 8 }}
|
||||||
|
{{- include "kube_client.envs" . | indent 8 }}
|
||||||
{{- include "opentelemtry.envs" . | indent 8 }}
|
{{- include "opentelemtry.envs" . | indent 8 }}
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.timer.resources | nindent 10 }}
|
{{- toYaml .Values.timer.resources | nindent 10 }}
|
||||||
|
|||||||
@@ -92,6 +92,13 @@ createNamespace: true
|
|||||||
##
|
##
|
||||||
enableIstio: false
|
enableIstio: false
|
||||||
|
|
||||||
|
## Kubernetes client QPS and Burst settings
|
||||||
|
##
|
||||||
|
## kubernetesClientQPS represents the maximum queries per second to the kubernetes api server from client instances of fission components.
|
||||||
|
kubernetesClientQPS: 200
|
||||||
|
## kubernetesClientBurst represents the maximum burst queries to the kubernetes api server from client instances of fission components.
|
||||||
|
kubernetesClientBurst: 500
|
||||||
|
|
||||||
## fetcher is a light weight component that helps in running functions.
|
## fetcher is a light weight component that helps in running functions.
|
||||||
## fetcher helps in fetching function source code/build and uploading it when function is invoked.
|
## fetcher helps in fetching function source code/build and uploading it when function is invoked.
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ import (
|
|||||||
"github.com/fission/fission/pkg/utils"
|
"github.com/fission/fission/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
EnvKubeClientQps = "KUBE_CLIENT_QPS"
|
||||||
|
EnvKubeClientBurst = "KUBE_CLIENT_BURST"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
ClientGeneratorInterface interface {
|
ClientGeneratorInterface interface {
|
||||||
GetRestConfig() (*rest.Config, error)
|
GetRestConfig() (*rest.Config, error)
|
||||||
@@ -60,6 +65,20 @@ func (cg *ClientGenerator) getRestConfig() (*rest.Config, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qps, _ := utils.GetUIntValueFromEnv(EnvKubeClientQps)
|
||||||
|
burst, _ := utils.GetIntValueFromEnv(EnvKubeClientBurst)
|
||||||
|
|
||||||
|
// Set QPS and Burst to higher values to avoid throttling
|
||||||
|
if qps == 0 {
|
||||||
|
qps = 200
|
||||||
|
}
|
||||||
|
if burst == 0 {
|
||||||
|
burst = 500
|
||||||
|
}
|
||||||
|
cg.restConfig.QPS = float32(qps)
|
||||||
|
cg.restConfig.Burst = burst
|
||||||
|
|
||||||
return cg.restConfig, nil
|
return cg.restConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -232,6 +232,18 @@ func GetUIntValueFromEnv(envVar string) (uint, error) {
|
|||||||
return uint(value), nil
|
return uint(value), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetIntValueFromEnv(envVar string) (int, error) {
|
||||||
|
s, err := GetStringValueFromEnv(envVar)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
value, err := strconv.Atoi(s)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return value, nil
|
||||||
|
}
|
||||||
|
|
||||||
func FindFreePort() (int, error) {
|
func FindFreePort() (int, error) {
|
||||||
listener, err := net.Listen("tcp", ":0")
|
listener, err := net.Listen("tcp", ":0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -162,3 +162,48 @@ func TestGetUIntValueFromEnv(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetIntValueFromEnv(t *testing.T) {
|
||||||
|
varName := "TEST_VAR"
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
value string
|
||||||
|
want int
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "empty string case",
|
||||||
|
value: "",
|
||||||
|
want: 0,
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "string case",
|
||||||
|
value: "test string",
|
||||||
|
want: 0,
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "not int case",
|
||||||
|
value: "-100",
|
||||||
|
want: -100,
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "int case",
|
||||||
|
value: "7",
|
||||||
|
want: 7,
|
||||||
|
wantErr: false,
|
||||||
|
}}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
os.Setenv(varName, tt.value)
|
||||||
|
got, err := GetIntValueFromEnv(varName)
|
||||||
|
if (err != nil) != tt.wantErr {
|
||||||
|
t.Errorf("GetIntValueFromEnv() error = %v, wantErr %v, got %d", err, tt.wantErr, got)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user