Kubernetes YAML Files

Firstly we’ll understand what is yaml file, why it is used in k8s and how is it useful
1. What is YAML File:
YAML (YAML Ain't Markup Language) is a human-readable data serialization language. In simple terms, it's a way to write data in a format that's easy for both humans and computers to understand.
2. Why YAML File is used:
In Kubernetes, YAML files are crucial for defining the desired state of your applications and infrastructure. These files, often called "manifests," tell Kubernetes what you want your cluster to look like. Here's how they're used
Defining Kubernetes Objects:
You use YAML to define various Kubernetes objects, such as:
Pods: The smallest deployable units in Kubernetes.
Deployments: Manage replicated applications.
Services: Expose applications to the network.
ConfigMaps and Secrets: Store configuration data and sensitive information.
Declarative Configuration:
Kubernetes uses a declarative approach, meaning you describe the desired state in your YAML files, and Kubernetes works to achieve that state.
This allows you to easily manage and automate deployments, scaling, and updates.
3. How YAML File is useful:
Ease of use: YAML's simple syntax makes it relatively easy to create and modify Kubernetes configurations.
Version control: YAML files can be stored in version control systems like Git, enabling you to track changes and manage configurations effectively.
Automation: YAML files enable the automation of kubernetes deployments.
Defining Kubernetes Objects using YAML file :
Pod:
It is smallest object that we create in k8s.
It is group of containers.
Pods can be created using two ways.
1. Imperative way( command):
SYNTAX: kubectl run pod_name --image= image_name
2. Declarative way(manifest file):
YAML file consist of KEY-VALUE Pair
This file contains the desired state of a Pod.
It takes care of creating, updating, or deleting the resources.
This manifest file need to follow the yaml indentation
apiVersion: This is the version of API from Kubernetes which is used to create objects.
kind: defines the object that we are creating.
metadata: data about the object like names,labels etc ...
spec: It is the specifications of the object
Click on the link to learn more :Next chapter
Subscribe to my newsletter
Read articles from Pradeep directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
