Skip to content

Commit

Permalink
Switch to HPP-CSI for CI tests
Browse files Browse the repository at this point in the history
Up until now, we were using the legacy way of deploying hostpath-provisioner.
We can start consuming HPP-CSI instead, which does not require setting up MachineConfigs and can take advantage of the underlying storage backend provided by the cloud provider.

Signed-off-by: Oren Cohen <[email protected]>
  • Loading branch information
orenc1 authored and kubevirt-bot committed Mar 29, 2023
1 parent d264b1c commit def59d9
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 205 deletions.
84 changes: 0 additions & 84 deletions hack/hpp/00_hpp_mc.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions hack/hpp/10_hpp_cr.yaml

This file was deleted.

12 changes: 7 additions & 5 deletions hack/hpp/10_hpp_pool_cr.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
---
kind: HostPathProvisioner
apiVersion: hostpathprovisioner.kubevirt.io/v1beta1
kind: HostPathProvisioner
metadata:
name: hostpath-provisioner
spec:
imagePullPolicy: IfNotPresent
storagePools:
- name: local
- name: hpp-csi-local-basic
path: "/var/hpp-csi-local-basic"
- name: hpp-csi-pvc-block
pvcTemplate:
storageClassName: local-block-hpp
volumeMode: Block
storageClassName: local-block-hpp # Replaced by configure_hpp_*.sh
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
path: "/var/hpvolumes"
storage: 70Gi
path: "/var/hpp-csi-pvc-block"
workload:
nodeSelector:
kubernetes.io/os: linux
20 changes: 20 additions & 0 deletions hack/hpp/20_hpp_pool_sc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: hostpath-provisioner
provisioner: kubevirt.io.hostpath-provisioner
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
parameters:
storagePool: hpp-csi-local-basic
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: hostpath-csi-pvc-block
provisioner: kubevirt.io.hostpath-provisioner
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
parameters:
storagePool: hpp-csi-pvc-block
8 changes: 0 additions & 8 deletions hack/hpp/20_hpp_sc.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions hack/hpp/30_hpp_csi_sc.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions hack/hpp/30_hpp_pool_sc.yaml

This file was deleted.

53 changes: 53 additions & 0 deletions hack/hpp/configure_hpp_ha.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

#
# Configures HPP-CSI on an OCP cluster using the StoragePool feature.
#
# Deploys two storage classes
# * hostpath-csi-basic - uses root filesystem of the worker nodes
# * hostpath-csi-pvc-block - utilize another storage class as a backend
#
# Requires HPP operator to be deployed on the cluster.

set -ex

readonly SCRIPT_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
HPP_VOLUME_SIZE=${HPP_VOLUME_SIZE:-${VOLUME_SIZE:-70}}Gi


CLUSTER_PLATFORM=$(
oc get infrastructure cluster \
--output=jsonpath='{$.status.platform}'
)

case "${CLUSTER_PLATFORM}" in
Azure)
HPP_BACKEND_STORAGE_CLASS=managed-csi
;;
AWS)
HPP_BACKEND_STORAGE_CLASS=gp3-csi
;;
GCP)
HPP_BACKEND_STORAGE_CLASS=standard-csi
;;
BareMetal)
HPP_BACKEND_STORAGE_CLASS=ocs-storagecluster-ceph-rbd
;;
None)
# UPI Installation
HPP_BACKEND_STORAGE_CLASS=${HPP_BACKEND_STORAGE_CLASS:-ocs-storagecluster-ceph-rbd}
;;
*)
echo "[ERROR] Unsupported cluster platform: [${CLUSTER_PLATFORM}]" >&2
exit 1
;;
esac


# Create HPP CustomResource using the StoragePool feature
sed "${SCRIPT_DIR}/10_hpp_pool_cr.yaml" \
-e "s|^\( \+storageClassName\): .*|\1: ${HPP_BACKEND_STORAGE_CLASS}|g" \
| oc create --filename=-

# Create HPP StorageClass using the StoragePool feature
oc create --filename="${SCRIPT_DIR}/20_hpp_pool_sc.yaml"
61 changes: 0 additions & 61 deletions hack/hpp/configure_hpp_legacy.sh

This file was deleted.

27 changes: 13 additions & 14 deletions hack/hpp/configure_hpp_pool.sh → hack/hpp/configure_hpp_sno.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/bin/bash

#
# Configures HPP on an OCP cluster using the StoragePool feature.
# Configures HPP-CSI on a SNO cluster using the StoragePool feature.
#
# Requires HPP operator to be deployed on the cluster. It is usually deployed
# as part of CNV by the HCO operator.
#
# See documentation:
# - https://docs.google.com/document/d/1v_kPxJKhy3WYVOIlTRviEpJbigqraE8Hte7BCKJNVBM
# Deploys two storage classes
# * hostpath-csi-basic - uses root filesystem of the worker nodes
# * hostpath-csi-pvc-block - utilize another storage class as a backend
#
# Requires HPP operator to be deployed on the cluster.

set -ex

readonly SCRIPT_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
VOLUME_BINDING_MODE="WaitForFirstConsumer"

CLUSTER_PLATFORM=$(
oc get infrastructure cluster \
Expand All @@ -28,6 +28,10 @@ case "${CLUSTER_PLATFORM}" in
HPP_BACKEND_STORAGE_CLASS=gp3-csi
HPP_VOLUME_SIZE=128Gi
;;
GCP)
HPP_BACKEND_STORAGE_CLASS=standard-csi
HPP_VOLUME_SIZE=128Gi
;;
BareMetal|None)
HPP_BACKEND_STORAGE_CLASS=local-block-hpp
HPP_VOLUME_SIZE=5Gi
Expand All @@ -38,16 +42,11 @@ case "${CLUSTER_PLATFORM}" in
;;
esac

# Create HPP CustomResource and StorageClass using the StoragePool feature
# Create HPP CustomResource using the StoragePool feature
sed "${SCRIPT_DIR}/10_hpp_pool_cr.yaml" \
-e "s|^\( \+storage\): .*|\1: ${HPP_VOLUME_SIZE}|g" \
-e "s|^\( \+storageClassName\): .*|\1: ${HPP_BACKEND_STORAGE_CLASS}|g" \
| oc create --filename=-
oc create --filename="${SCRIPT_DIR}/30_hpp_pool_sc.yaml"

# Set HPP-CSI as default StorageClass for the cluster
oc annotate storageclasses --all storageclass.kubernetes.io/is-default-class-
oc annotate storageclass hostpath-csi storageclass.kubernetes.io/is-default-class='true'

# Wait for HPP to be ready
oc wait hostpathprovisioner hostpath-provisioner --for=condition='Available' --timeout='10m'
# Create HPP StorageClass using the StoragePool feature
oc create --filename="${SCRIPT_DIR}/20_hpp_pool_sc.yaml"
11 changes: 6 additions & 5 deletions hack/hpp/deploy_hpp.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash

#
# Configures HPP on an OCP cluster:
# - on regular clusters, HPP is deployed the legacy way
# - on SNO clusters, HPP is deployed using the StoragePool feature
# Configures HPP on an OCP cluster using the StoragePool feature
#

set -ex
Expand All @@ -22,8 +20,11 @@ CLUSTER_VERSION=$(
if [[ "$CLUSTER_VERSION" != *"okd"* ]]; then
# skipping configuring HPP in case of an OKD cluster
if [[ "${CLUSTER_TOPOLOGY}" != 'SingleReplica' ]]; then
"${SCRIPT_DIR}"/configure_hpp_legacy.sh
"${SCRIPT_DIR}"/configure_hpp_ha.sh
else
"${SCRIPT_DIR}"/configure_hpp_pool.sh
"${SCRIPT_DIR}"/configure_hpp_sno.sh
fi

# Wait for HPP to be ready
oc wait hostpathprovisioner hostpath-provisioner --for=condition='Available' --timeout='10m'
fi

0 comments on commit def59d9

Please sign in to comment.