fix(examples): move examples from patchesStrategicMerge to patches

This commit is contained in:
Daniel Strebel
2023-06-09 22:32:19 +02:00
parent 336bc14e1a
commit d37c0eb477
15 changed files with 74 additions and 74 deletions

View File

@@ -73,8 +73,8 @@ commonLabels:
who: alice who: alice
resources: resources:
- ../../base - ../../base
patchesStrategicMerge: patches:
- temperature.yaml - path: temperature.yaml
EOF EOF
cat <<EOF >$DEMO_HOME/breakfast/overlays/alice/temperature.yaml cat <<EOF >$DEMO_HOME/breakfast/overlays/alice/temperature.yaml
@@ -96,8 +96,8 @@ commonLabels:
who: bob who: bob
resources: resources:
- ../../base - ../../base
patchesStrategicMerge: patches:
- topping.yaml - path: topping.yaml
EOF EOF
cat <<EOF >$DEMO_HOME/breakfast/overlays/bob/topping.yaml cat <<EOF >$DEMO_HOME/breakfast/overlays/bob/topping.yaml

View File

@@ -127,8 +127,8 @@ secretGenerator:
- site_key.txt - site_key.txt
- secret_key.txt - secret_key.txt
patchesStrategicMerge: patches:
- configmap.yaml - path: configmap.yaml
patchesJson6902: patchesJson6902:
- target: - target:
@@ -225,8 +225,8 @@ secretGenerator:
files: files:
- dbpass.txt - dbpass.txt
patchesStrategicMerge: patches:
- configmap.yaml - path: configmap.yaml
patchesJson6902: patchesJson6902:
- target: - target:
@@ -326,8 +326,8 @@ secretGenerator:
- site_key.txt - site_key.txt
- secret_key.txt - secret_key.txt
patchesStrategicMerge: patches:
- configmap.yaml - path: configmap.yaml
patchesJson6902: patchesJson6902:
- target: - target:
@@ -536,8 +536,8 @@ secretGenerator:
files: files:
- dbpass.txt - dbpass.txt
patchesStrategicMerge: patches:
- configmap.yaml - path: configmap.yaml
patchesJson6902: patchesJson6902:
- target: - target:
@@ -592,8 +592,8 @@ secretGenerator:
files: files:
- ldappass.txt - ldappass.txt
patchesStrategicMerge: patches:
- configmap.yaml - path: configmap.yaml
patchesJson6902: patchesJson6902:
- target: - target:

View File

@@ -72,8 +72,8 @@ commonAnnotations:
note: Hello, I am staging! note: Hello, I am staging!
resources: resources:
- ../../base - ../../base
patchesStrategicMerge: patches:
- map.yaml - path: map.yaml
EOF EOF
cat <<EOF >$OVERLAYS/staging/map.yaml cat <<EOF >$OVERLAYS/staging/map.yaml

View File

@@ -150,8 +150,8 @@ commonAnnotations:
note: Hello, I am staging! note: Hello, I am staging!
resources: resources:
- ../../base - ../../base
patchesStrategicMerge: patches:
- map.yaml - path: map.yaml
EOF EOF
``` ```
@@ -191,8 +191,8 @@ commonAnnotations:
note: Hello, I am production! note: Hello, I am production!
resources: resources:
- ../../base - ../../base
patchesStrategicMerge: patches:
- deployment.yaml - path: deployment.yaml
EOF EOF
``` ```

View File

@@ -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`. to change the image from `nginx` to `nginx:latest`.
<!-- @addSMPatch @test --> <!-- @addSMPatch @test -->
@@ -57,18 +57,18 @@ cat <<EOF >$SMP_OVERLAY/kustomization.yaml
resources: resources:
- ../base - ../base
patchesStrategicMerge: patches:
- |- - patch: |-
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: deploy name: deploy
spec: spec:
template: template:
spec: spec:
containers: containers:
- name: nginx - name: nginx
image: nginx:latest image: nginx:latest
EOF EOF
``` ```
@@ -110,18 +110,18 @@ cat <<EOF >$SMP_OVERLAY/kustomization.yaml
resources: resources:
- ../base - ../base
patchesStrategicMerge: patches:
- |- - patch: |-
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: deploy name: deploy
spec: spec:
template: template:
spec: spec:
containers: containers:
- name: nginx - name: nginx
$patch: delete $patch: delete
EOF EOF
``` ```

View File

@@ -1,5 +1,5 @@
resources: resources:
- ../../base - ../../base
patchesStrategicMerge: patches:
- deployment.yaml - path: deployment.yaml
namePrefix: production- namePrefix: production-

View File

@@ -1,7 +1,7 @@
resources: resources:
- ../../base - ../../base
patchesStrategicMerge: patches:
- deployment.yaml - path: deployment.yaml
namePrefix: staging- namePrefix: staging-
configMapGenerator: configMapGenerator:
- name: env-config - name: env-config

View File

@@ -150,7 +150,7 @@ Off the shelf MySQL uses `emptyDir` type volume, which
gets wiped away if the MySQL Pod is recreated, and that gets wiped away if the MySQL Pod is recreated, and that
is certainly not desirable for production is certainly not desirable for production
environment. So we want to use Persistent Disk in 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. resources.
<!-- @createPatchFile @testAgainstLatestRelease --> <!-- @createPatchFile @testAgainstLatestRelease -->
@@ -176,8 +176,8 @@ Add the patch file to `kustomization.yaml`:
<!-- @specifyPatch @testAgainstLatestRelease --> <!-- @specifyPatch @testAgainstLatestRelease -->
``` ```
cat <<'EOF' >> $DEMO_HOME/kustomization.yaml cat <<'EOF' >> $DEMO_HOME/kustomization.yaml
patchesStrategicMerge: patches:
- persistent-disk.yaml - path: persistent-disk.yaml
EOF EOF
``` ```
@@ -190,7 +190,7 @@ Lets break this down:
in deployment.yaml in deployment.yaml
- Then we added `persistent-disk.yaml` to list of - 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 will apply this patch to the deployment resource with
the name `mysql` as defined in the patch. the name `mysql` as defined in the patch.

View File

@@ -55,8 +55,8 @@ resources:
- wordpress - wordpress
- mysql - mysql
namePrefix: demo- namePrefix: demo-
patchesStrategicMerge: patches:
- patch.yaml - path: patch.yaml
EOF EOF
``` ```

View File

@@ -1,8 +1,8 @@
resources: resources:
- wordpress - wordpress
- mysql - mysql
patchesStrategicMerge: patches:
- patch.yaml - path: patch.yaml
namePrefix: demo- namePrefix: demo-
vars: vars:

View File

@@ -67,8 +67,8 @@ commonLabels:
who: alice who: alice
resources: resources:
- ../../base - ../../base
patchesStrategicMerge: patches:
- temperature.yaml - path: temperature.yaml
EOF EOF
cat <<EOF >$DEMO_HOME/breakfast/overlays/alice/temperature.yaml cat <<EOF >$DEMO_HOME/breakfast/overlays/alice/temperature.yaml
@@ -90,8 +90,8 @@ commonLabels:
who: bob who: bob
resources: resources:
- ../../base - ../../base
patchesStrategicMerge: patches:
- topping.yaml - path: topping.yaml
EOF EOF
cat <<EOF >$DEMO_HOME/breakfast/overlays/bob/topping.yaml cat <<EOF >$DEMO_HOME/breakfast/overlays/bob/topping.yaml

View File

@@ -77,8 +77,8 @@ commonAnnotations:
note: Hello, I am staging! note: Hello, I am staging!
resources: resources:
- ../../base - ../../base
patchesStrategicMerge: patches:
- map.yaml - path: map.yaml
EOF EOF
cat <<EOF >$OVERLAYS/staging/map.yaml cat <<EOF >$OVERLAYS/staging/map.yaml

View File

@@ -138,8 +138,8 @@ commonAnnotations:
note: Hello, I am staging! note: Hello, I am staging!
resources: resources:
- ../../base - ../../base
patchesStrategicMerge: patches:
- map.yaml - path: map.yaml
EOF EOF
``` ```
@@ -177,8 +177,8 @@ commonAnnotations:
note: Hello, I am production! note: Hello, I am production!
resources: resources:
- ../../base - ../../base
patchesStrategicMerge: patches:
- deployment.yaml - path: deployment.yaml
EOF EOF
``` ```

View File

@@ -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 --> <!-- @createPatchFile @testAgainstLatestRelease -->
``` ```
@@ -153,15 +153,15 @@ EOF
<!-- @specifyPatch @testAgainstLatestRelease --> <!-- @specifyPatch @testAgainstLatestRelease -->
``` ```
cat <<'EOF' >> $DEMO_HOME/kustomization.yaml cat <<'EOF' >> $DEMO_HOME/kustomization.yaml
patchesStrategicMerge: patches:
- persistent-disk.yaml - path: persistent-disk.yaml
EOF EOF
``` ```
`mysql-persistent-storage` 必须存在一个持久化磁盘才能使其成功运行,分为两步: `mysql-persistent-storage` 必须存在一个持久化磁盘才能使其成功运行,分为两步:
1. 创建一个名为 `persistent-disk.yaml` 的 YAML 文件,用于修改 deployment.yaml 的定义。 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 应用。 现在就可以将完整的配置输出并在集群中部署(将结果通过管道输出给 `kubectl apply`在生产环境创建MySQL 应用。

View File

@@ -54,8 +54,8 @@ resources:
- wordpress - wordpress
- mysql - mysql
namePrefix: demo- namePrefix: demo-
patchesStrategicMerge: patches:
- patch.yaml - path: patch.yaml
EOF EOF
``` ```