How To Run Kubernetes on Psychz Networks Bare Metal Servers
Publisher: Psychz Networks, May 11,2021Kubernetes, k8s, or Kube, is an open-source technology platform developed by Google Inc. that automates container operations. Kubernetes simplifies manual processes, which involve deploying, scaling, and managing containerized applications. With the help of Kubernetes, one can cluster (spanning the public, private, and hybrid cloud) a group of hosts running containers together and helps you manage them.
- Order Dedicated Server
- Install Docker
- Enable Docker
- Add Signing Keys
- Add Software Repositories
- Kube Admin Tools
- Assign Hostname
- Initialize Kubernetes
- Deploy Pod Network
- Connecting Worker Node
This guide will walk you through how to install Kubernetes on Ubuntu 18.04.
Step 1: Ordering a Dedicated Server
Psychz Networks offers best hosting solutions with high performing infrastructure to suit your budgets. We offer a wide range of hardware options to choose from and customize your server according to your needs. We give the customers full freedom to choose among a variety of features and customize the server as per their requirement. All you have to do is visit our dedicated hosting page and choose the features from our live inventory. You can choose between Processor, processor type, Hard disk, RAM, Operating System, Control Panels, Port Speed, Bandwidth and various other features.
You can use our live inventory to check the available hardware from the desired location, custom configure your server, check the price, and checkout immediately. Please use the following location to browse our inventory system https://www.psychz.net/dashboard/client/web/order/dedicated-server?processor=&processorBaseFreq=&numberOfCpu=7391&cpuCores=&location=
Note: You will need Min 2 servers (Ubuntu 18.04) and Root or Sudo access to both the servers.
Step 2: Installing Docker
We will first start with updating all the packages of your server. It is a standard practice to update all packages right after a fresh server installation.
1. Update server package list
sudo apt-get update
2. Install Docker
sudo apt-get install docker.io
Follow the above steps on all the servers acting as a node.
3. Check the installation (and version) by entering the following:
docker ––version
Output
Version: 20.10.2
API version: 1.41
Go version: go1.13.8
Git commit: 20.10.2-0ubuntu1~18.04.2
Built: Tue Mar 30 21:24:16 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Step 3: Start and Enable Docker
1. Enable Docker to start at boot
2. Verify Docker is running:
sudo systemctl status docker
Output
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-05-06 23:06:41 PDT; 4 days ago
Docs: https://docs.docker.com
Main PID: 2209 (dockerd)
Tasks: 16
CGroup: /system.slice/docker.service
└─2209 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
To start Docker if it's not running:
sudo systemctl start docker
Perform the above steps on all the other nodes.
Installing Kubernetes
Step 4: Add Kubernetes Signing Key
If you are downloading Kubernetes from a non-standard repository, it is essential to ensure that the software is authentic. You can make use of the signing-key, which you can add by following the steps below.
1. Add a signing key:
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
Perform the above step for each server node.
Step 5: Adding Software Repositories
Kubernetes does not come along with your default repositories. We have to add them separately. To do so, follow the steps below.
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
Repeat the step on each server node.
Step 6: Kubernetes admin Tools
kubeadm (Kubernete Admin) is a tool that helps initialize a cluster. It fast-tracks setup by using community-sourced best practices. Kubelet is the work package, which runs on every node and starts containers. The tool gives you command-line access to clusters.
1. Install Kubernetes tools with the command:
sudo apt-get install kubeadm kubelet kubectl
sudo apt-mark hold kubeadm kubelet kubectl
The process will take about a few minutes to complete
2. Verify the installation with:
kubeadm version
Output
N: Updating from such a repository can't be done securely and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
Repeat the above steps for each server node.
Note: Make sure you install the same version of each package on each machine. Different versions can create instability.
Deploying Kubernetes
We will start by disabling the swap memory on each server. If swap is not disabled, the kubelet service will not begin on the masters and nodes.
sudo swapoff –a
Step 7: Assign Unique Hostname for Each Server Node
Decide which server to set as the master node. Then enter the command:
sudo hostnamectl set-hostname master-node
Next, set a worker node hostname by entering the following on the worker server:
sudo hostnamectl set-hostname worker01
If you have additional worker nodes, use this process to set a unique hostname on each.
Step 8: Initialize Kubernetes on Master Node
Switch to the master server node, and enter the following:
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
Note: Kube-flannel yml file has 10.244.0.0/16 hardcoded as the network value. If you wanted to use another network (for example, the default that kubeadm uses), you would have to modify the yml to match that network. In this sense, it is easier to start kubeadm with 10.244.0.0/16, so the yml works out of the box.
Your Kubernetes control plane has initialized successfully!
To start using your cluster, you need to run the following as a root user.
export KUBECONFIG=/etc/Kubernetes/admin.conf
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml
" with one of the options listed at: https://kubernetes.io/docs/concepts/cluster-administration/addons/
Then you can join any number of worker nodes by running the following on each as root:
Once this command finishes, it will display a kubeadm join message at the end. Make a note of the whole entry. This will be used to join the worker nodes to the cluster.
Next, enter the following to create a directory for the cluster:
kubernetes-master:~$ mkdir -p $HOME/.kube
kubernetes-master:~$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
kubernetes-master:~$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
Step 9: Deploy Pod Network to Cluster
A Pod Network is a way to allow communication between different nodes in the cluster. This tutorial uses the flannel virtual network.
Enter the following:
sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
Allow the process to complete.
Verify that everything is running and communicating:
kubectl get pods --all-namespaces
Step 10: Join Worker Node to Cluster
As indicated in Step 7, you can enter the kubeadm join command on each worker node to connect it to the cluster.
Switch to the worker01 system and enter the command you noted from Step 7:
kubeadm join --discovery-token abcdef.1234567890abcdef --discovery-token-ca-cert-hash sha256:1234..cdef 1.2.3.4:6443
Replace the alphanumeric codes with those from your master server. Repeat for each worker node on the cluster. Wait a few minutes; then, you can check the status of the nodes.
Switch to the master server, and enter:
kubectl get nodes
The system should display the worker nodes that you joined to the cluster.
Congratulations! You have successfully installed Kubernetes on your Ubuntu 18 servers. Your current setup uses multiple servers to communicate back and forth. Kubernetes will allow you to launch and manage Docker containers across multiple servers in the pod.
Please click on the vote button to show your appreciation.