PART 1: Creating a single Control-Plane cluster with kubeadm and creating a Calico Pod Network
kubeadm Tool:
The kubeadm tool helps you bootstrap a minimum viable Kubernetes cluster that conforms to best practices.
The kubeadm tool is good if you need:
Before you begin, to follow this guide, you need:
Installing runtime
By default, Kubernetes uses the Container Runtime Interface (CRI) to interface with your chosen container runtime.
If you don't specify a runtime, kubeadm automatically tries to detect an installed container runtime by scanning through a list of well known Unix domain sockets.
The kubeadm tool is good if you need:
- A simple way for you to try out Kubernetes, possibly for the first time.
- A way for existing users to automate setting up a cluster and test their application.
- A building block in other ecosystem and/or installer tools with a larger scope.
Before you begin, to follow this guide, you need:
- One or more machines running a deb/rpm-compatible Linux OS; for example: Ubuntu or CentOS.
- 2 GB 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.
- Full network connectivity among all machines in the cluster. You can use either a public or a private network.
- Check required ports. (if internal network, do not need to configure ports)
- Control-plane node(s).
Installing runtime
By default, Kubernetes uses the Container Runtime Interface (CRI) to interface with your chosen container runtime.
If you don't specify a runtime, kubeadm automatically tries to detect an installed container runtime by scanning through a list of well known Unix domain sockets.
|
Runtime |
Path to Unix domain socket |
|
Docker |
/var/run/docker.sock |
|
Containerd |
/run/containerd/containerd.sock |
|
CRI-O |
/var/run/crio/crio.sock |
Installing kubeadm, kubelet and kubectl
· kubeadm:
the command to bootstrap the cluster.
· kubelet:
the component that runs on all of the machines in your cluster and does things like starting pods and containers.
· kubectl:
the command line utility to talk to your cluster.
Infrastructure
Example: 3 Virtual Machines (1 Master Node and 2 Worker Nodes). There must be network connectivity among these VMs.
Installation of kubeadm on Ubuntu (Both on Master and Worker Nodes)
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
Infrastructure
Example: 3 Virtual Machines (1 Master Node and 2 Worker Nodes). There must be network connectivity among these VMs.
Installation of kubeadm on Ubuntu (Both on Master and Worker Nodes)
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get update
apt install -qq -y kubeadm=1.21.0-00 kubelet=1.21.0-00 kubectl=1.21.0-00
sudo apt-mark hold kubelet kubeadm kubectl
OPTIONAL
So in particular case docker was using the groupfs which I changed to systemd
Create the file as:
vim /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
systemctl restart docker
systemctl restart docker
systemctl status docker
Installation of kubeadm on RHEL/CentOS (Both on Master and Worker Nodes)
In case if you are using CentOS/RHEL
Installation of kubeadm on RHEL/CentOS (Both on Master and Worker Nodes)
In case if you are using CentOS/RHEL
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg \
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kubelet kubeadm kubectl
EOF
# Set SELinux in permissive mode (effectively disabling it)
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg \
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kubelet kubeadm kubectl
EOF
# Set SELinux in permissive mode (effectively disabling it)
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
sudo systemctl enable --now kubelet
Create The Master Server/Control-Plane & Calico Pod Network
On master machine run the below command
1. initialize kubeadm and dont forget to change the master server IP! with a CIDR range which you can define yourself.
kubeadm init --apiserver-advertise-address=<<Master ServerIP>> --pod-network-cidr=192.168.0.0/16
2. mkdir -p $HOME/.kube
3. sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
4. sudo chown $(id -u):$(id -g) $HOME/.kube/config
5. kubeadm token create --print-join-command (Copy the token from master to agent/worker nodes (remember to swapoff -a))
5.2 Alternatively if you want to auto-off swapoff, you can type this:
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
6. Install Calico
6.1 kubectl create -f https://docs.projectcalico.org/v3.18/manifests/calico.yaml
6.2 kubectl get nodes (Wait for above command and run again it may take a minute or so to get all the nodes in ready state.)
OPTIONAL (Do not run below commands if Calico is configured properly by following the above steps)
6.1 kubectl create -f https://docs.projectcalico.org/v3.18/manifests/calico.yaml
6.2 kubectl get nodes (Wait for above command and run again it may take a minute or so to get all the nodes in ready state.)
OPTIONAL (Do not run below commands if Calico is configured properly by following the above steps)
Install the Tigera Calico operator and custom resource definitions.
kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml
Install Calico by creating the necessary custom resource. For more information on configuration options available in this manifest, see the installation reference.
kubectl create -f https://docs.projectcalico.org/manifests/custom-resources.yaml
Note: Before creating this manifest, read its contents and make sure its settings are correct for your environment. For example, you may need to change the default IP pool CIDR to match your pod network CIDR.
Confirm that all of the pods are running with the following command.
watch kubectl get pods -n calico-system
Wait until each pod has the STATUS of Running.
Note: The Tigera operator installs resources in the calico-system namespace. Other install methods may use the kube-system namespace instead.
Remove the taints on the master so that you can schedule pods on it.
kubectl taint nodes --all node-role.kubernetes.io/master-
It should return the following.
node/<your-hostname> untainted
Confirm that you now have a node in your cluster with the following command.
kubectl get nodes -o wide
It should return something like the following.
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME <your-hostname> Ready master 52m v1.12.2 10.128.0.28 <none> Ubuntu 18.
No comments:
Post a Comment