User Tools

Site Tools


k8s:core:yaml_basics

YAML Structure in Kubernetes

Kubernetes uses YAML files to describe what you want the cluster to create.

Instead of writing code, you declare the desired state.

Basic structure

Every Kubernetes YAML usually has 4 main parts:

  • apiVersion
  • kind
  • metadata
  • spec

Simple example

apiVersion: v1

kind: Pod

metadata: name: my-pod

spec: containers: - name: nginx image: nginx

Key idea

YAML is NOT procedural. It is declarative:

  • You say what you want
  • Kubernetes figures out how to do it
k8s/core/yaml_basics.txt · Last modified: by phong2018