Giter Club home page Giter Club logo

kubernetes-cluster's Introduction

Kubernetes Cluster

Create a kubernetes cluster from scratch with multipass vms and ansible.

A) Create the ubuntu vms with multipass

To create the vms run the up script (./up)

This script will:

  • Create and start 3 vms (with names kube-node-0, kube-node-1, kube-node-2)
  • Add the public key ./keys/key.pub in each vm's authorized_keys
  • Create the ansible inventory file by getting each vm's ip.

B) Create kubernetes cluster with ansible

Every ansible playbook must be run from ./ansible directory (cd ansible).

Install ansible and virtual environment

  • Create and activate virtual env (optional)
python3 -m venv --clear ./venv
source ./venv/bin/activate
pip install -U pip setuptools wheel # Optionally
  • Install ansible and tools
pip install -U ansible-core ansible ansible-lint ansible-navigator
  • ./bin/install-ansible-collections-and-roles Installs ansible collections and roles.
  • ./bin/ansible-playbook 00-requirements.yml Installs basic configuration requirements for each node.
  • ./bin/ansible-playbook 01-crio.yml Installs cri-o as container runtime
  • ./bin/ansible-playbook 02-kube-install.yml Installs kubernetes deployment tools (kubeadm, kubelet, kubectl).
  • ./bin/ansible-playbook 03-kube-cluster.yml Setups the kubernetes cluster into the first node kube-node-0.
  • (cni option 1) ./bin/ansible-playbook 04-cilium.yml Setups cilium (cni) networking add-on.
  • (cni option 2) ./bin/ansible-playbook 04-calico.yml Setups calico (cni) networking add-on.
  • ./bin/ansible-playbook 05-kube-join-nodes.yml Joins the rest vms to kubernetes cluster as nodes.

Access cluster

A) From kube-node-0 (multipass shell kube-node-0)

You can access kubernetes cluster through kube-node-0 by opening a shell to it with multipass shell kube-node-0.

multipass shell kube-node-0
kubectl get nodes

B) From host (get .kube/config from kube-node-0)

You can access the cluster directly with kubectl from the host machine by getting the ~/.kube/config from kube-node-0

mkdir -p ~/.kube/
multipass transfer kube-node-0:/home/ubuntu/.kube/config - > ~/.kube/config
kubectl get nodes

kubernetes-cluster's People

Contributors

moukoublen avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

devopswithmike

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.