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

OPTIONS

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

OPTIONS INHERITED FROM PARENT COMMANDS

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

EXAMPLE

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

SEE ALSO

214       kubectl(1),
215
216
217

HISTORY

219       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
220       com)  based  on the kubernetes source material, but hopefully they have
221       been automatically generated since!
222
223
224
225Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum