容器编排技术 -- Kubernetes kubectl create 命令详解

容器编排技术 -- Kubernetes kubectl create 命令详解

 

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

NameShorthandDefaultUsage
allow-missing-template-keys trueIf 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 falseIf true, only print the object that would be sent, without sending it.
edit falseEdit the API resource before creating
filenamef[]Filename, directory, or URL to files to use to create the resource
include-extended-apis trueIf true, include definitions of new APIs via calls to the API server. [default true]
no-headers falseWhen using the default or custom-column output format, don't print headers (default print headers).
outputo 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 falseRecord 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.
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
save-config falseIf 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/schemaIf non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
selectorl Selector (label query) to filter on, supports '=', '==', and '!='.
show-allafalseWhen printing, show all resources (default hide terminated pods.)
show-labels falseWhen 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 trueIf true, use a schema to validate the input before sending it
windows-line-endings falseOnly relevant if --edit=true. Use Windows line-endings (default Unix line-endings)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值