Skip to content

Commit

Permalink
Enable topolvm storage solution
Browse files Browse the repository at this point in the history
  • Loading branch information
electrocucaracha committed Dec 13, 2024
1 parent fc6530a commit 40c08a0
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/on-demand_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions _chart_installers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}}'
}
5 changes: 5 additions & 0 deletions _uninstallers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,8 @@ function uninstall_kubewarden {
function uninstall_longhorn {
_uninstall_helm longhorn
}

# uninstall_topolvm() - Uninstall TopoLVM services
function uninstall_topolvm {
_uninstall_helm topolvm
}
36 changes: 36 additions & 0 deletions tests/resources/topolvm/test.yaml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions tests/topolvm.sh
Original file line number Diff line number Diff line change
@@ -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 ====="

0 comments on commit 40c08a0

Please sign in to comment.