• Cygnet IRP
  • Glib.ai
  • IFSCA
Cygnet.One
  • About
  • Services
  • Products
  • Solutions
  • Partners
  • Resources
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Get Started
About
  • Overview

    A promise of limitless possibilities

  • We are Cygnet

    Together, we cultivate an environment of collaboration

  • In the News

    Catch up on the latest news and updates from Cygnet

  • CSR

    Impacting Communities, Enriching Lives

  • Careers

    Join Our Dynamic Team: Careers at Cygnet

  • Contact Us

    Connect with our teams across the globe

What’s new

chatgpt

ChatGPT: Raising the Standards of Conversational AI in Finance and Healthcare Space

Full Story

Services
  • Digital Engineering
    • Technical Due Diligence
    • Product Engineering
    • Application Modernization
    • Enterprise Integration
    • Hyperautomation
  • Quality Engineering
    • Test Consulting & Maturity Assessment
    • Business Assurance Testing
    • Enterprise Application & Software Testing
    • Data Transformation Testing
  • Cloud Engineering
    • Cloud Strategy and Design
    • Cloud Migration and Modernization
    • Cloud Native Development
    • Cloud Operations and Optimization
    • Cloud for AI First
  • Data Analytics & AI
    • Data Engineering and Management
    • Data Migration and Modernization
    • Insights Driven Business Transformation
    • Business Analytics and Embedded AI
  • Managed IT Services
    • IT Strategy and Consulting
    • Application Managed Services
    • Infrastructure Managed Services
    • Cybersecurity
    • Governance, Risk Management & Compliance
Products
  • Exclusively Available For Americas
  • Cygnet Finalyze
    • Bank Statement Analysis
    • Financial Statement Analysis
  • Cygnature

    Cloud-based digital & electronic signing solution

  • TestingWhiz

    Low code no code test automation tool

  • AutomationWhiz

    Automate business processes with RPA bots

  • Global Products
  • Cygnet Tax

    Transform tax processes to ensure compliance

  • Cygnet Vendor Postbox

    Automate end-to-end vendor management

  • Cygnet BridgeFlow

    Onboarding journey for seamless experience

  • Cygnet Bills

    Cloud based billing solution to generate bills, e-Invoices and e-Way bills

  • Cygnet IRP

    Approved Invoice Registration Portal by GSTN

  • Global Products
  • Cygnet BridgeCash

    One-stop solution for customer sourcing to loan disbursement

  • Litigation Management

    AI-enabled Litigation management solution

  • Managed Services

    Transform Compliance into Value

Solutions
  • Source to Pay
    • Accounts Payable
  • Intelligent Document Processing
  • GL Reconciliation
  • SAP Testing
  • BOTS
    • Bill of Entry / Shipping Bills Automation
    • Payment Reconciliation

What’s new

Innovative Engineering

AI-Powered Hyperautomation: Transforming Banking and Insurance Industry

Full Story

Innovative Engineering

Elevate Efficiency, Ensure Excellence: Optimize SAP with Testing Prowess

Full Story

Partners
Resources
  • Blogs
  • Case Studies
  • eBooks
  • Events
  • Webinars

Blogs

Streamlining Finance by Leveraging AI for Bank Statement Analysis

Streamlining Finance by Leveraging AI for Bank Statement Analysis

View All

Case Studies

Accelerated Process Transformation with SAP Implementation

Accelerated Process Transformation with SAP Implementation

View All

eBooks

Build Smart Workflow with Intelligent Automation and Analytics

Build Smart Workflow with Intelligent Automation and Analytics

View All

Events

Cygnet.One at the Tax Technology Conference 2024

Cygnet.One at the Tax Technology Conference 2024

View All

Webinars

Cygnet Invoice Management System Module Webinar Series

Cygnet Invoice Management System Module Webinar Series

View All
Cygnet IRP
Glib.ai
IFSCA

Step-by-Step Guide: Creating Pod in Kubernetes for Microservices 

  • By Abhijit Sen
  • July 12, 2024
  • 8 minutes read
Share
Subscribe

In our previous article, we learned about the docker and creating the container image for microservices. Now, let’s explore Kubernetes guide to understand why and how to create Pod in Kubernetes for Microservices.

The diagram below provides a canonical example of co-locating multiple applications into a single fundamental entity scheduled onto a single machine. While one container is dedicated to serving web requests in this deployment, the second one synchronizes the filesystem with a remote Git repository.

Putting a web server and a Git sync tool in one box might look easy, but they need different resources, especially the memory requirements differ. The web server must always answer user requests quickly, while the Git synchronizer works in the background with a “best effort” approach.

This method of using separate resources fits the elementary goal of containers, offering a robust way to make sure the web server works well.

As these two containers rely on each other, putting the web server on one machine and the Git tool on another doesn’t make sense. So, Kubernetes merges several containers into one unified unit called a “Pod.” This term is similar to the marine theme of Docker containers, where a group of whales is called a “Pod.”

Pods in Kubernetes (K8S)

A Pod is a group of application containers and volumes streaming in the same execution environment. The smallest deployable artifact in a Kubernetes cluster is the Pod, not the container. This means all the containers in a Pod always land on the same machine.

Containers within a Pod run together but share certain Linux namespaces. Applications coexisting within a single Pod exhibit the following characteristics:

  • They utilize a common IP address and port range, sharing a network namespace.
  • They share an integrated hostname established within the UTS namespace.
  • They can link through inherent interprocess communication pathways, encompassing System V IPC or POSIX message queues facilitated by the IPC namespace.

However, applications in different Pods are kept separate; they have different IP addresses, hostnames, and more. Containers in different Pods running on the same node may also be on different servers.

Thinking with Pods

When venturing into Kubernetes adoption, a frequent inquiry arises: “What constitutes suitable content for a Pod?” Sometimes, combining a WordPress container and a MySQL database container within a single Pod seems appealing. This combination, however, is not a good example of an approach to constructing Pods. Two key factors contribute to this assertion:

  1. Lack of True Interdependence: WordPress and its associated database aren’t inherently dependent on being co-located. Even if these containers are on different machines, they work well together as they communicate with each other effectively over network connections.
  2. Dissimilar Scaling Requirements: WordPress and its database have different scaling dynamics. While WordPress is easy to use and flexible for frontend load adjustments by creating additional WordPress Pods, a MySQL database scaling needs more careful planning. The constraint of utilizing a unified scaling strategy for both containers within the same Pod proves impractical.

The Pod Manifest

Pods are described in a Pod manifest – a text-file representation of the Kubernetes API object. Kubernetes strongly believes in declarative configuration, which means that you write down the desired state of the world in a Kubernetes Pod configuration and then submit that configuration to a service that takes actions to ensure the desired state becomes the actual state. This approach is a central part of any Kubernetes guide, specifically when working with microservices in Kubernetes.

  1. The Kubernetes API server accepts and processes Pod manifests before storing them in persistent storage (etcd).
  2. The scheduler also uses the Kubernetes API to find Pods that haven’t been scheduled to a node.
  3. It then places the Pods onto nodes depending on the resources and other constraints expressed in the Pod manifests.
  4. The scheduler can place several Pods on one machine, as long as there are enough resources. However, placing multiple copies of an application on the same machine could make it a single point of failure, reducing reliability. As a result, the Kubernetes scheduler aims to spread application Pods across different machines to enhance reliability and reduce the effects of potential failures.
  5. Once scheduled to a node, Pods don’t move and must be explicitly destroyed and rescheduled.

You can deploy multiple instances of a Pod repeating the workflow described here. However, ReplicaSets are better suited for running multiple instances of a Pod.

Creating a Pod

The simplest way to create a Pod is via the imperative kubectl apply command. For example, to run the my-cygnet-pod server, use the below code and create a file named “my-cygnet-pod”.

After creating the above file, run the kubectl apply command to create and run the pod.

$ kubectl apply -f my-cygnet-pod.yaml

You can see the status of this Pod by running the following:

$ kubectl get pods

Initially, you might observe the container in a Pending state, but later it will change to Running, indicating successful creation of the Pod and its containers.

For now, you can delete this Pod by running the following:

$ kubectl delete pods/my-cygnet-pod

Creating a Pod Manifest

You can write a Pod manifest using YAML or JSON, but YAML is generally preferred because it is slightly more human-editable and can add comments. It is essential to treat Pod manifests (along with other Kubernetes API objects) similar to source code, where comments play a role in explaining the Pod to new team members.

Pod manifests consist of various important fields and attributes. This includes a metadata section that defines the Pod and its labels, a specification section that details volumes, and a list of containers assigned to run within the Pod. Let’s deploy my-cygnet-pod using the following Docker command:

$ kubectl apply -f my-cygnet-pod.yaml

You can achieve a similar result by instead writing the below example to a file named my-cygnet-pod.yaml and then using kubectl commands to load that manifest to Kubernetes.

apiVersion: v1
kind: Pod
metadata:
         name: my-cygnet-pod
spec: containers:
         - image: nginx:latest
         name: my-cygnet-pod
         ports:
              - containerPort: 8080
              name: http
              protocol: TCP

While it might appear initially more intricate to oversee your application through this approach, maintaining a documented representation of the intended state proves to be the optimal strategy in the long term. This holds particularly true for sizable teams managing a multitude of applications.

Running Pods

We have created a Pod manifest that can be used to start a Pod running my-cygnet-pod. Now, we can use the kubectl apply command to launch a single instance of my-cygnet-pod:

$ kubectl apply -f my-cygnet-pod.yaml

The Kubernetes API server will receive and process the Pod manifest. Subsequently, the Kubernetes system will orchestrate the scheduling of the Pod onto a healthy node within the cluster, where the kubelet daemon will conduct continuous monitoring.

Listing Pods

We can list all Pods running in the cluster using the kubectl command-line tool. Here, this is the single Pod that we created in the previous step:

$ kubectl get pods

You can observe the Pod’s designated name (my-cygnet-pod), as assigned in the preceding YAML file. Aside from the count of operational containers (1/1), the output provides insights into the Pod’s current state, the frequency of its restarts and its lifespan.

Running this command promptly after the Pod’s creation could reveal further detail:

NAMEREADYSTATUSRESTARTSAGE
My-cygnet-pod0/1Pending01s

The Pending state implies that the Pod has been submitted but not scheduled yet.

When a more significant error occurs, such as trying to create a Pod with a container image that doesn’t exist, it is also listed in the status field.

Pod Details

Sometimes, the single-line view is insufficient because it is too terse. Additionally, Kubernetes maintains numerous events about Pods in the event stream, not attached to the Pod object.

To learn more about a Pod (or any Kubernetes object), you can use the kubectl describe command. For example, to describe the Pod we previously created, you can run the following:

$ kubectl describe pods my-cygnet-pod

This command generates a plethora of details concerning the Pod, organized into various sections.

At the top, fundamental information regarding the Pod is shown.

Then, there is information about the containers running in the Pod:

Finally, the events related to the Pod are listed. This includes information such as when the event was scheduled, when its image was pulled, and if/when it had to be restarted due to failing health checks.

Deleting a Pod

When deleting a Pod, you can delete it either by name:

$ kubectl delete pods/my-cygnet-pod

Or you can delete it using the same file that you used to create it:

$ kubectl delete -f my-cygnet-pod.yaml

When a Pod is deleted, it is not abruptly terminated abruptly. Instead, upon executing the command kubectl get pods, you’ll observe the Pod in a Terminating state.

Each Pod is allocated a termination grace period, typically set to 30 seconds by default. As a Pod transitions to the Terminating state, it ceases to accept new requests. This grace period serves a vital role by allowing the Pod to conclude ongoing requests and finalize processing before being shut down. This mechanism contributes significantly to enhancing reliability.

Accessing Pod

You may want to load the web service running in the Pod, view its logs, debug any problem, or even execute other commands inside it to help debug. Let’s learn how you can interact with the code and data inside your Pod.

Using Port Forwarding

While load balancers can make services accessible to the public or other containers, there are instances where you require direct access to a particular Pod, regardless of its internet traffic-serving status. This can be achieved through Kubernetes’ built-in port-forwarding feature, accessible via its API and command-line tools.

When you initiate the command:

$ kubectl port-forward my-cygnet-pod 8080:8080

A secure tunnel is established, extending from your local machine through the Kubernetes master and connecting to the active instance of the Pod on one of the worker nodes.

If the port-forward command is still running, you can access the Pod (the my-cygnet-pod web interface) at http://localhost:8080.

Getting More Info with Logs

You can dig deeper than describe to understand what the application is doing to debug it using Kubernetes commands for debugging running containers.

$kubectl debug <pod-name> -it –image=<debugging-tool-image>

Using the kubectl logs command, you can download the current logs from the running instance.

$ kubectl logs my-cygnet-pod

Adding the -f flag will cause you to stream logs continuously. The kubectl logs command attempts to fetch logs from the currently running container. Adding the –previous flag will get logs from a previous container instance. This is useful in cases where your containers are continuously restarting because of a problem at container startup.

Running Commands in Your Container with exec

Occasionally, logs might not provide adequate information, necessitating the execution of commands within the container’s environment to comprehend the situation. To achieve this, you can employ the following command:

$ kubectl exec my-cygnet-pod date  or  kubectl exec my-cygnet-pod – date

You just mastered the creation of Pods in Kubernetes for Microservices!

Conclusion

While microservices architecture helps you deploy features that prevent cascading failures, creating additional pods with Kubernetes deployments ensures no downtime, as containerized microservices in Kubernetes can be automatically managed and scaled.

To avail the additional benefits of deploying Kubernetes with microservices and creating pods for enhanced efficiency, contact our experts at Cygnet and learn more about the transformational outcomes your application can achieve with Kubernetes microservices architecture.

Abhijit Sen Linkedin
Abhijit Sen
VP & Head of Architecture and Innovation

Abhijit Sen is a business and technology architect with a proven ability to develop and implement Information Technology strategies to drive business operations. 14 years of experience in Fintech across technology and strategic change management with significant analysis, design, and architecture contributions to the delivery of regulatory, control, and large-scale changes.

Related Blog Posts

Ways to Scale Agile and DevOps Together
Ways to Scale Agile and DevOps Together

CalendarDecember 07, 2022

The Ultimate Guide to Cloud Transformation: Strategy, Implementation, and Optimization
The Ultimate Guide to Cloud Transformation: Strategy, Implementation, and Optimization

CalendarFebruary 20, 2025

Kubernetes for Microservices: Does Your Business Need Kubernetes?
Kubernetes for Microservices: Does Your Business Need Kubernetes?

CalendarJuly 25, 2024

Sign up to our Newsletter

    Latest Blog Posts

    What is Data Engineering? Everything You Need to Know
    What is Data Engineering? Everything You Need to Know

    CalendarJune 13, 2025

    Complete Guide to Goods and Services Tax (GST) in Singapore
    Complete Guide to Goods and Services Tax (GST) in Singapore

    CalendarJune 12, 2025

    Top AI-powered Analytics Tools for Data-Driven Enterprises
    Top AI-powered Analytics Tools for Data-Driven Enterprises

    CalendarJune 10, 2025

    Resources

    The more you engage, the better you will realize our role in the digital transformation journey for your business

    Read

    Dive into insights,articles,and expert perspectives

    Watch

    Explore Videos, Webinars, and Visual Insights

    Engage

    Join Conversations and Connect with Cygnet

    Let’s level up your Business Together!

    The more you engage, the better you will realize our role in the digital transformation journey of your business








      I agree to the Terms & Conditions and Privacy Policy and allow Cygnet One to contact me via email or phone call.*

      I agree to receive occasional product updates and promotional messages on WhatsApp / Email / SMS.

      Cygnet.One Locations

      India

      Cygnet Infotech Pvt. Ltd.
      2nd Floor, The Textile Association of India,
      Dinesh Hall, Ashram Rd,
      Navrangpura, Ahmedabad, Gujarat 380009

      Cygnet Infotech Pvt. Ltd.
      Community Coworking Space,
      501 B-Wing Ackruti Trade Center Road Number 7,
      Midc, Marol, Andheri East, Mumbai 400093

      Cygnet Infotech Pvt. Ltd.
      WESTPORT, Urbanworks,
      5th floor, Pan Card Club rd.,
      Baner, Pune, Maharashtra 411045

      Cygnet Infotech Pvt. Ltd.
      10th floor, 73 East Avenue,
      Sarabhai campus, Vadodara, 391101

      Global

      CYGNET INFOTECH LLC
      125 Village Blvd, 3rd Floor,
      Suite 315, Princeton Forrestal Village,
      Princeton, New Jersey- 08540

      CYGNET FINTECH SOFTWARE
      Office No 3301-022, 33rd Floor,
      Prime Business Centre,
      Business Bay- Dubai

      CYGNET INFOTECH PRIVATE LIMITED
      Level 35 Tower One,
      Barangaroo, Sydney, NSW 2000

      CYGNET ONE SDN.BHD.
      Unit F31, Block F, Third Floor Cbd Perdana 3,
      Jalan Perdana, Cyber 12 63000 Cyberjaya Selangor, Malaysia

      CYGNET INFOTECH LIMITED
      C/O Sawhney Consulting, Harrow Business Centre,
      429-433 Pinner Road, Harrow, England, HA1 4HN

      CYGNET INFOTECH PTY LTD
      152, Willowbridge Centre,
      39 Cronje Drive, Tyger Valley,
      Cape Town 7530

      CYGNET INFOTECH BV
      Peutiesesteenweg 74, Machelen (Brab.), Belgium

      Cygnet One Pte. Ltd.
      160 Robinson Road,
      #26-03, SBF Centre,
      Singapore – 068914

      • Explore more about us

      • Download Corporate Deck
      • Terms of Use
      • Privacy Policy
      • Contact Us
      © Copyright – 2025 Cygnet.One
      We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkNoPrivacy Policy
      Fill in the form to download

      Error: Contact form not found.

      Cygnet.One AI Assistant

      ✕
      AI Assistant at your help. Cygnet AI Assistant