Skip to content

Latest commit

 

History

History
118 lines (95 loc) · 2.5 KB

breakfast.md

File metadata and controls

118 lines (95 loc) · 2.5 KB

示例:早餐配置

定义一个工作空间:

DEMO_HOME=$(mktemp -d)

创建目录用于存放早餐的 base 配置:

mkdir -p $DEMO_HOME/breakfast/base

创建一个 kustomization 来定义早餐所需的食物。包含咖啡和薄煎饼:

cat <<EOF >$DEMO_HOME/breakfast/base/kustomization.yaml
resources:
- coffee.yaml
- pancakes.yaml
EOF

这里有一个 coffee 类型。定义kindmetdata/name 字段以符合 kubernetes API 对象样式,不需要其他文件或定义:

cat <<EOF >$DEMO_HOME/breakfast/base/coffee.yaml
kind: Coffee
metadata:
  name: morningCup
temperature: lukewarm
data:
  greeting: "Good Morning!"
EOF

name 字段仅将这种咖啡实例与其他实例(如果有的话)区分开

同样,定义 pancakes

cat <<EOF >$DEMO_HOME/breakfast/base/pancakes.yaml
kind: Pancakes
metadata:
  name: comfort
stacksize: 3
topping: none
EOF

为喜欢热咖啡的 Alice 定制她的早餐:

mkdir -p $DEMO_HOME/breakfast/overlays/alice

cat <<EOF >$DEMO_HOME/breakfast/overlays/alice/kustomization.yaml
commonLabels:
  who: alice
resources:
- ../../base
patchesStrategicMerge:
- temperature.yaml
EOF

cat <<EOF >$DEMO_HOME/breakfast/overlays/alice/temperature.yaml
kind: Coffee
metadata:
  name: morningCup
temperature: hot!
EOF

同样的,Bob 想要 5 块薄煎饼和草莓:

mkdir -p $DEMO_HOME/breakfast/overlays/bob

cat <<EOF >$DEMO_HOME/breakfast/overlays/bob/kustomization.yaml
commonLabels:
  who: bob
resources:
- ../../base
patchesStrategicMerge:
- topping.yaml
EOF

cat <<EOF >$DEMO_HOME/breakfast/overlays/bob/topping.yaml
kind: Pancakes
metadata:
  name: comfort
stacksize: 5
topping: strawberries
EOF

现在,可以为 Alice 的早餐生成配置了:

kustomize build $DEMO_HOME/breakfast/overlays/alice

同样的,也为 Bob 的早餐生成配置:

kustomize build $DEMO_HOME/breakfast/overlays/bob