Skip to main content

How to create a minikube single node cluster for learning Kubernetes



In this post I will explain how to setup a minikube single node kubernetes cluster using AWS EC2 instance which would help anyone who is trying to learn kubernetes and also help them to gain practical knowledge in kubernetes by running kubernetes commands, creating kubernetes objects etc.

Minikube is a single node kubernetes cluster which means a kubernetes cluster with only one node that is a single VM.

Minikube is only used for learning purposes and it is not an alternative for a real kubernetes cluster and should not be used for development and production usage.

In this example I have launched an AWS EC2 instance with below configuration where I will install minikube and related tools.

AWS EC2 Instance Configuration
AMI: Ubuntu Free tier eligible 64 bit
Instance type : t2-large ( For me t2-small or t2-micro is giving performance issues due to less memory)

Once the EC2 instance is up and running, login to the instance using below command on terminal. If you are using windows OS then use Putty or git bash or any tools like that.

ssh -i "my.pem" ubuntu@xxxxx.ca-central-1.compute.amazonaws.com

Step 1: Install kubectl
kubectl is a tool that you can use to execute kubernetes commands on the cluster to create and
monitor resources. Run below 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

Provide execute permission:
chmod +x kubectl

Move it to /usr/local/bin:
sudo mv kubectl /usr/local/bin/kubectl

Step 2: Install Docker runtime 
kubernets is a container orchestration tool and we would need to install a container run time such as docker or rkt etc. Here we are going to install docker.

Install Docker:
sudo apt-get update && sudo apt-get install docker.io -y

Verify Docker:
docker --version

Step 3: Install Minikube
Run below command:
curl -LO minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube

Move it to /usr/local/bin:
sudo install minikube /usr/local/bin/

Start minikube:
sudo minikube start --driver=none

If you get an error as below,
The none driver requires conntrack to be installed for kubernetes version 1.18.0


Install conntrack:
sudo apt-get -qq -y install conntrack

Try to Start minikube again:
sudo minikube start --driver=none


If successfull then you will see a message as below:
Done! kubectl is now configured to use "minikube"

Now verify our minikube cluster by running a kubectl command:
sudo kubectl get nodes

If everything configured correctly then you will see:
ubuntu@XXX:~$ sudo kubectl get nodes

NAME STATUS ROLES AGE VERSION
ip-172-31-10-105 Ready master 40m v1.18.0

Step 4: Create and verify kubernetes deployment
Create a deployment with a pod running nginx container:
sudo kubectl create deployment nginx --image=nginx

Verify the deployment and all resources created:
kubectl get all

ubuntu@ip-172-31-10-105:~$ k get all

NAME READY STATUS RESTARTS AGE
pod/nginx-f89759699-zzfj9 1/1 Running 0 72

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 52m

NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx 1/1 1 1 72

NAME DESIRED CURRENT READY AGE
replicaset.apps/nginx-f89759699 1 1 1 72s

If you want to save some typing then create an alias for "sudo kubectl":
alias k=sudo kubectl

then instead of "sudo kubectl" type just k as below:
k get all

ubuntu@ip-172-31-10-105:~$ k get all

NAME READY STATUS RESTARTS AGE
pod/nginx-f89759699-zzfj9 1/1 Running 0 4m58s

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 56m

NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx 1/1 1 1 4m58s

NAME DESIRED CURRENT READY AGE
replicaset.apps/nginx-f89759699 1 1 1 4m58s


Now your learning environment has been setup. Have a good learning experience! Please let me know your comments.

Comments

  1. Thanks for sharing this wonderful content.its very useful to us.
    I gained many unknown information, the way you have clearly explained is really fantastic.
    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    hadoop training in chennai

    hadoop training in bangalore

    ReplyDelete
  2. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! online outsourced bookkeeping services

    ReplyDelete
  3. The look rightly terrific. All these mini advice happen to be created implementing massive amount past working experience. I'd like to see the whole works very much. Smart contract development Pune

    ReplyDelete
  4. This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post.
    Custom MLM Software jaipur

    ReplyDelete
  5. Great Post…This Article is very unique. Thanks for sharing and very informative!!!MLM Software Development Company Mumbai

    ReplyDelete
  6. i really try these steps its very helpful to me , thanks for this amazing blog .... ERC20 TOKEN DEVELOPMENT COMPANY IN CHICAGO

    ReplyDelete
  7. In the event that your business has any online parts (like a site), SEO is urgent to the progressing achievement of your business.SEO Antwerpen

    ReplyDelete
  8. Great Post…This Article is very unique. Thanks for sharing and very informative!!gupt rog in Allahabad

    ReplyDelete
  9. Really an awesome post.I wondered by reading this post.gupt rog doctors in allahabad

    ReplyDelete
  10. i really try these steps its very helpful to me , thanks for this amazing blog ...sexologist Doctors

    ReplyDelete
  11. Excellent post. I certainly appreciate this website. Keep writing!top 10 sexologist doctors in allahabad

    ReplyDelete
  12. Your Blog is very nice.
    Wish to see much more like this. Thanks for sharing your information
    Buy Wireless Networking Accessories Online at Best Prices

    ReplyDelete
  13. iMyFone Filme Crack is a super easy-to-use video creation tool to create professional-looking videos. It provides you with plentiful effect .Gilisoft Video Editor Registration Code

    ReplyDelete

Post a Comment

Popular posts from this blog

How to format and install macOS in your old Macbook/ iMac

 You can follow these steps to install a mac OS on an old Mac book following these steps. Here I assume that you have the actual bootable CD for the OS for installation. 1. Restart the laptop 2. Press Command + R key until it shows recovery mode 3. Open Disk Utilities 4. Select the hard drive and try to partition the drive. For example I have created a partition called Partition1 5. Insert bootable CD and restart the laptop. When option comes choose to boot from the CD. 6. Choose partition1 as the place to install the OS 7. Continue the installation process. 8. Once installation is completed then it might need to restart for further updates. 9. Most of the times a more recent compatible version of the OS might be available. In order to upgrade to the more latest compatible OS follow below steps. 11. Find the latest compatible version of OS. 12. Go to apple support sites and manually download the image and click to install. 13. Follow installation instructions and this would upgrade you

log4j - How to write log to multiple log files using log4j.properties

In Java applications some times you may need to write your log messages to specific log files with its own specific log properties. If you are using log4j internally then first step that you need to do is to have a proper log4j.properties file. Below example shows 2 log4j appenders which write to 2 different log files, one is a debug log and another one is a reports log. Debug log file can have all log messages and reports log can have log messages specific to reporting on say splunk monitoring. # Root logger option log4j.rootLogger=ALL,STDOUT,debugLog log4j.logger.reportsLogger=INFO,reportsLog log4j.additivity.reportsLogger=false     log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout log4j.appender.STDOUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %C:%L - %m%n     # Direct log messages to a log file log4j.appender.debugLog=org.apache.log4j.RollingFileAppender log4j.appender.debugLo