GithubHelp home page GithubHelp logo

multipass-k3s's Introduction

k3s cluster on multipass instances

This script will create a configurable amount of instances using multipass, install k3s server(s) (HA using embedded etcd), and add the agent instances to the cluster.

Requirements

This is tested on MacOS and Ubuntu Linux 22.04.

Running it

Clone this repo, and run the script:

bash multipass-k3s.sh

This will (defaults):

  • Generate random name for your cluster (configurable using NAME)
  • Create init-cloud-init file for server to install the first k3s server with embedded etcd (contains --cluster-init to activate embedded etcd)
  • Create one instance for the first server with 2 CPU (SERVER_CPU_MACHINE), 10G disk (SERVER_DISK_MACHINE) and 1G of memory (SERVER_MEMORY_MACHINE) using Ubuntu focal (IMAGE)
  • Create cloud-init file for server to install additional k3s servers with embedded etcd.
  • Create one instance for additional server (configurable using SERVER_COUNT_MACHINE)
  • Create cloud-init file for agent to join the cluster.
  • Create one machine (configurable using AGENT_COUNT_MACHINE) with 1 CPU (AGENT_CPU_MACHINE), 3G disk (AGENT_DISK_MACHINE) and 512M of memory (AGENT_MEMORY_MACHINE) using Ubuntu focal (IMAGE)
  • Wait for the nodes to be joined to the cluster
  • Optionally merge the generated kubeconfig with the existing $KUBECONFIG (MERGE_KUBECONFIG)

Quickstart Ubuntu 22.04 droplet

sudo snap install multipass
wget https://raw.githubusercontent.com/superseb/multipass-k3s/master/multipass-k3s.sh
bash multipass-k3s.sh
curl -Lo /usr/local/bin/kubectl "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x /usr/local/bin/kubectl
kubectl --kubeconfig *-kubeconfig.yaml get nodes

Clean up

The files that are created are:

  • $NAME-agent-cloud-init.yaml
  • $NAME-cloud-init.yaml
  • $NAME-kubeconfig.yaml
  • $NAME-kubeconfig-orig.yaml
  • $NAME-kubeconfig-backup.yaml (if MERGE_KUBECONFIG is set)
  • $NAME-kubeconfig-merged.yaml (if MERGE_KUBECONFIG is set)

You can clean up the instances by running multipass delete k3s-server-$NAME-1 --purge and multipass delete k3s-agent-$NAME-{1,2,3} or (WARNING this deletes and purges all instances): multipass delete --all --purge

multipass-k3s's People

Contributors

superseb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

multipass-k3s's Issues

script fails

No server token given, generated server token: iizytxzu5etj4r3irtgn
No agent token given, generated agent token: akud5gjvscig6fu9f6cl
No name given, generated name: ext13m
Creating cluster ext13m with 1 server(s) and 1 agent(s)
Cloud-init is created at ext13m-init-cloud-init.yaml
Creating initial server instance: k3s-server-ext13m
Running multipass launch --cpus 2 --disk 5G --mem 1G focal --name k3s-server-ext13m --cloud-init ext13m-init-cloud-init.yaml
error: No such file: ext13m-init-cloud-init.yaml
There was an error launching the instance

Ubuntu 20.04 fresh install BM

HA setup?

Hello

I just found your script and was reading that it supports HA with embedded etcd.
So I checked the script but got confused how the config is working

# How many additional server instances to create
SERVER_COUNT_MACHINE="0"
# How many agent instances to create
AGENT_COUNT_MACHINE="1"

I would like to spin up 3 masters and 3 workers.

Do I understand correct that by default it only spin up 1 master?
So if I put SERVER_COUNT_MACHINE="2", it will generate a total of 3 masters?

And for the agent, I need to set it as AGENT_COUNT_MACHINE="3" ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.