Step 1: Setup the Raspberry Pis
Install Raspbian Lite on an SD Card
Boot the Pi
Copy the disk to the NVMe:
sudo dd if=/dev/mm** of=/dev/nvme** bs=32M
Shutdown, remove the SD Card, and reboot
Change the pi hostname to something unique
Expand the filesystem:
sudo raspi-config --expand-rootfs
edit cgroup settings in /boot/firmware/cmdline.txt
:
cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory
Update the pi firmware to apply the above setttings:
Reboot the Pi
Install the control-plane node on pi1:
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC=" server" sh -s - --flannel-backend none
Setup pi2 and pi3 as worker nodes (get K3S_TOKEN from /var/lib/rancher/k3s/server/node-token
on pi1):
curl -sfL https://get.k3s.io | K3S_URL=https://pi1:6443 K3S_TOKEN=[YOUR TOKEN] sh -s -
Copy the k3s.yaml and export it as your kubeconfig:
scp user@pi1:/etc/rancher/k3s/k3s.yaml ./k3s.yaml
export KUBECONFIG=./k3s.yaml
Install cilium as a CNI:
helm upgrade cilium cilium/cilium --version 1.16.5 \
--namespace kube-system \
--reuse-values \
--set l2announcements.enabled=true \
--set k8sClientRateLimit.qps=10 \
--set k8sClientRateLimit.burst=60 \
--set kubeProxyReplacement=true \
--set k8sServiceHost=pi1 \
--set k8sServicePort=6443
Step 3: Install the Altinity Operator
kubectl apply -f https://raw.githubusercontent.com/Altinity/clickhouse-operator/master/deploy/operator/clickhouse-operator-install-bundle.yaml
Step 4: Create a replicated ClickHouse Cluster
helm repo add altiniy https://helm.altinity.com
helm install clickhouse-dev --create-namespace --namespace clickhouse altinity/clickhouse --set keeper.enabled=true --set clickhouse.replicasCount=2
SELECT * FROM system .zookeeper WHERE path = ' /'
CREATE TABLE IF NOT EXISTS test_rep ON CLUSTER ` {cluster}`
(
` number` UInt32,
` created_at` DateTime DEFAULT now()
)
ENGINE = ReplicatedMergeTree
ORDER BY number ;
INSERT INTO test_rep (number ) SELECT number
FROM system .numbers
LIMIT 10 ;
SELECT hostName(), *
FROM clusterAllReplicas(' {cluster}' , default .test_rep )
ORDER BY 1 ASC , 2 ASC