Running Kubernetes on Linux Cloud VM
Hi Scholars, in this post I will help you setup your kubernetes work environment in Linux Cloud VM like (AWS EC2 instance or AZURE Container).
Throughout this blog, I’ll give some reference of the documentation so that you, if in future something change, you can directly refer the docs for latest update.
So, without wasting our time, let’s beginTo setup kubernetes environment, we need to install the following in our cloud VM:
1. Docker : docker-ce:18.06 or above
2. Kubectl
3. Minikube
Let’s talk about each of them and install them accordingly:
1. DOCKER
Docker is a tool that is designed to benefit both developers and system administrators, making it a part of many DevOps (developers + operations) toolchains.
Docker is a PaaS (Platform as a Service) product that uses OS-level virtualization. It delivers applications in containers, which bundles their own software, libraries and configuration files.
Let’s get our hands dirty by installing Docker on our AWS EC2 instance (you can use any other cloud VM).
STEP 1. Setup your Docker environment
0. Uninstall Old Version of Docker Container
$ sudo apt-get remove docker docker-engine docker.io containerd runc
1. Update the
apt
package index and install packages to allowapt
to use a repository over HTTPS:
$ sudo apt-get update$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
2. Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
2.1 Verify that you now have the key with the fingerprint
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
, by searching for the last 8 characters of the fingerprint.
$ sudo apt-key fingerprint 0EBFCD88
3. Use the following command to set up the stable repository. To add the nightly or test repository, add the word
nightly
ortest
(or both) after the wordstable
in the commands below. Learn about nightly and test channels.
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
Install Docker Engine
- Update the
apt
package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
Verify that Docker Engine is installed correctly by running the
hello-world
image.
$ sudo docker run hello-world
For more information on how to install docker please refer to the documentation of docker https://docs.docker.com/engine/install/ubuntu/
2. KUBECTL
kubectl is a binary used to access and manage any Kubernetes cluster, see Overview of kubectl. It is installed separately from Minikube. If we install kubectl after the Minikube installation, we may see warnings during the Minikube initialization — safe to disregard for the time being, but do keep in mind that we will have to install kubectl to be able to manage the Kubernetes cluster.
STEP 2. Install Kubectl on Linux Cloud VM
1. Download the latest release with the command:
$ curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
2. Make the kubectl binary executable.
$ chmod +x ./kubectl
3. Move the binary in to your PATH.
$ sudo mv ./kubectl /usr/local/bin/kubectl
4. Test to ensure the version you installed is up-to-date:
$ kubectl version --client
You can refer to the installation documentation of Kubectl at https://kubernetes.io/docs/tasks/tools/install-kubectl/
3. MINIKUBE
Minikube is Single Node Local K8S Cluster. It is installed and runs directly on a Linux, macOS, or Windows workstation. It is generally installed on Type 2 Hypervisor like,
- On macOS VirtualBox, HyperKit, or VMware Fusion
- On Windows VirtualBox or Hyper-V
- On Linux VirtualBox or KVM
NOTE: Minikube supports a — driver=none (with root permission or use — driver=docker as non root user (new)) option that runs the Kubernetes components directly on the host OS and not inside a VM. With this option a Docker installation is required and a Linux OS on the local workstation, but no hypervisor installation. If you use — vm-driver=none, be sure to specify a bridge network for Docker. Otherwise, it might change between network restarts, causing loss of connectivity to your cluster.
0. Before you begin check if virtualization is supported on Linux, run the following command and verify that the output is non-empty:
$ grep -E --color 'vmx|svm' /proc/cpuinfo
1. Download a stand-alone binary and give it executable permission
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
&& chmod +x minikube
2. Add the Minikube executable to your path
$ sudo mkdir -p /usr/local/bin/
$ sudo install minikube /usr/local/bin/
3. Start minikube and confirm installation
$ minikube start --driver=docker
$ minikube status
4. Test if kubectl is connected to minikube or not by creating a Pod with nginx docker image
$ kubectl run nginx --image=nginx
Here is original documentation of minikube intallation https://kubernetes.io/docs/tasks/tools/install-minikube/
Hope you were able to setup your kubernetes environment on Linux Cloud VM. If you liked this post and if it helped you then please give it a clap.
Happy Learning