YAML Multi-Document Streams

Document separators, multi-resource YAML files, and commands for splitting, filtering, and validating streamed YAML.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Multi-document YAML
Two YAML documents in one file
app: api
port: 8080
---
app: worker
port: 9090

# Use `---` to separate resources or configs.

Explicit document end marker
name: sample
...

# Use `...` to mark the end of a document when needed.

Apply a multi-document manifest
kubectl apply -f stack.yaml

# Send several Kubernetes resources in one file.

Split YAML documents into separate files
yq -s '.metadata.name' stack.yaml

# Write each YAML document to its own output file.

## Select and inspect documents
Read the first YAML document
yq 'select(documentIndex == 0)' stack.yaml

# Query the first document in a stream.

Select Kubernetes documents by kind
yq 'select(.kind == "Deployment")' stack.yaml

# Filter documents in a manifest stream.

Render Helm templates to YAML
helm template myapp ./chart

# Generate YAML output for inspection before deployment.

Recommended next

No recommendations yet.