【发布时间】:2020-09-02 22:45:21
【问题描述】:
有没有办法在 Kubernetes 中从环境变量而不是文件创建 tls 机密?
例如
kubectl create secret tls secret-tls --cert $ENV1 --key $ENV2
【问题讨论】:
-
是的,如果环境变量设置正确,您编写的命令将在 bash 中运行。
标签: kubernetes kubernetes-secrets
有没有办法在 Kubernetes 中从环境变量而不是文件创建 tls 机密?
例如
kubectl create secret tls secret-tls --cert $ENV1 --key $ENV2
【问题讨论】:
标签: kubernetes kubernetes-secrets
是的,你可以。运行帮助 cmd。
$ kubectl create secret tls --help
Create a TLS secret from the given public/private key pair.
The public/private key pair must exist before hand. The public key certificate must be .PEM encoded and match the given
private key.
Examples:
# Create a new TLS secret named tls-secret with the given key pair:
kubectl create secret tls tls-secret --cert=path/to/tls.cert --key=path/to/tls.key
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.
--append-hash=false: Append a hash of the secret to its name.
--cert='': Path to PEM encoded public key certificate.
--dry-run=false: If true, only print the object that would be sent, without sending it.
--generator='secret-for-tls/v1': The name of the API generator to use.
--key='': Path to private key associated with given certificate.
-o, --output='': Output format. One of:
json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.
--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.
--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 create secret tls NAME --cert=path/to/cert/file --key=path/to/key/file [--dry-run] [options]
Use "kubectl options" for a list of global command-line options (applies to all commands).
如果您想使用环境中的数据,请设置证书和 环境变量的密钥文件路径。不是数据本身。
【讨论】: