From 40c08a0ad3d3dd235e106774e010cdb61773105f Mon Sep 17 00:00:00 2001 From: Victor Morales Date: Fri, 13 Dec 2024 11:15:14 -0800 Subject: [PATCH] Enable topolvm storage solution --- .github/workflows/on-demand_ci.yml | 2 +- README.md | 1 + _chart_installers.sh | 13 +++++++++++ _uninstallers.sh | 5 +++++ tests/resources/topolvm/test.yaml | 36 ++++++++++++++++++++++++++++++ tests/topolvm.sh | 33 +++++++++++++++++++++++++++ 6 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 tests/resources/topolvm/test.yaml create mode 100755 tests/topolvm.sh diff --git a/.github/workflows/on-demand_ci.yml b/.github/workflows/on-demand_ci.yml index e6b013f7..d1d14bc2 100644 --- a/.github/workflows/on-demand_ci.yml +++ b/.github/workflows/on-demand_ci.yml @@ -42,7 +42,7 @@ jobs: - enable_tests: true krew_plugins_list: "virt" metallb_enabled: true - int_tests: "metallb istio kubevirt knative longhorn" + int_tests: "metallb istio kubevirt knative longhorn topolvm" - test_multinode: true run_conformance_tools: true - enable_tests: true diff --git a/README.md b/README.md index 81ab7967..542dc4f6 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ different scenarios. There are different setups located in the | ArgoCD | Declarative GitOps continuous delivery tool | | Implemented | | Tekton | CI/CD system | | Implemented | | Longhorn | Storage Operator | | Tested | +| TopoLVM | Storage Operator | | Tested | ## Quick Deployment diff --git a/_chart_installers.sh b/_chart_installers.sh index 697f35ce..49b7ff83 100755 --- a/_chart_installers.sh +++ b/_chart_installers.sh @@ -300,3 +300,16 @@ function install_longhorn { _add_helm_repo longhorn https://charts.longhorn.io KRD_CHART_VALUES="defaultSettings.defaultDataPath=/var/lib/csi-block" _install_chart longhorn longhorn/longhorn } + +# install_topolvm() - Installs TopoLVM distributed block storage system +function install_topolvm { + _add_helm_repo topolvm https://topolvm.github.io/topolvm + cert_manager_deployed="false" + kubectl get deployments cert-manager -n cert-manager >/dev/null && cert_manager_deployed="true" + replica_count=$(kubectl get node --selector='!node-role.kubernetes.io/master' -o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | wc -l) + for class in $(kubectl get storageclasses --no-headers -o custom-columns=name:.metadata.name); do + kubectl patch storageclass "$class" -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}' + done + KRD_CHART_VALUES="lvmd.deviceClasses[0].name=ssd,lvmd.deviceClasses[0].default=true,lvmd.deviceClasses[0].spare-gb=10,lvmd.deviceClasses[0].volume-group=${KRD_TOPOLVM_VOLUME_GROUP_NAME-myvg1},cert-manager.enabled=$cert_manager_deployed,controller.replicaCount=$replica_count" _install_chart topolvm topolvm/topolvm + kubectl patch storageclass topolvm-provisioner -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' +} diff --git a/_uninstallers.sh b/_uninstallers.sh index 86d6a6ad..bd332d78 100755 --- a/_uninstallers.sh +++ b/_uninstallers.sh @@ -166,3 +166,8 @@ function uninstall_kubewarden { function uninstall_longhorn { _uninstall_helm longhorn } + +# uninstall_topolvm() - Uninstall TopoLVM services +function uninstall_topolvm { + _uninstall_helm topolvm +} diff --git a/tests/resources/topolvm/test.yaml b/tests/resources/topolvm/test.yaml new file mode 100644 index 00000000..20288bb1 --- /dev/null +++ b/tests/resources/topolvm/test.yaml @@ -0,0 +1,36 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2024 +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pv-claim +spec: + storageClassName: topolvm-provisioner + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi +--- +apiVersion: v1 +kind: Pod +metadata: + name: my-pod +spec: + containers: + - name: pause + image: registry.k8s.io/pause + volumeMounts: + - mountPath: /data + name: volume + volumes: + - name: volume + persistentVolumeClaim: + claimName: pv-claim diff --git a/tests/topolvm.sh b/tests/topolvm.sh new file mode 100755 index 00000000..01204607 --- /dev/null +++ b/tests/topolvm.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2024 +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +set -o errexit +set -o nounset +set -o pipefail + +# shellcheck source=tests/_functions.sh +source _functions.sh +# shellcheck source=tests/_assertions.sh +source _assertions.sh + +function cleanup { + kubectl delete -f resources/topolvm/ +} + +trap cleanup EXIT + +info "===== Test started =====" + +kubectl apply -f resources/topolvm/ + +kubectl wait --for=jsonpath='{.status.phase}'=Bound pvc/pv-claim +assert_contains "$(kubectl get pv --no-headers)" 'pv-claim' "Persistent volume claim has not bind properly" + +info "===== Test completed ====="