更新时间:2022-05-10 GMT+08:00
分享

示例

创建namespace

为方便验证基本功能创建test-clickhouse-operator的namespace。

kubectl create namespace test-clickhouse-operator

Simple example

本示例来源于https://github.com/Altinity/clickhouse-operator/blob/master/docs/chi-examples/01-simple-layout-01-1shard-1repl.yaml

yaml文件如下:

apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
  name: "simple-01"

使用如下命令创建:

kubectl apply -n test-clickhouse-operator -f https://raw.githubusercontent.com/Altinity/clickhouse-operator/master/docs/chi-examples/01-simple-layout-01-1shard-1repl.yaml

一段时间后,查看资源运行情况:

kubectl get pod -n test-clickhouse-operator

kubectl get service -n test-clickhouse-operator

连接ClickHouse Database:

kubectl -n test-clickhouse-operator exec -ti chi-simple-01-cluster-0-0-0 -- clickhouse-client

Simple Persistent Volume Example

本示例来源于https://github.com/Altinity/clickhouse-operator/blob/master/docs/chi-examples/03-persistent-volume-01-default-volume.yaml

在CCE使用PVC时,yaml文件需做一些适配:

  • 使用云硬盘存储卷EVS
    1. 创建storageClass

      CCE默认支持的csi-disk为SAS类型的云硬盘。 若想使用超高I/O类型的云硬盘,需要创建对应的storageClass。

      vim csi disk ssd.yaml

      复制以下内容:

      allowVolumeExpansion: true
      apiVersion: storage.k8s.io/v1
      kind: StorageClass
      metadata:
        name: csi-disk-ssd
      parameters:
        csi.storage.k8s.io/csi-driver-name: disk.csi.everest.io
        csi.storage.k8s.io/fstype: ext4
        everest.io/disk-volume-type: SSD
        everest.io/passthrough: "true"
      provisioner: everest-csi-provisioner
      reclaimPolicy: Delete
      volumeBindingMode: Immediate

      保存后退出:

      kubectl create -f csi-disk-ssd.yaml

    2. accessModes需填写为ReadWriteOnce。
    3. 添加storageClassName: csi-disk-ssd。
  • 使用文件存储卷SFS
    1. accessModes需填写为ReadWriteMany。
    2. 添加storageClassName: csi-nas。

    下面以文件存储卷SFS为例,yaml文件如下:

    apiVersion: "clickhouse.altinity.com/v1"
    kind: "ClickHouseInstallation"
    metadata:
      name: "pv-simple"
    spec:
      defaults:
        templates:
          dataVolumeClaimTemplate: data-volume-template
          logVolumeClaimTemplate: log-volume-template
      configuration:
        clusters:
          - name: "simple"
            layout:
              shardsCount: 1
              replicasCount: 1
      templates:
        volumeClaimTemplates:
          - name: data-volume-template
            spec:
              accessModes:
                - ReadWriteMany
              resources:
                requests:
                  storage: 10Gi
              storageClassName: csi-nas
          - name: log-volume-template
            spec:
              accessModes:
                - ReadWriteMany
              resources:
                requests:
                  storage: 10Gi
              storageClassName: csi-nas

    使用如下命令创建:

    kubectl -n test-clickhouse-operator create -f 03-persistent-volume-01-default-volume.yaml

    一段时间后,查看资源运行情况:

    kubectl get pvc -n test-clickhouse-operator

    kubectl get pod -n test-clickhouse-operator

    查看存储卷挂载情况:

    kubectl -n test-clickhouse-operator exec -ti chi-pv-simple-simple-0-0-0 -c clickhouse bash

    df -h

    连接ClickHouse Database:

    kubectl -n test-clickhouse-operator exec -ti chi-pv-simple-simple-0-0-0 -- clickhouse-client

Simple Load Balancer Example

apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
  name: "ck-elb"
spec:
  defaults:
    templates:
      dataVolumeClaimTemplate: data-volume-nas
      serviceTemplate: chi-service-elb
  configuration:
    clusters:
      - name: "ck-elb"
        templates:
          podTemplate: pod-template-with-nas
        layout:
          shardsCount: 1
          replicasCount: 1
  templates:
    podTemplates:
      - name: pod-template-with-nas
        spec:
          containers:
            - name: clickhouse
              image: yandex/clickhouse-server:21.6.3.14
              volumeMounts:
                - name: data-volume-nas
                  mountPath: /var/lib/clickhouse
    volumeClaimTemplates:
      - name: data-volume-nas
        spec:
          accessModes:
            - ReadWriteMany
          resources:
            requests:
              storage: 20Gi
          storageClassName: csi-nas
    serviceTemplates:
      - name: chi-service-elb 
        metadata:
          annotations:
            kubernetes.io/elb.class: union
            kubernetes.io/elb.autocreate: >-
              {"type":"public","bandwidth_name":"cce-bandwidth-ck","bandwidth_chargemode":"bandwidth","bandwidth_size":5,"bandwidth_sharetype":"PER","eip_type":"5_bgp"}
        spec:
          ports:
            - name: http
              port: 8123
            - name: client
              port: 9000
          type: LoadBalancer

添加加粗部分内容。其中annotations kubernetes.io/elb.autocreate支持以下参数:

参数

参数类型

描述

name

String

自动创建的负载均衡的名称。

取值范围:1-64个字符,小写字母,数字,下划线,小写字母开头,小写字母或者数字结尾。

type

String

负载均衡实例网络类型,公网或者私网。

  • public :公网型负载均衡
  • inner :私网型负载均衡

bandwidth_name

String

带宽的名称,默认值为:cce-bandwidth-******。

取值范围:1-64个字符,小写字母,数字,下划线,小写字母开头,小写字母或者数字结尾。

bandwidth_chargemode

String

带宽付费模式。

  • bandwidth :按带宽计费
  • traffic :按流量计费

bandwidth_size

Integer

带宽大小

bandwidth_sharetype

String

带宽共享方式。

  • PER :独享带宽

eip_type

String

弹性公网IP类型

分享:

    相关文档

    相关产品

close