MountVolume.SetUp 卷 "realm-secret" 失败:未找到机密 "realm-secret"

MountVolume.SetUp failed for volume "realm-secret" : secrets "realm-secret" not found

我正在尝试在我的 minikube 上安装 keycloak 和 运行。

我正在安装 keycloak

helm upgrade -i -f kubernetes/keycloak/values.yaml keycloak stable/keycloak --set keycloak.persistence.dbHost=rolling-newt-postgresql

我在仪表板中看到一条错误消息:

MountVolume.SetUp failed for volume "realm-secret" : secrets "realm-secret" not found

在我的values.yaml中我有这样的配置:

  extraVolumes: |
    - name: realm-secret
      secret:
        secretName: realm-secret
    - name: theme
      emptyDir: {}
    - name: spi
      emptyDir: {}
  extraVolumeMounts: |
    - name: realm-secret
      mountPath: "/realm/"
      readOnly: true
    - name: theme
      mountPath: /opt/jboss/keycloak/themes/mytheme
    - name: spi
      mountPath: /opt/jboss/keycloak/standalone/deployments

我还有一个 realm.json 文件。

问题

在安装 keycloak 之前,我需要如何处理这个 real.json 文件?我该怎么做?

原因是您在 extraVolumes 中引用了一个名为 realm-secret 的秘密,但名称为 realm-secret 的秘密既不是由 helm chart 创建的(名为 stable/keycloak ) 也不是您手动操作的。

您可以在 https://github.com/helm/charts/tree/master/stable/keycloak 中轻松找到该图表。

解决方案

values.yaml中,保留字段extraVolumeextraVolumeMount,以便用户在需要时提供额外的volume和额外的volumeMount。它们将在 keycloak pod 中使用。

因此,如果您需要提供 extraVolumes 来装载秘密,那么您必须自己创建该秘密,因此您需要在同一命名空间中创建秘密 realm-secret其中 install/upgrade 您的图表。然后才 install/upgrade 图表。

$ kubectl create secret generic realm-secret --namespace=<chart_namespace> --from-file=path/to/realm.json