Skip to content

Commit 81bc45a

Browse files
committed
[CI] Add HPP for HyperShift/Kubevirt deployments
This is being done as a temporary workaround for kubernetes-sigs/gcp-compute-persistent-disk-csi-driver#608 that we're constantly seeing in the CI environment in GCP Signed-off-by: Oren Cohen <[email protected]>
1 parent 57e5343 commit 81bc45a

File tree

6 files changed

+169
-0
lines changed

6 files changed

+169
-0
lines changed

hack/ci/hpp/00_hpp_mc.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
#
3+
# Create and mount a dedicated partition for PersistentVolumes
4+
# provisioned by kubevirt-hostpath-provisioner.
5+
#
6+
# See documentation:
7+
# - https://github.com/kubevirt/hostpath-provisioner-operator/blob/master/contrib/machineconfig-selinux-hpp.yaml
8+
#
9+
10+
kind: MachineConfig
11+
apiVersion: machineconfiguration.openshift.io/v1
12+
metadata:
13+
name: 100-worker-hostpath-provisioner
14+
labels:
15+
machineconfiguration.openshift.io/role: worker
16+
spec:
17+
config:
18+
ignition:
19+
version: 3.2.0
20+
systemd:
21+
units:
22+
- contents: |
23+
[Unit]
24+
Description=Create directory for hostpath provisioner
25+
26+
[Service]
27+
Type=oneshot
28+
RemainAfterExit=yes
29+
ExecStart=mkdir -p /var/hpvolumes
30+
31+
[Install]
32+
WantedBy=local-fs.target
33+
enabled: true
34+
name: hostpath-provisioner-mkdir.service
35+
- contents: |
36+
# VirtualMachines have a dedicated disk for HPP while BM servers
37+
# use their rootdisk for HPP
38+
[Unit]
39+
Description=Create filesystem for hostpath provisioner
40+
ConditionPathExists=/dev/vdb
41+
ConditionVirtualization=vm
42+
43+
[Service]
44+
Type=oneshot
45+
RemainAfterExit=yes
46+
ExecStart=/bin/bash -c 'lsblk --noheadings --output=FSTYPE /dev/vdb | grep -Fw ext4 || /usr/sbin/mkfs.ext4 -q -L hpvolumes /dev/vdb'
47+
48+
[Install]
49+
WantedBy=local-fs.target
50+
enabled: true
51+
name: hostpath-provisioner-mkfs.service
52+
- contents: |
53+
[Unit]
54+
Description=Mount filesystem for hostpath provisioner
55+
ConditionPathExists=/dev/disk/by-label/hpvolumes
56+
ConditionVirtualization=vm
57+
Requires=hostpath-provisioner-mkdir.service hostpath-provisioner-mkfs.service
58+
After=hostpath-provisioner-mkdir.service hostpath-provisioner-mkfs.service
59+
Before=hostpath-provisioner-selinux.service
60+
61+
[Mount]
62+
What=/dev/disk/by-label/hpvolumes
63+
Where=/var/hpvolumes
64+
65+
[Install]
66+
WantedBy=local-fs.target
67+
enabled: true
68+
name: var-hpvolumes.mount
69+
- contents: |
70+
[Unit]
71+
Description=Set SELinux chcon for hostpath provisioner
72+
Requires=local-fs.target hostpath-provisioner-mkdir.service
73+
After=local-fs.target hostpath-provisioner-mkdir.service var-hpvolumes.mount
74+
Before=kubelet.service
75+
76+
[Service]
77+
Type=oneshot
78+
RemainAfterExit=yes
79+
ExecStart=/usr/bin/chcon -Rt container_file_t /var/hpvolumes
80+
81+
[Install]
82+
WantedBy=local-fs.target
83+
enabled: true
84+
name: hostpath-provisioner-selinux.service

hack/ci/hpp/10_hpp_cr.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
kind: HostPathProvisioner
3+
apiVersion: hostpathprovisioner.kubevirt.io/v1beta1
4+
metadata:
5+
name: hostpath-provisioner
6+
spec:
7+
imagePullPolicy: IfNotPresent
8+
pathConfig:
9+
path: "/var/hpvolumes"
10+
useNamingPrefix: false

hack/ci/hpp/20_hpp_sc.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
kind: StorageClass
3+
apiVersion: storage.k8s.io/v1
4+
metadata:
5+
name: hostpath-provisioner
6+
provisioner: kubevirt.io/hostpath-provisioner
7+
reclaimPolicy: Delete
8+
volumeBindingMode: WaitForFirstConsumer

hack/ci/hpp/30_hpp_pool_sc.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
kind: StorageClass
3+
apiVersion: storage.k8s.io/v1
4+
metadata:
5+
name: hostpath-csi
6+
provisioner: kubevirt.io.hostpath-provisioner
7+
reclaimPolicy: Delete
8+
volumeBindingMode: Immediate # must be set to WFFC for non SNO clusters
9+
parameters:
10+
storagePool: local

hack/ci/hpp/deploy_hpp.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
## HostPath Provisioner Deployment & Configuration
4+
# Used as a temporary workaround for https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/issues/608
5+
6+
set -ex
7+
8+
readonly SCRIPT_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
9+
readonly HCO_NAMESPACE="openshift-cnv"
10+
11+
echo_debug()
12+
{
13+
echo "$@" >&2
14+
}
15+
16+
# Wait until master and worker MCP are Updated
17+
# or timeout after 90min.
18+
wait_mcp_for_updated()
19+
{
20+
local mcp_updated="false"
21+
22+
sleep 30
23+
24+
for i in {1..60}
25+
do
26+
echo_debug "Attempt ${i}/60"
27+
sleep 30
28+
if oc wait mcp --all --for condition=updated --timeout=1m; then
29+
echo_debug "MCP is Updated"
30+
mcp_updated="true"
31+
break
32+
fi
33+
done
34+
35+
if [[ "$mcp_updated" == "false" ]]; then
36+
echo_debug "Error: MCP didn't get Updated!!"
37+
exit 1
38+
fi
39+
}
40+
41+
# Create and mount a dedicated partition for PersistentVolumes provisioned by HPP
42+
# => https://github.com/kubevirt/hostpath-provisioner-operator/blob/master/contrib/machineconfig-selinux-hpp.yaml
43+
oc create --filename="${SCRIPT_DIR}/00_hpp_mc.yaml" -n ${HCO_NAMESPACE} || true # Don't fail if resource already exists
44+
wait_mcp_for_updated
45+
46+
# Create HPP CustomResource and StorageClass
47+
oc create --filename="${SCRIPT_DIR}/10_hpp_cr.yaml" -n ${HCO_NAMESPACE}
48+
oc create --filename="${SCRIPT_DIR}/20_hpp_sc.yaml"
49+
oc create --filename="${SCRIPT_DIR}/30_hpp_csi_sc.yaml"
50+
51+
# Set HPP as default StorageClass for the cluster
52+
oc annotate storageclasses --all storageclass.kubernetes.io/is-default-class-
53+
oc annotate storageclass hostpath-provisioner storageclass.kubernetes.io/is-default-class='true'

hack/ci/install-cnv.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,7 @@ metadata:
127127
EOF
128128

129129
oc wait hyperconverged -n openshift-cnv kubevirt-hyperconverged --for=condition=Available --timeout=15m
130+
131+
132+
readonly SCRIPT_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
133+
"${SCRIPT_DIR}"/hpp/deploy_hpp.sh

0 commit comments

Comments
 (0)