Skip to content

Deploy a Kubernetes cluster with Kubeadm, Multipass, and Ansible

Notifications You must be signed in to change notification settings

DevOpsWithMike/kubernetes-cluster-multipass-ansible

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to deploy a Kubernetes cluster with Kubeadm, Multipass and Ansible

Create a Kubernetes cluster from scratch with multipass virtual machines and ansible.

To create the vms run the cluster-deploy script in this way: ./cluster-deploy

This script will perform the below steps:

1. Create the ubuntu vms with Multipass

  • Create and start 3 vms (with names control-plane-node, 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.

2. Create and configure Kubernetes cluster with ansible using the following playbooks

  • ./bin/install-ansible-collections-and-roles Installs ansible collections and roles.
  • ./bin/ansible-playbook 00-prequirements.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 and installs Calico networking.

How to access cluster

A) From host

You can access the cluster directly with kubectl, the script took the .kube/config from control-plane-node

kubectl get nodes

B) From control-plane-node (multipass shell control-plane-node)

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

multipass shell control-plane-node
kubectl get nodes

Virtual machine resource configuration

In this repo virtual machines are set with 3 GB RAM and 2 CPUs; you can modify those values in the cluster-deploy script.
The official documentation infact suggests:
2 GiB or more of RAM per machine--any less leaves little room for your apps. At least 2 CPUs on the machine that you use as a control-plane node.


Troubleshooting

If something went wrong during the cluster deployment you can get the following error: HTTP Error 500: Internal Server Error don't be discouraged it may be a momentaneous issue; undeploy the cluster running the script

./cluster-destroy

Check if there are no virtual machines running

multipass list

Deploy again the cluster

./cluster-deploy

About

Deploy a Kubernetes cluster with Kubeadm, Multipass, and Ansible

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%