Cloud Native 3 min read

Kubernetes Pod Creation: YAML Structure, Commands, and Example

This article explains the essential components of a Kubernetes Pod manifest, how to write the YAML definition, and the kubectl commands needed to create and manage Pods, including a complete example with metadata, containers, ports, and startup commands.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Kubernetes Pod Creation: YAML Structure, Commands, and Example

This guide introduces the key fields of a Kubernetes resource definition: apiVersion (group and version), kind (resource type), metadata (basic data), spec (desired state), and status (current state).

Resources are created by submitting JSON to the API server; YAML files are accepted because the server automatically converts them to JSON before processing. Useful commands include kubectl api-versions to list API groups.

An example Pod manifest is provided:

apiVersion: v1
kind: Pod
metadata:
  name: pod-test
  namespace: default
  labels:
    app: myapp1
    tier: frontend
spec:
  containers:
  - name: myapp1
    image: ikubernetes/myapp:v1
    imagePullPolicy: IfNotPresent
    ports:
    - containerPort: 8090
      name: web
  - name: busybox
    image: busybox:latest
    command: ["/bin/sh", "-c", "sleep 10"]

To inspect the definition of container ports you can run kubectl explain pods.spec.containers.ports.

Pods can be created from the YAML file with kubectl create -f <filename>.yaml or applied with kubectl apply -f <filename>.yaml. Alternatively, you can use

kubectl run pod-run --image=ikubernetes/myapp:v1 --image-pull-policy=IfNotPresent --port=8090

to launch a Pod directly.

The article concludes with a list of related resources covering Kubernetes deployments, monitoring, scaling, high‑availability clusters, and Ansible automation.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Cloud NativeDevOpsYAMLPodkubectl
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.