liveBook · Manning

YAML

As explained in Road to Kubernetes

YAML is a human-readable data serialization format commonly used for configuration and declarative programming.

YAML is a human-readable format for configuration. Its short, indented entries make settings easy to review at a glance. A YAML file can describe what an automation tool should do without spelling out every step the tool takes. section 4.1.1

Listing 4.1 YAML basics
name: Hello World
items:
  sub-item:
    name: Hello
    description: world
  sub-list:
    - element a
    - element b
  other-list: [1, 2, 3]

Start with `name: Hello World`. Indentation places `sub-item` under `items`; hyphens and square brackets show two ways to write lists. section 4.1.1

To automate a Python project with GitHub Actions, put a workflow in `.github/workflows/hello-world.yaml`. The YAML declares when to run, which job and operating system to use, and which steps to execute. Commit and push the file so GitHub Actions can recognize it. section 4.1.1

Listing 4.2 Hello World with GitHub Actions
name: Hello World
on:
  workflow_dispatch:
  push:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Hello World
      run: echo "Hello World"

This workflow runs on a push or a manual request. Its `build` job checks out the repository, then runs a command that prints “Hello World.” section 4.1.1

The same format serves other deployment tasks. Ansible playbooks use YAML to define the desired state of remote hosts. Once a container image and Kubernetes cluster are available, a YAML file called a manifest describes an application deployment. YAML is useful across these tools and across application languages such as Python and Node.js. section 4.2.1 section 8.0 section 4.3

How Road to Kubernetes covers it

How deep it goes
Defines YAML and illustrates nested entries and lists before a complete workflow; leaves Kubernetes manifest syntax unexplained.
Examples
Uses a small nested YAML file and a Hello World GitHub Actions workflow.
What it assumes
Starts from a Python project and GitHub repository while defining YAML and declarative programming in plain language.
What you can do after
Apply it via GitHub Actions by writing, committing, pushing, and running a Hello World workflow.
How it connects
Links declarative programming to GitHub Actions workflows and Ansible playbooks that describe desired remote-host state.

Also explained in

Compare how 16 books explain YAML →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.