vm-controller

module
v0.0.0-...-0be8373 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2019 License: Apache-2.0

README

VM Controller

A controller to operate VM resource in the Private Cloud(VM API) through Kubernetes. This controller is extened from sample-controller.

This repo contains an API server provides REST operations for managing VM. It implements the precondition for testing the sample-controller.

Building from Source

Clone repo into your go path under $GOPATH/src:

$ git clone https://github.com/kairen/vm-controller.git $GOPATH/src/github.com/kairen/vm-controller
$ cd $GOPATH/src/github.com/kairen/vm-controller
$ make dep
$ make

Running

Prerequisites:

  • Kubernetes cluster. Can start a cluster by Minikube: minikube start --kubernetes-version=v1.13.5.
  • Make sure your have all the build dependencies installed for libvirt. To run on Ubuntu 16.04:
$ sudo apt-get install -y qemu-kvm libvirt-bin virtinst bridge-utils cpu-checker
$ sudo mkdir -p /var/lib/libvirt/iso
$ sudo wget http://ftp.ubuntu-tw.org/mirror/ubuntu-releases/16.04.6/ubuntu-16.04.6-server-amd64.iso -O /var/lib/libvirt/iso/ubuntu.iso
API Server
Debug

Run the following command as the debug mode:

$ go run cmd/apiserver/main.go --iso-path=/var/lib/libvirt/iso/ubuntu.iso
Run on Docker

To run the API server on Docker:

$ docker run -d -p 8080:8080 --restart=on-failure \
    -v /var/lib/libvirt:/var/lib/libvirt \
    -v /var/run/libvirt/libvirt-sock:/var/run/libvirt/libvirt-sock \
    --name vm-apiserver \
    kairen/apiserver:v0.1.0 --iso-path=/var/lib/libvirt/iso/ubuntu.iso

You can view the API definition from http://host:port/swagger/index.html when the server started.

Controller
Debug out of the cluster

Run the following command to debug:

$ export POD_NAME=test-1
$ export POD_NAMESPACE=kube-system
$ go run cmd/controller/main.go --kubeconfig $HOME/.kube/config --logtostderr --v=2 --api-url=http://172.22.2.68:8080
Deploy in the cluster

Run the following command to deploy the controller:

$ kubectl apply -f artifacts/deploy
$ kubectl -n kube-system get po -l app=vm-controller

Directories

Path Synopsis
cmd
pkg
apis/samplecontroller/v1alpha1
Package v1alpha1 is the v1alpha1 version of the API.
Package v1alpha1 is the v1alpha1 version of the API.
generated/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
generated/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
generated/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
generated/clientset/versioned/typed/samplecontroller/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.

Jump to

Keyboard shortcuts

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