Kubernetes the hard way on bare metal/VMs — V1.12

An all encompassing series designed for beginners. From VM configuration to K8S cluster building.

Kubernetes Logo

Introduction

Setting up the resources

VMs used in this tutorial.

Networks
Kubernetes Subnet — 192.168.0.0/24 <- This is just my home network
POD_CIDR — 10.200.0.0/16 <- This is the private network the PODS will use.
SERVICE_CIDR — 10.32.0.0/16 <- This is the private network the services will use.

Machines
This PC (Lab machine)
: 192.168.0.2
This is the PC from which most of the commands in this guide will be run when configuring SSl/TLS, configs, running kubectl and more. We’ll copy files & configs to controllers & nodes as required later.
k8s-controller-loadbalancer-maintenance: 192.168.0.101

k8s-controllers-lb-VIP: 192.168.0.210 (aka KUBERNETES_PUBLIC_IP)
k8s-controller-0
: 192.168.0.110
k8s-controller-1: 192.168.0.111
k8s-controller-2: 192.168.0.112
k8s-worker-0: 192.168.0.120
k8s-worker-1: 192.168.0.121
k8s-worker-2: 192.168.0.122

If you wanted to do a single node setup, you could do everything in this guide on the one node; it would work as both a controller and worker.
You could also set up one controller and one worker. The number of each is pretty much limitless.

cat << EOF | sudo tee /etc/hosts
192.168.0.101 k8s-lb
192.168.0.210 k8s-controllers-lb
192.168.0.110 controller-0
192.168.0.111 controller-1
192.168.0.112 controller-2
192.168.0.120 worker-0
192.168.0.121 worker-1
192.168.0.122 worker-2
EOF

Installing packages

mkdir ~/k8s-the-hard-way-bare-metal
cd ~/k8s-the-hard-way-bare-metal
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

Setting up the Kubernetes Cluster

sudo apt install conntrack socat -y

Setting up cfssl & generating configs

Generate kubeconfigs and encryption key

Configuring controllers

Configuring the load balancer

Configuring the workers

Configure remote access

Configuring DNS

Testing the cluster

Conclusion

--

--

Kubernetes Admin & pretend Golang developer. Come find me on YouTube too: https://www.youtube.com/@LearnWithDrew

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store