From 8652ff115b5999e256e2b450c062df9d1ed21ac4 Mon Sep 17 00:00:00 2001 From: yyyangw <1135905221@qq.com> Date: Wed, 24 Jul 2024 20:48:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E2=80=9Chelm=20charts?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E6=96=B9=E5=BC=8F=E4=B8=8B=E7=9A=84=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=B1=A0=E6=89=A9=E5=AE=B9=E5=8A=9F=E8=83=BD=E2=80=9D?= =?UTF-8?q?=E5=8F=8A=E6=96=87=E6=A1=A3=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-charts/tca/README.md | 50 +++++++++-- ...eployment.yaml => deployment-default.yaml} | 42 +-------- .../templates/client/deployment-extra.yaml | 86 +++++++++++++++++++ helm-charts/tca/values.yaml | 41 ++++++--- 4 files changed, 163 insertions(+), 56 deletions(-) rename helm-charts/tca/templates/client/{deployment.yaml => deployment-default.yaml} (67%) create mode 100644 helm-charts/tca/templates/client/deployment-extra.yaml diff --git a/helm-charts/tca/README.md b/helm-charts/tca/README.md index 46ef79a4d..1676484ec 100644 --- a/helm-charts/tca/README.md +++ b/helm-charts/tca/README.md @@ -302,13 +302,51 @@ Helm will deploy `mariadb` by default. Reference: [bitnami/mariadb](https://gith | `tca.scmproxy.image.tag` | TCA scmproxy image tag | `latest` | | `tca.scmproxy.privateScmUrl` | TCA scmproxy private scm url | `""` | - ### TCA Client Configuration parameters -| Name | Description | Value | -| -------------------------------------------- | ------------------------------------------------------------------------ | ------------------------- | -| `tca.client.image.repository` | TCA client image repository | `tencenttca/tca-client` | -| `tca.client.image.repository` | TCA client image tag | `latest` | -| `tca.client.enabeld` | Enabled starting TCA client with helm | `true` | +#### Default node pool configuration +| Name | Description | Value | +|------------------------------------------------|----------------------------------------------| ------------------------ | +| `tca.client.image.repository` | TCA client image repository | `tencenttca/tca-client` | +| `tca.client.image.tag` | TCA client image tag | `latest` | +| `tca.client.enabeld` | Enabled starting TCA client with helm | `true` | +| `tca.client.replicas` | The number of nodes in the default node pool | `1` | +| `tca.client.tag` | Tag of the extra node pool | `Codedog_Linux` | +| `tca.client.resources.limits.cpu` | The upper limit of cpu usage | `2000m` | +| `tca.client.resources.limits.memory` | The upper limit of memory usage | `4Gi` | +| `tca.client.resources.requests.cpu` | Required cpu resources | `1000m` | +| `tca.client.resources.requests.memory` | Required memory resources | `2Gi` | + +#### Client Node pool expansion operations guide +You can configure node resources on the client. +If you do not manually configure node resources, the default node pool is used. +If the node pool resources are insufficient, expand the capacity of the node pool at any time. For details, refer to 'Procedure for expanding a node pool'. + +#### TCA client node pool expansion config +| Name | Description | +|--------------------------------------------------------------|---------------------------------------| +| `extraNodePools.nodepool` | Name of the extended node pool | +| `extraNodePools.nodepool.tag` | Tag of the extra node pool | +| `extraNodePools.nodepool.enabled` | Enabled extending node pool with helm | +| `extraNodePools.nodepool.replicas` | The number of nodes in the extra node pool | +| `extraNodePools.nodepool.resources.limits.cpu` | The upper limit of cpu usage | +| `extraNodePools.nodepool.resources.limits.memory` | The upper limit of memory usage | +| `extraNodePools.nodepool.resources.requests.cpu` | Required cpu resources | +| `extraNodePools.nodepool.resources.requests.memory` | Required memory resources | + +#### Procedure for expanding a node pool +1、Initially, deploy the project exclusively utilizing the default node pool. + +2、To expand the node pool, navigate to "Background Management > Node Management > Label Management" and add label information. + +3、Update the extra node pool configuration in the project file by navigating to "CodeAnalysis/helm-charts/tca/values.yaml" . + +4、To add configuration information for extra node pools, refer to the "TCA client node pool expansion config" section under "extraNodePools" in the client section of the TCA. + +5、Please note that the "extraNodePools.nodepool" tag can be customized to match the user's requirements for the node pool name. This tag should be the same as the tag name added in Step 2. + +6、To enable the current node pool, modify the "enabled" value to "true". + +7、Update project deployment. ### TCA Gateway Configuration parameters | Name | Description | Value | diff --git a/helm-charts/tca/templates/client/deployment.yaml b/helm-charts/tca/templates/client/deployment-default.yaml similarity index 67% rename from helm-charts/tca/templates/client/deployment.yaml rename to helm-charts/tca/templates/client/deployment-default.yaml index d01ff8ede..fb0ccc4c3 100644 --- a/helm-charts/tca/templates/client/deployment.yaml +++ b/helm-charts/tca/templates/client/deployment-default.yaml @@ -1,3 +1,4 @@ +{{- if .Values.tca.client.enabled }} apiVersion: apps/v1 kind: StatefulSet metadata: @@ -10,6 +11,7 @@ metadata: name: {{ template "tca.fullname" . }}-client spec: serviceName: "" + replicas: {{ .Values.tca.client.replicas }} selector: matchLabels: k8s-app: {{ template "tca.fullname" . }}-client @@ -42,7 +44,7 @@ spec: image: "{{ .Values.tca.client.image.repository }}:{{ .Values.tca.client.image.tag }}" imagePullPolicy: {{ .Values.global.imagePullPolicy }} command: ["python3"] - args: ["codepuppy.py", "start", "-t", "$(CODEDOG_TOKEN)", "--create-from", "docker", "--tag", "CodeDog_Linux"] + args: ["codepuppy.py", "start", "-t", "$(CODEDOG_TOKEN)", "--create-from", "docker", "--tag", "{{ .Values.tca.client.tag }}"] envFrom: - configMapRef: name: client-env @@ -56,7 +58,7 @@ spec: exec: command: - sleep - - '20' + - '20' resources: {{ toYaml .Values.tca.client.resources | indent 12 }} volumeMounts: @@ -71,40 +73,4 @@ spec: path: config.ini name: {{ template "tca.fullname" . }}-client-config name: client-config-conf ---- -{{- if .Values.tca.client.autoscaling.enabled }} -apiVersion: autoscaling/v2beta2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ template "tca.fullname" . }}-client - labels: - k8s-app: {{ template "tca.fullname" . }}-client - app: {{ template "tca.name" . }} - chart: {{ template "tca.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: StatefulSet - name: {{ template "tca.fullname" . }}-client - minReplicas: {{ .Values.tca.client.autoscaling.minReplicas }} - maxReplicas: {{ .Values.tca.client.autoscaling.maxReplicas }} - metrics: - {{- if .Values.tca.client.autoscaling.targetMemory }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.tca.client.autoscaling.targetMemory }} - {{- end }} - {{- if .Values.tca.client.autoscaling.targetCPU }} - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.tca.client.autoscaling.targetCPU }} - {{- end }} {{- end }} diff --git a/helm-charts/tca/templates/client/deployment-extra.yaml b/helm-charts/tca/templates/client/deployment-extra.yaml new file mode 100644 index 000000000..a2a22106f --- /dev/null +++ b/helm-charts/tca/templates/client/deployment-extra.yaml @@ -0,0 +1,86 @@ +{{ $myChartName := .Release.Name }} +{{ $myChartService := .Release.Service }} +{{ $Values := .Values}} +{{ $BasePath := $.Template.BasePath}} +{{ $Image := .Values.tca.client.image }} + +{{- range $key, $value := .Values.tca.client.extraNodePools }} +{{- if $value.enabled }} +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + labels: + k8s-app: {{ template "tca.fullname" $ }}-client-{{ $key }} + app: {{ template "tca.name" $ }} + chart: {{ template "tca.chart" $ }} + release: {{ $myChartName }} + heritage: {{ $myChartService }} + name: {{ template "tca.fullname" $ }}-client-{{ $key }} +spec: + serviceName: "" + replicas: {{ $value.replicas }} + selector: + matchLabels: + k8s-app: {{ template "tca.fullname" $ }}-client-{{ $key }} + release: {{ $myChartName }} + template: + metadata: + labels: + k8s-app: {{ template "tca.fullname" $ }}-client-{{ $key }} + release: {{ $myChartName }} + spec: + shareProcessNamespace: true + {{- with $Values.global.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- if $Values.tca.podAntiAffinity.enable }} + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + topologyKey: "{{ .Values.tca.podAntiAffinity.topologyKey }}" + labelSelector: + matchLabels: + k8s-app: {{ template "tca.fullname" $ }}-client-{{ $key }} + release: {{ $myChartName }} + {{- end }} + containers: + - name: {{ template "tca.fullname" $ }}-client-{{ $key }} + image: "{{ $Image.repository }}:{{ $Image.tag }}" + imagePullPolicy: {{ $Values.global.imagePullPolicy }} + command: ["python3"] + args: ["codepuppy.py", "start", "-t", "$(CODEDOG_TOKEN)", "--create-from", "docker", "--tag", "{{ $value.tag }}"] + envFrom: + - configMapRef: + name: client-env + env: + - name: _HASH_ENV_ + value: {{ include (print $BasePath "/client/configmap-env.yaml") $ | sha256sum }} + - name: _HASH_CONFIG_ + value: {{ include (print $BasePath "/client/configmap-conf.yaml") $ | sha256sum }} + lifecycle: + preStop: + exec: + command: + - sleep + - '20' + resources: +{{ toYaml $value.resources | indent 12 }} + volumeMounts: + - mountPath: /workspace/client/config.ini + subPath: config.ini + name: client-config-conf + volumes: + - configMap: + items: + - key: config.ini + mode: 420 + path: config.ini + name: {{ template "tca.fullname" $ }}-client-config + name: client-config-conf + +{{- end }} +{{- end }} diff --git a/helm-charts/tca/values.yaml b/helm-charts/tca/values.yaml index 3ada57116..741c46604 100644 --- a/helm-charts/tca/values.yaml +++ b/helm-charts/tca/values.yaml @@ -632,27 +632,44 @@ tca: ## TCA client: TCA client analysing code ## client: + ## @param tca.client.enabled Enable default TCA client starting + ## @param tca.client.replicas Indicates the number of nodes in the default node pool + ## @param tca.client.tag Tag of the default node pool + ## @param tca.client.resources Cpu and memory resource configuration of the default node pool + ## image: repository: tencenttca/tca-client tag: latest - ## @param tca.client.enabled Enable TCA client starting - ## enabled: true + replicas: 1 + tag: Codedog_Linux resources: limits: - cpu: "4000m" - memory: "8Gi" + cpu: "2000m" + memory: "4Gi" requests: cpu: "1000m" memory: "2Gi" - ## TCA client auto scaling config - ## - autoscaling: - enabled: true - minReplicas: 2 - maxReplicas: 4 - targetCPU: "" - targetMemory: "" + + ## TCA client node pool expansion config + ## @param tca.client.extraNodePools.nodepool Name of the extended node pool + ## @param tca.client.extraNodePools.{nodePoolName}.tag Tag of the extra node pool + ## @param tca.client.extraNodePools.{nodePoolName}.enabled Enable extra TCA client starting + ## @param tca.client.extraNodePools.{nodePoolName}.replicas Indicates the number of nodes in the extra node pool + ## @param tca.client.extraNodePools.{nodePoolName}.resources Cpu and memory resource configuration of the extra node pool + ## + extraNodePools: + nodepool: + tag: NodePoolTag + enabled: false + replicas: 2 + resources: + limits: + cpu: "2000m" + memory: "4Gi" + requests: + cpu: "1000m" + memory: "2Gi" ## TCA gateway: TCA gateway for all servers ## From d9c96f0767dbca2f29459a10105c763db94dc721 Mon Sep 17 00:00:00 2001 From: yyyangw <1135905221@qq.com> Date: Thu, 25 Jul 2024 09:59:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E2=80=9Chelm=20charts?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E6=96=B9=E5=BC=8F=E4=B8=8B=E7=9A=84=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=B1=A0=E6=89=A9=E5=AE=B9=E5=8A=9F=E8=83=BD=E2=80=9D?= =?UTF-8?q?=E5=8F=8A=E6=96=87=E6=A1=A3=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-charts/tca/README.md | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/helm-charts/tca/README.md b/helm-charts/tca/README.md index 1676484ec..bf32a52cf 100644 --- a/helm-charts/tca/README.md +++ b/helm-charts/tca/README.md @@ -334,19 +334,13 @@ If the node pool resources are insufficient, expand the capacity of the node poo | `extraNodePools.nodepool.resources.requests.memory` | Required memory resources | #### Procedure for expanding a node pool -1、Initially, deploy the project exclusively utilizing the default node pool. - -2、To expand the node pool, navigate to "Background Management > Node Management > Label Management" and add label information. - -3、Update the extra node pool configuration in the project file by navigating to "CodeAnalysis/helm-charts/tca/values.yaml" . - -4、To add configuration information for extra node pools, refer to the "TCA client node pool expansion config" section under "extraNodePools" in the client section of the TCA. - -5、Please note that the "extraNodePools.nodepool" tag can be customized to match the user's requirements for the node pool name. This tag should be the same as the tag name added in Step 2. - -6、To enable the current node pool, modify the "enabled" value to "true". - -7、Update project deployment. +1. Initially, deploy the project exclusively utilizing the default node pool. +2. To expand the node pool, navigate to "Background Management > Node Management > Label Management" and add label information. +3. Update the extra node pool configuration in the project file by navigating to "CodeAnalysis/helm-charts/tca/values.yaml" . +4. To add configuration information for extra node pools, refer to the "TCA client node pool expansion config" section under "extraNodePools" in the client section of the TCA. +5. Please note that the "extraNodePools.nodepool" tag can be customized to match the user's requirements for the node pool name. This tag should be the same as the tag name added in Step 2. +6. To enable the current node pool, modify the "enabled" value to "true". +7. Update project deployment. ### TCA Gateway Configuration parameters | Name | Description | Value |