1KUBERNETES(1)(kubernetes) KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7
9 kubectl replace - Replace a resource by file name or stdin
10
11
12
14 kubectl replace [OPTIONS]
15
16
17
19 Replace a resource by file name or stdin.
20
21
22 JSON and YAML formats are accepted. If replacing an existing resource,
23 the complete resource spec must be provided. This can be obtained by
24
25
26 $ kubectl get TYPE NAME -o yaml
27
28
29
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 --cascade="background" Must be "background", "orphan", or "fore‐
37 ground". Selects the deletion cascading strategy for the dependents
38 (e.g. Pods created by a ReplicationController). Defaults to background.
39
40
41 --dry-run="none" Must be "none", "server", or "client". If client
42 strategy, only print the object that would be sent, without sending it.
43 If server strategy, submit server-side request without persisting the
44 resource.
45
46
47 --field-manager="kubectl-replace" Name of the manager used to
48 track field ownership.
49
50
51 -f, --filename=[] The files that contain the configurations to re‐
52 place.
53
54
55 --force=false If true, immediately remove resources from API and
56 bypass graceful deletion. Note that immediate deletion of some re‐
57 sources may result in inconsistency or data loss and requires confirma‐
58 tion.
59
60
61 --grace-period=-1 Period of time in seconds given to the resource
62 to terminate gracefully. Ignored if negative. Set to 1 for immediate
63 shutdown. Can only be set to 0 when --force is true (force deletion).
64
65
66 -k, --kustomize="" Process a kustomization directory. This flag
67 can't be used together with -f or -R.
68
69
70 -o, --output="" Output format. One of: (json, yaml, name, go-tem‐
71 plate, go-template-file, template, templatefile, jsonpath, jsonpath-as-
72 json, jsonpath-file).
73
74
75 --raw="" Raw URI to PUT to the server. Uses the transport speci‐
76 fied by the kubeconfig file.
77
78
79 -R, --recursive=false Process the directory used in -f, --filename
80 recursively. Useful when you want to manage related manifests organized
81 within the same directory.
82
83
84 --save-config=false If true, the configuration of current object
85 will be saved in its annotation. Otherwise, the annotation will be un‐
86 changed. This flag is useful when you want to perform kubectl apply on
87 this object in the future.
88
89
90 --show-managed-fields=false If true, keep the managedFields when
91 printing objects in JSON or YAML format.
92
93
94 --subresource="" If specified, replace will operate on the subre‐
95 source of the requested object. Must be one of [status scale]. This
96 flag is beta and may change in the future.
97
98
99 --template="" Template string or path to template file to use when
100 -o=go-template, -o=go-template-file. The template format is golang tem‐
101 plates [http://golang.org/pkg/text/template/#pkg-overview].
102
103
104 --timeout=0s The length of time to wait before giving up on a
105 delete, zero means determine a timeout from the size of the object
106
107
108 --validate="strict" Must be one of: strict (or true), warn, ignore
109 (or false). "true" or "strict" will use a schema to validate
110 the input and fail the request if invalid. It will perform server side
111 validation if ServerSideFieldValidation is enabled on the api-server,
112 but will fall back to less reliable client-side validation if not.
113 "warn" will warn about unknown or duplicate fields without
114 blocking the request if server-side field validation is enabled on the
115 API server, and behave as "ignore" otherwise. "false" or
116 "ignore" will not perform any schema validation, silently dropping any
117 unknown or duplicate fields.
118
119
120 --wait=false If true, wait for resources to be gone before return‐
121 ing. This waits for finalizers.
122
123
124
126 --as="" Username to impersonate for the operation. User could be a
127 regular user or a service account in a namespace.
128
129
130 --as-group=[] Group to impersonate for the operation, this flag
131 can be repeated to specify multiple groups.
132
133
134 --as-uid="" UID to impersonate for the operation.
135
136
137 --azure-container-registry-config="" Path to the file containing
138 Azure container registry configuration information.
139
140
141 --cache-dir="/builddir/.kube/cache" Default cache directory
142
143
144 --certificate-authority="" Path to a cert file for the certificate
145 authority
146
147
148 --client-certificate="" Path to a client certificate file for TLS
149
150
151 --client-key="" Path to a client key file for TLS
152
153
154 --cluster="" The name of the kubeconfig cluster to use
155
156
157 --context="" The name of the kubeconfig context to use
158
159
160 --disable-compression=false If true, opt-out of response compres‐
161 sion for all requests to the server
162
163
164 --insecure-skip-tls-verify=false If true, the server's certificate
165 will not be checked for validity. This will make your HTTPS connections
166 insecure
167
168
169 --kubeconfig="" Path to the kubeconfig file to use for CLI re‐
170 quests.
171
172
173 --match-server-version=false Require server version to match
174 client version
175
176
177 -n, --namespace="" If present, the namespace scope for this CLI
178 request
179
180
181 --password="" Password for basic authentication to the API server
182
183
184 --profile="none" Name of profile to capture. One of
185 (none|cpu|heap|goroutine|threadcreate|block|mutex)
186
187
188 --profile-output="profile.pprof" Name of the file to write the
189 profile to
190
191
192 --request-timeout="0" The length of time to wait before giving up
193 on a single server request. Non-zero values should contain a corre‐
194 sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
195 out requests.
196
197
198 -s, --server="" The address and port of the Kubernetes API server
199
200
201 --tls-server-name="" Server name to use for server certificate
202 validation. If it is not provided, the hostname used to contact the
203 server is used
204
205
206 --token="" Bearer token for authentication to the API server
207
208
209 --user="" The name of the kubeconfig user to use
210
211
212 --username="" Username for basic authentication to the API server
213
214
215 --version=false Print version information and quit
216
217
218 --warnings-as-errors=false Treat warnings received from the server
219 as errors and exit with a non-zero exit code
220
221
222
224 # Replace a pod using the data in pod.json
225 kubectl replace -f ./pod.json
226
227 # Replace a pod based on the JSON passed into stdin
228 cat pod.json | kubectl replace -f -
229
230 # Update a single-container pod's image version (tag) to v4
231 kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -
232
233 # Force replace, delete and then re-create the resource
234 kubectl replace --force -f ./pod.json
235
236
237
238
240 kubectl(1),
241
242
243
245 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
246 com) based on the kubernetes source material, but hopefully they have
247 been automatically generated since!
248
249
250
251Manuals User KUBERNETES(1)(kubernetes)