Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

Kubernetes - YAML File

Back


Vim

Shortcut Action
:set nu Show Line Numbers
V + > Indent visually selected lines
>> Indent current line
<< Outdent current line
5>> Indent the next 5 lines
= Auto-align selected lines

YAML


Basic Syntax

---
# document 1
codename: YAML
name: YAML ain't markup language
release: 2001
---
# document 2
uses:
  - configuration language
  - data persistence
  - internet messaging
  - cross-language data sharing
---
# document 3
company: spacelift
domain:
  - devops
  - devsecops
tutorial:
  - name: yaml
  - type: awesome
  - rank: 1
  - born: 2001
author: omkarbirade
published: true

Common Data Structure

Scalar - Strings, numbers, boolean, …

message: >
  even though
  it looks like
  this is a multiline message,
  it is actually not

# ==
message: "even though it looks like this is a multiline message,it is actually not"

message: |
  this is
  a real multiline
  message

Mapping - Maps/Dictionaries

Fruit: Apple
Vegetable: Carrot
Liquid: Water
Meat: Chicken

Banana:
  Calories: 105
  Fat: 0.4 g
  Carbs: 27 g

Grapes:
  Calories: 62
  Fat: 0.3 g
  Carbs: 16 g

Sequences - Arrays/Lists

Fruits:
  - Orange
  - Apple
  - Banna

Vegetables: [Carrot, Cauliflower, Tomato]

Advanced

Fruits:
  - Banana:
      Calories: 105
      Fat: 0.4 g
      Carbs: 27 g

  - Grapes:
      Calories: 62
      Fat: 0.3 g
      Carbs: 16 g

Yaml File in Kubernetes

apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  # user custom label
  labels:
    app: myapp
    type: front-end
spec:
  # a list
  containers:
    - name: nginx-container
      image: nginx
Kind Version
pod v1
Service v1
ReplicaSet apps/v1
Deployment apps/v1