使用来自私有镜像仓库的自定义镜像

从 Neo4j 4.4.4 版本开始,您可以通过添加新的或现有的 imagePullSecrets 来使用私有仓库中的自定义镜像。

添加现有的 imagePullSecret

您可以在 values.yaml 文件中指定 imagePullSecret 的名称,从而为您的 Neo4j 部署使用现有的 imagePullSecret。Neo4j Helm Chart 会检查指定的 imagePullSecret 是否存在于 Kubernetes 集群中并使用它。如果集群中不存在指定名称的 Secret,Neo4j Helm Chart 将会报错。

有关如何将 Docker 凭据设置为集群 Secret 的更多信息,请参阅 Kubernetes 文档

使用已存在的 Secret mysecret
# values.yaml
# Override image settings in Neo4j pod
image:
  imagePullPolicy: IfNotPresent
  # set a customImage if you want to use your own docker image
  customImage: demo_neo4j_image:v1

  #imagePullSecrets list
  imagePullSecrets:
      - "mysecret"

创建并添加新的 imagePullSecret

或者,您也可以通过在 values.yaml 文件中定义相应的 imageCredential,为您的 Neo4j 部署创建一个新的 imagePullSecret

Neo4j Helm Chart 会创建一个指定名称的 Secret,并将其用作 imagePullSecret 来拉取定义的自定义镜像。以下示例展示了如何定义名称为 mysecret 的私有 Docker 仓库 imageCredential

创建并将 mysecret 作为 imagePullSecret 添加到集群中。
# values.yaml
# Override image settings in Neo4j pod
image:
  imagePullPolicy: IfNotPresent
  # set a customImage if you want to use your own docker image
  customImage: custom_neo4j_image:v1

  #imagePullSecrets list
  imagePullSecrets:
      - "mysecret"

  #imageCredentials list for which Secret of type docker-registry will be created automatically using the details provided
  # password and name are compulsory fields for an imageCredential, without these fields helm chart will throw an error
  # registry, username, and email are optional fields, but either the username or the email must be provided
  # imageCredential name should be part of the imagePullSecrets list or else the respective imageCredential will be ignored and no Secret creation will be done
  # In case of a Secret already pre-existing you don't need to mention the imageCredential, just add the pre-existing secretName to the imagePullSecret list
  # and that will be used as an imagePullSecret
  imageCredentials:
    - registry: "https://index.docker.io/v1/"
      username: "myusername"
      password: "your_password"
      email: "myusername@example.com"
      name: "mysecret"