1KUBERNETES(1)(kubernetes)                            KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7

NAME

9       kubectl patch - Update fields of a resource
10
11
12

SYNOPSIS

14       kubectl patch [OPTIONS]
15
16
17

DESCRIPTION

19       Update  fields  of a resource using strategic merge patch, a JSON merge
20       patch, or a JSON patch.
21
22
23       JSON and YAML formats are accepted.
24
25
26       Note: Strategic merge patch is not supported for custom resources.
27
28
29

OPTIONS

31       --allow-missing-template-keys=true      If true, ignore any  errors  in
32       templates  when a field or map key is missing in the template. Only ap‐
33       plies to golang and jsonpath output formats.
34
35
36       --dry-run="none"      Must be "none", "server", or "client". If  client
37       strategy, only print the object that would be sent, without sending it.
38       If server strategy, submit server-side request without  persisting  the
39       resource.
40
41
42       --field-manager="kubectl-patch"       Name of the manager used to track
43       field ownership.
44
45
46       -f, --filename=[]      Filename, directory, or URL to files identifying
47       the resource to update
48
49
50       -k,  --kustomize=""      Process the kustomization directory. This flag
51       can't be used together with -f or -R.
52
53
54       --local=false      If true, patch will operate on the  content  of  the
55       file, not the server-side resource.
56
57
58       -o,  --output=""      Output format. One of: (json, yaml, name, go-tem‐
59       plate, go-template-file, template, templatefile, jsonpath, jsonpath-as-
60       json, jsonpath-file).
61
62
63       -p, --patch=""      The patch to be applied to the resource JSON file.
64
65
66       --patch-file=""      A file containing a patch to be applied to the re‐
67       source.
68
69
70       --record=false      Record current kubectl command in the resource  an‐
71       notation.  If  set to false, do not record the command. If set to true,
72       record the command. If not set, default to updating the existing  anno‐
73       tation value only if one already exists.
74
75
76       -R, --recursive=false      Process the directory used in -f, --filename
77       recursively. Useful when you want to manage related manifests organized
78       within the same directory.
79
80
81       --show-managed-fields=false       If  true, keep the managedFields when
82       printing objects in JSON or YAML format.
83
84
85       --subresource=""      If specified, patch will operate  on  the  subre‐
86       source  of  the  requested  object. Must be one of [status scale]. This
87       flag is alpha and may change in the future.
88
89
90       --template=""      Template string or path to template file to use when
91       -o=go-template, -o=go-template-file. The template format is golang tem‐
92       plates [http://golang.org/pkg/text/template/#pkg-overview].
93
94
95       --type="strategic"      The type of patch being provided; one of  [json
96       merge strategic]
97
98
99

OPTIONS INHERITED FROM PARENT COMMANDS

101       --as=""      Username to impersonate for the operation. User could be a
102       regular user or a service account in a namespace.
103
104
105       --as-group=[]      Group to impersonate for the  operation,  this  flag
106       can be repeated to specify multiple groups.
107
108
109       --as-uid=""      UID to impersonate for the operation.
110
111
112       --azure-container-registry-config=""       Path  to the file containing
113       Azure container registry configuration information.
114
115
116       --cache-dir="/builddir/.kube/cache"      Default cache directory
117
118
119       --certificate-authority=""      Path to a cert file for the certificate
120       authority
121
122
123       --client-certificate=""      Path to a client certificate file for TLS
124
125
126       --client-key=""      Path to a client key file for TLS
127
128
129       --cluster=""      The name of the kubeconfig cluster to use
130
131
132       --context=""      The name of the kubeconfig context to use
133
134
135       --disable-compression=false       If true, opt-out of response compres‐
136       sion for all requests to the server
137
138
139       --insecure-skip-tls-verify=false      If true, the server's certificate
140       will not be checked for validity. This will make your HTTPS connections
141       insecure
142
143
144       --kubeconfig=""      Path to the kubeconfig file to  use  for  CLI  re‐
145       quests.
146
147
148       --match-server-version=false        Require  server  version  to  match
149       client version
150
151
152       -n, --namespace=""      If present, the namespace scope  for  this  CLI
153       request
154
155
156       --password=""      Password for basic authentication to the API server
157
158
159       --profile="none"         Name   of   profile   to   capture.   One   of
160       (none|cpu|heap|goroutine|threadcreate|block|mutex)
161
162
163       --profile-output="profile.pprof"      Name of the  file  to  write  the
164       profile to
165
166
167       --request-timeout="0"       The length of time to wait before giving up
168       on a single server request. Non-zero values  should  contain  a  corre‐
169       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
170       out requests.
171
172
173       -s, --server=""      The address and port of the Kubernetes API server
174
175
176       --tls-server-name=""      Server name to  use  for  server  certificate
177       validation.  If  it  is  not provided, the hostname used to contact the
178       server is used
179
180
181       --token=""      Bearer token for authentication to the API server
182
183
184       --user=""      The name of the kubeconfig user to use
185
186
187       --username=""      Username for basic authentication to the API server
188
189
190       --version=false      Print version information and quit
191
192
193       --warnings-as-errors=false      Treat warnings received from the server
194       as errors and exit with a non-zero exit code
195
196
197

EXAMPLE

199                # Partially update a node using a strategic merge patch, specifying the patch as JSON
200                kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}'
201
202                # Partially update a node using a strategic merge patch, specifying the patch as YAML
203                kubectl patch node k8s-node-1 -p $'spec:\n unschedulable: true'
204
205                # Partially update a node identified by the type and name specified in "node.json" using strategic merge patch
206                kubectl patch -f node.json -p '{"spec":{"unschedulable":true}}'
207
208                # Update a container's image; spec.containers[*].name is required because it's a merge key
209                kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}'
210
211                # Update a container's image using a JSON patch with positional arrays
212                kubectl patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'
213
214                # Update a deployment's replicas through the scale subresource using a merge patch.
215                kubectl patch deployment nginx-deployment --subresource='scale' --type='merge' -p '{"spec":{"replicas":2}}'
216
217
218
219

SEE ALSO

221       kubectl(1),
222
223
224

HISTORY

226       January  2015,  Originally compiled by Eric Paris (eparis at redhat dot
227       com) based on the kubernetes source material, but hopefully  they  have
228       been automatically generated since!
229
230
231
232Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum