Golang SDK for creating kubernetes clusters. Operations that are currently supported are -
- Create cluster
- Add nodes
- Remove nodes
- Delete cluster
The library automatically detects the operating system and then perform the operation for that particular os.
Currently the only way to manage cluster operation on-prem/VM/baremetal machines are using custom ansible script or using kubespray.
go-kubeadmclient
empowers you with a sdk to create cluster so that you can build your clusters based on logic/workflow etc.
There are various projects for automation for custom kubernetes distribution. We believe something similar lacks for upstream kubernetes distribution.
There aren't many SDK based approach to managing cluster operation therefore this project was initiated.
go get github.com/debarshibasak/go-kubeadmclient
package main
import (
"github.com/debarshibasak/go-kubeadmclient/kubeadmclient"
"log"
)
func main(){
k := kubeadmclient.Kubeadm{
MasterNodes:[]*kubeadmclient.MasterNode{
kubeadmclient.NewMasterNode("ubuntu", "192.168.1.9", "/home/debarshi/.ssh/id_rsa"),
},
WorkerNodes:[]*kubeadmclient.WorkerNode{
kubeadmclient.NewWorkerNode("ubuntu", "192.168.1.10", "/home/debarshi/.ssh/id_rsa"),
kubeadmclient.NewWorkerNode("ubuntu", "192.168.1.11", "/home/debarshi/.ssh/id_rsa"),
kubeadmclient.NewWorkerNode("ubuntu", "192.168.1.12", "/home/debarshi/.ssh/id_rsa"),
},
Netorking: networking.Flannel,
VerboseMode: false,
}
err := k.CreateCluster()
if err != nil {
log.Fatal(err)
}
}
If you want to create and HA Cluster follow this example The example sets up an HAProxy, master and workers.
If you want to add nodes to an existing cluster follow this example The example requires an existing master that is setup and list of worker. The automation provisions workers and adds them to the cluster.
if you want to remove node from an existing cluster follow this example This example requires an existing cluster, access to master node and list of workers that has to be removed.
If you want to delete a cluster provisioned by this orchestration, you can follow this example
This example requires access to one of the master to delete nodes, but you would need details of all the nodes if you want to reset the nodes.
If you want to delete an existing cluster label the worker nodes as node-type="worker"
, and they will be picked up for deletion.
- This has been tested only on ubuntu. If you want this orchestration to be tested on centos or redhat, please create a github issue.
- Please make sure the user with which you create the VMs are passwordless sudoers.
- Added support for HA cluster
- Parallel worker node provisioning
- Added support for multipass
- Add HA Proxy Support for multi master setup
- cli for creating cluster
- More structure approach towards CNI, pod cidrs, service cidrs, dns domains etc.
- Ubuntu 18.04, 16.04 (tested)
- CentOS 7.x (not tested, but mostly possible)
- CentOS 8.x (not tested)
- RedHat (not available, please create issue list for that)
- Testing this orchestration on centos, redhat
- Add Support for remove node
- Add support for delete cluster
- Smart use MaxSession from ssh_config to buffer adding nodes
- Add docker daemon options like insecure registries etc.
- Add option to install docker-ee
- Add Support for offline installation
- Add Support for waiting till nodes are ready
- If you want to join this project, please feel free to create pull requests or message me.
- You can support my effort with donation at patreon
- More than happy to talk about this in local meetups. Please feel free to approache me.
Become a Patron!<script async src="https://c6.patreon.com/becomePatronButton.bundle.js"></script>