Container Concept, Kubernetes and Service types

Neeraj Nawale
5 min readSep 30, 2022

This article contains information about what actually a container is?, need of Docker, meaning of Kubernetes, how it works and what different services does it support.

What is a Container?

Source: sectigo.com

Container word was introduced by Solomon Hykes in 2013, the main motive behind container was to solve “shipping of software” problem.
Shipping a software from place A to place B is one of the challenging task because, shipping the software with exact code or dependencies or libraries is never easy, shipping could be done using “sandbox” but, it has some limitations and in every scenario there was one/more dependencies that would affect the shipping process. In other words, sandboxing is incomplete. However, what container does is, it packs all the dependencies and executable packages into a box (container) and can be run from any environment.
Therefore, containers virtualize the operating system and run anywhere, from a private data center to the public cloud or even on a developer’s personal laptop. A container shares the same host OS or system kernel, much lighter in size, often only megabytes and mostly takes seconds to start.
Additionally, container technology plays a vital role in DevOps field and supports CI/CD pipeline means to build, test, and deployment from the same container images. Docker and Kubernetes are two most commonly used container technologies.

Know more about DevOps and CI/CD pipeline

Docker :-

Docker is a container technology which is used to ship software in packages called containers. Shipping is done so well that the infrastructure doesn’t have to care about what’s inside the container and similarly developer doesn’t have to care about how its been shipped. Docker is written in Go Programming Language.
Docker is superfast meaning, it can launch a new OS or environment in seconds. The reason behind this is that, docker is just a command and what it does at backend is; creates a container, allocate a filesystem for it, mount it with rewrite layer, allocate a network interface, set an IP for it and lastly executes the process provided by the developer. Docker have some tools and terms ::

  1. Dockerfile
    A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Dockerfile automates the process of Docker image creation.
  2. Docker images
    Docker image contain executable application source code as well as all the tools, libraries, and dependencies that the application code needs to run as a container. When a developer run the Docker image, it becomes one instance of the container.
  3. Docker Hub
    Docker Hub is a public repository of Docker images that calls itself the world’s largest library and community for container images. It holds over 100,000 container images sourced from commercial software vendors, open-source projects, and individual developers.

Kubernetes :-

Source: kubernetes.io

Kubernetes (also known as k8s) is a container management tool and is used to manage docker and containers. After container technology was introduced to public world, Kubernetes was an internal project for Google developers and after some years, they made Kubernetes an open source tool.
Main motive of this tool is to provide automation. Kubernetes can internally connect with docker and run containers as well. Purpose of Kubernetes is to roll out changes in your applications, scale your application, monitoring the application and automate operational tasks in easier way. Kubernetes have lots of terminologies such as ::

  1. Pod
    A Pod is a group of one or more container with shared storage and network resources, and a specification for how to run the containers. When a Pod runs multiple containers, the containers are managed as a single entity and share the Pod’s resources.
  2. Node
    A node is kind of virtual or physical machine that has multiple pods inside it. Node contains pod and pod related information in it.
  3. Cluster
    A Kubernetes cluster is a set of nodes that run containerized applications. In other words, running kubernetes meaning to run cluster. Cluster is the heart of k8s and is capable to schedule and run containers across a group machines.
  4. YAML file
    YAML is a human-readable text-based format that lets you easily specify configuration-type information by using a combination of maps of name-value pairs and lists of items. It specifies the configuration for a Deployment object.

Service and its Types :-

A k8s service is used to expose an application deployed on a set of pods using a single endpoint. It enables communication between nodes, pods, and users of app, both internal and external, to the cluster. Service also provides load balancing when you have Pod replicas .Service can be described using the following explanation ::

Pods in k8s have its own IP and gets replaced by new ones automatically (if not functioning properly). When old pod is deleted or dies, new pod created for replacement acquires a new IP. Hence, it doesn’t make sense to use pod IP directly as developer needs to adjust it every time a pod is recreated. This results in a problem of identifying which pod connects to which deployed application.
Therefore, with service component of k8s, developer can have a static and stable IP address that remains the same even if pod is recreated or destroyed. Using service, clients can now call single stable IP instead of calling each pod differently or independently.

There are four types of services ::

  1. ClusterIP
  2. NodePort
  3. LoadBalancer
  4. ExternalName

ClusterIP :-

  • ClusterIP provides a load-balanced IP address.
  • Cluster-internal IP address gets assigned by k8s to ClusterIP service. This makes the service private within cluster, in other words, service is reachable within the cluster.
  • Developer cannot make requests to pods from outside the cluster.

NodePort :-

  • NodePort service is better version of ClusterIP service.
  • Developer can expose this service to outside cluster and it exposes the service on each Node’s IP at a static port.
  • <NodeIP>:<NodePort> is the format to access or contact NodePort service from outside the cluster.
  • A NodePort is an open port on every node of your cluster. Each node proxies that port into your Service. So, external traffic has access to fixed port on each Node.

LoadBalancer :-

  • LoadBalancer service is an extension of NodePort.
  • This type of service is also used in cloud based applications.
  • It exposes the Service externally using a cloud provider’s load balancer.
  • Cloud providers like AWS, Azure, GCP, etc. has their own load balancer implementation. he cloud provider will create a load balancer, which then automatically routes requests to your Kubernetes Service.
  • Traffic from the external load balancer is directed at the backend Pods. The cloud provider decides how it is load balanced.
  • Every time a developer needs to expose a service to the outside world, you have to create a new LoadBalancer and get an IP.

ExternalName :-

  • An ExternalName service is a special case of service that does not have selectors.
  • Developer needs to specify these Services with the `spec.externalName` parameter and proxying is not established.

Happy Learning
Thank You…

--

--