Kubernetes kubectl replace 命令详解

kubectl replace



$ kubectl get TYPE NAME -o yaml



$ replace -f FILENAME



kubectl replace -f ./pod.json


cat pod.json | kubectl replace -f -


kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -


kubectl replace --force -f ./pod.json


Name Shorthand Default Usage
cascade false Only relevant during a force replace. If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController).
filename f [] Filename, directory, or URL to files to use to replace the resource.
force false Delete and re-create the specified resource
grace-period -1 Only relevant during a force replace. Period of time in seconds given to the old resource to terminate gracefully. Ignored if negative.
include-extended-apis true If true, include definitions of new APIs via calls to the API server. [default true]
output o Output mode. Use "-o name" for shorter output (resource/name).
record false Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursive R false Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
save-config false If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
schema-cache-dir ~/.kube/schema If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
timeout 0s Only relevant during a force replace. The length of time to wait before giving up on a delete of the old resource, zero means determine a timeout from the size of the object. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h).
validate true If true, use a schema to validate the input before sending it





业精于勤 荒于嬉;行成于思 毁于随;

《Kubernetes kubectl replace 命令详解》有2个想法

  1. cat pod.json | kubectl replace -f –



Time limit exceeded. Please complete the captcha once again.