Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HPA for read replica #2307

Merged
merged 10 commits into from
Jan 29, 2024
3 changes: 2 additions & 1 deletion .github/helm/values/values-readreplica.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ agent:
readreplica:
enabled: true
snapshot_classname: "csi-hostpath-snapclass"
replica: 1
hpa:
enabled: true

discoverer:
minReplicas: 1
Expand Down
186 changes: 186 additions & 0 deletions charts/vald-benchmark-operator/README.md

Large diffs are not rendered by default.

190 changes: 188 additions & 2 deletions charts/vald-helm-operator/crds/valdrelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,23 @@ spec:
type: string
enabled:
type: boolean
hpa:
type: object
properties:
enabled:
type: boolean
targetCPUUtilizationPercentage:
type: integer
label_key:
type: string
maxReplicas:
type: integer
minimum: 1
minReplicas:
type: integer
minimum: 1
name:
type: string
replica:
type: integer
service:
type: object
properties:
Expand Down Expand Up @@ -5314,6 +5325,181 @@ spec:
type: boolean
duration:
type: string
read_client:
type: object
properties:
addrs:
type: array
items:
type: string
backoff:
type: object
properties:
backoff_factor:
type: number
backoff_time_limit:
type: string
enable_error_log:
type: boolean
initial_duration:
type: string
jitter_limit:
type: string
maximum_duration:
type: string
retry_count:
type: integer
call_option:
type: object
x-kubernetes-preserve-unknown-fields: true
circuit_breaker:
type: object
properties:
closed_error_rate:
type: number
closed_refresh_timeout:
type: string
half_open_error_rate:
type: number
min_samples:
type: integer
open_timeout:
type: string
connection_pool:
type: object
properties:
enable_dns_resolver:
type: boolean
enable_rebalance:
type: boolean
old_conn_close_duration:
type: string
rebalance_duration:
type: string
size:
type: integer
dial_option:
type: object
properties:
backoff_base_delay:
type: string
backoff_jitter:
type: number
backoff_max_delay:
type: string
backoff_multiplier:
type: number
enable_backoff:
type: boolean
initial_connection_window_size:
type: integer
initial_window_size:
type: integer
insecure:
type: boolean
interceptors:
type: array
items:
type: string
enum:
- TraceInterceptor
keepalive:
type: object
properties:
permit_without_stream:
type: boolean
time:
type: string
timeout:
type: string
max_msg_size:
type: integer
min_connection_timeout:
type: string
net:
type: object
properties:
dialer:
type: object
properties:
dual_stack_enabled:
type: boolean
keepalive:
type: string
timeout:
type: string
dns:
type: object
properties:
cache_enabled:
type: boolean
cache_expiration:
type: string
refresh_duration:
type: string
socket_option:
type: object
properties:
ip_recover_destination_addr:
type: boolean
ip_transparent:
type: boolean
reuse_addr:
type: boolean
reuse_port:
type: boolean
tcp_cork:
type: boolean
tcp_defer_accept:
type: boolean
tcp_fast_open:
type: boolean
tcp_no_delay:
type: boolean
tcp_quick_ack:
type: boolean
tls:
type: object
properties:
ca:
type: string
cert:
type: string
enabled:
type: boolean
insecure_skip_verify:
type: boolean
key:
type: string
read_buffer_size:
type: integer
timeout:
type: string
write_buffer_size:
type: integer
health_check_duration:
type: string
max_recv_msg_size:
type: integer
max_retry_rpc_buffer_size:
type: integer
max_send_msg_size:
type: integer
tls:
type: object
properties:
ca:
type: string
cert:
type: string
enabled:
type: boolean
insecure_skip_verify:
type: boolean
key:
type: string
wait_for_ready:
type: boolean
index_replica:
type: integer
minimum: 1
Expand Down
47 changes: 47 additions & 0 deletions charts/vald-readreplica/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Copyright (C) 2019-2024 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
{{- $agent := .Values.agent -}}
{{- $readreplica := .Values.agent.readreplica -}}
{{- if $agent.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $readreplica.name }}-config
labels:
app.kubernetes.io/name: {{ include "vald.name" . }}
helm.sh/chart: {{ include "vald.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.Version }}
app.kubernetes.io/component: agent
data:
config.yaml: |
---
version: {{ $agent.version }}
time_zone: {{ default .Values.defaults.time_zone $agent.time_zone }}
logging:
{{- $logging := dict "Values" $agent.logging "default" .Values.defaults.logging }}
{{- include "vald.logging" $logging | nindent 6 }}
server_config:
{{- $servers := dict "Values" $agent.server_config "default" .Values.defaults.server_config }}
{{- include "vald.servers" $servers | nindent 6 }}
observability:
{{- $observability := dict "Values" $agent.observability "default" .Values.defaults.observability }}
{{- include "vald.observability" $observability | nindent 6 }}
ngt:
{{- toYaml $agent.ngt | nindent 6 }}
is_readreplica: true
{{- end }}
8 changes: 4 additions & 4 deletions charts/vald-readreplica/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ metadata:
{{- end }}
spec:
{{- if not $agent.hpa.enabled }}
replicas: {{ $readreplica.replica }}
replicas: {{ $readreplica.minReplicas }}
{{- end }}
revisionHistoryLimit: {{ $agent.revisionHistoryLimit }}
selector:
Expand Down Expand Up @@ -110,7 +110,7 @@ spec:
{{- toYaml $agent.env | nindent 12 }}
{{- end }}
volumeMounts:
- name: {{ $agent.name }}-config
- name: {{ $readreplica.name }}-config
mountPath: /etc/server/
{{- if not $agent.ngt.enable_in_memory_mode }}
{{- if $agent.ngt.index_path }}
Expand All @@ -136,10 +136,10 @@ spec:
{{- end }}
terminationGracePeriodSeconds: {{ $agent.terminationGracePeriodSeconds }}
volumes:
- name: {{ $agent.name }}-config
- name: {{ $readreplica.name }}-config
configMap:
defaultMode: 420
name: {{ $agent.name }}-config
name: {{ $readreplica.name }}-config
- name: {{ $readreplica.volume_name }}
persistentVolumeClaim:
claimName: {{ $readreplica.name }}-pvc-{{ $id }}
Expand Down
67 changes: 67 additions & 0 deletions charts/vald-readreplica/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#
# Copyright (C) 2019-2024 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
{{- $agent := .Values.agent -}}
{{- $readreplica := .Values.agent.readreplica -}}
{{- $defaults := .Values.defaults -}}
{{- $release := .Release -}}
{{- $chart := .Chart -}}
{{- $valdname := include "vald.name" . -}}
{{- $valdchart := include "vald.chart" . -}}
{{- $cap := .Capabilities -}}
{{- if and $readreplica.enabled $readreplica.hpa.enabled }}
{{ range $id := until (int $agent.minReplicas) }}
---
{{- if ($cap.APIVersions.Has "autoscaling/v2") }}
apiVersion: autoscaling/v2
{{- else if ($cap.APIVersions.Has "autoscaling/v1") }}
apiVersion: autoscaling/v1
{{- else if ($cap.APIVersions.Has "autoscaling/v2beta2") }}
apiVersion: autoscaling/v2beta2
{{- else }}
apiVersion: autoscaling/v2beta1
{{- end }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ $readreplica.name }}-{{ $id }}
labels:
app.kubernetes.io/name: {{ $valdname }}
helm.sh/chart: {{ $valdchart }}
app.kubernetes.io/managed-by: {{ $release.Service }}
app.kubernetes.io/instance: {{ $release.Name }}
app.kubernetes.io/version: {{ $chart.Version }}
app.kubernetes.io/component: {{ $readreplica.component_name }}
{{ $readreplica.label_key }}: "{{ $id }}"
spec:
maxReplicas: {{ $readreplica.maxReplicas }}
minReplicas: {{ $readreplica.minReplicas }}
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ $readreplica.name }}-{{ $id }}
{{- if or ($cap.APIVersions.Has "autoscaling/v2") ($cap.APIVersions.Has "autoscaling/v2beta2") ($cap.APIVersions.Has "autoscaling/v2beta1") }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ $readreplica.hpa.targetCPUUtilizationPercentage }}
{{ else }}
targetCPUUtilizationPercentage: {{ $readreplica.hpa.targetCPUUtilizationPercentage }}
{{- end }}
status:
{{- end }}
{{- end }}
Loading
Loading