Code Monkey home page Code Monkey logo

inception-of-things's Introduction

Inception of Things

This repository gathers three little projects using Vagrant, Kubernetes and more.

Table of Contents

  1. Prerequisites
  2. Part 1: Automate a simple k3s cluster with Vagrant
  3. Part 2
  4. Part 3

Prerequisites

Before proceeding with the setup, ensure you have the following prerequisites on your host machine:

  • Vagrant installed, and
  • VirtualBox (or any other Vagrant provider) installed for virtualization capabilities.

Part 1: Automate a simple K3s cluster with Vagrant

The first project p1 involves automating a 2-machine cluster using k3s and vagrant.

K3s is a lightweight virtual machine-based Kubernetes distribution tool made for IoT and CI/CD environments.

Setting up the Virtual Machines

In part1, we define two boxes: a server and a worker.Vagrant helps us automate the creation and provisioning of multiple virtual machines from one configuration file: the Vagrantfile. Both boxes run the latest stable Ubuntu Operating System and run on 1 CPU and 1024 MB of RAM. Their hostnames and IP addresses are defined at the top of the file.

SERVER_IP = "192.168.56.110"
WORKER_IP = "192.168.56.111"
SERVER_NAME = "corozcoS"
WORKER_NAME = "corozcoSW"
TOKEN_FILE = "/vagrant/node-token"

Vagrant.configure("2") do |config|

  config.vm.box = "ubuntu/focal64"
  config.vm.provider "virtualbox" do |vb|
    vb.memory = 1024
    vb.cpus = 1
  end

  config.vm.define "#{SERVER_NAME}" do |control|
    control.vm.hostname = "#{SERVER_NAME}"
    control.vm.network "private_network", bridge: "enp0s8", ip: "#{SERVER_IP}"
  end

  config.vm.define "#{WORKER_NAME}" do |control|
    control.vm.hostname = "#{WORKER_NAME}"
    control.vm.network "private_network", bridge: "enp0s8", ip: "#{WORKER_IP}"
  end
end

Deploying the k3s cluster

Once our machines are up and running, we can configure the k3s cluster.

Server node

# Initialize a new cluster using etcd specifying the node's advertising address 
# Copy the node-token to the host machine
$serverscript = <<-SCRIPT
apt-get update
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--cluster-init --node-ip #{SERVER_IP}" sh -
cp /var/lib/rancher/k3s/server/node-token /vagrant
SCRIPT

# We run this script on the server machine
control.vm.provision "shell", inline: $serverscript
# Initialize a new cluster using etcd specifying the node's advertising address 
# Copy the node-token to the host machine
$serverscript = <<-SCRIPT
apt-get update
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--cluster-init --node-ip #{SERVER_IP}" sh -
cp /var/lib/rancher/k3s/server/node-token /vagrant
SCRIPT

# We run this script on the node server
control.vm.provision "shell", inline: $nodescript

Part 2:

Part 3:

  • create VM
  • install docker, k3d, kubectl etc

K3d deploys Docker-based k3s Kubernetes clusters.

inception-of-things's People

Contributors

segfah avatar louisabricot avatar

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.