Use Helm to deploy TDengine

Helm is a package manager for Kubernetes that can provide more capabilities in deploying on Kubernetes.

Install Helm

1. curl -fsSL -o get_helm.sh \
2. https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
3. chmod +x get_helm.sh
4. ./get_helm.sh

Helm uses the kubectl and kubeconfig configurations to perform Kubernetes operations. For more information, see the Rancher configuration for Kubernetes installation.

Install TDengine Chart

To use TDengine Chart, download it from GitHub:

1. wget https://github.com/taosdata/TDengine-Operator/raw/3.0/helm/tdengine-3.0.0.tgz

Query the storageclass of your Kubernetes deployment:

1. kubectl get storageclass

With minikube, the default value is standard.

Use Helm commands to install TDengine:

1. helm install tdengine tdengine-3.0.0.tgz \
2. --set storage.className=<your storage class name>

You can configure a small storage size in minikube to ensure that your deployment does not exceed your available disk space.

1. helm install tdengine tdengine-3.0.0.tgz \
2. --set storage.className=standard \
3. --set storage.dataSize=2Gi \
4. --set storage.logSize=10Mi

After TDengine is deployed, TDengine Chart outputs information about how to use TDengine:

1. export POD_NAME=$(kubectl get pods --namespace default \
2. -l "app.kubernetes.io/name=tdengine,app.kubernetes.io/instance=tdengine" \
3. -o jsonpath="{.items[0].metadata.name}")
4. kubectl --namespace default exec $POD_NAME -- taos -s "show dnodes; show mnodes"
5. kubectl --namespace default exec -it $POD_NAME -- taos

You can test the deployment by creating a table:

1. kubectl --namespace default exec $POD_NAME -- \
2. taos -s "create database test;
3. use test;
4. create table t1 (ts timestamp, n int);
5. insert into t1 values(now, 1)(now + 1s, 2);
6. select * from t1;"

Configuring Values

You can configure custom parameters in TDengine with the values.yaml file.

Run the helm show values command to see all parameters supported by TDengine Chart.

1. helm show values tdengine-3.0.0.tgz

Save the output of this command as values.yaml. Then you can modify this file with your desired values and use it to deploy a TDengine cluster:

1. helm install tdengine tdengine-3.0.0.tgz -f values.yaml

The parameters are described as follows:

1. # Default values for tdengine.
2. # This is a YAML-formatted file.
3. # Declare variables to be passed into helm templates.

5. replicaCount: 1

7. image:
8. prefix: tdengine/tdengine
9. #pullPolicy: Always
10. # Overrides the image tag whose default is the chart appVersion.
11. #  tag: "3.0.0.0"

13. service:
14. # ClusterIP is the default service type, use NodeIP only if you know what you are doing.
15. type: ClusterIP
16. ports:
17. # TCP range required
18. tcp: [6030, 6041, 6042, 6043, 6044, 6046, 6047, 6048, 6049, 6060]
19. # UDP range
20. udp: [6044, 6045]

23. # Set timezone here, not in taoscfg
24. timezone: "Asia/Shanghai"

26. resources:
27. # We usually recommend not to specify default resources and to leave this as a conscious
28. # choice for the user. This also increases chances charts run on environments with little
29. # resources, such as Minikube. If you do want to specify resources, uncomment the following
30. # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
31. # limits:
32. #   cpu: 100m
33. #   memory: 128Mi
34. # requests:
35. #   cpu: 100m
36. #   memory: 128Mi

38. storage:
39. # Set storageClassName for pvc. K8s use default storage class if not set.
40. #
41. className: ""
42. dataSize: "100Gi"
43. logSize: "10Gi"

45. nodeSelectors:
46. taosd:
47. # node selectors

49. clusterDomainSuffix: ""
50. # Config settings in taos.cfg file.
51. #
52. # The helm/k8s support will use environment variables for taos.cfg,
53. # converting an upper-snake-cased variable like `TAOS_DEBUG_FLAG`,
54. # to a camelCase taos config variable `debugFlag`.
55. #
56. # See the [Configuration Variables](../../reference/config)
57. #
58. # Note:
59. # 1. firstEp/secondEp: should not be setted here, it's auto generated at scale-up.
60. # 2. serverPort: should not be setted, we'll use the default 6030 in many places.
61. # 3. fqdn: will be auto generated in kubenetes, user should not care about it.
62. # 4. role: currently role is not supported - every node is able to be mnode and vnode.
63. #
64. # Btw, keep quotes "" around the value like below, even the value will be number or not.
65. taoscfg:
66. # Starts as cluster or not, must be 0 or 1.
67. #   0: all pods will start as a seperate TDengine server
68. #   1: pods will start as TDengine server cluster. [default]
69. CLUSTER: "1"

71. # number of replications, for cluster only
72. TAOS_REPLICA: "1"

74. #
75. # TAOS_NUM_OF_RPC_THREADS: number of threads for RPC
76. #TAOS_NUM_OF_RPC_THREADS: "2"

79. #
80. # TAOS_NUM_OF_COMMIT_THREADS: number of threads to commit cache data
81. #TAOS_NUM_OF_COMMIT_THREADS: "4"

83. # enable/disable installation / usage report
84. #TAOS_TELEMETRY_REPORTING: "1"

86. # time interval of system monitor, seconds
87. #TAOS_MONITOR_INTERVAL: "30"

89. # time interval of dnode status reporting to mnode, seconds, for cluster only
90. #TAOS_STATUS_INTERVAL: "1"

92. # time interval of heart beat from shell to dnode, seconds
93. #TAOS_SHELL_ACTIVITY_TIMER: "3"

95. # minimum sliding window time, milli-second
96. #TAOS_MIN_SLIDING_TIME: "10"

98. # minimum time window, milli-second
99. #TAOS_MIN_INTERVAL_TIME: "1"

101. # the compressed rpc message, option:
102. #  -1 (no compression)
103. #   0 (all message compressed),
104. # > 0 (rpc message body which larger than this value will be compressed)
105. #TAOS_COMPRESS_MSG_SIZE: "-1"

107. # max number of connections allowed in dnode
108. #TAOS_MAX_SHELL_CONNS: "50000"

110. # stop writing logs when the disk size of the log folder is less than this value
111. #TAOS_MINIMAL_LOG_DIR_G_B: "0.1"

113. # stop writing temporary files when the disk size of the tmp folder is less than this value
114. #TAOS_MINIMAL_TMP_DIR_G_B: "0.1"

116. # if disk free space is less than this value, taosd service exit directly within startup process
117. #TAOS_MINIMAL_DATA_DIR_G_B: "0.1"

119. # One mnode is equal to the number of vnode consumed
120. #TAOS_MNODE_EQUAL_VNODE_NUM: "4"

122. # enbale/disable http service
123. #TAOS_HTTP: "1"

125. # enable/disable system monitor
126. #TAOS_MONITOR: "1"

128. # enable/disable async log
129. #TAOS_ASYNC_LOG: "1"

131. #
132. # time of keeping log files, days
133. #TAOS_LOG_KEEP_DAYS: "0"

135. # The following parameters are used for debug purpose only.
136. # debugFlag 8 bits mask: FILE-SCREEN-UNUSED-HeartBeat-DUMP-TRACE_WARN-ERROR
137. # 131: output warning and error
138. # 135: output debug, warning and error
139. # 143: output trace, debug, warning and error to log
140. # 199: output debug, warning and error to both screen and file
141. # 207: output trace, debug, warning and error to both screen and file
142. #
143. # debug flag for all log type, take effect when non-zero value\
144. #TAOS_DEBUG_FLAG: "143"

146. # generate core file when service crash
147. #TAOS_ENABLE_CORE_FILE: "1"

Scaling Out

For information about scaling out your deployment, see Kubernetes. Additional Helm-specific is described as follows.

First, obtain the name of the StatefulSet service for your deployment.

1. export STS_NAME=$(kubectl get statefulset \
2. -l "app.kubernetes.io/name=tdengine" \
3. -o jsonpath="{.items[0].metadata.name}")

You can scale out your deployment by adding replicas. The following command scales a deployment to three nodes:

1. kubectl scale --replicas 3 statefulset/$STS_NAME

Run the show dnodes and show mnodes commands to check whether the scale-out was successful.

Scaling In

Helm - 图1warning

Exercise caution when scaling in a cluster.

Determine which dnodes you want to remove and drop them manually.

1. kubectl --namespace default exec $POD_NAME -- \
2. cat /var/lib/taos/dnode/dnodeEps.json \
3. | jq '.dnodeInfos[1:] |map(.dnodeFqdn + ":" + (.dnodePort|tostring)) | .[]' -r
4. kubectl --namespace default exec $POD_NAME -- taos -s "show dnodes"
5. kubectl --namespace default exec $POD_NAME -- taos -s 'drop dnode "<you dnode in list>"'

Remove a TDengine Cluster

You can use Helm to remove your cluster:

1. helm uninstall tdengine

However, Helm does not remove PVCs automatically. After you remove your cluster, manually remove all PVCs.