- Blog Categories
- Project Management
- Agile Management
- IT Service Management
- Cloud Computing
- Business Management
- Business Intelligence
- Quality Engineer
- Cyber Security
- Career
- Big Data
- Programming
- Most Popular Blogs
- PMP Exam Schedule for 2024: Check PMP Exam Date
- Top 60+ PMP Exam Questions and Answers for 2024
- PMP Cheat Sheet and PMP Formulas To Use in 2024
- What is PMP Process? A Complete List of 49 Processes of PMP
- Top 15+ Project Management Case Studies with Examples 2024
- Top Picks by Authors
- Top 170 Project Management Research Topics
- What is Effective Communication: Definition
- How to Create a Project Plan in Excel in 2024?
- PMP Certification Exam Eligibility in 2024 [A Complete Checklist]
- PMP Certification Fees - All Aspects of PMP Certification Fee
- Most Popular Blogs
- CSM vs PSM: Which Certification to Choose in 2024?
- How Much Does Scrum Master Certification Cost in 2024?
- CSPO vs PSPO Certification: What to Choose in 2024?
- 8 Best Scrum Master Certifications to Pursue in 2024
- Safe Agilist Exam: A Complete Study Guide 2024
- Top Picks by Authors
- SAFe vs Agile: Difference Between Scaled Agile and Agile
- Top 21 Scrum Best Practices for Efficient Agile Workflow
- 30 User Story Examples and Templates to Use in 2024
- State of Agile: Things You Need to Know
- Top 24 Career Benefits of a Certifed Scrum Master
- Most Popular Blogs
- ITIL Certification Cost in 2024 [Exam Fee & Other Expenses]
- Top 17 Required Skills for System Administrator in 2024
- How Effective Is Itil Certification for a Job Switch?
- IT Service Management (ITSM) Role and Responsibilities
- Top 25 Service Based Companies in India in 2024
- Top Picks by Authors
- What is Escalation Matrix & How Does It Work? [Types, Process]
- ITIL Service Operation: Phases, Functions, Best Practices
- 10 Best Facility Management Software in 2024
- What is Service Request Management in ITIL? Example, Steps, Tips
- An Introduction To ITIL® Exam
- Most Popular Blogs
- A Complete AWS Cheat Sheet: Important Topics Covered
- Top AWS Solution Architect Projects in 2024
- 15 Best Azure Certifications 2024: Which one to Choose?
- Top 22 Cloud Computing Project Ideas in 2024 [Source Code]
- How to Become an Azure Data Engineer? 2024 Roadmap
- Top Picks by Authors
- Top 40 IoT Project Ideas and Topics in 2024 [Source Code]
- The Future of AWS: Top Trends & Predictions in 2024
- AWS Solutions Architect vs AWS Developer [Key Differences]
- Top 20 Azure Data Engineering Projects in 2024 [Source Code]
- 25 Best Cloud Computing Tools in 2024
- Most Popular Blogs
- Company Analysis Report: Examples, Templates, Components
- 400 Trending Business Management Research Topics
- Business Analysis Body of Knowledge (BABOK): Guide
- ECBA Certification: Is it Worth it?
- How to Become Business Analyst in 2024? Step-by-Step
- Top Picks by Authors
- Top 20 Business Analytics Project in 2024 [With Source Code]
- ECBA Certification Cost Across Countries
- Top 9 Free Business Requirements Document (BRD) Templates
- Business Analyst Job Description in 2024 [Key Responsibility]
- Business Analysis Framework: Elements, Process, Techniques
- Most Popular Blogs
- Best Career options after BA [2024]
- Top Career Options after BCom to Know in 2024
- Top 10 Power Bi Books of 2024 [Beginners to Experienced]
- Power BI Skills in Demand: How to Stand Out in the Job Market
- Top 15 Power BI Project Ideas
- Top Picks by Authors
- 10 Limitations of Power BI: You Must Know in 2024
- Top 45 Career Options After BBA in 2024 [With Salary]
- Top Power BI Dashboard Templates of 2024
- What is Power BI Used For - Practical Applications Of Power BI
- SSRS Vs Power BI - What are the Key Differences?
- Most Popular Blogs
- Data Collection Plan For Six Sigma: How to Create One?
- Quality Engineer Resume for 2024 [Examples + Tips]
- 20 Best Quality Management Certifications That Pay Well in 2024
- Six Sigma in Operations Management [A Brief Introduction]
- Top Picks by Authors
- Six Sigma Green Belt vs PMP: What's the Difference
- Quality Management: Definition, Importance, Components
- Adding Green Belt Certifications to Your Resume
- Six Sigma Green Belt in Healthcare: Concepts, Benefits and Examples
- Most Popular Blogs
- Latest CISSP Exam Dumps of 2024 [Free CISSP Dumps]
- CISSP vs Security+ Certifications: Which is Best in 2024?
- Best CISSP Study Guides for 2024 + CISSP Study Plan
- How to Become an Ethical Hacker in 2024?
- Top Picks by Authors
- CISSP vs Master's Degree: Which One to Choose in 2024?
- CISSP Endorsement Process: Requirements & Example
- OSCP vs CISSP | Top Cybersecurity Certifications
- How to Pass the CISSP Exam on Your 1st Attempt in 2024?
- Most Popular Blogs
- Best Career options after BA [2024]
- Top Picks by Authors
- Top Career Options & Courses After 12th Commerce in 2024
- Recommended Blogs
- 30 Best Answers for Your 'Reason for Job Change' in 2024
- Recommended Blogs
- Time Management Skills: How it Affects your Career
- Most Popular Blogs
- Top 28 Big Data Companies to Know in 2024
- Top Picks by Authors
- Top Big Data Tools You Need to Know in 2024
- Most Popular Blogs
- Web Development Using PHP And MySQL
- Top Picks by Authors
- Top 30 Software Engineering Projects in 2024 [Source Code]
- More
- Tutorials
- Practise Tests
- Interview Questions
- Free Courses
- Agile & PMP Practice Tests
- Agile Testing
- Agile Scrum Practice Exam
- CAPM Practice Test
- PRINCE2 Foundation Exam
- PMP Practice Exam
- Cloud Related Practice Test
- Azure Infrastructure Solutions
- AWS Solutions Architect
- AWS Developer Associate
- IT Related Pratice Test
- ITIL Practice Test
- Devops Practice Test
- TOGAF® Practice Test
- Other Practice Test
- Oracle Primavera P6 V8
- MS Project Practice Test
- Project Management & Agile
- Project Management Interview Questions
- Release Train Engineer Interview Questions
- Agile Coach Interview Questions
- Scrum Interview Questions
- IT Project Manager Interview Questions
- Cloud & Data
- Azure Databricks Interview Questions
- AWS architect Interview Questions
- Cloud Computing Interview Questions
- AWS Interview Questions
- Kubernetes Interview Questions
- Web Development
- CSS3 Free Course with Certificates
- Basics of Spring Core and MVC
- Javascript Free Course with Certificate
- React Free Course with Certificate
- Node JS Free Certification Course
- Data Science
- Python Machine Learning Course
- Python for Data Science Free Course
- NLP Free Course with Certificate
- Data Analysis Using SQL
How To Install Kubernetes on Ubuntu [Step-By-Step Guide]
Updated on 27 May, 2021
12.34K+ views
• 7 min read
Table of Contents
Kubernetes is a free and open-source container management framework providing a forum for automated deployment, scaling, and container operations across host clusters. You can use your hybrid, local and public cloud infrastructure free of charge with Kubernetes to operate your organisation's deployment tasks.
In this tutorial, we will illustrate the installation of Kubernetes in Ubuntu and deploy Kubernetes in a two-node Ubuntu cluster. Meanwhile, read about how to Install Jenkins on Ubuntu.
Kubernetes (or, as is informally known, the K8s) is an open-source system which is used for containerized systems automation, scaling and management. Some of the advantages of Kubernetes include:
- Automatic installation and machine rollback: Kubernetes updates an interface progressively and monitors its health to ensure that all instances are not destroyed simultaneously. If something goes wrong, Kubernetes will reverse changes for us.
- Load balancing and service exploration: The Pods can be loaded by Kubernetes and can distribute IP addresses and DNS names for the collection of Pods.
- Repository orchestration: Users can install local or cloud storage systems automatically.
- Container automatic packaging: Kubernetes distributes containers automatically according to their resource specifications and other restrictions. The greater the allocation of the container and its resources, the better the device efficiency.
- Use of Kubernetes packages: Kubernetes can handle your package configurations, in addition to its services.
- Self-recovery: Kubernetes tracks the container situation and can substitute it with new containers if anything goes wrong. Containers are also recreated that are already destroyed.
- Kubeadm: automates Kubernetes installation and setup, including the API, Controller Manager and Kube DNS server.
What is Kubeadm?
Kubeadm automates Kubernetes components including API servers, Controller Manager and Kube DNS installation and setup. However, it does not build users or manage the installation and configuration of operating system dependencies.
A configuration management tool like Ansible or SaltStack can be used for these preliminary tasks. The use of these tools makes it much easier and more feasible to create new clusters or to recreate existing clusters.
Prerequisites:
Hardware Requirement:
- For Master:
- RAM: 2 GB
- CPU: 2 Cores
- For Slave:
- RAM: 1 GB
- CPU: 1 Core
- For Master:
Software Requirement:
- 2 or more Ubuntu 18.04 servers
- Access to a sudo or root privileged user account on each device
- The apt package manager.
Swap disabled. You MUST disable swap in order for the kubernetes to work properly.
The commands and procedures specified in this article were executed on an Ubuntu 18.04 LTS framework. You can open all commands through either the Dash, or the Ctrl+Alt+T shortcut, as we will use the Ubuntu command line, the Terminal.
The two-node cluster will consist of a Master Node and Slave Node. These two nodes must be installed with Kubernetes.
Master Node: The master Node is responsible for the administration of the cluster state (a node in Kubernetes refers to a server).
Slave Node: The servers on which your workloads (i.e., container applications and services) are running are worker nodes or slave nodes. When delegated, the workload is continued by a worker even though the master falls when the schedule is complete. By adding workers, the capacity of a cluster can be increased.
Follow the steps below to install Kubernetes on the two nodes in Ubuntu.
Installation Procedure:
Step 1: Installing Docker
On both master and slave nodes, the following must be performed.
1. Docker's installation is the first thing to do. Login into the server to do this and export the command:
$ sudo apt-get install docker.io
In order to continue the installation, you will be asked to choose a Y/N option. Please enter Y to continue, then press Enter and your machine will be configured with Docker.
2. The installation can also be checked by using the following instruction, and the Docker version number:
$ docker --version
You must add your user to the docker community once Docker is installed (otherwise you must carry out all the sudo docker commands which could lead to security problems).
3. Use the command to connect your user to the docker group:
$ sudo usermod -aG docker $USER
Log out and log in, so that adjustments come into effect.
4. Launch and activate the docker daemon with the commands:
$ sudo systemctl start docker
$ sudo systemctl enable docker
Step 2: Installing Kubernetes
Now, install Kubernetes on both the machines. As Kubernetes is downloaded from a non-standard repository, it is essential for the software to be authentic. This is achieved with the addition of a signing key.
1. Add the GPG Kubernetes key with the command:
$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
2. If curl is not installed on your system, then you can install it with the commands:
$ sudo apt install curl
In order to continue the installation, you will be asked to choose a Y/N option. Please enter Y, then press Enter. You will then install the Curl utility on your device.
3. Sometimes Kubernetes is not added in default repository. To add the Xenial Kubernetes repository, run the following command on both nodes:
$ sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
4. Installing Kubeadm (Kubernetes Admin) on both nodes by command is the final stage of the installation process:
$ sudo apt-get install kubeadm kubelet kubectl
Run the below command to check whether the versions of the components installed are compatible with each other
sudo apt-mark hold kubeadm kubelet kubectl
In order to continue the installation, you will be asked to choose a Y/N option. Please enter Y to continue, then press Enter. Kubeadm will then be installed on your device.
5. You can also check Kubeadm's version number and verify the installation using the following command:
$ kubeadm version
Repeat for each server node.
Ensure that on each computer you install the same package version. Instability can arise from various versions. This mechanism also prevents Kubernetes from being updated automatically.
Step 3: Running and Deploying Kubernetes
1. Disable swap memory:
You can deactivate the swap memory in both nodes because Kubernetes does not work properly on a swap-based device. Run the following command to disable swap memory on both nodes:
$ sudo swapoff -a
2. Unique hostnames to each node:
In order to facilitate things, each server needs to be assigned a specific hostname.
- To assign it a unique hostname, run the following command in the master node:
$ sudo hostnamectl set-hostname master-node
- To assign it a unique hostname, run the following command in the slave node:
$ sudo hostnamectl set-hostname slave-node
In case of additional worker nodes, use the command to set a unique hostname on each.
3. Initialize Kubernetes on Master Node:
Switch to the master server node and type:
$ sudo kubeadm init –pod-network-cidr=192.168.43.211/24
You can find pod network CIDR in /etc/kubernetes/manifests/kube-controller-manager.yaml
sudo grep cidr /etc/kubernetes/manifests/kube-*
Upon completion of the command, a kubeadm join message is displayed at the end. Depending on your Internet connection, the process can take a minute or more. Make a note of the entire entry. This is used for joining the cluster's nodes.
- You need to run the following as a daily user to start using your cluster:
$ mkdir -p $HOME/ .kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$sudo chown $(id -u):$(id -g) $HOME/.kube/config
- By running the following command, you can check the status of the master node:
$ kubectl get nodes
4. Deploy Pod Network to Cluster:
A pod network is a communication medium between network nodes.
- This article uses the following command to deploy a Flannel pod network in our cluster:
$ sudo kubectl apply -f https://raw.githubusercontent.com/coreos/ flannel/master/Documentation/kube-flannel.yml
- To display the network status, use the following command:
$ kubectl get pods --all-namespaces
5. Add the slave node to form a cluster:
you can enter the kubeadm join command on each slave node to connect it to the cluster.
- Run the command that you created when you initialized Kubernetes on your master node at the slave node:
$ sudo kubeadm join 192.168.100.6:6443 --token 06tl4c.oqn35jzecidg0r0m --discovery-token-ca-cert-hash sha256:c40f5fa0aba6ba311efcdb0e8cb637ae0eb8ce27b7a03d47be6d966142f2204c
- So now you run the command on the master node, it confirms that your device has two nodes, the Master node and Server nodes.
$ sudo kubectl get nodes
This shows that the two-node cluster now operates via the container management system in Kubernetes.
4) Uninstalling Kubernetes
1. Clear Pods
Using this command, you can delete all the nodes:
$ kubectl delete node --all
2. Remove kubeadm completely
$ sudo apt-get purge kubeadm kubectl kubelet kubernetes-cni kube*
$ sudo apt-get autoremove
Learn more about the core concepts of Kubernetes Components, Architecture, Pods and Deployment with Kubernetes Training Course.
Conclusion:
You should now have Kubernetes installed on Ubuntu, after following carefully the steps stated in this article.
This network uses many servers for back-and-forth communication. You can launch and manage Docker containers on several servers on the pod from Kubernetes.
The Kubernetes container management system installed on two Ubuntu nodes was discussed in this post. We then developed and deployed Kubernetes to a single two-node cluster. This clustered network is now available for use,and you can use any service like a Nginx server or Apache container.