kubevirt-vm-operator

module
v0.0.0-...-98c04c6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2019 License: Apache-2.0

README

kubevirt-vm-operator

Operator which deploy various operating systems on top of Kubernetes.

Installation

kubectl create -f deploy/crds/guest_v1alpha1_fedora_crd.yaml
kubectl create -f deploy/service_account.yaml
kubectl create -f deploy/role.yaml
kubectl create -f deploy/role_binding.yaml
kubectl create -f deploy/operator.yaml

Create Fedora virtual machine

cat <<EOF | kubectl create -f -
apiVersion: guest.kubevirt.io/v1alpha1
kind: Fedora
metadata:
  name: fedora-vm
spec:
  osVersion: "29"
  memory: "512Mi"
  cpuCores: 1
  cloudInit: |
    #!/bin/bash
    echo "fedora" | passwd fedora --stdin
EOF

Verify VM was created:

kubectl get vm fedora-vm

Troubleshooting

Check operator pod for errors:

kubectl logs kubevirt-vm-oprator-xyz

Development

After cloning the repository, run the operator locally using:

export GO111MODULE=on
go mod vendor
operator-sdk up local --namespace=default

After changes to types file run:

operator-sdk generate k8s

In order to debug the operator locally using 'dlv', start the operator locally:

operator-sdk build quay.io/$USER/kubevirt-vm-operator:v0.0.1
OPERATOR_NAME=kubevirt-vm-operator WATCH_NAMESPACE=default ./build/_output/bin/kubevirt-vm-operator

Kubernetes cluster should be avaiable and pointed by ~/.kube/config. The CRDs of ./deploy/crds/ should be applied on it.

From a second terminal window run:

dlv attach --headless --api-version=2 --listen=:2345 $(pgrep -f kubevirt-vm-operator) ./build/_output/bin/kubevirt-vm-operator

Connect to the debug session, i.e. if using vscode, create launch.json as:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Connect to kubevirt-vm-operator",
            "type": "go",
            "request": "launch",
            "mode": "remote",
            "remotePath": "${workspaceFolder}",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${workspaceFolder}",
            "env": {},
            "args": []
        }
    ]
}

Directories

Path Synopsis
cmd
pkg
apis/guest/v1alpha1
Package v1alpha1 contains API Schema definitions for the guest v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=guest.kubevirt.io
Package v1alpha1 contains API Schema definitions for the guest v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=guest.kubevirt.io

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL