[CKA] YAML 빠른 참조
쿠버네티스 매니페스트를 읽고 쓰는 데 필요한 YAML 문법을 한 페이지로 정리합니다.
# 주석과 스칼라
string_value: Hello, World!
integer_value: 42
float_value: 3.14159
boolean_value: true
null_value: null
# 따옴표와 여러 줄 문자열
quoted_string: "This is a quoted string"
single_quoted: 'This is a single-quoted string'
multi_line: |
This is a multi-line string.
It preserves newlines.
folded_string: >
This is a folded string.
It folds newlines to spaces.
# 리스트와 맵
simple_list:
- item1
- item2
dictionary:
key1: value1
key2: value2
# 중첩 구조
person:
name: John Doe
age: 30
hobbies:
- reading
- swimming
# 앵커와 별칭
defaults: &defaults
key1: value1
key2: value2
copied: *defaults
# 명시적 타입
explicit_string: !!str 42
explicit_int: !!int "42"
쿠버네티스 매니페스트도 같은 구조를 사용합니다.
apiVersion: v1
kind: Pod
metadata:
name: example-pod
labels:
app: myapp
spec:
containers:
- name: myapp-container
image: busybox
command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600']