@@ -54,15 +54,12 @@ get terminated and replaced by new ones.
54
54
At this point, each Pod has one Container that runs the nginx image. Now suppose
55
55
you want each Pod to have two containers: one that runs nginx and one that runs redis.
56
56
57
- Create a file named ` patch-file.yaml ` that has this content :
57
+ Create a file named ` patch-file.yaml ` that has ` .spec.template.spec.containers ` field as follow :
58
58
59
59
``` shell
60
- spec:
61
- template:
62
- spec:
63
- containers:
64
- - name: patch-demo-ctr-2
65
- image: redis
60
+ containers:
61
+ - name: patch-demo-ctr-2
62
+ image: redis
66
63
```
67
64
68
65
Patch your Deployment:
@@ -81,14 +78,14 @@ The output shows that the PodSpec in the Deployment has two Containers:
81
78
82
79
``` shell
83
80
containers:
84
- - image: nginx
85
- imagePullPolicy: Always
86
- name: patch-demo-ctr
87
- ...
88
81
- image: redis
89
82
imagePullPolicy: Always
90
83
name: patch-demo-ctr-2
91
84
...
85
+ - image: nginx
86
+ imagePullPolicy: Always
87
+ name: patch-demo-ctr
88
+ ...
92
89
```
93
90
94
91
View the Pods associated with your patched Deployment:
@@ -118,10 +115,10 @@ The output shows that the Pod has two Containers: one running nginx and one runn
118
115
119
116
```
120
117
containers:
121
- - image: nginx
122
- ...
123
118
- image: redis
124
119
...
120
+ - image: nginx
121
+ ...
125
122
```
126
123
127
124
### Notes on the strategic merge patch
@@ -160,15 +157,12 @@ The default value for the `type` parameter is `strategic`. So in the preceding e
160
157
did a strategic merge patch.
161
158
162
159
Next, do a JSON merge patch on your same Deployment. Create a file named ` patch-file-2.yaml `
163
- that has this content :
160
+ that has ` .spec.template.spec.containers ` field as follow :
164
161
165
162
``` shell
166
- spec:
167
- template:
168
- spec:
169
- containers:
170
- - name: patch-demo-ctr-3
171
- image: gcr.io/google-samples/node-hello:1.0
163
+ containers:
164
+ - name: patch-demo-ctr-3
165
+ image: gcr.io/google-samples/node-hello:1.0
172
166
```
173
167
174
168
In your patch command, set ` type ` to ` merge ` :
0 commit comments