diff --git a/tools/kubeblocks_helm/pika-cluster/templates/cluster.yaml b/tools/kubeblocks_helm/pika-cluster/templates/cluster.yaml index aa4ad160d8..3176fc14ef 100644 --- a/tools/kubeblocks_helm/pika-cluster/templates/cluster.yaml +++ b/tools/kubeblocks_helm/pika-cluster/templates/cluster.yaml @@ -115,6 +115,22 @@ spec: storage: {{ .size }} {{- end }} {{- end }} + - name: pika-exporter + {{- if .Values.useLegacyCompDef }} + componentDefRef: pika-exporter # ref clusterDefinition.componentDefs[x].name + {{- else }} + componentDef: pika-exporter # ref componentDefinition name + {{- end }} + replicas: 1 + {{- with .Values.resources.pikaExporter }} + resources: + limits: + cpu: {{ .limits.cpu | quote }} + memory: {{ .limits.memory | quote }} + requests: + cpu: {{ .requests.cpu | quote }} + memory: {{ .requests.memory | quote }} + {{- end }} - name: codis-proxy {{- if .Values.useLegacyCompDef }} componentDefRef: codis-proxy # ref clusterDefinition.componentDefs[x].name diff --git a/tools/kubeblocks_helm/pika-cluster/values.yaml b/tools/kubeblocks_helm/pika-cluster/values.yaml index b57960d8fa..328a3c4216 100644 --- a/tools/kubeblocks_helm/pika-cluster/values.yaml +++ b/tools/kubeblocks_helm/pika-cluster/values.yaml @@ -6,7 +6,7 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. # if useLegacyCompDef is false ,cluster will be rendered by component definition rather than componentDefRef in cluster definition -useLegacyCompDef: false +useLegacyCompDef: true nameOverride: "" fullnameOverride: "" @@ -52,6 +52,13 @@ resources: requests: cpu: 500m memory: 1Gi + pikaExporter: + limits: + cpu: 500m + memory: 3Gi + requests: + cpu: 500m + memory: 1Gi codisProxy: limits: cpu: 500m diff --git a/tools/kubeblocks_helm/pika/config/exporter-info.tpl b/tools/kubeblocks_helm/pika/config/exporter-info.tpl new file mode 100644 index 0000000000..5597752f93 --- /dev/null +++ b/tools/kubeblocks_helm/pika/config/exporter-info.tpl @@ -0,0 +1,12 @@ +server = true +data = true +clients = true +stats = true +cpu = true +replication = true +keyspace = true +cache = true + +execcount = false +commandstats = false +rocksdb = false diff --git a/tools/kubeblocks_helm/pika/templates/_helpers.tpl b/tools/kubeblocks_helm/pika/templates/_helpers.tpl index 06bf287318..6686215ff4 100644 --- a/tools/kubeblocks_helm/pika/templates/_helpers.tpl +++ b/tools/kubeblocks_helm/pika/templates/_helpers.tpl @@ -61,6 +61,18 @@ Define image {{ .Values.image.pika.pullPolicy | default "IfNotPresent" }} {{- end }} +{{/* +Define Pika Exporter image +*/}} + +{{- define "pikaExporter.image" -}} +{{ .Values.image.pikaExporter.registry | default "docker.io" }}/{{ .Values.image.pikaExporter.repository }}:{{ .Values.image.pikaExporter.tag }} +{{- end }} + +{{- define "pikaExporter.imagePullPolicy" -}} +{{ .Values.image.pikaExporter.pullPolicy | default "IfNotPresent" }} +{{- end }} + {{/* Define codis image */}} diff --git a/tools/kubeblocks_helm/pika/templates/clusterdefinition.yaml b/tools/kubeblocks_helm/pika/templates/clusterdefinition.yaml index 537b80453f..c1a9f1d403 100644 --- a/tools/kubeblocks_helm/pika/templates/clusterdefinition.yaml +++ b/tools/kubeblocks_helm/pika/templates/clusterdefinition.yaml @@ -176,6 +176,49 @@ spec: value: "2500" - name: ETCD_ENABLE_V2 value: "true" + - name: pika-exporter + workloadType: Stateless + characterType: pika + service: + ports: + - name: expoter + targetPort: expoter + port: 9121 + configSpecs: + - name: pika-config + templateRef: pika-conf-template + namespace: {{ .Release.Namespace }} + volumeName: config + podSpec: + initContainers: + - name: wait-codis-dashboard + env: + - name: DASHBOARD_ADDR + value: "$(KB_CLUSTER_NAME)-codis-dashboard" + image: busybox:1.28 + command: + - 'sh' + - '-c' + - "until nc -z ${DASHBOARD_ADDR} 18080; do echo waiting for codis dashboard; sleep 2; done;" + containers: + - name: pika-exporter + imagePullPolicy: IfNotPresent + ports: + - containerPort: 9121 + name: exporter + volumeMounts: + - name: config + mountPath: /etc/pika + env: + - name: DASHBOARD_ADDR + value: "$(KB_CLUSTER_NAME)-codis-dashboard" + command: + - "/pika/bin/pika_exporter" + args: + - "-config" + - "/etc/pika/info.toml" + - "-codis.addr" + - "http://$(DASHBOARD_ADDR):18080/topom" - name: codis-proxy workloadType: Stateful characterType: pika diff --git a/tools/kubeblocks_helm/pika/templates/clusterversion.yaml b/tools/kubeblocks_helm/pika/templates/clusterversion.yaml index 3cc49fb5e8..b698449d83 100644 --- a/tools/kubeblocks_helm/pika/templates/clusterversion.yaml +++ b/tools/kubeblocks_helm/pika/templates/clusterversion.yaml @@ -22,6 +22,12 @@ spec: - name: etcd image: {{ include "etcd.image" . }} imagePullPolicy: {{ include "etcd.imagePullPolicy" . }} + - componentDefRef: pika-exporter + versionsContext: + containers: + - name: pika-exporter + image: {{ include "pikaExporter.image" . }} + imagePullPolicy: {{ include "pikaExporter.imagePullPolicy" . }} - componentDefRef: codis-proxy versionsContext: containers: diff --git a/tools/kubeblocks_helm/pika/templates/componentdefinition-pika-exporter.yaml b/tools/kubeblocks_helm/pika/templates/componentdefinition-pika-exporter.yaml new file mode 100644 index 0000000000..292c496fc5 --- /dev/null +++ b/tools/kubeblocks_helm/pika/templates/componentdefinition-pika-exporter.yaml @@ -0,0 +1,58 @@ +apiVersion: apps.kubeblocks.io/v1alpha1 +kind: ComponentDefinition +metadata: + name: pika-exporter + labels: + {{- include "pika.labels" . | nindent 4 }} +spec: + provider: pika + description: A pika exporter component definition + serviceKind: pika-exporter + serviceVersion: {{ .Chart.AppVersion }} + services: + - name: expoter + serviceName: expoter + spec: + ports: + - name: expoter + port: 9121 + targetPort: expoter + updateStrategy: Serial + configs: + - name: pika-config + templateRef: pika-conf-template + volumeName: config + vars: + ## reference to the pika-codis-dashboard service + - name: DASHBOARD_ADDR + valueFrom: + serviceVarRef: + compDef: pika-codis-dashboard + name: dashboard + optional: true + host: Optional + runtime: + initContainers: + - name: wait-codis-dashboard + image: busybox:1.28 + command: + - 'sh' + - '-c' + - "until nc -z ${DASHBOARD_ADDR} 18080; do echo waiting for codis dashboard; sleep 2; done;" + containers: + - name: pika-exporter + image: {{ include "pikaExporter.image" . }} + imagePullPolicy: {{ include "pikaExporter.imagePullPolicy" . }} + ports: + - name: expoter + containerPort: 9121 + volumeMounts: + - name: config + mountPath: /etc/pika + command: + - "/pika/bin/pika_exporter" + args: + - "-config" + - "/etc/pika/info.toml" + - "-codis.addr" + - "http://$(DASHBOARD_ADDR):18080/topom" \ No newline at end of file diff --git a/tools/kubeblocks_helm/pika/templates/configmap.yaml b/tools/kubeblocks_helm/pika/templates/configmap.yaml index c302f1633e..20e9448f4c 100644 --- a/tools/kubeblocks_helm/pika/templates/configmap.yaml +++ b/tools/kubeblocks_helm/pika/templates/configmap.yaml @@ -11,3 +11,5 @@ data: {{- .Files.Get "config/codis-dashboard.tpl" | nindent 4 }} proxy.toml: |- {{- .Files.Get "config/codis-proxy.tpl" | nindent 4 }} + info.toml: |- + {{- .Files.Get "config/exporter-info.tpl" | nindent 4 }} \ No newline at end of file