Deploy a Pod to Kubernetes With YAML File

This blog post will use a YAML file to deploy a simple pod to a kubernetes cluster running on Docker Desktop.

A pod is a group of one or more containers. These are treated as a single entity by the scheduler. Deployments are configuration objects that describe how pods are created, updated and deleted. Their use is recommended since they can provide declarative updates using templates.

In our previous posts, we deeply a pod using kubectl, and we covered Kubernetes manifest file.

Manifest file

Kubernetes manifests are configuration files that allow cluster administrators to create and manage workloads easily. A manifest file contains a list of resources to be managed by Kubernetes. Resources are the objects managed by Kubernetes, which are typically individual pods or deployments. A

To deploy a pod using a YAML file, I will use a manifest file that declares three sections (kind, metadata and spec). The kind section defines the type of object that is going to deploy. The metadata defines the object’s name, and finally, the spec defines image, port, networking and more.

In the manifest file below, I am deploying a pod that runs the nginx web server and opens port 80.

apiVersion: v1
kind: Pod
metadata:
  name: mynginx
  labels:
    env: test
    version: v1
spec:
  containers:
  - name: nginx
    image: nginx:latest
    ports:
    - containerPort: 80

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.