Kubernetes
Kubernetes Manifest
DevOps
Container Orchestration
Cloud Native

What is a Kubernetes Manifest?

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Kubernetes is a powerful platform for automating the deployment, scaling, and operation of application containers. A core component in managing these applications is the Kubernetes Manifest. A Kubernetes Manifest is a YAML or JSON configuration file that describes the desired state and behavior of various components within a Kubernetes cluster, such as Pods, Services, Deployments, and more.

Why Use Manifests?

Manifests play a vital role in establishing a declarative approach to managing applications within Kubernetes. By using Manifests, you can easily define, deploy, and maintain configurations, allowing Kubernetes to continuously monitor and ensure that the actual state mirrors the desired state as specified.

Basic Structure

A Kubernetes Manifest file typically includes these key sections:

  1. apiVersion: Describes the version of the Kubernetes API you're using.
  2. kind: Specifies the kind of object you're creating (e.g., Pod, Service, Deployment).
  3. metadata: Provides metadata about the object, such as name and labels.
  4. spec: Details the desired behavior and characteristics of the object.

Example Kubernetes Manifest

Here's an example of a simple Pod manifest:

yaml
1apiVersion: v1
2kind: Pod
3metadata:
4  name: myapp-pod
5  labels:
6    app: myapp
7spec:
8  containers:
9  - name: myapp-container
10    image: nginx
11    ports:
12    - containerPort: 80

Explanation

  • apiVersion: Specifies the version of the API used (v1 in this case).
  • kind: Defines the object type, which is a Pod.
  • metadata: Contains name specifying the Pod's name and labels providing additional metadata.
  • spec: Describes the container configurations inside the Pod. Here, it specifies a single container using the Nginx image, exposing port 80.

Applying a Manifest

To apply a manifest file, you can use the kubectl apply command followed by the -f flag with your file name:

bash
kubectl apply -f myapp-pod.yaml

This command directs Kubernetes to create the resources defined in the manifest or update them if they already exist.

Standard Kubernetes Manifests

Below is a table summarizing common types of Kubernetes objects typically specified through Manifests:

Object TypePurposeSpec Details Example
PodSmallest unit of deploymentContainers, Ports
ServiceExpose Pods as network serviceType, Selector, Ports
DeploymentManages Pods/ReplicaSetsReplicas, Selector, Template
ConfigMapConfig data for PodsData, BinaryData
SecretStore sensitive informationData for encoded values
PersistentVolumeClaim(PVC)Request storageStorage size, Access modes

Advanced Topics

Managing Environments with ConfigMaps and Secrets

Using ConfigMaps and Secrets allows you to decouple configuration artifacts from image content, making applications portable. A ConfigMap stores simple, non-sensitive configuration like URLs, while Secrets store sensitive data like passwords.

Using Helm for Managing Manifests

Helm is a Kubernetes package manager that helps in templating Kubernetes Manifests and managing releases of applications. Instead of writing separate YAML files for different environments, Helm allows you to template your Manifests and manage them efficiently.

Manifest Lifecycle

Changes to a Manifest are monitored by the Kubernetes Control Plane. When you update a Manifest, Kubernetes evaluates the differences between the current state and the desired state. If discrepancies exist, it takes action to reconcile the state, making deployments easier and more resilient.

Conclusion

Kubernetes Manifests form the backbone of application configuration within Kubernetes. By clearly defining the desired state of components via YAML or JSON, enterprises and developers can achieve a high degree of automation and reliability. Understanding and leveraging Manifests is essential for anyone aiming to harness the full power of Kubernetes.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.