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

kubectl create(创建一个集群资源对象

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

kubectl create

通过配置文件名或 stdin 创建一个集群资源对象。

支持 JSON 和 YAML 格式的文件。

语法

$ create -f FILENAME

示例

通过 pod.json 文件创建一个 pod。

kubectl create -f ./pod.json

通过 stdin 的 JSON 创建一个 pod。

cat pod.json | kubectl create -f -

API 版本为 v1 的 JSON 格式的 docker-registry.yaml 文件创建资源。

kubectl create -f docker-registry.yaml --edit --output-version=v1 -o json

Flags

Name Shorthand Default Usage
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.
edit false Edit the API resource before creating
filename f [] Filename, directory, or URL to files to use to create the resource
include-extended-apis true If true, include definitions of new APIs via calls to the API server. [default true]
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.
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’
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].
validate true If true, use a schema to validate the input before sending it
windows-line-endings false Only relevant if –edit=true. Use Windows line-endings (default Unix line-endings)

 

K8S 中文社区微信公众号

本文转载自 kubectl create(创建一个集群资源对象


蜷缩的蜗牛 , 版权所有丨如未注明 , 均为原创丨 转载请注明kubectl create(创建一个集群资源对象
喜欢 (0)
[]
分享 (0)