• 欢迎访问蜷缩的蜗牛博客 蜷缩的蜗牛
  • 微信搜索: 蜷缩的蜗牛 | 联系站长 kbsonlong@qq.com
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

kubectl set image(更新已有资源对象中的容器镜像)

kubectl命令表 蜷缩的蜗牛 3个月前 (06-20) 7次浏览 已收录

kubectl set image

更新现有的资源对象的容器镜像。

可使用资源对象包括(不区分大小写):

pod (po)、replicationcontroller (rc)、deployment (deploy)、daemonset (ds)、job、replicaset (rs)

语法

$ image (-f FILENAME | TYPE NAME) CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N

示例

将 deployment 中的 nginx 容器镜像设置为“nginx:1.9.1”。

kubectl set image deployment/nginx busybox=busybox nginx=nginx:1.9.1

所有 deployment 和 rc 的 nginx 容器镜像更新为“nginx:1.9.1”

kubectl set image deployments,rc nginx=nginx:1.9.1 --all

将 daemonset abc 的所有容器镜像更新为“nginx:1.9.1”

kubectl set image daemonset abc *=nginx:1.9.1

从本地文件中更新 nginx 容器镜像

kubectl set image -f path/to/file.yaml nginx=nginx:1.9.1 --local -o yaml

Flags

Name Shorthand Default Usage
all false select all resources in the namespace of the specified resource types
allow-missing-template-keys true If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
dry-run false If true, only print the object that would be sent, without sending it.
filename f [] Filename, directory, or URL to files identifying the resource to get from a server.
local false If true, set image will NOT contact api-server but run locally.
no-headers false When using the default or custom-column output format, don’t print headers (default print headers).
output o Output format. One of: json|yaml|wide|name|custom-columns=…|custom-columns-file=…|go-template=…|go-template-file=…|jsonpath=…|jsonpath-file=… See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-version DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: ‘jobs.v1.batch/myjob’).
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.
selector l Selector (label query) to filter on, supports ‘=’, ‘==’, and ‘!=’.
show-all a false When printing, show all resources (default hide terminated pods.)
show-labels false When printing, show all labels as the last column (default hide labels column)
sort-by If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. ‘{.metadata.name}’). The field in the API resource specified by this JSONPath expression must be an integer or a string.
template Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
K8S 中文社区微信公众号

本文转载自 kubectl set image(更新已有资源对象中的容器镜像)


蜷缩的蜗牛 , 版权所有丨如未注明 , 均为原创丨 转载请注明kubectl set image(更新已有资源对象中的容器镜像)
喜欢 (0)
[]
分享 (0)