gpt4 book ai didi

kubernetes - 如何转换 Kubernetes 对象的 apiVersion?

转载 作者:行者123 更新时间:2023-12-02 11:42:25 24 4
gpt4 key购买 nike

由于 kubectl convert 自 v1.14 起已弃用,并将在 v1.17 中删除,您如何转换 Kubernetes 对象的 API 版本?

还有其他简单安全的解决方案吗?

最佳答案

这正在 https://github.com/kubernetes/kubectl/issues/725 中讨论.目前此命令没有其他选择。

计划是在 1.17 上删除它,但我正在运行 1.18,并且该命令仍在运行。

我要说的是,目前您无需担心替代方案,因为它仍然有效。

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:56:40Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:48:36Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
$ kubectl convert --help
Convert config files between different API versions. Both YAML and JSON formats are accepted.

The command takes filename, directory, or URL as input, and convert it into format of version specified by
--output-version flag. If target version is not specified or not supported, convert to latest version.

The default output will be printed to stdout in YAML format. One can use -o option to change to output destination.

Examples:
# Convert 'pod.yaml' to latest version and print to stdout.
kubectl convert -f pod.yaml

# Convert the live state of the resource specified by 'pod.yaml' to the latest version
# and print to stdout in JSON format.
kubectl convert -f pod.yaml --local -o json

# Convert all files under current directory to latest version and create them all.
kubectl convert -f . | kubectl create -f -

Options:
--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.
-f, --filename=[]: Filename, directory, or URL to files to need to get converted.
-k, --kustomize='': Process the kustomization directory. This flag can't be used together with -f or -R.
--local=true: If true, convert will NOT try to contact api-server but run locally.
-o, --output='yaml': Output format. One of:
json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.
--output-version='': Output the formatted object with the given group version (for ex: 'extensions/v1beta1').
-R, --recursive=false: Process the directory used in -f, --filename recursively. Useful when you want to manage
related manifests organized within the same directory.
--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

Usage:
kubectl convert -f FILENAME [options]

Use "kubectl options" for a list of global command-line options (applies to all commands).

关于kubernetes - 如何转换 Kubernetes 对象的 apiVersion?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62283277/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com