Giter VIP home page Giter VIP logo

k3s-ansible-traefik-rancher's Introduction

Build a Kubernetes HA-cluster using k3s & kube-vip & metal-lb via Ansible

Based on https://docs.technotim.live/posts/k3s-etcd-ansible/ and <https://github.com/k3s-io/k3s-ansible

BIG SHOUTOUT TO TechnoTim who made this possible and inspired me be sure to check him out!

Instructions/notes

Here: https://thepcgeek.net/posts/ansible-to-k3s-rancher/

K3s Ansible Playbook

Build a k3s Kubernetes cluster using Ansible. The goal is easily install a highly available Kubernetes cluster with Traefik and Rancher on machines running:

  • Debian
  • Ubuntu
  • CentOS

on processor architecture:

  • x64
  • arm64
  • armhf

System requirements

Deployment environment must have Ansible 2.4.0+ Master and nodes must have passwordless SSH access

Usage

First create a new directory based on the sample directory within the inventory directory:

cp -R inventory/sample inventory/my-cluster

Second, edit inventory/my_cluster/hosts.ini to match the system information gathered above. For example:

[master]
192.16.35.12

[node]
192.16.35.[10:11]

[k3s_cluster:children]
master
node

If multiple hosts are in the master group, the playbook will automatically setup k3s in HA mode with etcd. https://rancher.com/docs/k3s/latest/en/installation/ha-embedded/ This requires at least k3s version 1.19.1

Edit inventory/my_cluster/group_vars/all.yml to match your environment.

You can also make any edits needed to the traefik config or chart values ie:(adding resolvers for TLS certs), those files are under roles/traefik/templates keep the file names the same though or the playbook will fail

Start provisioning of the cluster using the following command:

ansible-playbook site.yml -i inventory/my-cluster/hosts.ini --ask-pass --ask-become-pass

After deployment control plane will be accessible via virtual ip-address which is defined in inventory/my-cluster/group_vars/all.yml as apiserver_endpoint

Traefik dashboard will be available on the DNS name you specified in the all.yml variables

Rancher will also be available shortly after the playbook finishes at it's DNS name also specified in the variable file

A note about node-taints and having masters not run workloads on them

In Tim's version he has encorperated adding the criticaladdonsonly=noexecute taint to his playbook process. I have decided not to include this in my version because I run only 3 master nodes and they run my stuff on them which is perfectly fine to do. I don't have the need to taint my masters. If you want to continue using my playbook you can taint your masters after deployment by running a kubectl command or adding the taint to the nodes in rancher.

Remove k3s cluster

ansible-playbook reset.yml -i inventory/my-cluster/hosts.ini --ask-pass --ask-become-pass

Kubeconfig

To get access to your Kubernetes cluster just

scp debian@master_ip:~/.kube/config ~/.kube/config

kube-vip

See https://kube-vip.io/control-plane/

MetalLB

see https://metallb.universe.tf/installation/

Links

Techno-Tim's video on his playbook this is based on: https://www.youtube.com/watch?v=CbkEWcUZ7zM

Kube-vip Control Plane is described -> https://kube-vip.io/control-plane/

k3s-ansible-traefik-rancher's People

Contributors

christhepcgeek avatar timothystewart6 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.