gpt4 book ai didi

kubernetes - 是否可以获取 `.env`文件来创建Kubernetes secret ?

转载 作者:行者123 更新时间:2023-12-04 00:37:18 25 4
gpt4 key购买 nike

docs states

To create a Secret from one or more files, use --from-file. You specify files in any plaintext format, such as .txt or .env, as long as the files contain key-value pairs.



.test-secret
NAME=martin
GENDER=male

测试以基于我的.test-secret文件创建一个 secret 。
kubectl create secret generic person --from-file .test-secret -o yml

$ kubectl get secret person -o yaml
apiVersion: v1
data:
.test-secret: TkFNRT1tYXJ0aW4KR0VOREVSPW1hbGUK
kind: Secret
metadata:
creationTimestamp: 2018-07-19T09:23:05Z
name: person
namespace: default
resourceVersion: "229992"
selfLink: /api/v1/namespaces/default/secrets/person
uid: 579198ab-8b35-11e8-8895-42010a840008
type: Opaque

是否可以读取这样的键/值列表?甚至可以从 .env文件中这样做吗? kubectl get pods返回CreateContainerConfigError

my-app.yml
 77             - name: NAME
78 valueFrom:
79 secretKeyRef:
80 name: person
81 key: NAME

最佳答案

是的,使用选项--from-env-file

kubectl create secret generic person --from-env-file=.test-secret

关于kubernetes - 是否可以获取 `.env`文件来创建Kubernetes secret ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51419102/

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