8000 Doc : Add OpenEBS example by lorellalou · Pull Request #1527 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/check_helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: check_helm
on:
pull_request:
branches:
- '*'
push:
branches:
- '*'

jobs:
check_helm:
name: Test Helm Chart
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: medyagh/setup-minikube@master
with:
driver: docker
container-runtime: containerd
kubernetes-version: v1.31.0
cpus: max
memory: max

- name: Local Helm Test
run: |
set -xe
minikube kubectl create ns test
helm install -n test test-operator ./deploy/helm/clickhouse-operator/
sleep 10
workflow_count=$(kubectl get all --all-namespaces | grep -c "test-operator")
configmap_count=$(kubectl get cm --all-namespaces | grep -c "test-operator")
if [ "$workflow_count" -lt 4 ]; then
echo "Error: Workload count is less than 4. Current count: $workflow_count"
exit 1
fi

if [ "$configmap_count" -lt 9 ]; then
echo "Error: ConfigMap count is less than 9. Current count: $configmap_count"
exit 1
fi
20 changes: 20 additions & 0 deletions .github/workflows/release_chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,34 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install chart-releaser
run: |
wget https://github.com/helm/chart-releaser/releases/download/v1.4.1/chart-releaser_1.4.1_linux_amd64.tar.gz
tar -zxf chart-releaser_1.4.1_linux_amd64.tar.gz cr
sudo install cr /usr/local/bin/
rm -f cr chart-releaser_1.4.1_linux_amd64.tar.gz

- name: Package Chart
run: cr package deploy/helm/clickhouse-operator

- name: Get Release Assets
run: |
CHART_PATH=$(ls .cr-release-packages/altinity-clickhouse-operator-*.tgz)
ASSET_NAME=$(basename ${CHART_PATH})
ASSET_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets" | \
jq -r ".[] | select(.name == \"$ASSET_NAME\") | .id")

echo "Asset ID is $ASSET_ID"
echo "::set-output name=asset_id::$ASSET_ID"

- name: Delete Existing Release Artifacts
if: steps.get_assets.outputs.asset_id != ''
run: |
curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository

- name: Upload Release Artifacts
run: |
CHART_PATH=$(ls .cr-release-packages/altinity-clickhouse-operator-*.tgz)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
with:
driver: docker
container-runtime: containerd
kubernetes-version: v1.30.0
kubernetes-version: v1.31.0
cpus: max
memory: max

Expand Down
3 changes: 1 addition & 2 deletions deploy/helm/clickhouse-operator/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-etc-keeper-operator-confd-files" (include "altinity-clickhouse-operator.fullname" .) }}
name: {{ printf "%s-keeper-confd-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.etcKeeperOperatorConfdFiles) | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.keeperConfdFiles) | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-etc-keeper-operator-configd-files" (include "altinity-clickhouse-operator.fullname" .) }}
name: {{ printf "%s-keeper-configd-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.etcKeeperOperatorConfigdFiles) | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.keeperConfigdFiles) | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-etc-keeper-operator-templatesd-files" (include "altinity-clickhouse-operator.fullname" .) }}
name: {{ printf "%s-keeper-templatesd-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.etcKeeperOperatorTemplatesdFiles) | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.keeperTemplatesdFiles) | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-etc-keeper-operator-usersd-files" (include "altinity-clickhouse-operator.fullname" .) }}
name: {{ printf "%s-keeper-usersd-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.etcKeeperOperatorUsersdFiles) | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.keeperUsersdFiles) | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ spec:
checksum/configd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-configd-files.yaml") . | sha256sum }}
checksum/templatesd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-templatesd-files.yaml") . | sha256sum }}
checksum/usersd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-usersd-files.yaml") . | sha256sum }}
checksum/etc-keeper-operator-confd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-etc-keeper-operator-confd-files.yaml") . | sha256sum }}
checksum/etc-keeper-operator-configd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-etc-keeper-operator-configd-files.yaml") . | sha256sum }}
checksum/etc-keeper-operator-templatesd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-etc-keeper-operator-templatesd-files.yaml") . | sha256sum }}
checksum/etc-keeper-operator-usersd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-etc-keeper-operator-usersd-files.yaml") . | sha256sum }}
checksum/keeper-confd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-keeper-operator-confd-files.yaml") . | sha256sum }}
checksum/keeper-configd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-keeper-operator-configd-files.yaml") . | sha256sum }}
checksum/keeper-templatesd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-keeper-operator-templatesd-files.yaml") . | sha256sum }}
checksum/keeper-usersd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-keeper-operator-usersd-files.yaml") . | sha256sum }}
spec:
serviceAccountName: {{ include "altinity-clickhouse-operator.serviceAccountName" . }}
volumes:
Expand All @@ -53,16 +53,16 @@ spec:
name: {{ include "altinity-clickhouse-operator.fullname" . }}-usersd-files
- name: etc-keeper-operator-confd-folder
configMap:
name: etc-keeper-operator-confd-files
name: {{ include "altinity-clickhouse-operator.fullname" . }}-keeper-confd-files
- name: etc-keeper-operator-configd-folder
configMap:
name: etc-keeper-operator-configd-files
name: {{ include "altinity-clickhouse-operator.fullname" . }}-keeper-configd-files
- name: etc-keeper-operator-templatesd-folder
configMap:
name: etc-keeper-operator-templatesd-files
name: {{ include "altinity-clickhouse-operator.fullname" . }}-keeper-templatesd-files
- name: etc-keeper-operator-usersd-folder
configMap:
name: etc-keeper-operator-usersd-files
name: {{ include "altinity-clickhouse-operator.fullname" . }}-keeper-usersd-files
containers:
- name: {{ .Chart.Name }}
image: {{ .Values.operator.image.repository }}:{{ include "altinity-clickhouse-operator.operator.tag" . }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ metadata:
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
annotations: {{ toYaml .Values.serviceAccount.annotations | nindent 4 }}

# Template Parameters:
#
# NAMESPACE=kube-system
Expand Down
8 changes: 4 additions & 4 deletions deploy/helm/clickhouse-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,8 @@ configs:
</default>
</profiles>
</yandex>
etcKeeperOperatorConfdFiles: null
etcKeeperOperatorConfigdFiles:
keeperConfdFiles: null
keeperConfigdFiles:
01-keeper-01-default-config.xml: |
<!-- IMPORTANT -->
<!-- This file is auto-generated -->
Expand Down Expand Up @@ -759,10 +759,10 @@ configs:
</http_control>
</keeper_server>
</clickhouse>
etcKeeperOperatorTemplatesdFiles:
keeperTemplatesdFiles:
readme: |-
Templates in this folder are packaged with an operator and available via 'useTemplate'
etcKeeperOperatorUsersdFiles: null
keeperUsersdFiles: null
# additionalResources -- list of additional resources to create (are processed via `tpl` function), useful for create ClickHouse clusters together with clickhouse-operator, look `kubectl explain chi` for details

additionalResources: []
Expand Down
123 changes: 123 additions & 0 deletions deploy/openebs/lvm/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
## OpenEBS - LocalPV-LVM CSI Driver with ClickHouse
LocalPV-LVM CSI Driver became GA in August 2021 (with the release v0.8.0). It is now a very mature product and a core component of the OpenEBS storage platform.
Due to the major adoption of LocalPV-LVM (+50,000 users), this Data-Engine is now being unified and integrated into the core OpenEBS Storage platform; instead of being maintained as an external Data-Engine within our project.

## Setup

Find the disk which you want to use for the LocalPV-LVM. Note: For testing you can use the loopback device.

```
truncate -s 1024G /tmp/disk.img
sudo losetup -f /tmp/disk.img --show
```

> [!NOTE]
> - This is the old maual config process <BR>
> - LocalPV-LVM will num dynamically provision the VG fro you <BR>
> - The PV, VG and LV names will be dynamically provisioned by OpenEBS LocalPV-LVM as K8s unique entities (for safety, you cannot provide your own PV, VG or LV names)

Create the Volume group on all the nodes, which will be used by the LVM2 Driver for provisioning the volumes

```
sudo pvcreate /dev/loop0
sudo vgcreate vg-test /dev/loop0 ## here lvmvg is the volume group name to be created
```

Display the Volume Group

```
vgdisplay
```

## Installation

Install the latest release of OpenEBS LVM2 LocalPV-LVM driver by running the following command. Note: All nodes must be running the same version of LocalPV-LVM, LMV2, device-mapper & dm-snapshot.

Create a variable containing the K8s namesapce

```bash
OPENEBS_NAMESPACE=openebs
```

Install the OpenEBS component without the distributed component (MayaStor) and ZFS

```bash
helm repo add openebs https://openebs.github.io/openebs
helm repo update
helm install openebs --namespace ${OPENEBS_NAMESPACE} openebs/openebs --set engines.replicated.mayastor.enabled=false --set engines.local.zfs.enabled=false --create-namespace --version 4.1.1
```

List the OpenEBS chart and check that it's deployed

```bash
helm list -n ${OPENEBS_NAMESPACE}
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
openebs openebs 1 2024-06-01 12:28:49.358189 +0200 CEST deployed openebs-4.0.1 4.0.1
```

You can uninstall the OpenEBS componenent if there is any issues or for testing different version

```bash
helm uninstall openebs --namespace ${OPENEBS_NAMESPACE}
```

Create a new Storage Class using the test volume group (!! for testing only !!)
```yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
allowVolumeExpansion: true
metadata:
10BC8 name: openebs-lvm-test
parameters:
fsType: xfs
storage: lvm
vgpattern: vg-test
provisioner: local.csi.openebs.io
reclaimPolicy: Retain
volumeBindingMode: Immediate
```

Install a test installation of Clickhouse with a ``volumeClaimTemplates``
```bash
kubecl apply -f clickhouse-installation-with-openebs.yaml -n ch-test
```

Connect to the the Clickhouse pod and check the mounted volume name
```bash
# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
overlay 73334784 10300660 63034124 15% /
tmpfs 65536 0 65536 0% /dev
/dev/mapper/rhel_vg-root 73334784 10300660 63034124 15% /etc/hosts
shm 65536 0 65536 0% /dev/shm
/dev/mapper/vg--test-pvc--d2c6219b--755d--4540--8382--a8959c5f1eb5 983040 41684 941356 5% /var/lib/clickhouse
tmpfs 15804764 12 15804752 1% /run/secrets/kubernetes.io/serviceaccount
tmpfs 7902380 0 7902380 0% /proc/asound
tmpfs 7902380 0 7902380 0% /proc/acpi
tmpfs 7902380 0 7902380 0% /proc/scsi
tmpfs 7902380 0 7902380 0% /sys/firmware
tmpfs 7902380 0 7902380 0% /sys/devices/virtual/powercap
```

You can find it on the host with the following LVM command
```bash
# lvdisplay

--- Logical volume ---
LV Path /dev/vg-test/pvc-d2c6219b-755d-4540-8382-a8959c5f1eb5
LV Name pvc-d2c6219b-755d-4540-8382-a8959c5f1eb5
VG Name vg-test
LV UUID KqDQ6f-70gM-fbyN-gePw-iROE-XL5E-6zTn5d
LV Write Access read/write
LV Creation host, time openebs-lvm-localpv-node-zfg4x, 2024-10-11 08:52:06 +0200
LV Status available
# open 1
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:4
```

41 changes: 41 additions & 0 deletions deploy/openebs/lvm/clickhouse-installation-with-openebs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: clickhouse.altinity.com/v1
kind: ClickHouseInstallation
metadata:
name: clickhouse-openebs
spec:
configuration:
clusters:
- layout:
replicasCount: 1
shardsCount: 1
name: simple
defaults:
templates:
dataVolumeClaimTemplate: openebs
podTemplate: clickhouse:24.3
templates:
podTemplates:
- metadata:
name: clickhouse:24.3
spec:
containers:
- image: clickhouse/clickhouse-server:24.3
name: clickhouse
ports:
- containerPort: 8123
name: http
- containerPort: 9000
name: client
- containerPort: 9009
name: interserver
- containerPort: 9363
name: metrics
volumeClaimTemplates:
- name: openebs
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: openebs-lvm-test
13 changes: 13 additions & 0 deletions deploy/openebs/lvm/delete-openebs-lvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

OPENEBS_NAMESPACE="${OPENEBS_NAMESPACE:-openebs}"
CLICKHOUSE_NAMESPACE="${CLICKHOUSE_NAMESPACE:-ch-test}"

echo "Delete Test ClickHouse installation"
kubectl delete --namespace="${CLICKHOUSE_NAMESPACE}" ClickhouseInstallation clickhouse-openebs

echo "Delete OpenEBS namespace ${OPENEBS_NAMESPACE}"
LVMVOLUMNE_TO_DELETE=$(kubectl get LVMVolume --namespace "${OPENEBS_NAMESPACE}" | tail -1 | cut -f1 -d ' ')
kubectl delete LVMVolume $LVMVOLUMNE_TO_DELETE --namespace "${OPENEBS_NAMESPACE}"
helm uninstall openebs --namespace ${OPENEBS_NAMESPACE}
kubectl delete namespace "${OPENEBS_NAMESPACE}"
Loading
0