The main goal of Nova-kubernetes-drain is to perform evacuation of Openstack compute node when Kubernetes node is being drained. Nova-kubernetes-drain should be deployed as a Daemonset via Stackanetes.
Nova-kubernetes-drain can be run as a daemon or as one-off task. Those two modes are simple configure by command line flag.
Nova-kubernetes-drain based on two clients:
- Kubernetes client: https://godoc.org/k8s.io/kubernetes/pkg/client/unversioned
- Openstack client*: http://gophercloud.io/docs/compute/
* Rackspace client is deprecated, but new client currently does not support live-migration. Client should be switched when new client supports live-migration.
Nova-kubernetes-drain requires config.yaml. Configuration file should contain all variables necessary to establish connection with openstack. config.yaml example:
IdentityEndpoint: "http://keystone-api:5000/v3/"
Username: "admin"
Password: "mysupersecretpassword"
TenantName: "admin"
DomainID: "default"
Run once is a default mode. So to performe a single evacuation you need to just run application without any additional flag. When evacuation is successful the application will exit without any error code.
To run it:
./drainer
The application will execute following actions:
- Load Openstack Authorisation variables from file.
- Determine nova-compute name in Openstack of the pod.
- Disable nova-compute in Openstack.
- Identify all VMs on this nova-compute node.
- Trigger live-migration for each of those VMs.
- Exit application.
To run Nova-kubernetes-drain as a daemon. One have to pass additional -daemon
flag.
./drainer -daemon
In this mode specific kubernetes events are triggering openstack actions. Kubernetes drain node command will disable Openstack compute-node and perform evacuation of VMs. Kubernetes uncrodon node command will enable Openstack compute-node.
Lifecycle of the application:
- Load Openstack Authorisation variables from file.
- Hook to Kubernetes event stream and wait for proper events.
- According to event message, trigger proper command:
- Unschedulable event received:
- Disable nova-compute in Openstack.
- Identify all VMs on this nova-compute node.
- Trigger live-migration for each of those VMs.
- Schedulable event received:
- Enable nova-compute in Openstack.
- Unschedulable event received: