@@ -46,6 +46,25 @@ cat <<EOF >$DEMO_HOME/ingress_patch.json
46
46
EOF
47
47
```
48
48
49
+ You can also write the patch in YAML format. This example also shows the "add" operation:
50
+
51
+ <!-- @addYamlPatch @test -->
52
+ ```
53
+ cat <<EOF >$DEMO_HOME/ingress_patch.yaml
54
+ - op: replace
55
+ path: /spec/rules/0/host
56
+ value: foo.bar.io
57
+
58
+ - op: add
59
+ path: /spec/rules/0/http/paths/-
60
+ value:
61
+ path: '/test'
62
+ backend:
63
+ serviceName: my-test
64
+ servicePort: 8081
65
+ EOF
66
+ ```
67
+
49
68
Apply the patch by adding _ patchesJson6902_ field in kustomization.yaml
50
69
51
70
<!-- @applyJsonPatch @test -->
@@ -61,17 +80,39 @@ patchesJson6902:
61
80
EOF
62
81
```
63
82
64
- Running ` kustomize build $DEMO_HOME ` , in the ourput confirm that host has been updated correctly.
83
+ Running ` kustomize build $DEMO_HOME ` , in the output confirm that host has been updated correctly.
65
84
<!-- @confirmHost @test -->
66
85
```
67
86
test 1 == \
68
87
$(kustomize build $DEMO_HOME | grep "host: foo.bar.io" | wc -l); \
69
88
echo $?
70
89
```
71
- Running ` kustomize build $DEMO_HOME ` , in the ourput confirm that the servicePort has been updated correctly.
90
+ Running ` kustomize build $DEMO_HOME ` , in the output confirm that the servicePort has been updated correctly.
72
91
<!-- @confirmServicePort @test -->
73
92
```
74
93
test 1 == \
75
94
$(kustomize build $DEMO_HOME | grep "servicePort: 8080" | wc -l); \
76
95
echo $?
77
96
```
97
+
98
+ If the patch is YAML-formatted, it will be parsed correctly:
99
+
100
+ <!-- @applyYamlPatch @test -->
101
+ ```
102
+ cat <<EOF >>$DEMO_HOME/kustomization.yaml
103
+ patchesJson6902:
104
+ - target:
105
+ group: extensions
106
+ version: v1beta1
107
+ kind: Ingress
108
+ name: my-ingress
109
+ path: ingress_patch.yaml
110
+ EOF
111
+ ```
112
+
113
+ <!-- @confirmYamlPatch @test -->
114
+ ```
115
+ test 1 == \
116
+ $(kustomize build $DEMO_HOME | grep "path: /test" | wc -l); \
117
+ echo $?
118
+ ```
0 commit comments