Examples
Creating a Namespace
Create a namespace named test-clickhouse-operator to facilitate verification of basic functions.
kubectl create namespace test-clickhouse-operator

Simple Example
This example is available at https://github.com/Altinity/clickhouse-operator/blob/master/docs/chi-examples/01-simple-layout-01-1shard-1repl.yaml.
The YAML file is as follows:
apiVersion: "clickhouse.altinity.com/v1" kind: "ClickHouseInstallation" metadata: name: "simple-01"
Run the following command:
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

After a period of time, check the resource running status.
kubectl get pod -n test-clickhouse-operator
kubectl get service -n test-clickhouse-operator

Connect to the ClickHouse database.
kubectl -n test-clickhouse-operator exec -ti chi-simple-01-cluster-0-0-0 -- clickhouse-client

Simple Persistent Volume Example
This example is available at https://github.com/Altinity/clickhouse-operator/blob/master/docs/chi-examples/03-persistent-volume-01-default-volume.yaml.
Before using this YAML file to create a PVC on CCE, modify the file based on the storage volume you want to use.
- If an EVS disk is used as a storage volume, do as follows:
- Create a StorageClass.
By default, the CSI disk type supported by CCE is SAS. If you want to use ultra-high I/O EVS disks, you need to create the corresponding StorageClass.
vim csi disk ssd.yaml
Copy the following content:
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
Save the file and exit.
kubectl create -f csi-disk-ssd.yaml
- Set accessModes to ReadWriteOnce.
- Add storageClassName: csi-disk-ssd.
- Create a StorageClass.
- If an SFS file system is used as a storage volume, do as follows:
- Set accessModes to ReadWriteMany.
- Add storageClassName: csi-nas.
For example, if an SFS file system is used, the YAML file content is as follows:
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-nasRun the following command to create a PV:
kubectl -n test-clickhouse-operator create -f 03-persistent-volume-01-default-volume.yaml

After a period of time, check the resource running status.
kubectl get pvc -n test-clickhouse-operator

kubectl get pod -n test-clickhouse-operator

Run the following command to check the mounting status of the storage volume:
kubectl -n test-clickhouse-operator exec -ti chi-pv-simple-simple-0-0-0 -c clickhouse bash
df -h

Connect to the 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
Add the information in bold to the YAML file. The following table describes the parameters supported by annotations kubernetes.io/elb.autocreate.
|
Parameter |
Type |
Description |
|---|---|---|
|
name |
String |
Name of the automatically created load balancer. Value range: a string of 1 to 64 characters, including lowercase letters, digits, and underscores (_). The value must start with a lowercase letter and end with a lowercase letter or digit. |
|
type |
String |
Network type of the load balancer.
|
|
bandwidth_name |
String |
Bandwidth name. The default value is cce-bandwidth-******. Value range: a string of 1 to 64 characters, including lowercase letters, digits, and underscores (_). The value must start with a lowercase letter and end with a lowercase letter or digit. |
|
bandwidth_chargemode |
String |
Bandwidth billing mode.
|
|
bandwidth_size |
Integer |
Bandwidth. |
|
bandwidth_sharetype |
String |
Bandwidth sharing mode.
|
|
eip_type |
String |
EIP type. |
Last Article: Deploying ClickHouse Operator
Next Article: Running Spark on CCE
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.