Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#5201 from danistrebel/fix/examples…
Browse files Browse the repository at this point in the history
…-patches

fix(examples): move examples from patchesStrategicMerge to patches
  • Loading branch information
k8s-ci-robot authored Feb 25, 2024
2 parents 9e68399 + d37c0eb commit 6ffcc08
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 74 deletions.
8 changes: 4 additions & 4 deletions examples/breakfast.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions examples/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ secretGenerator:
- site_key.txt
- secret_key.txt
patchesStrategicMerge:
- configmap.yaml
patches:
- path: configmap.yaml
patchesJson6902:
- target:
Expand Down Expand Up @@ -225,8 +225,8 @@ secretGenerator:
files:
- dbpass.txt
patchesStrategicMerge:
- configmap.yaml
patches:
- path: configmap.yaml
patchesJson6902:
- target:
Expand Down Expand Up @@ -326,8 +326,8 @@ secretGenerator:
- site_key.txt
- secret_key.txt
patchesStrategicMerge:
- configmap.yaml
patches:
- path: configmap.yaml
patchesJson6902:
- target:
Expand Down Expand Up @@ -536,8 +536,8 @@ secretGenerator:
files:
- dbpass.txt
patchesStrategicMerge:
- configmap.yaml
patches:
- path: configmap.yaml
patchesJson6902:
- target:
Expand Down Expand Up @@ -592,8 +592,8 @@ secretGenerator:
files:
- ldappass.txt
patchesStrategicMerge:
- configmap.yaml
patches:
- path: configmap.yaml
patchesJson6902:
- target:
Expand Down
4 changes: 2 additions & 2 deletions examples/configGeneration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions examples/helloWorld/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ commonAnnotations:
note: Hello, I am staging!
resources:
- ../../base
patchesStrategicMerge:
- map.yaml
patches:
- path: map.yaml
EOF
```
Expand Down Expand Up @@ -191,8 +191,8 @@ commonAnnotations:
note: Hello, I am production!
resources:
- ../../base
patchesStrategicMerge:
- deployment.yaml
patches:
- path: deployment.yaml
EOF
```
Expand Down
52 changes: 26 additions & 26 deletions examples/inlinePatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand All @@ -57,18 +57,18 @@ cat <<EOF >$SMP_OVERLAY/kustomization.yaml
resources:
- ../base
patchesStrategicMerge:
- |-
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy
spec:
template:
spec:
containers:
- name: nginx
image: nginx:latest
patches:
- patch: |-
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy
spec:
template:
spec:
containers:
- name: nginx
image: nginx:latest
EOF
```
Expand Down Expand Up @@ -110,18 +110,18 @@ cat <<EOF >$SMP_OVERLAY/kustomization.yaml
resources:
- ../base

patchesStrategicMerge:
- |-
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy
spec:
template:
spec:
containers:
- name: nginx
$patch: delete
patches:
- patch: |-
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy
spec:
template:
spec:
containers:
- name: nginx
$patch: delete

EOF
```
Expand Down
4 changes: 2 additions & 2 deletions examples/ldap/overlays/production/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- ../../base
patchesStrategicMerge:
- deployment.yaml
patches:
- path: deployment.yaml
namePrefix: production-
4 changes: 2 additions & 2 deletions examples/ldap/overlays/staging/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resources:
- ../../base
patchesStrategicMerge:
- deployment.yaml
patches:
- path: deployment.yaml
namePrefix: staging-
configMapGenerator:
- name: env-config
Expand Down
8 changes: 4 additions & 4 deletions examples/mySql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand All @@ -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
```
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions examples/wordpress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ resources:
- wordpress
- mysql
namePrefix: demo-
patchesStrategicMerge:
- patch.yaml
patches:
- path: patch.yaml
EOF
```

Expand Down
4 changes: 2 additions & 2 deletions examples/wordpress/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resources:
- wordpress
- mysql
patchesStrategicMerge:
- patch.yaml
patches:
- path: patch.yaml
namePrefix: demo-

vars:
Expand Down
8 changes: 4 additions & 4 deletions examples/zh/breakfast.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/zh/configGeneration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions examples/zh/helloWorld.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ commonAnnotations:
note: Hello, I am staging!
resources:
- ../../base
patchesStrategicMerge:
- map.yaml
patches:
- path: map.yaml
EOF
```
Expand Down Expand Up @@ -177,8 +177,8 @@ commonAnnotations:
note: Hello, I am production!
resources:
- ../../base
patchesStrategicMerge:
- deployment.yaml
patches:
- path: deployment.yaml
EOF
```
Expand Down
8 changes: 4 additions & 4 deletions examples/zh/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
```
Expand All @@ -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 应用。
Expand Down
4 changes: 2 additions & 2 deletions examples/zh/vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ resources:
- wordpress
- mysql
namePrefix: demo-
patchesStrategicMerge:
- patch.yaml
patches:
- path: patch.yaml
EOF
```

Expand Down

0 comments on commit 6ffcc08

Please sign in to comment.