Skip to content

Commit

Permalink
Merge pull request #1144 from yyyangw/feature/client_nodepool
Browse files Browse the repository at this point in the history
增加“helm charts部署方式下的节点池扩容功能”及文档说明
  • Loading branch information
Lingghh authored Jul 25, 2024
2 parents e97fbac + d9c96f0 commit 997971b
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 56 deletions.
44 changes: 38 additions & 6 deletions helm-charts/tca/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,45 @@ 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 |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.tca.client.enabled }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -56,7 +58,7 @@ spec:
exec:
command:
- sleep
- '20'
- '20'
resources:
{{ toYaml .Values.tca.client.resources | indent 12 }}
volumeMounts:
Expand All @@ -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 }}
86 changes: 86 additions & 0 deletions helm-charts/tca/templates/client/deployment-extra.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
41 changes: 29 additions & 12 deletions helm-charts/tca/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
##
Expand Down

0 comments on commit 997971b

Please sign in to comment.