Getting Started with Kubernetes
Deepak Porwal
Posted on October 5, 2021
Orchestration
Container orchestration is all about managing the life cycles of containers, especially in large, dynamic environments.
Container Orchestration can be used to perform a lot of tasks, some of them includes:
- Provisioning and deployment of containers
- Scaling up or removing containers to spread application load evenly
- Movement of containers from one host to another if there is a shortage of resources
- Load balancing of service discovery between containers
- Health monitoring of containers and hosts
There are many container orchestration solutions which are available, some of the popular ones include:
- Docker Swarm
- Kubernetes
- Apache Mesos
- Elastic Container Service (AWS ECS)
There are also various container orchestration platforms available like EKS.
Introduction to Kubernetes
Kubernetes (K8s) is and open-Source container Orchestration engine developed by Google.
It is originally designed by Google, and is now maintained by the Cloud Native Computing Foundation.
Installation Options for K8s
Installation Aspects
Things to configure while working with Kubernetes.
Sr No | Things to Install | Description |
---|---|---|
1 | kubectl | CLI for running user commands against cluster |
2 | Kubernetes Master | Kubernetes Cluster by itself |
3 | Worker Node Agents | Kubernetes Node Agent |
Understanding Installation Methods
There are multiple ways to get started with fully functional k8s environment.
- Use the Managed K8s Service
- Use Minikube
- Install & Configure K8s Manually (Hard Way)
Install & Configure K8s Manually(Hard Way)
In this approach you have to install all the components ok K8s Individually
Components to be Configured - Managed Service
You have to just download kubectl and that's it. As rest all the things are taken care by Managed Service. Download CLI and just need to connect with K8s master.
Components to be Configured - Minikube
Take care of K8s master also the worker node, then we need to configure the kubectl.
It has disadvantage that it provision single node cluster.
Kubernetes API Primitives
Depending on the Operations there are various APIs availble.
eg: /apis , /metrics ,
/api/v1/pods or /api/v1/nodes or /api/v1/services
to explore APIs, run below command and goto: localhost:8080
kubectl proxy --port 8080
Kubernetes POD
A pod is a collection of containers and its storage inside a node of a Kubernetes cluster. It is possible to create a pod with multiple containers inside it. For example, keeping a database container and data container in the same pod.
There are two types of Pods −
- Single container pod
- Multi container pod
Single container pod
$ kubectl run <name of pod> --image=<name of the image from registry>
eg:
kubectl run tomcat --image = tomcat:8.0
Multi container pod
Multi container pods are created using yaml mail with the definition of the containers.
apiVersion: v1
kind: Pod
metadata:
name: Tomcat
spec:
containers:
- name: Tomcat
image: tomcat: 8.0
ports:
containerPort: 7500
imagePullPolicy: Always
-name: Database
Image: mongoDB
Ports:
containerPort: 7501
imagePullPolicy: Always
For more deep on Pods goto: Kubernetes Pods
Kubernetes Objects
Kubernetes Objects are basically a record of intent that you pass on to the Kubernetes Cluster.
Once you create the object, the kubernetes system will constantly work to ensure that object exists.
Commands and Arguments in K8s
In Docker main difference between ENTRYPOINT and CMD is that Override the main command in Dockerfile with the command passing as arguments.
Whereas, in Kubernetes we can override both the ENTRYPOINT and CMD with command and arguments field.
Dockerfile VS K8s Menifest Perspective
Docker Field Name | K8s field Name | Description |
---|---|---|
ENTRYPOINT | command | Command that will run by the container |
CMD | args | Argument passed to the container |
Let me show you how command and args work on kubernetes.
Reference: Define a Command and Arguments for a Container
References:
Official Documentation
Udemy Course
Credit:
Zeal Vora
Specific Kubernetes setups, coming soon!!!!!!!!!!!!!!!!
Posted on October 5, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.