githubEdit

Kubeadm Deploy

Deploy Kubernetes cluster with kubeadm and containerd on Ubuntu

Step-by-step guide to deploying a Kubernetes cluster using kubeadm with containerd as the container runtime on Ubuntu.

Environment Preparation

1. Multipass Virtual Machine Creation

# Generate key pair
ssh-keygen -t rsa -b 4096 -f ~/k8s_rsa -C k8s

# Create Master node
multipass launch -c 2 -m 2G -d 20G -n master --cloud-init - << EOF
ssh_authorized_keys:
- $(cat ~/.ssh/k8s_rsa.pub)
EOF

# Create Node nodes
multipass launch -c 1 -m 2G -d 20G -n node1 --cloud-init - << EOF
ssh_authorized_keys:
- $(cat ~/.ssh/k8s_rsa.pub)
EOF

multipass launch -c 1 -m 2G -d 20G -n node2 --cloud-init - << EOF
ssh_authorized_keys:
- $(cat ~/.ssh/k8s_rsa.pub)
EOF

--cloud-init: Import locally generated public key into the initialization system, enabling passwordless SSH

2. Host and Network Planning

Host IP

Hostname

Host Config

Node Role

192.168.64.4

master1

2C/2G

master node

192.168.64.5

node1

1C/1G

node

192.168.64.6

node2

1C/1G

node

Subnet

CIDR Range

nodeSubnet

192.168.64.0/24

PodSubnet

172.16.0.0/16

ServiceSubnet

10.10.0.0/16

3. Software Versions

Software

Version

Operating System

Ubuntu 20.04.4 LTS

Kernel Version

5.4.0-109-generic

containerd

1.5.10-1

kubernetes

v1.23.2

etcd

v3.5.1

CNI Plugin (calico)

v3.18

Cluster Configuration (Execute on All Nodes)

1. Node Initialization

  • Hostname and host resolution

  • Disable firewall and swap partition

Why does K8s cluster installation require disabling swap? Swap must be disabled, otherwise kubelet cannot start, which prevents the K8s cluster from starting. Additionally, if kubelet uses swap for data exchange, it significantly impacts performance.

  • Synchronize time and timezone

  • Kernel module loading and configuration

  • Configure passwordless login (execute on master node, optional)

2. Container Runtime Installation

Build Cluster

1. Component Installation (Execute on All Nodes)

2. Initialize Master Node

  • Execute on Master Node

  • Execute on Node

3. Install CNI Network Plugin (calico)

calico plugin official page: https://projectcalico.docs.tigera.io/getting-started/kubernetes/quickstartarrow-up-right

4. Cluster Deployment Verification

Kubernetes Dashboard

Kubernetes Native Dashboard

Official documentation: https://kubernetes.io/zh/docs/tasks/access-application-cluster/web-ui-dashboard/arrow-up-right

K9S Cluster Management Tool

Official documentation: https://k9scli.io/arrow-up-right

Reference:

Last updated