github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/deploy/greptimedb/templates/clusterdefinition.yaml (about) 1 apiVersion: apps.kubeblocks.io/v1alpha1 2 kind: ClusterDefinition 3 metadata: 4 name: greptimedb 5 labels: 6 {{- include "greptimedb.labels" . | nindent 4 }} 7 spec: 8 connectionCredential: 9 username: root 10 password: "$(RANDOM_PASSWD)" 11 endpoint: "$(SVC_FQDN):$(SVC_PORT_mysql)" 12 host: "$(SVC_FQDN)" 13 port: "$(SVC_PORT_mysql)" 14 accesskey: "" 15 secretkey: "" 16 componentDefs: 17 - name: frontend 18 workloadType: Stateless 19 characterType: greptimedb 20 probes: 21 configSpecs: 22 - name: greptimedb-frontend 23 templateRef: greptimedb-frontend 24 volumeName: frontend-config 25 namespace: {{ .Release.Namespace }} 26 service: 27 ports: 28 - name: http 29 port: 4000 30 targetPort: http 31 - name: grpc 32 port: 4001 33 targetPort: grpc 34 - name: mysql 35 port: 4002 36 targetPort: mysql 37 - name: postgres 38 port: 4003 39 targetPort: postgres 40 - name: opentsdb 41 port: 4242 42 targetPort: opentsdb 43 componentDefRef: 44 - &metaRef 45 componentDefName: meta 46 componentRefEnv: 47 - name: GREPTIMEDB_META_SVC 48 valueFrom: 49 type: ServiceRef 50 - &datanodeRef 51 componentDefName: datanode 52 componentRefEnv: 53 - name: GREPTIMEDB_DATANODE_SVC 54 valueFrom: 55 type: ServiceRef 56 podSpec: 57 initContainers: 58 - name: wait-datanode 59 image: busybox:1.28 60 imagePullPolicy: {{default .Values.images.pullPolicy "IfNotPresent"}} 61 command: 62 - bin/sh 63 - -c 64 - | 65 until nslookup ${GREPTIMEDB_DATANODE_SVC}-headless.${KB_NAMESPACE}.svc{{ .Values.clusterDomain }}; do 66 # frontend requires at least one datanode is ready 67 echo "waiting for datanode"; sleep 2; 68 done; 69 containers: 70 - name: frontend 71 imagePullPolicy: {{default .Values.images.pullPolicy "IfNotPresent"}} 72 livenessProbe: 73 failureThreshold: 3 74 httpGet: 75 path: /health 76 port: 4000 77 scheme: HTTP 78 periodSeconds: 10 79 successThreshold: 1 80 timeoutSeconds: 3 81 readinessProbe: 82 failureThreshold: 5 83 httpGet: 84 path: /health 85 port: 4000 86 scheme: HTTP 87 periodSeconds: 10 88 successThreshold: 1 89 timeoutSeconds: 3 90 terminationMessagePath: /dev/termination-log 91 terminationMessagePolicy: File 92 volumeMounts: 93 - mountPath: /etc/greptimedb 94 name: frontend-config 95 args: 96 - frontend 97 - start 98 - --metasrv-addr 99 - $(GREPTIMEDB_META_SVC).$(KB_NAMESPACE).svc{{ .Values.clusterDomain }}:3002 100 - --http-addr 101 - 0.0.0.0:4000 102 - --grpc-addr 103 - 0.0.0.0:4001 104 - --mysql-addr 105 - 0.0.0.0:4002 106 - --postgres-addr 107 - 0.0.0.0:4003 108 - --opentsdb-addr 109 - 0.0.0.0:4242 110 - --config-file 111 - /etc/greptimedb/config.toml 112 ports: 113 - name: http 114 containerPort: 4000 115 - name: grpc 116 containerPort: 4001 117 - name: mysql 118 containerPort: 4002 119 - name: postgres 120 containerPort: 4003 121 - name: opentsdb 122 containerPort: 4242 123 serviceAccountName: greptimedb-cluster 124 terminationGracePeriodSeconds: 10 125 dnsPolicy: ClusterFirst 126 restartPolicy: Always 127 128 - name: datanode 129 workloadType: Stateful 130 characterType: greptimedb 131 probes: 132 logConfigs: 133 configSpecs: 134 - name: greptimedb-datanode 135 templateRef: greptimedb-datanode 136 volumeName: datanode-config 137 namespace: {{ .Release.Namespace }} 138 service: 139 ports: 140 - name: http 141 port: 4000 142 targetPort: http 143 - name: grpc 144 port: 4001 145 targetPort: grpc 146 componentDefRef: 147 - *metaRef 148 podSpec: 149 containers: 150 - name: datanode 151 imagePullPolicy: {{default .Values.images.pullPolicy "IfNotPresent"}} 152 livenessProbe: 153 failureThreshold: 3 154 httpGet: 155 path: /health 156 port: 4000 157 scheme: HTTP 158 periodSeconds: 10 159 successThreshold: 1 160 timeoutSeconds: 3 161 readinessProbe: 162 failureThreshold: 5 163 httpGet: 164 path: /health 165 port: 4000 166 scheme: HTTP 167 periodSeconds: 10 168 successThreshold: 1 169 timeoutSeconds: 3 170 terminationMessagePath: /dev/termination-log 171 terminationMessagePolicy: File 172 volumeMounts: 173 - mountPath: /etc/greptimedb 174 name: config 175 - mountPath: /tmp/greptimedb 176 name: datanode 177 ports: 178 - name: grpc 179 containerPort: 4001 180 - name: http 181 containerPort: 4000 182 args: 183 - datanode 184 - start 185 - --metasrv-addr 186 - $(GREPTIMEDB_META_SVC).$(KB_NAMESPACE).svc{{ .Values.clusterDomain }}:3002 187 - --http-addr 188 - 0.0.0.0:4000 189 - --config-file 190 - /etc/greptimedb/config.toml 191 dnsPolicy: ClusterFirst 192 initContainers: 193 - name: wait-meta 194 image: busybox:1.28 195 imagePullPolicy: {{default .Values.images.pullPolicy "IfNotPresent"}} 196 command: 197 - bin/sh 198 - -c 199 - | 200 until nslookup ${GREPTIMEDB_META_SVC}-headless.${KB_NAMESPACE}.svc{{ .Values.clusterDomain }}; do 201 # datanode requires at least one meta is ready 202 echo "waiting for meta"; sleep 2; 203 done; 204 - name: initializer 205 args: 206 - --config-path 207 - /etc/greptimedb/config.toml 208 - --init-config-path 209 - /etc/greptimedb-init/config.toml 210 - --datanode-rpc-port 211 - "4001" 212 - --datanode-service-name 213 - $(KB_CLUSTER_COMP_NAME)-headless 214 - --namespace 215 - $(KB_NAMESPACE) 216 - --component-kind 217 - datanode 218 command: 219 - greptimedb-initializer 220 env: 221 - name: POD_IP 222 value: $(KB_POD_IP) 223 - name: POD_NAME 224 value: $(KB_POD_NAME) 225 image: docker.io/greptime/greptimedb-initializer:0.1.0-alpha.12 226 imagePullPolicy: {{default .Values.images.pullPolicy "IfNotPresent"}} 227 terminationMessagePath: /dev/termination-log 228 terminationMessagePolicy: File 229 volumeMounts: 230 - mountPath: /etc/greptimedb 231 name: config 232 - mountPath: /etc/greptimedb-init 233 name: datanode-config 234 serviceAccountName: greptimedb-cluster 235 terminationGracePeriodSeconds: 10 236 volumes: 237 - emptyDir: {} 238 name: config 239 240 - name: meta 241 workloadType: Stateless 242 characterType: greptimedb 243 probes: 244 configSpecs: 245 - name: greptimedb-meta 246 templateRef: greptimedb-meta 247 volumeName: meta-config 248 namespace: {{ .Release.Namespace }} 249 service: 250 ports: 251 - name: grpc 252 port: 3002 253 targetPort: grpc 254 - name: http 255 port: 4000 256 targetPort: http 257 componentDefRef: 258 - &etcdRef 259 componentDefName: etcd 260 componentRefEnv: 261 - name: GREPTIMEDB_ETCD_SVC 262 valueFrom: 263 type: ServiceRef 264 podSpec: 265 initContainers: 266 - name: wait-etcd 267 image: busybox:1.28 268 imagePullPolicy: {{default .Values.images.pullPolicy "IfNotPresent"}} 269 command: 270 - bin/sh 271 - -c 272 - | 273 until nslookup ${GREPTIMEDB_ETCD_SVC}-headless.${KB_NAMESPACE}.svc{{ .Values.clusterDomain }}; do 274 echo "waiting for etcd"; sleep 2; 275 done; 276 containers: 277 - name: meta 278 imagePullPolicy: {{default .Values.images.pullPolicy "IfNotPresent"}} 279 livenessProbe: 280 failureThreshold: 3 281 httpGet: 282 path: /health 283 port: 4000 284 scheme: HTTP 285 periodSeconds: 10 286 successThreshold: 1 287 timeoutSeconds: 3 288 readinessProbe: 289 failureThreshold: 5 290 httpGet: 291 path: /health 292 port: 4000 293 scheme: HTTP 294 periodSeconds: 10 295 successThreshold: 1 296 timeoutSeconds: 3 297 terminationMessagePath: /dev/termination-log 298 terminationMessagePolicy: File 299 ports: 300 - containerPort: 3002 301 name: grpc 302 - containerPort: 4000 303 name: http 304 volumeMounts: 305 - mountPath: /etc/greptimedb 306 name: meta-config 307 args: 308 - metasrv 309 - start 310 - --bind-addr 311 - 0.0.0.0:3002 312 - --http-addr 313 - 0.0.0.0:4000 314 - --server-addr 315 - $(KB_POD_IP):3002 316 - --store-addr 317 - $(GREPTIMEDB_ETCD_SVC)-headless.$(KB_NAMESPACE).svc{{ .Values.clusterDomain }}:2379 318 - --config-file 319 - /etc/greptimedb/config.toml 320 env: 321 - name: GREPTIMEDB_METASRV__DISABLE_REGION_FAILOVER 322 value: {{ .Values.meta.disableRegionFailover | quote}} 323 serviceAccountName: greptimedb-cluster 324 terminationGracePeriodSeconds: 10 325 dnsPolicy: ClusterFirst 326 restartPolicy: Always 327 328 - name: etcd 329 workloadType: Consensus 330 characterType: etcd 331 consensusSpec: 332 leader: 333 name: "leader" 334 accessMode: ReadWrite 335 followers: 336 - name: "follower" 337 accessMode: ReadWrite 338 updateStrategy: BestEffortParallel 339 probes: 340 roleProbe: 341 periodSeconds: 1 342 failureThreshold: 3 343 configSpecs: 344 service: 345 ports: 346 - name: client 347 port: 2379 348 targetPort: client 349 - name: peer 350 port: 2380 351 targetPort: peer 352 podSpec: 353 initContainers: 354 - name: volume-permissions 355 image: busybox:1.28 356 imagePullPolicy: {{default .Values.images.pullPolicy "IfNotPresent"}} 357 command: 358 - /bin/sh 359 - -ec 360 - | 361 chown -R 1001:1001 /var/lib/etcd 362 securityContext: 363 runAsUser: 0 364 volumeMounts: 365 - name: etcd-storage 366 mountPath: /var/lib/etcd 367 containers: 368 - name: etcd 369 imagePullPolicy: {{default .Values.images.pullPolicy "IfNotPresent"}} 370 terminationMessagePath: /dev/termination-log 371 terminationMessagePolicy: File 372 volumeMounts: 373 - mountPath: /var/lib/etcd 374 name: etcd-storage 375 ports: 376 - name: client 377 containerPort: 2379 378 - name: peer 379 containerPort: 2380 380 command: 381 - bin/sh 382 - -c 383 - | 384 echo "start etcd..." 385 PEERS="" 386 DOMAIN=$KB_NAMESPACE".svc{{ .Values.clusterDomain }}" 387 i=0 388 while [ $i -lt $KB_REPLICA_COUNT ]; do 389 if [ $i -ne 0 ]; then 390 PEERS="$PEERS,"; 391 fi; 392 host=$(eval echo \$KB_"$i"_HOSTNAME) 393 host=$host"."$DOMAIN 394 hostname=${KB_CLUSTER_COMP_NAME}-${i} 395 PEERS="$PEERS$hostname=http://$host:2380" 396 i=$(( i + 1 )) 397 done 398 MY_PEER=$KB_POD_FQDN{{ .Values.clusterDomain }} 399 exec etcd --name ${HOSTNAME} \ 400 --listen-peer-urls http://0.0.0.0:2380 \ 401 --listen-client-urls http://0.0.0.0:2379 \ 402 --advertise-client-urls http://${MY_PEER}:2379 \ 403 --initial-advertise-peer-urls http://${MY_PEER}:2380 \ 404 --initial-cluster-token greptimedb-cluster \ 405 --initial-cluster ${PEERS} \ 406 --initial-cluster-state new \ 407 --data-dir /var/lib/etcd 408 env: 409 - name: ETCDCTL_API 410 value: "3" 411 - name: ETCD_ON_K8S 412 value: "yes"