DEV Community

Cover image for YAML & JSONPath Essentials
Anusha Kuppili
Anusha Kuppili

Posted on

YAML & JSONPath Essentials

YAML & JSONPath Essentials

A Practical Guide for DevOps, Kubernetes, and Real-World Debugging

Most DevOps engineers use YAML every day.

But very few truly understand how it behaves.

And when it breaks… debugging becomes painful.

Let’s break YAML and JSONPath down the way they actually work in real systems.

— -

YAML: The Language of Configuration

YAML is everywhere in DevOps:

  • Kubernetes manifests
  • CI/CD pipelines
  • Docker Compose
  • Infrastructure as Code

It is human-readable.

But also extremely strict.

One wrong space → everything breaks.

— -

YAML Structure: Indentation Defines Meaning

Unlike JSON, YAML depends on indentation.

Example:


yaml
app:
name: my-app
version: v1

Here:

app is the parent
name and version are children
If indentation is wrong, structure breaks.

This is the #1 cause of YAML issues.

YAML Data Types
YAML supports:

Strings → “hello”
Integers → 10
Booleans → true / false
Lists
Maps (key-value pairs)
Example:

replicas: 3
enabled: true
Everything in Kubernetes depends on correct typing.

YAML Lists
Lists are defined using -

Example:

containers:
  - name: app
  - name: sidecar
Each - represents a new item.

Misalignment here breaks parsing.

YAML Maps (Dictionaries)
Maps are key-value structures.

Example:

metadata:
  name: nginx
  labels:
    app: web
Nested maps are common in Kubernetes manifests.

YAML in Kubernetes
YAML is the backbone of Kubernetes.

Become a Medium member
Example structure:

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  containers:
    - name: nginx
      image: nginx
Every deployment, service, and config follows this pattern.

Common YAML Mistakes
Most issues come from:

Wrong indentation
Mixing tabs and spaces
Incorrect nesting
Missing - in lists
Example mistake:

containers:
- name: app
 image: nginx
That space misalignment will break parsing.

JSONPath: Extracting Data from JSON
YAML defines configuration.

JSONPath extracts data.

Used in:

kubectl queries
debugging cluster state
automation scripts
JSONPath Basics
JSONPath uses expressions to extract values.

Example:

kubectl get pods -o jsonpath='{.items[*].metadata.name}'
This returns:
All pod names.

JSONPath Syntax
Key patterns:

$ → root
. → child
[*] → all elements
[0] → index
Example:

{.items[0].metadata.name}
Gets first pod name.

JSONPath Filters
You can filter results.

Example:

{.items[?(@.status.phase=="Running")].metadata.name}
Returns only running pods.

This is powerful for debugging.

YAML + JSONPath Together
Real DevOps workflow:

Write YAML → define system
Apply → kubectl apply
Query → JSONPath
Debug → fix YAML
This loop is how production systems are managed.

Real Insight
YAML defines state.

JSONPath helps you observe that state.

Together, they form:

👉 Configuration + Visibility

Final Thought
Most engineers struggle with Kubernetes not because of Kubernetes…

But because they don’t fully understand YAML and JSONPath.

Once you master these two:

Everything becomes easier.

🎥 Watch full visual breakdown:
[https://www.youtube.com/watch?v=QXax6d8TO0M]

Follow for more DevOps deep dives 🚀
Enter fullscreen mode Exit fullscreen mode

Top comments (0)