/dok8su

(Yet another) collection of scripts to install kubernetes (k8s) to @digitalocean

Primary LanguageShellMIT LicenseMIT

dok8su (u for unmanaged)

BEWARE: This is probably not the project you are looking for. Please see dok8s for DigitalOcean's managed Kubernetes solution

Not For Production Use

(Yet another) Collection of scripts to create an unmanaged kubernetes cluster with multiple nodes using kubeadm from the latest stable version of kubernetes.

By default master uses 2gb and nodes use 4gb droplets. They can be configured via setting MASTER_SIZE and NODE_SIZE environment variables, respectively. Master and nodes uses the ubuntu 18.04 [bionic] image.

dok8su uses Cilium for networking. It also installs dashboard, metrics server, Prometheus [with node_exporter] and Grafana.

It uses Kubernetes Cloud Controller Manager for DigitalOcean, Container Storage Interface (CSI) Driver for DigitalOcean Block Storage and configures the DigitalOcean Firewall

Requires

Getting Started

To create a cluster:

$ DIGITALOCEAN_ACCESS_TOKEN=<omitted> SSH_KEY_NAME=yubikey REGION=nyc3 TAG_PREFIX=nyc3-k8s MASTER_NAME=master NODE_NAME=node NODE_COUNT=3 MASTER_SIZE=s-2vcpu-2gb NODE_SIZE=s-2vcpu-4gb ./dok8su-create
- Creating the master
- Waiting master to finish installation
- Creating nodes
- Waiting nodes to be ready
- Deploying manifests
- Waiting load-balancers to be ready
- Creating the master firewall
- Creating the node firewall
- Installation completed (took 428 seconds)
- To learn your dashboard token, please run;
    kubectl --kubeconfig /home/dok8su/admin.k8s.conf -n kube-system describe secret dok8su-admin-token-lkzpl

$ kubectl --kubeconfig admin.k8s.conf get nodes
NAME     STATUS   ROLES    AGE     VERSION
master   Ready    master   5m38s   v1.13.3
node1    Ready    <none>   4m21s   v1.13.3
node2    Ready    <none>   4m15s   v1.13.3
node3    Ready    <none>   4m13s   v1.13.3

To access Dashboard from your local workstation you must create a secure channel to your Kubernetes cluster. Run the following command:

$ kubectl  --kubeconfig admin.k8s.conf proxy

Now access Dashboard at:

http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

To destroy the cluster, run the following command:

$ DIGITALOCEAN_ACCESS_TOKEN=<omitted> TAG_PREFIX=nyc3-k8s MASTER_NAME=master NODE_NAME=node ./dok8su-destroy
- Destroying the droplets
- Destroying the tags
- Destroying the node firewall
- Destroying the master firewall
- Destroy completed

Environment variables

Name Default Value Required
REGION sfo2 no
SSH_KEY_NAME default yes
MASTER_NAME master no
NODE_NAME node no
MASTER_SIZE s-2vcpu-2gb no
NODE_SIZE s-2vcpu-4gb no
NODE_COUNT 3 no
TAG_PREFIX k8s no

Acknowledgements

Uses bits and pieces from following projects: