mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 10:15:22 +00:00
fix(examples): move examples from patchesStrategicMerge to patches
This commit is contained in:
@@ -73,8 +73,8 @@ commonLabels:
|
||||
who: alice
|
||||
resources:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- temperature.yaml
|
||||
patches:
|
||||
- path: temperature.yaml
|
||||
EOF
|
||||
|
||||
cat <<EOF >$DEMO_HOME/breakfast/overlays/alice/temperature.yaml
|
||||
@@ -96,8 +96,8 @@ commonLabels:
|
||||
who: bob
|
||||
resources:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- topping.yaml
|
||||
patches:
|
||||
- path: topping.yaml
|
||||
EOF
|
||||
|
||||
cat <<EOF >$DEMO_HOME/breakfast/overlays/bob/topping.yaml
|
||||
|
||||
@@ -127,8 +127,8 @@ secretGenerator:
|
||||
- site_key.txt
|
||||
- secret_key.txt
|
||||
|
||||
patchesStrategicMerge:
|
||||
- configmap.yaml
|
||||
patches:
|
||||
- path: configmap.yaml
|
||||
|
||||
patchesJson6902:
|
||||
- target:
|
||||
@@ -225,8 +225,8 @@ secretGenerator:
|
||||
files:
|
||||
- dbpass.txt
|
||||
|
||||
patchesStrategicMerge:
|
||||
- configmap.yaml
|
||||
patches:
|
||||
- path: configmap.yaml
|
||||
|
||||
patchesJson6902:
|
||||
- target:
|
||||
@@ -326,8 +326,8 @@ secretGenerator:
|
||||
- site_key.txt
|
||||
- secret_key.txt
|
||||
|
||||
patchesStrategicMerge:
|
||||
- configmap.yaml
|
||||
patches:
|
||||
- path: configmap.yaml
|
||||
|
||||
patchesJson6902:
|
||||
- target:
|
||||
@@ -536,8 +536,8 @@ secretGenerator:
|
||||
files:
|
||||
- dbpass.txt
|
||||
|
||||
patchesStrategicMerge:
|
||||
- configmap.yaml
|
||||
patches:
|
||||
- path: configmap.yaml
|
||||
|
||||
patchesJson6902:
|
||||
- target:
|
||||
@@ -592,8 +592,8 @@ secretGenerator:
|
||||
files:
|
||||
- ldappass.txt
|
||||
|
||||
patchesStrategicMerge:
|
||||
- configmap.yaml
|
||||
patches:
|
||||
- path: configmap.yaml
|
||||
|
||||
patchesJson6902:
|
||||
- target:
|
||||
|
||||
@@ -72,8 +72,8 @@ commonAnnotations:
|
||||
note: Hello, I am staging!
|
||||
resources:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- map.yaml
|
||||
patches:
|
||||
- path: map.yaml
|
||||
EOF
|
||||
|
||||
cat <<EOF >$OVERLAYS/staging/map.yaml
|
||||
|
||||
@@ -150,8 +150,8 @@ commonAnnotations:
|
||||
note: Hello, I am staging!
|
||||
resources:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- map.yaml
|
||||
patches:
|
||||
- path: map.yaml
|
||||
EOF
|
||||
```
|
||||
|
||||
@@ -191,8 +191,8 @@ commonAnnotations:
|
||||
note: Hello, I am production!
|
||||
resources:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- deployment.yaml
|
||||
patches:
|
||||
- path: deployment.yaml
|
||||
EOF
|
||||
```
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@ EOF
|
||||
```
|
||||
|
||||
|
||||
## Inline Patch for PatchesStrategicMerge
|
||||
## Inline Patch
|
||||
|
||||
Create an overlay and add an inline patch in `patchesStrategicMerge` field to the kustomization file
|
||||
Create an overlay and add an inline patch in the `patches` field to the kustomization file
|
||||
to change the image from `nginx` to `nginx:latest`.
|
||||
|
||||
<!-- @addSMPatch @test -->
|
||||
@@ -57,8 +57,8 @@ cat <<EOF >$SMP_OVERLAY/kustomization.yaml
|
||||
resources:
|
||||
- ../base
|
||||
|
||||
patchesStrategicMerge:
|
||||
- |-
|
||||
patches:
|
||||
- patch: |-
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -110,8 +110,8 @@ cat <<EOF >$SMP_OVERLAY/kustomization.yaml
|
||||
resources:
|
||||
- ../base
|
||||
|
||||
patchesStrategicMerge:
|
||||
- |-
|
||||
patches:
|
||||
- patch: |-
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
resources:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- deployment.yaml
|
||||
patches:
|
||||
- path: deployment.yaml
|
||||
namePrefix: production-
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
resources:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- deployment.yaml
|
||||
patches:
|
||||
- path: deployment.yaml
|
||||
namePrefix: staging-
|
||||
configMapGenerator:
|
||||
- name: env-config
|
||||
|
||||
@@ -150,7 +150,7 @@ Off the shelf MySQL uses `emptyDir` type volume, which
|
||||
gets wiped away if the MySQL Pod is recreated, and that
|
||||
is certainly not desirable for production
|
||||
environment. So we want to use Persistent Disk in
|
||||
production. kustomize lets you apply `patchesStrategicMerge` to the
|
||||
production. kustomize lets you apply `patches` to the
|
||||
resources.
|
||||
|
||||
<!-- @createPatchFile @testAgainstLatestRelease -->
|
||||
@@ -176,8 +176,8 @@ Add the patch file to `kustomization.yaml`:
|
||||
<!-- @specifyPatch @testAgainstLatestRelease -->
|
||||
```
|
||||
cat <<'EOF' >> $DEMO_HOME/kustomization.yaml
|
||||
patchesStrategicMerge:
|
||||
- persistent-disk.yaml
|
||||
patches:
|
||||
- path: persistent-disk.yaml
|
||||
EOF
|
||||
```
|
||||
|
||||
@@ -190,7 +190,7 @@ Lets break this down:
|
||||
in deployment.yaml
|
||||
|
||||
- Then we added `persistent-disk.yaml` to list of
|
||||
`patchesStrategicMerge` in `kustomization.yaml`. `kustomize build`
|
||||
`patches` in `kustomization.yaml`. `kustomize build`
|
||||
will apply this patch to the deployment resource with
|
||||
the name `mysql` as defined in the patch.
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ resources:
|
||||
- wordpress
|
||||
- mysql
|
||||
namePrefix: demo-
|
||||
patchesStrategicMerge:
|
||||
- patch.yaml
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
EOF
|
||||
```
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
resources:
|
||||
- wordpress
|
||||
- mysql
|
||||
patchesStrategicMerge:
|
||||
- patch.yaml
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
namePrefix: demo-
|
||||
|
||||
vars:
|
||||
|
||||
@@ -67,8 +67,8 @@ commonLabels:
|
||||
who: alice
|
||||
resources:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- temperature.yaml
|
||||
patches:
|
||||
- path: temperature.yaml
|
||||
EOF
|
||||
|
||||
cat <<EOF >$DEMO_HOME/breakfast/overlays/alice/temperature.yaml
|
||||
@@ -90,8 +90,8 @@ commonLabels:
|
||||
who: bob
|
||||
resources:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- topping.yaml
|
||||
patches:
|
||||
- path: topping.yaml
|
||||
EOF
|
||||
|
||||
cat <<EOF >$DEMO_HOME/breakfast/overlays/bob/topping.yaml
|
||||
|
||||
@@ -77,8 +77,8 @@ commonAnnotations:
|
||||
note: Hello, I am staging!
|
||||
resources:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- map.yaml
|
||||
patches:
|
||||
- path: map.yaml
|
||||
EOF
|
||||
|
||||
cat <<EOF >$OVERLAYS/staging/map.yaml
|
||||
|
||||
@@ -138,8 +138,8 @@ commonAnnotations:
|
||||
note: Hello, I am staging!
|
||||
resources:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- map.yaml
|
||||
patches:
|
||||
- path: map.yaml
|
||||
EOF
|
||||
```
|
||||
|
||||
@@ -177,8 +177,8 @@ commonAnnotations:
|
||||
note: Hello, I am production!
|
||||
resources:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- deployment.yaml
|
||||
patches:
|
||||
- path: deployment.yaml
|
||||
EOF
|
||||
```
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ sed -i.bak 's/app: helloworld/app: prod/' \
|
||||
|
||||
### 存储定制
|
||||
|
||||
现成的 MySQL 使用 `emptyDir` 类型的 volume,如果 MySQL Pod 被重新部署,则该类型的 volume 将会消失,这是不能应用于生产环境的,因此在生产环境中我们需要使用持久化磁盘。在 kustomize 中可以使用`patchesStrategicMerge` 来应用资源。
|
||||
现成的 MySQL 使用 `emptyDir` 类型的 volume,如果 MySQL Pod 被重新部署,则该类型的 volume 将会消失,这是不能应用于生产环境的,因此在生产环境中我们需要使用持久化磁盘。在 kustomize 中可以使用`patches` 来应用资源。
|
||||
|
||||
<!-- @createPatchFile @testAgainstLatestRelease -->
|
||||
```
|
||||
@@ -153,15 +153,15 @@ EOF
|
||||
<!-- @specifyPatch @testAgainstLatestRelease -->
|
||||
```
|
||||
cat <<'EOF' >> $DEMO_HOME/kustomization.yaml
|
||||
patchesStrategicMerge:
|
||||
- persistent-disk.yaml
|
||||
patches:
|
||||
- path: persistent-disk.yaml
|
||||
EOF
|
||||
```
|
||||
|
||||
`mysql-persistent-storage` 必须存在一个持久化磁盘才能使其成功运行,分为两步:
|
||||
|
||||
1. 创建一个名为 `persistent-disk.yaml` 的 YAML 文件,用于修改 deployment.yaml 的定义。
|
||||
2. 在 `kustomization.yaml` 中添加 `persistent-disk.yaml` 到 `patchesStrategicMerge` 列表中。运行 `kustomize build` 将 patch 应用于 Deployment 资源。
|
||||
2. 在 `kustomization.yaml` 中添加 `persistent-disk.yaml` 到 `patches` 列表中。运行 `kustomize build` 将 patch 应用于 Deployment 资源。
|
||||
|
||||
现在就可以将完整的配置输出并在集群中部署(将结果通过管道输出给 `kubectl apply`),在生产环境创建MySQL 应用。
|
||||
|
||||
|
||||
@@ -54,8 +54,8 @@ resources:
|
||||
- wordpress
|
||||
- mysql
|
||||
namePrefix: demo-
|
||||
patchesStrategicMerge:
|
||||
- patch.yaml
|
||||
patches:
|
||||
- path: patch.yaml
|
||||
EOF
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user