frank@kubemaster:~$ mkdir kubectl-convert
frank@kubemaster:~$ cd kubectl-convert/
curl -LO “https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl-convert”
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 138 100 138 0 0 896 0 –:–:– –:–:– –:–:– 896
100 55.0M 100 55.0M 0 0 28.6M 0 0:00:01 0:00:01 –:–:– 38.4M
curl -LO “https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl-convert.sha256”
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 138 100 138 0 0 901 0 –:–:– –:–:– –:–:– 901 100 64 100 64 0 0 163 0 –:–:– –:–:– –:–:– 163
echo “$(cat kubectl-convert.sha256) kubectl-convert” | sha256sum –check
kubectl-convert: OK
sudo install -o root -g root -m 0755 kubectl-convert /usr/local/bin/kubectl-convert
frank@kubemaster:~/kubectl-convert$
frank@kubemaster:~/kubectl-convert$ 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.
Usage:
convert -f FILENAME
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 -
Flags:
--allow-missing-template-keys 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. (default true)
--as string Username to impersonate for the operation. User could be a regular user or a service account in a namespace.
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid string UID to impersonate for the operation.
--cache-dir string Default cache directory (default "/home/frank/.kube/cache")
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use
--context string The name of the kubeconfig context to use
--disable-compression If true, opt-out of response compression for all requests to the server
-f, --filename strings Filename, directory, or URL to files to need to get converted.
-h, --help help for convert
--insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
--kubeconfig string Path to the kubeconfig file to use for CLI requests.
-k, --kustomize string Process the kustomization directory. This flag can't be used together with -f or -R.
--local If true, convert will NOT try to contact api-server but run locally. (default true)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--match-server-version Require server version to match client version
-n, --namespace string If present, the namespace scope for this CLI request
-o, --output string Output format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). (default "yaml")
--output-version string Output the formatted object with the given group version (for ex: 'extensions/v1beta1').
--password string Password for basic authentication to the API server
-R, --recursive Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
--request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
-s, --server string The address and port of the Kubernetes API server
--show-managed-fields If true, keep the managedFields when printing objects in JSON or YAML format.
--template string 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].
--tls-server-name string Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used
--token string Bearer token for authentication to the API server
--user string The name of the kubeconfig user to use
--username string Username for basic authentication to the API server
-v, --v Level number for the log level verbosity
--validate string[="strict"] Must be one of: strict (or true), warn, ignore (or false).
"true" or "strict" will use a schema to validate the input and fail the request if invalid. It will perform server side validation if ServerSideFieldValidation is enabled on the api-server, but will fall back to less reliable client-side validation if not.
"warn" will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as "ignore" otherwise.
"false" or "ignore" will not perform any schema validation, silently dropping any unknown or duplicate fields. (default "strict")
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging (only works for the default text log format)