我正在使用Gitlab helm chart在我的集群上安装 Gitlab。我想设置initialRootPassword,这样我就可以登录而无需执行kubectl get secret
## Initial root password for this GitLab installation
## Secret created according to doc/installation/secrets.md#initial-root-password
## If allowing shared-secrets generation, this is OPTIONAL.
initialRootPassword: {}
# secret: RELEASE-gitlab-initial-root-password
# key: password
上面的 block 有点令人困惑。你能帮我解决这个问题吗?谢谢。
最佳答案
初始RootPassword指的是secret kubernetes 中的对象,因此您必须首先在与 gitlab 实例相同的命名空间中创建一个 key ,然后将initialRootPassword 指向它。
例如,如果您希望root密码为“password”,首先需要对其进行base64编码
$ echo -n "password"|base64
cGFzc3dvcmQ=
然后添加到kubernetes
# secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: gitlab-root-password
data:
password: cGFzc3dvcmQ=
kubectl apply -f secret.yaml
还有其他方法可以创建 secret ,see the docs了解更多信息。
然后您可以设置初始RootPassword
initialRootPassword:
secret: gitlab-root-password
key: password
这里的key是指 secret 对象中数据 key 的名称。
另一种方法是使用 Gitlab default values它允许您创建一个将自动使用的 secret 对象,而无需显式设置initialRootPassword
此示例取自gitlab docs (将 <name>
替换为版本名称)。
kubectl create secret generic <name>-gitlab-initial-root-password --from-literal=password=$(head -c 512 /dev/urandom | LC_CTYPE=C tr -cd 'a-zA-Z0-9' | head -c 32)
关于kubernetes - 设置 gitlab 初始 root 密码 - Gitlab Helm 图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65695163/