How to set up Kubernetes in Docker

Last updated on May 27 2022
Raigiri Patil

Table of Contents

How to set up Kubernetes in Docker

Docker – Kubernetes Architecture

Kubernetes is an orchestration framework for Docker containers which helps expose containers as services to the outside world. For example, you can have two services − One service would contain nginx and mongoDB, and another service would contain nginx and redis. Each service can have an IP or service point which can be connected by other applications. Kubernetes is then employed to manage these services.

The subsequent diagram shows in a simplistic format how Kubernetes works from an architecture point of view.

Page 1 Image 2 5
architecture

The minion is the node on which all the services run. You can have many minions running at one point in time. Each minion will host one or more POD. Each POD is like hosting a service. Each POD then contains the Docker containers. Each POD can host a different set of Docker containers. The proxy is then employed to control the exposing of these services to the outside world.

Kubernetes has several components in its architecture. The role of each component is explained below &mius;

  • etcd − This component is a highly available key-value store that’s employed for storing shared configuration and service discovery. Here the various applications will be able to connect to the services via the discovery service.
  • Flannel − This is a backend network which is required for the containers.
  • kube-apiserver − This is an API which can be employed to orchestrate the Docker containers.
  • kube-controller-manager − This is employed to control the Kubernetes services.
  • kube-scheduler − This is employed to schedule the containers on hosts.
  • Kubelet − This is employed to control the launching of containers via manifest files.
  • kube-proxy − This is employed to provide network proxy services to the outside world.

Docker – Working of Kubernetes

In this blog, we’ll see how to install Kubenetes via kubeadm. This is a tool which helps in the installation of Kubernetes. Let’s go step by step and learn how to install Kubernetes.

Step 1 − Ensure that the Ubuntu server version you are working on is 16.04.

Step 2 − Ensure that you generate a ssh key which can be employed for ssh login. You can do this using the subsequent command.

ssh-keygen

This will generate a key in your home folder as shown below.

Page 2 Image 4 5
home_folder

Step 3 − Next, depending on the version of Ubuntu you have, you’ll need to add the relevant site to the docker.list for the apt package manager, so that it will be able to detect the Kubernetes packages from the kubernetes site and download them accordingly.

We can do it using the subsequent commands.

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add –  echo “deb http://apt.kubernetes.io/ kubernetes-xenial main” | sudo tee /etc/apt/sources.list.d/docker.list

Step 4 − We then issue an apt-get update to ensure all packages are downloaded on the Ubuntu server.

Page 3 Image 6 6
apt-get-update

Step 5 − Install the Docker package as detailed in the earlier chapters.

Step 6 − Now it’s time to install kubernetes by installing the subsequent packages −

apt-get install –y kubelet kubeadm kubectl kubernetes-cni

Page 3 Image 7
packages
Page 4 Image 9 1
package_install

Step 7 − Once all kubernetes packages are downloaded, it’s time to start the kubernetes controller using the subsequent command −

kubeadm init

Page 4 Image 10
start-kubernetes

Once done, you’ll get a successful message that the master is up and running and nodes can now join the cluster.

So, this brings us to the end of blog. This Tecklearn ‘How to set up Kubernetes in Docker’ blog helps you with commonly asked questions if you are looking out for a job in DevOps. If you wish to learn Docker and build a career in DevOps domain, then check out our interactive, Containerization using Docker Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

https://www.tecklearn.com/course/containerization-using-docker/

Containerization using Docker Training

About the Course

Tecklearn has specially designed this Containerization using Docker Training Course to advance your skills for a successful career in this domain. his Docker training online course will help you learn Docker containerization, running Docker containers, Docker image creation, Dockerfile, Docker orchestration, security best practices and more through hands-on projects and case studies. Upon completion of this online training, you will hold a solid understanding and hands-on experience with Docker.

Why Should you take Containerization using Docker Training?

  • Average salary of Docker Expert is $110k – Indeed.com
  • According to Grand View Research, the DevOps market size is estimated to be worth $12.85 billion by 2025. DevOps professionals are highly paid and in-demand throughout industries including retail, eCommerce, finance, and technology.
  • Intuit, PayPal, Splunk, Uber & many other MNC’s worldwide use Docker across industries

What you will Learn in this Course?

Introduction to DevOps

  • What is Software Development
  • Software Development Life Cycle
  • Why DevOps?
  • What is DevOps?
  • DevOps Lifecycle
  • DevOps Tools
  • Benefits of DevOps
  • How DevOps is related to Agile Delivery
  • DevOps Implementation

Containerization using Docker – Part 1

  • Introduction to Docker
  • Understanding Docker Lifecycle
  • Docker Architecture
  • Components of Docker Ecosystem
  • Common Docker Operations
  • Committing changes in a Container
  • Hands On

Containerization using Docker – Part 2

  • Building Custom Docker Images
  • Docker Image
  • Introduction to Docker Swarm
  • Deploying a 2-Node Cluster using Docker Swarm
  • Hands on

 

0 responses on "How to set up Kubernetes in Docker"

Leave a Message

Your email address will not be published. Required fields are marked *