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 alpha 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 --insecure-skip-tls-verify=false If true, the server's certificate
161 will not be checked for validity. This will make your HTTPS connections
162 insecure
163
164
165 --kubeconfig="" Path to the kubeconfig file to use for CLI re‐
166 quests.
167
168
169 --match-server-version=false Require server version to match
170 client version
171
172
173 -n, --namespace="" If present, the namespace scope for this CLI
174 request
175
176
177 --password="" Password for basic authentication to the API server
178
179
180 --profile="none" Name of profile to capture. One of
181 (none|cpu|heap|goroutine|threadcreate|block|mutex)
182
183
184 --profile-output="profile.pprof" Name of the file to write the
185 profile to
186
187
188 --request-timeout="0" The length of time to wait before giving up
189 on a single server request. Non-zero values should contain a corre‐
190 sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
191 out requests.
192
193
194 -s, --server="" The address and port of the Kubernetes API server
195
196
197 --tls-server-name="" Server name to use for server certificate
198 validation. If it is not provided, the hostname used to contact the
199 server is used
200
201
202 --token="" Bearer token for authentication to the API server
203
204
205 --user="" The name of the kubeconfig user to use
206
207
208 --username="" Username for basic authentication to the API server
209
210
211 --version=false Print version information and quit
212
213
214 --warnings-as-errors=false Treat warnings received from the server
215 as errors and exit with a non-zero exit code
216
217
218
220 # Replace a pod using the data in pod.json
221 kubectl replace -f ./pod.json
222
223 # Replace a pod based on the JSON passed into stdin
224 cat pod.json | kubectl replace -f -
225
226 # Update a single-container pod's image version (tag) to v4
227 kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -
228
229 # Force replace, delete and then re-create the resource
230 kubectl replace --force -f ./pod.json
231
232
233
234
236 kubectl(1),
237
238
239
241 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
242 com) based on the kubernetes source material, but hopefully they have
243 been automatically generated since!
244
245
246
247Manuals User KUBERNETES(1)(kubernetes)