在 kubernetes helm 中拉取 azure 容器注册表映像

Abd*_*man 5 azure docker kubernetes kubernetes-helm azure-container-registry

我正在开发一个使用 Helm-kubernetes 和 azure kubernetes 服务的项目,其中我尝试使用一个简单的节点映像,该映像已被推送到我的 helm 图表内的 azure 容器注册表上,但它返回ImagePullBackOff错误。

以下是一些细节:

我的Dockerfile

FROM node:8

# Create app directory
WORKDIR /usr/src/app


COPY package*.json ./

RUN npm install

# Bundle app source
COPY . .

EXPOSE 32000
CMD [ "npm", "start" ]
Run Code Online (Sandbox Code Playgroud)

我的helm_chart/values.yaml

replicaCount: 1

image:
  registry: helmcr.azurecr.io
  repository: helloworldtest
  tag: 0.7
  pullPolicy: IfNotPresent

nameOverride: ""
fullnameOverride: ""

service:
  name: http
  type: LoadBalancer
  port: 32000
  internalPort: 32000

ingress:
  enabled: false
  annotations: {}
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  paths: []
  hosts:
    - name: mychart.local
      path: /
  tls: []

resources: {}

nodeSelector: {}

tolerations: []

affinity: {}
Run Code Online (Sandbox Code Playgroud)

当我尝试使用以下命令直接拉取图像时: docker pull helmcr.azurecr.io/helloworldtest:0.7 然后它会成功拉取图像。

这里有什么问题吗?

提前致谢!

4c7*_*b41 5

您的 kubernetes 集群需要通过容器注册表的身份验证才能提取映像,通常这是通过 docker 密钥来完成的:

kubectl create secret docker-registry regcred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>
Run Code Online (Sandbox Code Playgroud)

如果您使用的是AKS,您可以向注册表授予集群应用程序ID拉取权限,这就足够了。

阅读:https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/