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"
            }]
        }]
  }
}

 

posted @ 2020-03-22 16:08  Vincen_shen  阅读(838)  评论(0编辑  收藏  举报