How to Install Kubernetes(k8s) with Minikube on CentOS 8
Abstract: get its url by running the beneath command. [[email protected] ~]# minikube service test-minikube --url[[email protected] ~]# install minikube /usr/lo
Kubernetes, also known as k8s or simply as Kube, is an open-source container orchestration platform used for the automation scaling and deployment of containers. Minikube is a cross-platform and open-source tool that makes it possible for you to deploy a single-node Kubernetes cluster on your local machine or inside a virtual machine (vm). In this topic, you will learn how to install Kubernetes with Minikube on a CentOS 8 VM.
Prerequisites of MiniKube- A copy of freshly installed CentOS 8 (with GUI) VM
- Minimum of 2 GB RAM and 2 vCPUs
- 20 GB hard disk space
- Root privileges
- A stable internet connection
With all the prerequisites met, it’s time now to roll up our sleeves and get our hands dirty.
Step 1) Install Updates and Disable SELinuxFirst and foremost, we are going to install the latest available updates necessary for the installation to proceed without any hitches. Run the following dnf command,
[[email protected] ~]# dnf update -y
Next, execute the commands below to disable SELinux,
[[email protected] ~]# setenforce 0 [[email protected] ~]# sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinuxStep 2) Install Docker and Enable its Service
Since we are going to deploy a local Kubernetes cluster with MiniKube inside a VM. So, Install Docker CE on your CentOS 8 VM using the following commands,
[[email protected] ~]# dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo [[email protected] ~]# [[email protected] ~]# dnf install docker-ce --nobest -y
Run following systemctl commands to start and enable docker service,
[[email protected] ~]# systemctl start docker [[email protected] ~]# systemctl enable docker
Set the following firewall rules using firewall-cmd command,
[[email protected] ~]# firewall-cmd --zone=public --add-masquerade --permanent [[email protected] ~]# firewall-cmd --reload
Install 「conntrack」 package using following command, conntrack is the dependency for minikube setup,
[[email protected] ~]# dnf install conntrack -y
Note: Kubernetes using MiniKube can be installed on a local machine or server but for that it requires a hypervisor such as KVM or VirtualBox.
Step 3) Install Kubectl ManuallyKubectl is a command-line tool which interacts with Kubernetes cluster via APIs. Using kubectl we deploy our applications as deployment. By default, kubectl is not included in CentOS 8 package repositories. Therefore, we are going to manually install it using beneath commands,
[[email protected] ~]# curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl [[email protected] ~]# chmod +x ./kubectl [[email protected] ~]# mv ./kubectl /usr/local/bin/kubectl [[email protected] ~]# kubectl version --client
Output of above commands would be something like below,
Step 4) Install and Start MinikubeAfter installing the kubectl, let’s install minikube using the following commands,
[[email protected] ~]# curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 [[email protected] ~]# chmod +x minikube [[email protected] ~]# mkdir -p /usr/local/bin/ [[email protected] ~]# install minikube /usr/local/bin/
To start Minikube run the command:
[[email protected] ~]# minikube start --driver=none
As we can see above output, minikube command has downloaded and started the docker containers for setting up single node Kubernetes cluster.
Run below minikube command to verify the status of your local Kubernetes cluster,
[[email protected] ~]# minikube status host: Running kubelet: Running apiserver: Running kubeconfig: Configured [[email protected] ~]# minikube ip 192.168.29.216 [[email protected] ~]#
To stop a Kubernetes cluster, execute,
[[email protected] ~]# minikube stop
Execute the 「kubectl cluster-info」 command to view cluster information,
[[email protected] ~]# kubectl cluster-info
Run below command to view cluster nodes,
[[email protected] ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION minikube-centos8 Ready master 144m v1.18.0 [[email protected] ~]#Step:6) Test and Verify Kubernetes Cluster
To test Kubernetes cluster, let try to create k8s deployment using echoserver image, it is equivalent to http web server and expose it as a service on port 8080,
[[email protected] ~]# kubectl create deployment test-minikube --image=k8s.gcr.io/echoserver:1.10 deployment.apps/test-minikube created [[email protected] ~]#
To access test-minikube deployment, expose it as service, run the following command,
[[email protected] ~]# kubectl expose deployment test-minikube --type=NodePort --port=8080 service/test-minikube exposed [[email protected] ~]#
Run below kubectl command to get pod information for above created deployment,
[[email protected] ~]# kubectl get pod NAME READY STATUS RESTARTS AGE test-minikube-f4df69575-fkxdh 1/1 Running 0 3m29s [[email protected] ~]#
To access service, get its url by running the beneath command.
[[email protected] ~]# minikube service test-minikube --url http://192.168.29.216:31356 [[email protected] ~]#
Now type above url in your web browser,
Great, it means our Kubernetes cluster is working fine. In the next step, let’s try to deploy and access Kubernetes dashboard
Step 7) Enable and Access Kubernetes DashboardKubernetes ships with a dashboard that allows you to manage your cluster. In Minikube, dashboard has been added as an addons.To view all the addons that come with minikube run:
[[email protected] ~]# minikube addons list
To activate the Kubernetes dashboard, execute below command,
[[email protected] ~]# minikube dashboard --url
This will give us a dashboard url , copy and paste it on minikube system’s web browser.
And that’s just about it. We have managed to successfully install Kubernetes with Minikube on CentOS 8. You are welcome to share your feedback and comments.
Also Read : How to Configure NFS based Persistent Volume in Kubernetes