From d66d9a284a24248cc18daef91648a19a8622599b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=20=E5=BB=BA=E6=98=8C?= Date: Wed, 10 Aug 2022 14:26:51 +0800 Subject: [PATCH] [Chart] update deepflow **Phenomenon and reproduction steps** update deepflow - Add the access between DeepFlow-servers through POD name - Optimize the SVC - Optimization of replicas **Root cause and solution** **Impactions** **Test method** (Test method to ensure the bug is fixed) **Affected branch(es)** * main **Checklist** - [ ] Dependencies update required - [ ] Common bug (similar problem in other repo) --- charts/deepflow-agent/Chart.yaml | 2 +- charts/deepflow/Chart.yaml | 2 +- .../clickhouse/templates/configmap.yaml | 3 +- .../charts/clickhouse/templates/service.yaml | 24 ++++++---- .../clickhouse/templates/statefulset.yaml | 3 +- .../charts/mysql/templates/deployment.yaml | 2 +- .../charts/mysql/templates/service.yaml | 2 +- charts/deepflow/templates/app-deployment.yaml | 8 ++-- .../templates/server-statefulset.yaml | 5 +- charts/deepflow/templates/service.yaml | 48 +++++++++++-------- charts/deepflow/values.yaml | 2 + 11 files changed, 59 insertions(+), 42 deletions(-) diff --git a/charts/deepflow-agent/Chart.yaml b/charts/deepflow-agent/Chart.yaml index 99bb90a..ab4f767 100644 --- a/charts/deepflow-agent/Chart.yaml +++ b/charts/deepflow-agent/Chart.yaml @@ -3,7 +3,7 @@ description: An automated observability platform for cloud-native developers. name: deepflow-agent engine: gotpl type: application -version: 0.1.008 +version: 0.1.009 appVersion: "6.1.1" kubeVersion: ">=1.16.0-0" sources: diff --git a/charts/deepflow/Chart.yaml b/charts/deepflow/Chart.yaml index 0b2e851..6a14654 100644 --- a/charts/deepflow/Chart.yaml +++ b/charts/deepflow/Chart.yaml @@ -3,7 +3,7 @@ description: An automated observability platform for cloud-native developers. name: deepflow engine: gotpl type: application -version: 0.1.008 +version: 0.1.009 appVersion: "6.1.1" kubeVersion: ">=1.16.0-0" sources: diff --git a/charts/deepflow/charts/clickhouse/templates/configmap.yaml b/charts/deepflow/charts/clickhouse/templates/configmap.yaml index c673046..7aaf2c8 100644 --- a/charts/deepflow/charts/clickhouse/templates/configmap.yaml +++ b/charts/deepflow/charts/clickhouse/templates/configmap.yaml @@ -530,7 +530,8 @@ data: --> - {{range $i, $e := until (atoi (printf "%d" (int64 ( tpl .Values.replicas . )))) }} + {{- $replicas := int (tpl (toString .Values.replicas) .) }} + {{- range $i := until $replicas }} {{ $.Release.Name }}-clickhouse-headless-{{$i}} diff --git a/charts/deepflow/charts/clickhouse/templates/service.yaml b/charts/deepflow/charts/clickhouse/templates/service.yaml index bb69964..87fb52c 100644 --- a/charts/deepflow/charts/clickhouse/templates/service.yaml +++ b/charts/deepflow/charts/clickhouse/templates/service.yaml @@ -38,7 +38,7 @@ spec: nodePort: {{ tpl (toString .nodePort) $ }} {{- end }} protocol: {{ tpl .protocol $ }} - {{- end }} + {{- end }} {{- if .Values.service.additionalPorts }} {{ toYaml .Values.service.additionalPorts | indent 2 }} {{- end }} @@ -55,15 +55,17 @@ metadata: spec: clusterIP: None ports: - - name: tcp - port: 9000 - targetPort: 9000 - protocol: TCP + {{- range .Values.service.ports }} + - name: {{ tpl .name $ }} + port: {{ tpl (toString .port) $ }} + targetPort: {{ tpl (toString .targetPort) $ }} + protocol: {{ tpl .protocol $ }} + {{- end }} selector: {{- include "clickhouse.selectorLabels" . | nindent 4 }} type: ClusterIP -{{- $replicas := int (tpl .Values.replicas . |toString) }} +{{- $replicas := int (tpl (toString .Values.replicas) .) }} {{- range $i := until $replicas }} --- apiVersion: v1 @@ -78,10 +80,12 @@ spec: type: ClusterIP clusterIP: None ports: - - name: tcp - port: 9000 - targetPort: 9000 - protocol: TCP + {{- range $.Values.service.ports }} + - name: {{ tpl .name $ }} + port: {{ tpl (toString .port) $ }} + targetPort: {{ tpl (toString .targetPort) $ }} + protocol: {{ tpl .protocol $ }} + {{- end }} selector: {{- include "clickhouse.selectorLabels" $ | nindent 4 }} "statefulset.kubernetes.io/pod-name": {{ include "clickhouse.fullname" $ }}-{{ $i }} diff --git a/charts/deepflow/charts/clickhouse/templates/statefulset.yaml b/charts/deepflow/charts/clickhouse/templates/statefulset.yaml index 1a7d927..cf234f9 100644 --- a/charts/deepflow/charts/clickhouse/templates/statefulset.yaml +++ b/charts/deepflow/charts/clickhouse/templates/statefulset.yaml @@ -8,8 +8,7 @@ metadata: labels: {{- include "clickhouse.labels" . | nindent 4 }} spec: -spec: - replicas: {{ tpl .Values.replicas . }} + replicas: {{ tpl (toString .Values.replicas) . }} podManagementPolicy: {{ tpl .Values.podManagementPolicy . }} serviceName: {{ include "clickhouse.fullname" . }}-headless selector: diff --git a/charts/deepflow/charts/mysql/templates/deployment.yaml b/charts/deepflow/charts/mysql/templates/deployment.yaml index 3173290..7d54d94 100644 --- a/charts/deepflow/charts/mysql/templates/deployment.yaml +++ b/charts/deepflow/charts/mysql/templates/deployment.yaml @@ -9,7 +9,7 @@ metadata: labels: {{- include "mysql.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicas }} + replicas: {{ tpl (toString .Values.replicas) . }} strategy: type: Recreate selector: diff --git a/charts/deepflow/charts/mysql/templates/service.yaml b/charts/deepflow/charts/mysql/templates/service.yaml index 3cf1833..5055787 100644 --- a/charts/deepflow/charts/mysql/templates/service.yaml +++ b/charts/deepflow/charts/mysql/templates/service.yaml @@ -40,7 +40,7 @@ spec: nodePort: {{ tpl (toString .nodePort) $ }} {{- end }} protocol: {{ tpl .protocol $ }} - {{- end }} + {{- end }} {{- if .Values.service.additionalPorts }} {{ toYaml .Values.service.additionalPorts | indent 2 }} {{- end }} diff --git a/charts/deepflow/templates/app-deployment.yaml b/charts/deepflow/templates/app-deployment.yaml index 62d10a9..c31971a 100644 --- a/charts/deepflow/templates/app-deployment.yaml +++ b/charts/deepflow/templates/app-deployment.yaml @@ -5,16 +5,18 @@ metadata: labels: {{- include "deepflow-app.labels" . | nindent 4 }} spec: - replicas: {{ tpl .Values.app.replicas . }} + replicas: {{ tpl (toString .Values.app.replicas) . }} selector: matchLabels: {{- include "deepflow-app.selectorLabels" . | nindent 6 }} template: metadata: - {{- with .Values.podAnnotations }} annotations: + {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + checksum/customConfig: {{ sha256sum (print (tpl (toYaml .Values.configmap) $)) }} labels: {{- include "deepflow-app.selectorLabels" . | nindent 8 }} spec: diff --git a/charts/deepflow/templates/server-statefulset.yaml b/charts/deepflow/templates/server-statefulset.yaml index e32ee94..1b0d507 100644 --- a/charts/deepflow/templates/server-statefulset.yaml +++ b/charts/deepflow/templates/server-statefulset.yaml @@ -9,7 +9,7 @@ spec: rollingUpdate: partition: 0 type: RollingUpdate - replicas: {{ tpl .Values.server.replicas . }} + replicas: {{ tpl (toString .Values.server.replicas) . }} podManagementPolicy: {{ tpl .Values.server.podManagementPolicy . }} serviceName: {{ include "deepflow.fullname" . }}-server-headless selector: @@ -28,6 +28,9 @@ spec: spec: hostNetwork: {{ tpl .Values.server.hostNetwork . }} dnsPolicy: {{ tpl .Values.server.dnsPolicy . }} + dnsConfig: + searches: + - {{ include "deepflow.fullname" . }}-server-headless.{{ .Release.Namespace }}.svc.{{ tpl .Values.clusterDomain . }} imagePullSecrets: {{- with .Values.imagePullSecrets }} {{- toYaml . | nindent 8 }} diff --git a/charts/deepflow/templates/service.yaml b/charts/deepflow/templates/service.yaml index 13d914d..fb1d454 100644 --- a/charts/deepflow/templates/service.yaml +++ b/charts/deepflow/templates/service.yaml @@ -38,32 +38,38 @@ spec: nodePort: {{ tpl (toString .nodePort) $ }} {{- end }} protocol: {{ tpl .protocol $ }} - {{- end }} + {{- end }} {{- if .Values.server.service.additionalPorts }} {{ toYaml .Values.server.service.additionalPorts | indent 2 }} {{- end }} selector: {{- include "deepflow-server.selectorLabels" . | nindent 4 }} type: "{{ .Values.server.service.type }}" -{{/* -# --- -# apiVersion: v1 -# kind: Service -# metadata: -# name: {{ include "deepflow.fullname" . }}-server-headless -# labels: -# {{- include "deepflow-server.labels" . | nindent 4 }} -# spec: -# clusterIP: None -# ports: -# - name: tcp -# port: 20416 -# targetPort: 20416 -# protocol: TCP -# selector: -# {{- include "deepflow-server.selectorLabels" . | nindent 4 }} -# type: ClusterIP -*/}} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "deepflow.fullname" . }}-server-headless + labels: + {{- include "deepflow-server.labels" . | nindent 4 }} +{{- if .Values.server.service.annotations }} + annotations: +{{ toYaml .Values.server.service.annotations | indent 4 }} +{{- end }} +spec: + clusterIP: None + ports: + {{- range .Values.server.service.ports }} + - name: {{ tpl .name $ }} + port: {{ tpl (toString .port) $ }} + targetPort: {{ tpl (toString .targetPort) $ }} + {{- if and (eq $serviceType "NodePort") (.nodePort) }} + {{- end }} + protocol: {{ tpl .protocol $ }} + {{- end }} + selector: + {{- include "deepflow-server.selectorLabels" . | nindent 4 }} + type: ClusterIP --- apiVersion: v1 kind: Service @@ -105,7 +111,7 @@ spec: nodePort: {{ tpl (toString .nodePort) $ }} {{- end }} protocol: {{ tpl .protocol $ }} - {{- end }} + {{- end }} {{- if .Values.app.service.additionalPorts }} {{ toYaml .Values.app.service.additionalPorts | indent 2 }} {{- end }} diff --git a/charts/deepflow/values.yaml b/charts/deepflow/values.yaml index 9606010..47b95ff 100644 --- a/charts/deepflow/values.yaml +++ b/charts/deepflow/values.yaml @@ -32,6 +32,7 @@ global: ## Whether to enable allInone local storage, if enabled, the local /opt directory is used to store data by default, ignoring the node affinity check, and is not responsible for any data persistence allInOneLocalStorage: false storageClass: "" + clusterDomain: cluster.local image: server: @@ -51,6 +52,7 @@ imagePullSecrets: [] nameOverride: "" fullnameOverride: "" +clusterDomain: "{{ .Values.global.clusterDomain }}" timezone: "{{ .Values.global.timezone }}" podAnnotations: {}