Strongly inspired by https://hackernoon.com/running-linux-applications-as-unikernels-with-k8s-gl2p3yfr
- Run and test the image
GOOS=linux go build main.go
ops run -n -p 8083 main
- Move and put image in format for K8s to understand
cp $HOME/.ops/images/main.img .
xz main.img
- Upload image to a bucket, CDN or something similar
kind create cluster --name unikernel-k8s
- Install
export VERSION=$(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 $VERSION
kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml
kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml
- Verify
kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.phase}"
kubectl get all -n kubevirt
- Install
export VERSION=$(curl -sL https://github.com/kubevirt/containerized-data-importer/releases/latest | grep -o -m1 "v[0-9]\.[0-9]*\.[0-9]*")
kubectl create -f https://github.com/kubevirt/containerized-data-importer/releases/download/$VERSION/cdi-operator.yaml
kubectl create -f https://github.com/kubevirt/containerized-data-importer/releases/download/$VERSION/cdi-cr.yaml
- Verify
kubectl get cdi cdi -n cdi
kubectl get pods -n cdi
- Update
cdi.kubevirt.io/storage.import.endpoint
to the URL where the image is stored - Optionally change the name of the PVC by modifying
name
kubectl create -f manifests/pvc_main_go.yaml
- Check if the storage Pod for the PVC could be created:
kubectl get pvc main-go -o jsonpath="{.metadata.annotations.cdi\.kubevirt\.io/storage\.pod\.phase}"
- Change
claimName
to the name of the PVC (if modified) kubectl create -f manifests/vm1_pvc.yaml
- Check
Phase
of Virtual Machine bykubectl get vmi
and copy the IP address
- SSH into the control-plane of the kind cluster
curl <ip-address>:8083