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

chore: replace the extra-env annotation with cluster API #1056

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions addons-cluster/apecloud-mysql/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ metadata:
labels:
{{ include "kblib.clusterLabels" . | nindent 4 }}
auditLogEnabled: "{{ .Values.auditLogEnabled }}"
{{- if and (eq .Values.mode "raftGroup") .Values.proxyEnabled }}
annotations:
kubeblocks.io/extra-env: '{"KB_PROXY_ENABLED":"on","ETCDCTL_API": "{{ .Values.etcd.etcdctlApi}}"}'
{{- end }}
spec:
terminationPolicy: {{ .Values.extra.terminationPolicy }}
{{- include "kblib.affinity" . | indent 2 }}
clusterDef: apecloud-mysql # ref clusterdefinition.name
topology: {{ include "apecloud-mysql-cluster.topology" . }}
componentSpecs:
- name: mysql
{{- if and (eq .Values.mode "raftGroup") .Values.proxyEnabled }}
env:
- name: KB_PROXY_ENABLED
value: "on"
- name: ETCDCTL_API
value: "{{ .Values.etcd.etcdctlApi }}"
{{- end }}
{{- include "kblib.componentMonitor" . | indent 6 }}
{{- if and (eq .Values.mode "raftGroup") .Values.proxyEnabled (not .Values.localEtcdEnabled) }}
serviceRefs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ metadata:
name: {{ include "kblib.clusterName" . }}
namespace: {{ .Release.Namespace }}
labels: {{ include "kblib.clusterLabels" . | nindent 4 }}
annotations:
kubeblocks.io/extra-env: '{"mdit-roles":"master,data,ingest,transform","mode":"{{ .Values.mode }}"}'
spec:
terminationPolicy: {{ .Values.extra.terminationPolicy }}
{{- include "kblib.affinity" . | indent 2 }}
componentSpecs:
- name: mdit
componentDef: elasticsearch-{{ include "elasticsearch.majorVersion" . }}
serviceVersion: {{ include "elasticsearch.version" . }}
env:
- name: mdit-roles
value: "master,data,ingest,transform"
- name: mode
value: {{ .Values.mode }}
serviceAccountName: {{ include "kblib.serviceAccountName" . }}
{{- include "elasticsearch-cluster.replicaCount" . | indent 6 }}
{{- include "kblib.componentMonitor" . | indent 6 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ metadata:
name: {{ include "kblib.clusterName" . }}
namespace: {{ .Release.Namespace }}
labels: {{ include "kblib.clusterLabels" . | nindent 4 }}
annotations:
kubeblocks.io/extra-env: '{"mode":"{{ .Values.mode }}"}'
spec:
terminationPolicy: {{ .Values.extra.terminationPolicy }}
{{- include "kblib.affinity" . | indent 2 }}
componentSpecs:
- name: mdit
componentDef: elasticsearch-{{ include "elasticsearch.majorVersion" . }}
serviceVersion: {{ include "elasticsearch.version" . }}
env:
- name: mode
value: {{ .Values.mode }}
serviceAccountName: {{ include "kblib.serviceAccountName" . }}
{{- include "elasticsearch-cluster.replicaCount" . | indent 6 }}
{{- include "kblib.componentMonitor" . | indent 6 }}
Expand Down
37 changes: 36 additions & 1 deletion addons-cluster/kafka/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: {{ include "kblib.clusterName" . }}
labels: {{ include "kblib.clusterLabels" . | nindent 4 }}
annotations:
"kubeblocks.io/extra-env": '{"KB_KAFKA_ENABLE_SASL":"{{ $.Values.saslEnable }}","KB_KAFKA_BROKER_HEAP":"{{ $.Values.brokerHeap }}","KB_KAFKA_CONTROLLER_HEAP":"{{ $.Values.controllerHeap }}","KB_KAFKA_PUBLIC_ACCESS":"{{ $.Values.extra.publiclyAccessible }}"}'
{{/* {{- include "kafka-cluster.brokerAddrFeatureGate" . | nindent 4 }}*/}}
spec:
clusterDef: kafka # ref clusterdefinition.name
Expand All @@ -30,6 +29,15 @@ spec:
{{- if .Values.useLegacyCompDef }}
componentDef: kafka-server
{{- end }}
env:
- name: KB_KAFKA_ENABLE_SASL
value: "{{ $.Values.saslEnable }}"
- name: KB_KAFKA_BROKER_HEAP
value: "{{ $.Values.brokerHeap }}"
- name: KB_KAFKA_CONTROLLER_HEAP
value: "{{ $.Values.controllerHeap }}"
- name: KB_KAFKA_PUBLIC_ACCESS
value: "{{ $.Values.extra.publiclyAccessible }}"
tls: {{ $.Values.tlsEnable }}
{{- if $.Values.tlsEnable }}
issuer:
Expand Down Expand Up @@ -70,6 +78,15 @@ spec:
{{- if .Values.useLegacyCompDef }}
componentDef: kafka-broker
{{- end }}
env:
- name: KB_KAFKA_ENABLE_SASL
value: "{{ $.Values.saslEnable }}"
- name: KB_KAFKA_BROKER_HEAP
value: "{{ $.Values.brokerHeap }}"
- name: KB_KAFKA_CONTROLLER_HEAP
value: "{{ $.Values.controllerHeap }}"
- name: KB_KAFKA_PUBLIC_ACCESS
value: "{{ $.Values.extra.publiclyAccessible }}"
tls: {{ $.Values.tlsEnable }}
{{- if $.Values.tlsEnable }}
issuer:
Expand Down Expand Up @@ -109,6 +126,15 @@ spec:
{{- if .Values.useLegacyCompDef }}
componentDef: controller
{{- end }}
env:
- name: KB_KAFKA_ENABLE_SASL
value: "{{ $.Values.saslEnable }}"
- name: KB_KAFKA_BROKER_HEAP
value: "{{ $.Values.brokerHeap }}"
- name: KB_KAFKA_CONTROLLER_HEAP
value: "{{ $.Values.controllerHeap }}"
- name: KB_KAFKA_PUBLIC_ACCESS
value: "{{ $.Values.extra.publiclyAccessible }}"
tls: {{ $.Values.tlsEnable }}
{{- if $.Values.tlsEnable }}
issuer:
Expand All @@ -134,6 +160,15 @@ spec:
{{- if .Values.useLegacyCompDef }}
componentDef: kafka-exporter
{{- end }}
env:
- name: KB_KAFKA_ENABLE_SASL
value: "{{ $.Values.saslEnable }}"
- name: KB_KAFKA_BROKER_HEAP
value: "{{ $.Values.brokerHeap }}"
- name: KB_KAFKA_CONTROLLER_HEAP
value: "{{ $.Values.controllerHeap }}"
- name: KB_KAFKA_PUBLIC_ACCESS
value: "{{ $.Values.extra.publiclyAccessible }}"
replicas: {{ $.Values.monitorReplicas }}
{{- include "kblib.componentResources" . | nindent 6 }}
{{- end }}
20 changes: 18 additions & 2 deletions addons-cluster/llm/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ metadata:
name: {{ include "kblib.clusterName" . }}
namespace: {{ .Release.Namespace }}
labels: {{ include "kblib.clusterLabels" . | nindent 4 }}
annotations:
"kubeblocks.io/extra-env": "{\"MODEL_NAME\":\"{{ .Values.model }}\", \"EXTRA_ARGS\":\"{{ .Values.extraArgs }}\", \"MODEL_URL\":\"{{ .Values.url }}\", \"QUANTIZE\":\"{{ .Values.quantize }}\"}"
spec:
terminationPolicy: {{ .Values.extra.terminationPolicy }}
{{- include "kblib.affinity" . | indent 2 }}
Expand All @@ -14,6 +12,15 @@ spec:
componentSpecs:
- name: ggml
componentDefRef: ggml
env:
- name: MODEL_NAME
value: {{ .Values.model }}
- name: EXTRA_ARGS
value: {{ .Values.extraArgs }}
- name: MODEL_URL
value: {{ .Values.url }}
- name: QUANTIZE
value: {{ .Values.quantize }}
{{- include "kblib.componentMonitor" . | indent 6 }}
replicas: {{ .Values.replicas }}
serviceAccountName: {{ include "kblib.serviceAccountName" . }}
Expand All @@ -23,6 +30,15 @@ spec:
componentSpecs:
- name: vllm
componentDefRef: vllm
env:
- name: MODEL_NAME
value: {{ .Values.model }}
- name: EXTRA_ARGS
value: {{ .Values.extraArgs }}
- name: MODEL_URL
value: {{ .Values.url }}
- name: QUANTIZE
value: {{ .Values.quantize }}
{{- include "kblib.componentMonitor" . | indent 6 }}
replicas: {{ .Values.replicas }}
serviceAccountName: {{ include "kblib.serviceAccountName" . }}
Expand Down
14 changes: 10 additions & 4 deletions addons-cluster/mysql/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ kind: Cluster
metadata:
name: {{ include "kblib.clusterName" . }}
labels: {{ include "kblib.clusterLabels" . | nindent 4 }}
annotations:
{{- if eq .Values.topology "server-with-proxy" }}
kubeblocks.io/extra-env: '{"PROXY_ENABLED":"on"}'
{{- end }}
spec:
terminationPolicy: {{ .Values.extra.terminationPolicy }}
{{- include "kblib.affinity" . | indent 2 }}
Expand All @@ -18,6 +14,11 @@ spec:
{{- $compdef = printf "%s-orc" $compdef }}
{{- end }}
componentDef: {{ $compdef }}
{{- if eq .Values.topology "server-with-proxy" }}
env:
- name: PROXY_ENABLED
value: "on"
{{- end }}
{{- include "kblib.componentMonitor" . | indent 6 }}
{{- include "mysql-cluster.replicaCount" . | indent 6 }}
{{- include "kblib.componentResources" . | indent 6 }}
Expand All @@ -42,6 +43,11 @@ spec:
{{- if eq .Values.topology "server-with-proxy" }}
- name: proxysql
componentDef: proxysql
{{- if eq .Values.topology "server-with-proxy" }}
env:
- name: PROXY_ENABLED
value: "on"
{{- end }}
replicas: {{.Values.proxysql.replicas}}
resources:
limits:
Expand Down
34 changes: 18 additions & 16 deletions addons-cluster/oceanbase-ce/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,23 @@ Create the name of the service account to use
Create extra env
*/}}
{{- define "oceanbase-cluster.extra-envs" }}
{
{{- if .Values.tenant }}
"TENANT_NAME": "{{ .Values.tenant.name }}",
"TENANT_CPU": "{{ min (sub .Values.cpu 1) .Values.tenant.max_cpu }}",
"TENANT_MEMORY": "{{ print (min (sub .Values.memory 2) .Values.tenant.memory_size) "G" }}",
"TENANT_DISK": "{{ print (.Values.tenant.log_disk_size | default 5) "G" }}",
{{- end }}
"ZONE_COUNT": "{{ .Values.zoneCount | default "1" }}",
"OB_CLUSTERS_COUNT": "{{ .Values.obClusters | default "1" }}",
"OB_DEBUG": "{{ .Values.debug | default "false" }}"
}
env:
{{- if .Values.tenant }}
- name: TENANT_NAME
value: "{{ .Values.tenant.name }}"
- name: TENANT_CPU
value: "{{ min (sub .Values.cpu 1) .Values.tenant.max_cpu }}"
- name: TENANT_MEMORY
value: "{{ print (min (sub .Values.memory 2) .Values.tenant.memory_size) "G" }}"
- name: TENANT_DISK
value: "{{ print (.Values.tenant.log_disk_size | default 5) "G" }}"
{{- end }}
- name: ZONE_COUNT
value: "{{ .Values.zoneCount | default "1" }}"
- name: OB_CLUSTERS_COUNT
value: "{{ .Values.obClusters | default "1" }}"
- name: OB_DEBUG
value: "{{ .Values.debug | default "false" }}"
{{- end }}


Expand All @@ -93,10 +99,6 @@ Create extra env
{{- end }}


{{- define "oceanbase-cluster.annotations.extra-envs" -}}
"kubeblocks.io/extra-env": {{ include "oceanbase-cluster.extra-envs" . | nospace | quote }}
{{- end -}}

{{/*
Define oceanbase cluster annotation pod-ordinal-svc feature gate.
*/}}
Expand All @@ -111,4 +113,4 @@ kubeblocks.io/enabled-pod-ordinal-svc: {{ include "observers" . | quote}}
{{- $observers = print "ob-bundle-" $idx | append $observers -}}
{{- end -}}
{{- join "," $observers -}}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion addons-cluster/oceanbase-ce/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
labels:
{{- include "oceanbase.labels" . | nindent 4 }}
annotations:
{{- include "oceanbase-cluster.annotations.extra-envs" . | nindent 4 }}
{{- include "oceanbase-cluster.featureGate" . | nindent 4 }}
spec:
terminationPolicy: {{ .Values.extra.terminationPolicy }}
Expand All @@ -26,6 +25,7 @@ spec:
{{- range $i, $e := until (int .Values.obClusters) }}
- name: ob-bundle-{{ $i }}
componentDef: {{ include "oceanbase-cluster.compdef" $}}
{{- include "oceanbase-cluster.extra-envs" $ | indent 6 }}
replicas: {{ max $.Values.zoneCount $.Values.replicas}}
{{- include "kblib.componentResources" $ | indent 6 }}
volumeClaimTemplates:
Expand Down
4 changes: 0 additions & 4 deletions addons-cluster/opentenbase/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ Expand the name of the chart.
{{- define "opentenbase.name" -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "opentenbase.extraEnv" -}}
{"DATANODE_COUNT":"{{ len .Values.dn }}", "COORDINATOR_COUNT":"{{ len .Values.cn }}"}
{{- end }}
17 changes: 15 additions & 2 deletions addons-cluster/opentenbase/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ apiVersion: apps.kubeblocks.io/v1
kind: Cluster
metadata:
name: {{ include "opentenbase.name" . }}
annotations:
kubeblocks.io/extra-env: {{ include "opentenbase.extraEnv" . | squote }}
spec:
clusterDef: opentenbase
terminationPolicy: {{ .Values.terminationPolicy }}
componentSpecs:
- name: gtm
componentDefRef: gtm
env:
- name: DATANODE_COUNT
value: "{{ len .Values.dn }}"
- name: COORDINATOR_COUNT
value: "{{ len .Values.cn }}"
replicas: {{ .Values.gtm.replicas }}
{{- with .Values.gtm.resources }}
resources:
Expand Down Expand Up @@ -38,6 +41,11 @@ spec:
{{- range .Values.dn }}
- name: dn-{{ $i }}
componentDefRef: dn
env:
- name: DATANODE_COUNT
value: "{{ len .Values.dn }}"
- name: COORDINATOR_COUNT
value: "{{ len .Values.cn }}"
replicas: {{ .replicas }}
{{- with .resources }}
resources:
Expand Down Expand Up @@ -68,6 +76,11 @@ spec:
{{- range .Values.cn }}
- name: cn-{{ $j }}
componentDefRef: cn
env:
- name: DATANODE_COUNT
value: "{{ len .Values.dn }}"
- name: COORDINATOR_COUNT
value: "{{ len .Values.cn }}"
replicas: {{ .replicas }}
{{- with .resources }}
resources:
Expand Down
20 changes: 0 additions & 20 deletions addons-cluster/orchestrator/templates/_helpers.tpl

This file was deleted.

9 changes: 7 additions & 2 deletions addons-cluster/orchestrator/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ kind: Cluster
metadata:
name: {{ include "kblib.clusterName" . }}
labels: {{ include "kblib.clusterLabels" . | nindent 4 }}
annotations:
{{- include "orchestrator-cluster.annotations.extra-envs" . | nindent 4 }}
spec:
clusterDef: orchestrator
topology: {{ .Values.mode }}
Expand All @@ -19,6 +17,13 @@ spec:
port: 80
componentSpecs:
- name: orchestrator
env:
- name: ORC_TOPOLOGY_PASSWORD
value: {{ .Values.secret.TOPOLOGY_PASSWORD | default "orchestrator" }}
- name: ORC_META_PASSWORD
value: {{ .Values.secret.META_PASSWORD | default "orchestrator" }}
- name: ORC_META_DATABASE
value: {{ .Values.secret.META_DATABASE | default "orchestrator" }}
{{- include "kblib.componentMonitor" . | indent 6 }}
replicas: {{ .Values.replicas }}
{{- include "kblib.componentResources" . | indent 6 }}
Expand Down
Loading