• Stars
    star
    166
  • Rank 227,202 (Top 5 %)
  • Language Makefile
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Kubernetes Vagrant Multi node environment using kubeadm.

k8s-vagrant-multi-node

Build Status

This project was based on work from coolsvap/kubeadm-vagrant by @coolsvap, now it is mostly independent.

A demo of the start and destroy of a cluster can be found here: README.md Demo section.

Prerequisites

  • make
  • kubectl - Optional when KUBECTL_AUTO_CONF is set to false (default: true).
  • grep
  • cut
  • rsync
  • Source for randomness (only used to generate a kubeadm token, when no custom KUBETOKEN is given):
    • /dev/urandom
    • openssl command - Fallback for when /dev/urandom is not available.
  • Vagrant (>= 2.2.0)
    • Tested with 2.2.2 (if you should experience issues, please upgrade to at least this Vagrant version or higher)
    • Plugins
      • vagrant-reload REQUIRED For BOX_OS=fedora (set by default) and when using the vagrant-reload* targets, the vagrant-reload plugin is needed. An automatic attempt to install the plugin is made. To install manually run one of the following commands:
        • make vagrant-plugins or
        • vagrant plugin install vagrant-reload
  • Vagrant Provider (one of the following two is needed)
    • libvirt (vagrant plugin install vagrant-libvirt)
      • Tested with libvirtd version 5.10.0.
      • Libvirt support is still a bit experimental and can be unstable (e.g., VMs not getting IPs).
        • Troubleshooting: If your VM creation is hanging at Waiting for domain to get an IP address..., using virsh run virsh force reset VM_NAME (VM_NAME can be obtained using virsh list command) or in virt-manager Force Reset on the VM.
    • Virtualbox (WARNING VirtualBox seems to hang the Makefile randomly for some people, libvirt is recommended)
      • Tested with 6.0.0 (if you should experience issues, please upgrade to at least this version or higher)
      • VBoxManage binary in PATH.

NOTE kubectl is only needed when the kubectl auto configuration is enabled (default is enabled), to disable it set the variable KUBECTL_AUTO_CONF to false. For more information, see the Configuration / Variables doc page.

Hardware Requirements

  • Master
    • CPU: 2 Cores (MASTER_CPUS)
    • Memory: 2GB (MASTER_MEMORY_SIZE_GB)
  • 1x Node:
    • CPU: 1 Core (it is recommended to use at least 2 Cores; NODE_CPUS)
    • Memory: 2GB (it is recommended to use more than 2GB; NODE_MEMORY_SIZE_GB)

These resources can be changed by setting the according variables for the make up command, see Configuration / Variables doc page.

Quickstart

To start with the defaults, 1x master and 2x workers, run the following:

$ make up -j 3

The -j3 will cause three VMs to be started in parallel to speed up the cluster creation.

NOTE Your kubectl is automatically configured to use a context for the created cluster, after the master VM is started. The context is named after the directory the Makefile is in.

$ kubectl config current-context
k8s-vagrant-multi-node
$ kubectl get componentstatus
NAME                 STATUS    MESSAGE              ERROR
scheduler            Healthy   ok
controller-manager   Healthy   ok
etcd-0               Healthy   {"health": "true"}
$ kubectl get nodes
NAME      STATUS    ROLES     AGE       VERSION
master    Ready     master    4m        v1.17.3
node1     Ready     <none>    4m        v1.17.3
node2     Ready     <none>    4m        v1.17.3

VM OS Selection

There are multiple sets of Vagrantfiles available (see vagrantfiles/) which can be used to use a different OS for the Kubernetes environment.

See VM OS Selection doc page.

Usage

Also see Usage doc page.

Starting the environment

To start up the Vagrant Kubernetes multi node environment with the default of two worker nodes + a master (not parallel) run:

$ make up

NOTE Your kubectl is automatically configured to use a context for the created cluster, after the master VM is started. The context is named after the directory the Makefile is in.

Faster (parallel) environment start

To start up 4 VMs in parallel run (-j flag does not control how many (worker) VMs are started, the NODE_COUNT variable is used for that):

$ NODE_COUNT=3 make up -j4

The flag -j CORES/THREADS allows yout to set how many VMs (Makefile targets) will be run at the same time. You can also use -j $(nproc) to start as many VMs as cores/threads you have in your machine. So to start up all VMs (master and three nodes) in parallel, you would add one to the chosen NODE_COUNT.

Show status of VMs

$ make status
master                    not created (virtualbox)
node1                     not created (virtualbox)
node2                     not created (virtualbox)

Shutting down the environment

To destroy the Vagrant environment run:

$ make clean
$ make clean-data

Copy local Docker image into VMs

The make load-image target can be used to copy a docker image from your local docker daemon to all the VMs in your cluster. The IMG variable can be expressed in a few ways, for example:

$ make load-image IMG=your_name/your_image_name:your_tag
$ make load-image IMG=your_name/your_image_name
$ make load-image IMG=my-private-registry.com/your_name/your_image_name:your_tag

You can also specify a new image name and tag to use after the image has been copied to the VM's by setting the TAG variable. This will not change the image/tag in your local docker daemon, it will only affect the image in the VM's.

$ make load-image IMG=repo/image:tag TAG=new_repo/new_image:new_tag

Data inside VM

See the data/VM_NAME/ directories, where VM_NAME is for example master.

make Targets

See make Targets doc page.

Configuration / Variables

See Configuration / Variables doc page.

Troubleshooting

See Troubleshooting doc page.

Demo

See Demo doc page.


Creating an Issue

Please attach the output of the make versions command to the issue as is shown in the issue template. This makes debugging easier.

More Repositories

1

presentation-gitlab-k8s

These are the example files for my presentation and blog post about GitLab + Kubernetes for Continuous Delivery.
Go
165
star
2

dellhw_exporter

Prometheus exporter for Dell Hardware components using Dell OMSA.
Go
112
star
3

container-healthchecks

Simple to use Container Image for https://github.com/healthchecks/healthchecks.
Dockerfile
63
star
4

kubernetes-keycloak

This repo contains manifests to run Keycloak by Red Hat inside of Kubernetes with "host discovery".
36
star
5

srcds_exporter

Prometheus exporter for SRCDS Gameserver using Source RCON.
Go
25
star
6

docker-sinusbot

Docker container for the famous TeamSpeak 3 SinusBot by Michael Friese.
Dockerfile
25
star
7

container-staytus

adamcooke/staytus (https://staytus.co/) as a Container Image without the MySQL server.
Dockerfile
20
star
8

container-vlc

VLC Media Player in a Container Image.
Makefile
20
star
9

docker-nginx-php-fpm

Run Nginx with PHP-FPM on Kubernetes.
Dockerfile
18
star
10

container-node_exporter-textfiles

Container Image for easily running textfile exporter scripts to be collected by the prometheus/node_exporter.
Smarty
17
star
11

kubernetes-manifests

Contains a collection of several Kubernetes manifests for applications (mostly from my blog posts).
16
star
12

presentation-distributed-storage-with-rook

Demo files for the "Distributed storage with Rook" talk by Kim-Norman Sahm and me, and other Rook related presentations.
Shell
13
star
13

docker-taigaio

Taiga.Io as a Docker Image. Ready to docker-compose up.
Shell
13
star
14

elasticsearch-operator

Elasticsearch Operator creates/configures/manages Elasticsearch clusters atop Kubernetes
Go
8
star
15

workshop-docker

Workshop about Docker and Kubernetes.
Shell
7
star
16

ansible-ntp

Ansible NTP client role.
Jinja
6
star
17

docker-percona-xtradb-cluster

percona/percona-docker Percona xtraDB optimized for Kubernetes clustering.
Shell
5
star
18

alertmanager-githubfiles-receiver

An Alertmanager webhook receiver which creates files in a GitHub repository based on the received alert(s), e.g., when using cstate/cstate Status page.
Go
5
star
19

ansible-timezone

Ansible role for setting/changing the timezone.
4
star
20

ansible-ntpdate

Ansible role for running ntpdate. To "force" update the time.
4
star
21

kubernetes-mailserver

Work in progress! Mail server in Kubernetes.
Shell
3
star
22

ansible-kernel-modules

Ansible role for simple management of kernel modules including persisting module loading, blacklisting.
3
star
23

fivenet

From searching the state's citizen and vehicles database, filling documents for investigations, court, and a livemap of your colleagues and dispatches. All that and more is (mostly) ready in this net, the FiveNet.
Vue
3
star
24

vanilla-steamsignin

Vanilla Forums Steam Sign-in Plugin (fork of https://github.com/daigo75 aeliasteamsignin-plugin).
PHP
3
star
25

presentation-gitlab-k8s-php

These are the example files for my article and presentation about GitLab + Kubernetes for Continuous Delivery with an example PHP "Hello World!" application.
PHP
3
star
26

container-jts3servermod

JTS3ServerMod by Stefan1200 as a Container Image.
Dockerfile
3
star
27

container-backups

Have you ever wanted to backup applications running in containers? Yeah ... about that.
Shell
3
star
28

owncloud-kubernetes-rook

Running OwnCloud on Kubernetes using Rook Ceph for storage.
2
star
29

dotfiles

My personal Doty McDotface files.
Shell
2
star
30

presentation-k8s-prometheus

Smarty
2
star
31

ansible-cockpit

An Ansible role to "setup" features of Fedora's Cockpit.
2
star
32

extended-ceph-exporter

A Prometheus exporter to provide "extended" metrics about a Ceph cluster's running components (e.g., RGW).
Go
2
star
33

k8sglue

WIP "Kleber" for Kubernetes in public and private (cloud) environments with Salt, kubeadm and some magic glue.
Go
2
star
34

k8s-minecraft

Minecraft in K8S because why not?
Shell
2
star
35

container-gameserver

Container Image for running (some) Gameservers easily in Containers.
Dockerfile
2
star
36

docs.galexrt.moe

Source of https://docs.galexrt.moe/
Makefile
2
star
37

goytdler

Simple webinterface to use youtube-dl.
Go
1
star
38

docker-steamcmd

Docker SteamCMD Image
1
star
39

workshop-k8s-basics

1
star
40

presentation-golang-microthingy

These are the live code example files for my presentation about "Writing your first Golang Microthingy".
Makefile
1
star
41

ansible-sshkeymgt

Ansible role for simple SSH key management.
1
star
42

ansible-firewall

A try at at an Ansible ipset and iptables managing role.
Jinja
1
star
43

srcds_controller

Go
1
star
44

go-gitlab-webhooks

Go GitLab webhooks struct
Go
1
star
45

go-rcon

Go library for querying Source RCON servers
Go
1
star
46

ansible-raid-check

Ansible role for configuring raid-check settings.
1
star
47

container-restic-sftp

Container image with Restic + SSH + Wrapper for simply SFTP backups with restic.
Shell
1
star
48

container-toolbox

A toolbox container for debugging and stuff in containers.
Dockerfile
1
star
49

desktop-helper

Small helper for "configuration"-less switching of workplaces (run scripts on "events").
Go
1
star
50

workshop-container-docker-kubernetes

Tasks / Files / Examples for my upcoming workshop about Containers, Docker and Kubernetes.
HCL
1
star
51

docker-nginx-php-fpm-pagespeed

Docker Image with Nginx + PHP-FPM and Google Pagespeed Module.
1
star