Introduction

A plugin for CloudStack to create, manage Kubernetes cluster through CloudStack management server API and UI. This plugin will not make any changes to CloudStack core architecture or schema. It will be disabled by default and can be enabled using global setting value.

It will provide following features,


Document History

VersionAuhtor/ReviewerDate
1.0Abhishek Kumar24/September/2019

Use Cases

Plugin will provide Kubernetes integration with CloudStack enabling user to run containerized services using k8s clusters.



Feature Specification

CloudStack Kubernetes Service plugin will add Kubernetes integration in the CloudStack. Plugin will be disabled by default and admin can control its usage using global setting. It will enable run containerized services using k8s clusters.

CKS will use the CoreOS based template for node VMs for running Kubernetes services. For installation of Kubernetes binaries on cluster nodes, a binaries ISO will be used to achieve faster, offline installation. Root admin will be provided with API and UI to upload/register such ISOs for a particular Kubernetes version. A shell script will be added in the codebase to easily create such ISO for a Kubernetes version.

For deployment and setup Kubernetes on cluster nodes, plugin will use Kubernetes tool, kubeadm. kubeadm is the command line tool for easily provisioning a secure Kubernetes cluster on top of physical or cloud servers or virtual machine. Under the hood, master node(s) of the cluster will start a k8s cluster using kubeadm init command with a custom token and worker nodes will be able to join this k8s cluster using kubeadm join command with the same token. More about kubeadm, https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm/

To access Kubernetes dashboard securely, plugin will provide access to kube.config file data which would allow using Kubernetes tools such as kubectl to run proxy locally and thereby accessing dashboard. More about kubectl, https://kubernetes.io/docs/reference/kubectl/overview/

User will be able to create a CloudStack Kubernetes cluster using UI or API. Both UI and API will allow listing these clusters, perform lifecycle tasks over them and perform scaling for number of nodes in a running cluster.



Implementation

API

Kubernetes version management related

K8s version management related APIs can only be accessed by root admins

Add an ISO containing k8s binaries for a specific k8s version

Parameters

===========

displaytext = (string) the display text of the ISO. This is usually used for display purposes. (required)

name = (string) the name of the ISO. (required)

url = (string) the URL to where the ISO is currently being hosted. (required)

zoneid = (uuid) the ID of the zone you wish to register the ISO to.

checksum = (boolean) the MD5 checksum value of this ISO.

isfeatured = (boolean) true if you want this ISO to be featured.

ispublic = (boolean) true if you want to register the ISO to be publicly available to all users, false otherwise.



K8s cluster management related APIs can be accessed by all users

Schema

  1. Table for CKS cluster
    cks_cluster:
    id (bigint, auto_increment),
    uuid (varchar, unique),
    name (varchar, unique),
    description (varchar),
    zone_id (bigint),
    service_offering_id (bigint),
    template_id (bigint),
    network_id (bigint),
    node_count (bigint),
    account_id (bigint),
    domain_id (bigint),
    state (enum/string),
    key_pair (varchar),
    cores (bigint),
    memory (bigint),
    endpoint (varchar),
    console_endpoint (varchar),
    created (datetime)
    removed  (datetime)


  2. Table for CKS details
    cks_cluster_details:
    id (bigint, auto_increment),
    cluster_id (bigint),
    name (varchar),
    value (varchar)


  3. Table for CKS VM reference
    cks_cluster_vm_ref:
    id (bigint, auto_increment),
    cluster_id (bigint),
    vm_id (bigint)


UI Changes


List of currently created clusters will be show in UI, in ui/plugins/cks.js. UI will allow user to perform lifecycle tasks on the cluster. It will show a tab based interface to provide cluster details, running VM instances, network rules and steps to access Kubernetes dashboard using kubectl tool


Testing


Marvin tests cases

    CRUD tests:
        Add cluster, list clusters to confirm addition
        Delete cluster, list clusters to confirm deletion
        Scale cluster, list clusters to confirm scaling
    Cluster management tests:
    Start cluster
    Stop cluster
    Get cluster config