Skip to content

Commit

Permalink
unify kubevirt deployment for ocp / vanilla
Browse files Browse the repository at this point in the history
  • Loading branch information
danpaul81 committed Feb 8, 2024
1 parent 89f46dc commit f92480c
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 160 deletions.
7 changes: 0 additions & 7 deletions assets/kubevirt/migration.yml

This file was deleted.

16 changes: 16 additions & 0 deletions assets/kubevirt/ocp/pxbbq-route.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: pxbbq
namespace: pxbbq
labels:
app: pxbbq-web
px-dr: 'false'
spec:
to:
kind: Service
name: pxbbq-svc
weight: 100
port:
targetPort: 8080
wildcardPolicy: None
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,6 @@ spec:
selector:
app: pxbbq-web
---
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: pxbbq
namespace: pxbbq
labels:
app: pxbbq-web
px-dr: 'false'
spec:
to:
kind: Service
name: pxbbq-svc
weight: 100
port:
targetPort: 8080
wildcardPolicy: None
---
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
Expand Down
17 changes: 0 additions & 17 deletions assets/kubevirt/ocp/pxbbq.yml → assets/kubevirt/pxbbq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,6 @@ spec:
selector:
app: pxbbq-web
---
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: pxbbq
namespace: pxbbq
labels:
app: pxbbq-web
px-dr: 'false'
spec:
to:
kind: Service
name: pxbbq-svc
weight: 100
port:
targetPort: 8080
wildcardPolicy: None
---
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
Expand Down
81 changes: 0 additions & 81 deletions assets/kubevirt/vm.yml

This file was deleted.

4 changes: 2 additions & 2 deletions docs/templates/ocp-kubevirt/readme.MD
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ env:

* in case pxbbq deployment fails you can delete the default (FreeBSD) Deployment and try Ubuntu

* **c1cli**: `$ kubectl delete -f /assets/kubevirt/ocp/pxbbq-freebsd.yml`
* **c1cli**: `$ kubectl delete -f /assets/kubevirt/pxbbq-freebsd.yml`

* `$ kubectl apply -f /assets/kubevirt/ubuntu-dv.yml`

* `$ kubectl apply -f /assets/kubevirt/ocp/pxbbq-freebsd.yml`
* `$ kubectl apply -f /assets/kubevirt/pxbbq.yml`
44 changes: 25 additions & 19 deletions scripts/kubevirt
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
export KUBEVIRTVERSION="v1.1.0"
export CDIVERSION="v1.57.0"
export KUBEVIRTVERSION="v1.1.1"
export CDIVERSION="v1.58.1"

#export KUBEVIRTVERSION=$(curl -s https://api.github.com/repos/kubevirt/kubevirt/releases | grep tag_name | grep -v -- '-rc' | sort -r | head -1 | awk -F': ' '{print $2}' | sed 's/,//' | xargs)

echo "downloading kubevirt $KUBEVIRTVERSION"
kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRTVERSION}/kubevirt-operator.yaml
kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRTVERSION}/kubevirt-operator.yaml

echo "waiting for kubevirt operator readiness"
while ! kubectl wait --for=condition=ready pod --timeout=300s -lname=virt-operator -n kubevirt; do
sleep 2
done

# check if emulation (slow!!!) needed
# hint: check only done on master node...
egrep '^flags.*(vmx|svm)' /proc/cpuinfo >/dev/null
if [ $? = 1 ]; then
echo "No virtualizazion capabilities found on master node cpu"
echo "switching on software emulation (slow)"
kubectl -n kubevirt patch kubevirts kubevirt --type=merge --patch '{"spec":{"configuration":{"developerConfiguration":{"useEmulation":true}}}}'
fi

kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRTVERSION}/kubevirt-cr.yaml
kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRTVERSION}/kubevirt-cr.yaml

echo "waiting for kubevirt CRD readiness"
while ! kubectl wait kubevirt.kubevirt.io/kubevirt -n kubevirt --timeout=300s --for=jsonpath='{.status.phase}'='Deployed'; do
sleep 2
done

# check node-1-1 if emulation (slow!!!) needed
echo "checking for virtualizazion capabilities on node-1-1 cpu"
ssh node-1-1 egrep '^flags.*\(vmx\|svm\)' /proc/cpuinfo >/dev/null
if [ $? = 1 ]; then
echo "No virtualizazion capabilities found on node-1-1 cpu"
echo "enabling software emulation (slow)"
kubectl -n kubevirt patch kubevirts kubevirt --type=merge --patch '{"spec":{"configuration":{"developerConfiguration":{"useEmulation":true}}}}'
fi

echo "installing virtctl"
ARCH=$(uname -s | tr A-Z a-z)-$(uname -m | sed 's/x86_64/amd64/') || windows-amd64.exe
echo ${ARCH}
Expand All @@ -35,12 +35,18 @@ chmod +x /tmp/virtctl
sudo install /tmp/virtctl /usr/local/bin
ln -s /usr/local/bin/virtctl /usr/local/bin/kubectl-virt

kubectl create -f https://github.com/kubevirt/containerized-data-importer/releases/download/${CDIVERSION}/cdi-operator.yaml
kubectl create -f https://github.com/kubevirt/containerized-data-importer/releases/download/${CDIVERSION}/cdi-cr.yaml

kubectl apply -f /assets/kubevirt/px-virt-sc.yml
kubectl apply -f https://github.com/kubevirt/containerized-data-importer/releases/download/${CDIVERSION}/cdi-operator.yaml
kubectl apply -f https://github.com/kubevirt/containerized-data-importer/releases/download/${CDIVERSION}/cdi-cr.yaml

while ! kubectl patch storageprofile --type merge px-virtualization -p '{ "spec": { "claimPropertySets": [ { "accessModes": [ "ReadWriteMany" ], "volumeMode": "Filesystem" } ], "cloneStrategy": "csi-clone" } }'; do
echo waiting for storageprofile
echo "waiting for cdi operator readiness"
while ! kubectl wait cdis.cdi.kubevirt.io cdi -n cdi --for=jsonpath='{.status.phase}'='Deployed'; do
sleep 2
done


#kubectl apply -f /assets/kubevirt/px-virt-sc.yml

#while ! kubectl patch storageprofile --type merge px-virtualization -p '{ "spec": { "claimPropertySets": [ { "accessModes": [ "ReadWriteMany" ], "volumeMode": "Filesystem" } ], "cloneStrategy": "csi-clone" } }'; do
# echo waiting for storageprofile
# sleep 2
#done
17 changes: 17 additions & 0 deletions scripts/kubevirt-apps
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
kubectl create ns pxbbq
kubectl label ns pxbbq app=pxbbq
kubectl label ns pxbbq backup=true

kubectl apply -f /assets/kubevirt/dv-ubuntu.yml
kubectl apply -f /assets/kubevirt/pxbbq.yml

if [ "$platform" = ocp4 ]; then
kubectl apply -f /assets/kubevirt/ocp/pxbbq-route.yml
else
kubectl patch svc pxbbq-svc -n pxbbq --type='json' -p '[{"op":"replace","path":"/spec/type","value":"NodePort"}]'
pubIP=$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
appPort=$(kubectl get svc pxbbq-svc -n pxbbq -o=jsonpath='{.spec.ports[?(@.port==80)].nodePort}')
echo "Access PXBBQ on http://$pubIP:$appPort" >> /etc/motd
fi


17 changes: 17 additions & 0 deletions scripts/kubevirt-apps-freebsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
kubectl create ns pxbbq
kubectl label ns pxbbq app=pxbbq
kubectl label ns pxbbq backup=true

curl -O https://object-storage.public.mtl1.vexxhost.net/swift/v1/1dbafeefbd4f4c80864414a441e72dd2/bsd-cloud-image.org/images/freebsd/13.2/2023-04-21/zfs/freebsd-13.2-zfs-2023-04-21.qcow2
virtctl image-upload pvc freebsd-image -n pxbbq --size 5Gi --insecure --storage-class px-csi-db --image-path=./freebsd-13.2-zfs-2023-04-21.qcow2

kubectl apply -f /assets/kubevirt/pxbbq-freebsd.yml

if [ "$platform" = ocp4 ]; then
kubectl apply -f /assets/kubevirt/ocp/pxbbq-route.yml
else
kubectl patch svc pxbbq-svc -n pxbbq --type='json' -p '[{"op":"replace","path":"/spec/type","value":"NodePort"}]'
pubIP=$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
appPort=$(kubectl get svc pxbbq-svc -n pxbbq -o=jsonpath='{.spec.ports[?(@.port==80)].nodePort}')
echo "Access PXBBQ on http://$pubIP:$appPort" >> /etc/motd
fi
6 changes: 0 additions & 6 deletions scripts/ocp-kubevirt-apps

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/ocp-kubevirt-apps-freebsd

This file was deleted.

2 changes: 1 addition & 1 deletion templates/kubevirt.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
description: Install kubevirt on a bare-metal cluster
scripts: ["install-px","kubevirt"]
scripts: ["install-px","kubevirt","kubevirt-apps"]
#aws_type: "c5n.metal"

2 changes: 1 addition & 1 deletion templates/ocp-kubevirt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cloud: "aws"
clusters: 2
cluster:
- id: 1
scripts: [ "ocp-kubevirt-apps-freebsd", "helm-backup", "helm-backup-ocp4-kubevirt"]
scripts: [ "kubevirt-apps-freebsd", "helm-backup", "helm-backup-ocp4-kubevirt"]
- id: 2
scripts: ["clusterpair-dr"]
env:
Expand Down
2 changes: 1 addition & 1 deletion vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ func vsphere_init() {
var govc_opts []string

config := parse_yaml("defaults.yml")
fmt.Printf("Hint: there is a way faster way to deploy the base template. \n Please follow this documentation:\n https://github.com/andrewh1978/px-deploy/tree/master/docs/vsphere/README.md \n Or get a coffee now\n")
fmt.Printf("Hint: there is a way faster way to deploy the base template. \n Please follow this documentation:\n https://github.com/andrewh1978/px-deploy/tree/master/docs/cloud/vsphere/README.md \n Or get a coffee now\n")
checkvar := []string{"vsphere_compute_resource", "vsphere_datacenter", "vsphere_datastore", "vsphere_host", "vsphere_network", "vsphere_resource_pool", "vsphere_template", "vsphere_user", "vsphere_password", "vsphere_repo"}
emptyVars := isEmpty(config.Vsphere_Compute_Resource, config.Vsphere_Datacenter, config.Vsphere_Datastore, config.Vsphere_Host, config.Vsphere_Network, config.Vsphere_Resource_Pool, config.Vsphere_Template, config.Vsphere_User, config.Vsphere_Password, config.Vsphere_Repo)
if len(emptyVars) > 0 {
Expand Down

0 comments on commit f92480c

Please sign in to comment.