0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ConohaVPSでKubernetes Clusterを構築

Last updated at Posted at 2023-08-10

Update to the latest

sudo apt update
sudo apt -y full-upgrade
shutdown -r now

Load br_netfilter module

modprobe br_netfilter
lsmod | grep br_netfilter

Install pre-requisit

cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF

sudo modprobe overlay
sudo modprobe br_netfilter

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF

Apply sysctl params without reboot

sudo sysctl --system

Install containerd

apt -y install containerd
mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
systemctl restart containerd

Install kubeadm, kubelet, kubectl

sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg

echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list

sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

Set host name

sudo hostnamectl set-hostname <New host name>

Make swapp off

swapoff -a
sudo ufw allow 6443/tcp
(sudo ufw allow from <other node IPs>)

Execute only on the controlplane node

kubeadm init --apiserver-advertise-address=<controlplane IP address> --pod-network-cidr=10.244.0.0/16

Execute only on worker nodes

kubeadm join xxxx

Execute only on the controlplane node

mkdir -p \$HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf \$HOME/.kube/config
sudo chown \$(id -u):\$(id -g) \$HOME/.kube/config

export KUBECONFIG=/etc/kubernetes/admin.conf

Deploy network plugin

kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?