github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/deploy/clickhouse/templates/clusterdefinition.yaml (about)

     1  apiVersion: apps.kubeblocks.io/v1alpha1
     2  kind: ClusterDefinition
     3  metadata:
     4    name: clickhouse
     5    labels:
     6      {{- include "clickhouse.labels" . | nindent 4 }}
     7      {{- if .Values.commonLabels }}
     8      {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
     9      {{- end }}
    10    {{- if .Values.commonAnnotations }}
    11    annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
    12    {{- end }}
    13  spec:
    14    type: clickhouse
    15    connectionCredential:
    16      username: "admin"
    17      admin-password: "$(RANDOM_PASSWD)"
    18      endpoint: "http://$(SVC_FQDN):$(SVC_PORT_http)"
    19      tcpEndpoint: "$(SVC_FQDN):$(SVC_PORT_tcp)"
    20      mysqlEndpoint: "$(SVC_FQDN):$(SVC_PORT_tcp-mysql)"
    21      pgEndpoint: "$(SVC_FQDN):$(SVC_PORT_tcp-postgresql)"
    22    componentDefs:
    23      - name: clickhouse
    24        workloadType: Stateful
    25        characterType: clickhouse
    26        probes:
    27        monitor:
    28          builtIn: false
    29          exporterConfig:
    30            scrapePath: /metrics
    31            scrapePort: 8001
    32        logConfigs:
    33          {{- range $name, $pattern := .Values.logConfigs }}
    34          - name: {{ $name }}
    35            filePathPattern: {{ $pattern }}
    36          {{- end }}
    37        configSpecs:
    38          - name: clickhouse-tpl
    39            templateRef: clickhouse-tpl
    40            volumeName: config
    41            namespace: {{ .Release.Namespace }}
    42        service:
    43          ports:
    44            - name: http
    45              targetPort: http
    46              port: 8123
    47            - name: tcp
    48              targetPort: tcp
    49              port: 9000
    50            - name: tcp-mysql
    51              targetPort: tcp-mysql
    52              port: 9004
    53            - name: tcp-postgresql
    54              targetPort: tcp-postgresql
    55              port: 9005
    56            - name: http-intersrv
    57              targetPort: http-intersrv
    58              port: 9009
    59            - name: http-metrics
    60              targetPort: http-metrics
    61              port: 8001
    62        podSpec:
    63          securityContext:
    64            fsGroup: 1001
    65            seccompProfile:
    66              type: RuntimeDefault
    67          containers:
    68            - name: clickhouse
    69              securityContext:
    70                allowPrivilegeEscalation: false
    71                capabilities:
    72                  drop:
    73                    - ALL
    74                runAsNonRoot: true
    75                runAsUser: 1001
    76              env:
    77                - name: CLICKHOUSE_ADMIN_PASSWORD
    78                  valueFrom:
    79                    secretKeyRef:
    80                      # notes: could also reference the secret's 'password' key,
    81                      # just keeping the same secret keys as bitnami Clickhouse chart
    82                      name: $(CONN_CREDENTIAL_SECRET_NAME)
    83                      key: admin-password
    84                      optional: false
    85                - name: BITNAMI_DEBUG
    86                  value: "false"
    87                - name: CLICKHOUSE_HTTP_PORT
    88                  value: "8123"
    89                - name: CLICKHOUSE_TCP_PORT
    90                  value: "9000"
    91                - name: CLICKHOUSE_MYSQL_PORT
    92                  value: "9004"
    93                - name: CLICKHOUSE_POSTGRESQL_PORT
    94                  value: "9005"
    95                - name: CLICKHOUSE_INTERSERVER_HTTP_PORT
    96                  value: "9009"
    97                - name: CLICKHOUSE_METRICS_PORT
    98                  value: "8001"
    99                - name: CLICKHOUSE_ADMIN_USER
   100                  value: "default"
   101                - name: CLICKHOUSE_SHARD_ID
   102                  value: "$(KB_COMP_NAME)"
   103                - name: CLICKHOUSE_REPLICA_ID
   104                  valueFrom:
   105                    fieldRef:
   106                      fieldPath: metadata.name
   107              ports:
   108                - name: http
   109                  containerPort: 8123
   110                - name: tcp
   111                  containerPort: 9000
   112                - name: tcp-postgresql
   113                  containerPort: 9005
   114                - name: tcp-mysql
   115                  containerPort: 9004
   116                - name: http-intersrv
   117                  containerPort: 9009
   118                - name: http-metrics
   119                  containerPort: 8001
   120              livenessProbe:
   121                failureThreshold: 3
   122                initialDelaySeconds: 10
   123                periodSeconds: 10
   124                successThreshold: 1
   125                timeoutSeconds: 1
   126                httpGet:
   127                  path: /ping
   128                  port: http
   129              readinessProbe:
   130                failureThreshold: 3
   131                initialDelaySeconds: 10
   132                periodSeconds: 10
   133                successThreshold: 1
   134                timeoutSeconds: 1
   135                httpGet:
   136                  path: /ping
   137                  port: http
   138              volumeMounts:
   139                - name: data
   140                  mountPath: /bitnami/clickhouse
   141                - name: config
   142                  mountPath: /bitnami/clickhouse/etc/conf.d/default
   143  
   144      - name: ch-keeper
   145        workloadType: Stateful # Consensus
   146        characterType: zookeeper
   147        probes:
   148        monitor:
   149          builtIn: false
   150          exporterConfig:
   151            scrapePath: /metrics
   152            scrapePort: 8001
   153        logConfigs:
   154          {{- range $name,$pattern := .Values.logConfigs }}
   155          - name: {{ $name }}
   156            filePathPattern: {{ $pattern }}
   157          {{- end }}
   158        configSpecs:
   159          - name: clickhouse-keeper-tpl
   160            templateRef: clickhouse-keeper-tpl
   161            volumeName: config
   162            namespace: {{ .Release.Namespace }}
   163        service:
   164          ports:
   165            - name: tcp
   166              targetPort: tcp
   167              port: 2181
   168            - name: http-metrics
   169              targetPort: http-metrics
   170              port: 8001
   171        podSpec:
   172          securityContext:
   173            fsGroup: 1001
   174            seccompProfile:
   175              type: RuntimeDefault
   176          containers:
   177            - name: clickhouse
   178              securityContext:
   179                allowPrivilegeEscalation: false
   180                capabilities:
   181                  drop:
   182                    - ALL
   183                runAsNonRoot: true
   184                runAsUser: 1001
   185              env:
   186                - name: CLICKHOUSE_ADMIN_PASSWORD
   187                  valueFrom:
   188                    secretKeyRef:
   189                      name: $(CONN_CREDENTIAL_SECRET_NAME)
   190                      key: admin-password
   191                      optional: false
   192                - name: BITNAMI_DEBUG
   193                  value: "false"
   194                - name: CLICKHOUSE_KEEPER_TCP_PORT
   195                  value: "2181"
   196                - name: CLICKHOUSE_KEEPER_RAFT_PORT
   197                  value: "9181"
   198                - name: CLICKHOUSE_METRICS_PORT
   199                  value: "8001"
   200              ports:
   201                - name: tcp
   202                  containerPort: 2181
   203                - name: raft
   204                  containerPort: 9444
   205                - name: http-metrics
   206                  containerPort: 8001
   207              # livenessProbe:
   208              #   failureThreshold: 6
   209              #   initialDelaySeconds: 30
   210              #   periodSeconds: 10
   211              #   successThreshold: 1
   212              #   timeoutSeconds: 5
   213              #   exec:
   214              #     command: ['/bin/bash', '-c', 'echo "ruok" | timeout 2 nc -w 2 localhost 2181 | grep imok']
   215              # readinessProbe:
   216              #   failureThreshold: 6
   217              #   initialDelaySeconds: 5
   218              #   periodSeconds: 10
   219              #   successThreshold: 1
   220              #   timeoutSeconds: 5
   221              #   exec:
   222              #     command: ['/bin/bash', '-c', 'echo "ruok" | timeout 2 nc -w 2 localhost 2181 | grep imok']
   223              volumeMounts:
   224                - name: data
   225                  mountPath: /bitnami/clickhouse
   226                - name: config
   227                  mountPath: /bitnami/clickhouse/etc/conf.d/default
   228  
   229      - name: zookeeper
   230        workloadType: Stateful #Consensus
   231        characterType: zookeeper
   232        # probes:
   233        #   roleProbe:
   234        #     cmd: "stat | grep 'Leader'"
   235        #     failureThreshold: {{ .Values.zookeeper.roleProbe.failureThreshold }}
   236        #     periodSeconds: {{ .Values.zookeeper.roleProbe.periodSeconds }}
   237        #     successThreshold: {{ .Values.zookeeper.roleProbe.successThreshold }}
   238        monitor:
   239          builtIn: false
   240          exporterConfig:
   241            scrapePath: /metrics
   242            scrapePort: 9141
   243        logConfigs:
   244          {{- range $name,$pattern := .Values.zookeeper.logConfigs }}
   245          - name: {{ $name }}
   246            filePathPattern: {{ $pattern }}
   247          {{- end }}
   248        configSpecs:
   249        {{- if .Values.zookeeper.configuration }}
   250          - name: zookeeper-tpl
   251            templateRef: zookeeper-tpl
   252            namespace: {{ .Release.Namespace }}
   253            volumeName: config
   254        {{- end }}
   255        scriptSpecs:
   256          - name: zookeeper-scripts-tpl
   257            templateRef: zookeeper-scripts-tpl
   258            namespace: {{ .Release.Namespace }}
   259            volumeName: scripts
   260            defaultMode: 0755
   261        service:
   262          ports:
   263            - name: tcp-client
   264              port: 2181
   265              targetPort: client
   266            - name: metrics
   267              port: 9141
   268              targetPort: metrics
   269        podSpec:
   270          securityContext:
   271            fsGroup: 1001
   272          initContainers:
   273          containers:
   274            - name: zookeeper
   275              securityContext:
   276                allowPrivilegeEscalation: false
   277                runAsNonRoot: true
   278                runAsUser: 1001
   279              command:
   280                - /scripts/setup.sh
   281              resources:
   282                limits: {}
   283                requests:
   284                  cpu: 250m
   285                  memory: 256Mi
   286              env:
   287                - name: POD_NAME
   288                  valueFrom:
   289                    fieldRef:
   290                      apiVersion: v1
   291                      fieldPath: metadata.name
   292                - name: BITNAMI_DEBUG
   293                  value: "false"
   294                - name: ZOO_DATA_LOG_DIR
   295                  value: ""
   296                - name: ZOO_PORT_NUMBER
   297                  value: "2181"
   298                - name: ZOO_TICK_TIME
   299                  value: "2000"
   300                - name: ZOO_INIT_LIMIT
   301                  value: "10"
   302                - name: ZOO_SYNC_LIMIT
   303                  value: "5"
   304                - name: ZOO_PRE_ALLOC_SIZE
   305                  value: "65536"
   306                - name: ZOO_SNAPCOUNT
   307                  value: "100000"
   308                - name: ZOO_MAX_CLIENT_CNXNS
   309                  value: "60"
   310                - name: ZOO_4LW_COMMANDS_WHITELIST
   311                  value: "srvr, mntr, ruok"
   312                - name: ZOO_LISTEN_ALLIPS_ENABLED
   313                  value: "no"
   314                - name: ZOO_AUTOPURGE_INTERVAL
   315                  value: "0"
   316                - name: ZOO_AUTOPURGE_RETAIN_COUNT
   317                  value: "3"
   318                - name: ZOO_MAX_SESSION_TIMEOUT
   319                  value: "40000"
   320                # HACK: hack for single ZK node only
   321                - name: ZOO_SERVERS
   322                  value: "$(KB_POD_NAME).$(KB_CLUSTER_COMP_NAME).$(KB_NAMESPACE).svc.cluster.local:2888:3888::1"
   323                  # value: myck-zookeeper-0.myck-zookeeper-headless.$(POD_NAMESPACE).svc:2888:3888::1 myck-zookeeper-1.myck-zookeeper-headless.$(POD_NAMESPACE).svc:2888:3888::2 myck-zookeeper-2.myck-zookeeper-headless.$(POD_NAMESPACE).svc:2888:3888::3 
   324                - name: ZOO_ENABLE_AUTH
   325                  value: "no"
   326                - name: ZOO_ENABLE_QUORUM_AUTH
   327                  value: "no"
   328                - name: ZOO_HEAP_SIZE
   329                  value: "1024"
   330                - name: ZOO_LOG_LEVEL
   331                  value: "ERROR"
   332                - name: ALLOW_ANONYMOUS_LOGIN
   333                  value: "yes"
   334                - name: ZOO_ENABLE_PROMETHEUS_METRICS
   335                  value: "yes"
   336                - name: ZOO_PROMETHEUS_METRICS_PORT_NUMBER
   337                  value: "9141"
   338                - name: POD_NAME
   339                  value: "$(KB_POD_NAME)"
   340                - name: POD_NAMESPACE
   341                  value: "$(KB_NAMESPACE)"
   342                # TODO: using componentDefRef to inject zookeeper or keeper env
   343              ports:
   344                - name: client
   345                  containerPort: 2181
   346                - name: follower
   347                  containerPort: 2888
   348                - name: election
   349                  containerPort: 3888
   350                - name: metrics
   351                  containerPort: 9141
   352              livenessProbe:
   353                failureThreshold: 6
   354                initialDelaySeconds: 30
   355                periodSeconds: 10
   356                successThreshold: 1
   357                timeoutSeconds: 5
   358                exec:
   359                  command: ['/bin/bash', '-c', 'echo "ruok" | timeout 2 nc -w 2 localhost 2181 | grep imok']
   360              readinessProbe:
   361                failureThreshold: 6
   362                initialDelaySeconds: 5
   363                periodSeconds: 10
   364                successThreshold: 1
   365                timeoutSeconds: 5
   366                exec:
   367                  command: ['/bin/bash', '-c', 'echo "ruok" | timeout 2 nc -w 2 localhost 2181 | grep imok']
   368              volumeMounts:
   369                - name: scripts
   370                  mountPath: /scripts/setup.sh
   371                  subPath: setup.sh
   372                - name: data
   373                  mountPath: /bitnami/zookeeper