How to Scale End-to-End Observability in AWS Environments

This is What You Need to Know About Kubernetes YAML, Pods, Deployments, and ReplicaSets (1/3)

in Kubernetes

YAML, Pods, Deployments, and ReplicaSets

In this step by a step tutorial, we will explore and discuss different options to deploy applications on Kubernetes clusters, and we will focus on the following points: The basics of YAML, creating Pods in Kubernetes, deploying applications using Pods and deploying applications using Deployments.


    This tutorial contains 3 parts, make sure to read part 2 and part 3.

    Requirements

    Before proceeding, make sure that your environment satisfies these requirements. Start by installing Docker and Kubectl in your machine. You will also need a K8s cluster; you can use Minikube for this purpose.

    Introduction to YAML

    Kubernetes is a tool that can be used for automating deployment, scaling, and management of containerized applications. Interacting with Kubernetes can be used via Restful API requests to the Kubernetes API server. The Kubernetes API server is responsible for accepting the requests for performing actions on the Kubernetes clusters. These actions can be performed to create, read, update, or delete resources from the Kubernetes cluster.

    To interact with the Kubernetes API server, you need to know the URL or the API server, and you have to build your web request with JSON (The body of the request that represents the Kubernetes resources). Managing Kubernetes resources in JSON is tricky due to readability issues. Luckily the kubectl command allows us to define the Kubernetes in a more readable and easy to write format, which is YAML, and the kubectl will take care of translating the resource definitions to JSON format and send the request to the API server.

    YAML (Yet Another Markup Language) is a human-readable data serialization language. YAML is widely used for defining and storing configuration and data. YAML allows us to store complex data and configurations such as Lists, Maps, and more Objects. For instance, on the one hand, YAML allows us to define collections of items such as the list of top movies, and on the other hand, it allows us to define a nested mapping like the list of actors in each movie.

    The below snippet is showing an example of an invoice in the YAML format.

    ---
    receipt:     Liddo Invoice
    date:        2020-09-24
    customer:
        first_name:   Jan
        family_name:  Marria
    
    items:
        - part_no:   B4896
          descriptin:   Cable
          price:     1.47
          quantity:  4
    
        - part_no:   RH628
          descrip:   CD/DVD
          size:      8
          price:     133.7
          quantity:  1
    
    bill-to:  &address
        street: |
                345 Tornado Alley
                Suite 40
        city:   East Centerville
        state:  KS
    
    ship-to:  *address

    As you can see in the above snippet YAML is an easy-to-read format, and it also allows reusing the data defined instead of duplicating it over and over. For instance, in the above file, we defined the customer address only once and reused it for the ship-to configurations.

    As said before, the Kubectl tool allows us to define the Kubernetes resources in the YAML format. It will take care of managing the communications with the Kubernetes API server. This feature has a big advantage because it is much easier to write and read the Kubernetes resource definitions in the YAML format.

    Kubernetes Resources: Pods, Deployments, and ReplicaSets

    Kubernetes offer a wide range of resources that can be created and managed by the cluster, such as Secrets, Configmaps, services, deployments, and many others. The supported resources cover and support several areas that are related to hosting and securing applications running on the Kubernetes cluster. For Instance, a Pod resource is used to represent a running instance of given applications, while a namespace resource is used to isolate a group of resources from other resources that belong to different namespaces.

    To view the complete list of the resources supported by Kubernetes, you can use the below command, as shown in the screenshot.

    Pods, Deployments, and ReplicaSets Pods, Deployments, and ReplicaSets

    From the above screenshot, it is clear that each of the supported resources has the following attributes: resource name, API group, kind, and whether the resource is scoped to a specific namespace or is available on the cluster level.  These attributes are very important for defining the resources of YAML files, especially the Kind and the API group.

    Each of the supported resources can be managed by creating a YAML file representing the status of the resource and then using the kubectl command to instruct Kubernetes to create the same resource.

    In part 2 of "This is What You Need to Know About Kubernetes YAML, Pods, Deployments, and ReplicaSets", we will focus on the general structure of the Kubernetes YAML files and the possible ways to create a Pod resource.


    Get similar stories in your inbox weekly, for free



    Share this story:
    cloudplex
    Cloudplex

    Founder and CEO of Cloudplex - We make Kubernetes easy for developers.

    How to Scale End-to-End Observability in AWS Environments

    Latest stories


    How ManageEngine Applications Manager Can Help Overcome Challenges In Kubernetes Monitoring

    We tested ManageEngine Applications Manager to monitor different Kubernetes clusters. This post shares our review …

    AIOps with Site24x7: Maximizing Efficiency at an Affordable Cost

    In this post we'll dive deep into integrating AIOps in your business suing Site24x7 to …

    A Review of Zoho ManageEngine

    Zoho Corp., formerly known as AdventNet Inc., has established itself as a major player in …

    Should I learn Java in 2023? A Practical Guide

    Java is one of the most widely used programming languages in the world. It has …

    The fastest way to ramp up on DevOps

    You probably have been thinking of moving to DevOps or learning DevOps as a beginner. …

    Why You Need a Blockchain Node Provider

    In this article, we briefly cover the concept of blockchain nodes provider and explain why …

    Top 5 Virtual desktop Provides in 2022

    Here are the top 5 virtual desktop providers who offer a range of benefits such …

    Why Your Business Should Connect Directly To Your Cloud

    Today, companies make the most use of cloud technology regardless of their size and sector. …

    7 Must-Watch DevSecOps Videos

    Security is a crucial part of application development and DevSecOps makes it easy and continuous.The …