YAML语法格式
YAML两个主要的元素:
- List
- Map
List示例
YAML格式:
args: -beijing -shanghai -shenzhen -guangzhou
等同于:
{
"args": ["beijing", "shanghai", "shenzhen", "guangzhou"]
}
Map示例
YAML格式: apiVersion: v1 kind: Pod metadata: name: kube-site labels: app: web
等同于:
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "kube-site",
"labels" {"app": "web"}
}
}
综合示例
YAML示例:
apiVersion: v1 kind: Pod metadata: name: kube100-site labels: app: web spec: containers: - name: front-end image: nginx ports: - containerPort: 80 - name: flaskapp-demo image: jcdemo/flaskapp ports: 8080
等同于:
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "kube100-site",
"labels": {
"app": "web"
},
},
"spec": {
"containers": [{
"name": "front-end",
"image": "nginx",
"ports": [{
"containerPort": "80"
}]
}, {
"name": "flaskapp-demo",
"image": "jcdemo/flaskapp",
"ports": [{
"containerPort": "5000"
}]
}]
}
}