-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathocp-kubevirt
More file actions
84 lines (72 loc) · 2.62 KB
/
ocp-kubevirt
File metadata and controls
84 lines (72 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
OPVERSION=$(kubectl get packagemanifests.packages.operators.coreos.com kubevirt-hyperconverged -o json | jq -r '.status.channels[] | select(.name=="stable") | .currentCSV')
kubectl patch storageclass gp3-csi -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "false"}}}'
kubectl apply -f /assets/kubevirt/px-rwx-kubevirt.yml
echo "current kubevirt-hyperconverged operator version is $OPVERSION"
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: openshift-cnv
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: kubevirt-hyperconverged-group
namespace: openshift-cnv
spec:
targetNamespaces:
- openshift-cnv
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: hco-operatorhub
namespace: openshift-cnv
spec:
source: redhat-operators
sourceNamespace: openshift-marketplace
name: kubevirt-hyperconverged
startingCSV: $OPVERSION
channel: "stable"
EOF
curl -Lo /usr/bin/virtctl https://github.com/kubevirt/kubevirt/releases/download/v1.1.1/virtctl-v1.1.1-linux-amd64
chmod 755 /usr/bin/virtctl
echo "waiting for kubevirt-hyperconverged operator readiness"
while ! kubectl wait clusterserviceversions.operators.coreos.com $OPVERSION -n openshift-cnv --timeout=300s --for=jsonpath='{.status.phase}'='Succeeded'; do
sleep 2
done
cat <<EOF | kubectl apply -f -
apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged
metadata:
name: kubevirt-hyperconverged
namespace: openshift-cnv
spec:
EOF
sleep 2
# check if hyperconverged CRD has status condition containing ReconcileCompleted/True/Available
# TODO: maybe there is a better way to detect if this CRD is ready?
HC=$(kubectl get hyperconvergeds.hco.kubevirt.io kubevirt-hyperconverged -n openshift-cnv -ojson | jq -r '.status.conditions[] | select((.reason=="ReconcileCompleted") and (.status=="True") and (.type=="Available")) | .status')
while [ ! "$HC" == "True" ]; do
echo "Waiting for hyperconverged CRD to complete reconcile"
sleep 5
HC=$(kubectl get hyperconvergeds.hco.kubevirt.io kubevirt-hyperconverged -n openshift-cnv -ojson | jq -r '.status.conditions[] | select((.reason=="ReconcileCompleted") and (.status=="True") and (.type=="Available")) | .status')
done
kubectl apply -f /assets/kubevirt/storageprofile.yml
# add colored console notification on OCP GUI
if [ $cluster == "1" ]; then
bgcolor='#fe5000'
else
bgcolor='#40b605'
fi
cat <<EOF | kubectl apply -f -
apiVersion: console.openshift.io/v1
kind: ConsoleNotification
metadata:
name: clusternumber
spec:
text: cluster-$cluster
location: BannerTop
color: '#fff'
backgroundColor: '$bgcolor'
EOF