這就是我嘗試為我的 kubernetes mongodb 創建秘密的方式,它使用bitnami mongodb helm chart進行部署:
apiVersion: v1
kind: Secret
metadata:
name: mongodb-secret
namespace: mongodb
labels:
app.kubernetes.io/component: mongodb
type: Opaque
data:
mongodb-root-password: 'encoded value'
mongodb-passwords: '???'
mongodb-metrics-password: 'encoded value'
mongodb-replica-set-key: 'encoded value'
掌舵圖 values.yaml 說:
auth:
## MongoDB(®) custom users and databases
## ref: https://github.com/bitnami/containers/tree/main/bitnami/mongodb#creating-a-user-and-database-on-first-run
## @param auth.usernames List of custom users to be created during the initialization
## @param auth.passwords List of passwords for the custom users set at `auth.usernames`
## @param auth.databases List of custom databases to be created during the initialization
##
usernames: []
passwords: []
databases: []
## @param auth.existingSecret Existing secret with MongoDB(®) credentials (keys: `mongodb-passwords`, `mongodb-root-password`, `mongodb-metrics-password`, ` mongodb-replica-set-key`)
## NOTE: When it's set the previous parameters are ignored.
##
existingSecret: ""
each和 eachpasswords的字串陣列也是如此。usernamedatabase
我如何在我的秘密中實施這些多個密碼?
helm 模板應該給我一個提示,但我不明白:secret.yaml
或者它是一個簡單的字串,所有密碼都由 分隔,和編碼?
uj5u.com熱心網友回復:
應該是這樣的:
auth:
usernames: ["bob", "alice"]
passwords: ["bobpass", "alicepass"]
databases: ["bobdb", "alicedb"]
如果你想在 cli --set 標志上傳遞那些,你應該能夠按照這個評論使用花括號:https ://github.com/helm/helm/issues/1987#issuecomment-280497496 - 比如:
--set auth.usernames={bob,alice},auth.passwords={bobpass,alicepass},auth.databases={bobdb,alicedb}
這將產生如下秘密 - 您可以使用helm template命令進行檢查:
---
# Source: mongodb/templates/secrets.yaml
apiVersion: v1
kind: Secret
metadata:
name: release-name-mongodb
namespace: default
labels:
app.kubernetes.io/name: mongodb
helm.sh/chart: mongodb-13.4.4
app.kubernetes.io/instance: release-name
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: mongodb
type: Opaque
data:
mongodb-root-password: "Uk1tZThhYzNFZg=="
mongodb-passwords: "Ym9icGFzcyxhbGljZXBhc3M="
---
您可以解碼 mongodb-passwords,使用:
echo -n Ym9icGFzcyxhbGljZXBhc3M= | base64 -d
并注意它看起來如下:bobpass,alicepass
另請注意,似乎有一個選項可以將 mongodb.createSecret 標志設定為 false 并手動創建該秘密(這可能更安全,具體取決于具體的作業流程)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/537955.html
標籤:数据库库伯内特斯kubernetes-helmkubernetes-秘密
