ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
有时一些 Pods 需要进入数据库,我们在本地机器上定义`username.txt`和`password.txt`文件存储 Pod 需要使用的用户名和密码。 ~~~bash echo -n 'admin' > /home/shiyanlou/username.txt echo -n '1f2d1e2e67df' > /home/shiyanlou/password.txt ~~~ 使用`kubectl create secret`命令以及参数`--from-file`指定使用这些文件调用 Api 服务器创建 Secret: ~~~bash $ kubectl create secret generic db-user-pass --from-file=/home/shiyanlou/username.txt --from-file=/home/shiyanlou/password.txt secret/db-user-pass created ~~~ 查看刚刚创建的 Secret: ~~~bash $ kubectl get secrets NAME TYPE DATA AGE db-user-pass Opaque 2 2m35s # 使用 describe 默认不会展示 secrets 的内容 $ kubectl describe secrets/db-user-pass Name: db-user-pass Namespace: default Labels: <none> Annotations: <none> Type: Opaque Data ==== password.txt: 12 bytes username.txt: 5 bytes ~~~