如何使用 Azure DevOps 将 JFrog Artifactory 中的镜像部署到 Azure Kubernetes 服务中

How to deploy the image from JFrog Artifactory into Azure Kubernetes service using Azure DevOps

我使用 Azure DevOps 构建管道构建 docker 图像并将其推送到 JFrog Artifactory。然后使用下面的 yaml 文件在发布定义中使用 Kubectl 任务将映像部署到 Azure AKS 环境中。

--- 
apiVersion: apps/v1
kind: Deployment
metadata: 
  labels: 
    app: webapplication-jfrog-deployment
  name: webapplication-jfrog-deployment
spec: 
  replicas: 2
  selector: 
    matchLabels: 
      app: webapplication-jfrog
  template: 
    metadata: 
      labels: 
        app: webapplication-jfrog
    spec: 
      containers: 
        - 
          image: #{JFrog_Login_Server_Name}#/webapplication:#{Version}#
          imagePullPolicy: Always
          name: webapplication-jfrog
          ports: 
            - 
              containerPort: 80
--- 
apiVersion: v1
kind: Service
metadata: 
  name: webapplication-jfrog-service
spec: 
  ports: 
    - 
      port: 80
  selector: 
    app: webapplication-jfrog
  type: LoadBalancer

部署上述 yaml 文件后,我在 pods:

中收到以下错误

Failed to pull image "xxxx-poc.jfrog.io/webapplication:xx": rpc error: code = Unknown desc = Error response from daemon: Get https://xxxx-poc.jfrog.io/v2/webapplication/manifests/xx: unknown: Authentication is required

出现此错误可能是身份验证问题,同时将图像从 JFrog Artifactory 拉入 Azure AKS 环境。

所以,谁能建议我如何将镜像从 JFrog Artifactory 部署到 Azure Kubernetes 服务中。

对于任何私有注册表,您需要创建一个 docker-registry 秘密,并在使用 imagePullSecrets.

拉取图像时指定它
  1. 创建秘密
kubectl create secret docker-registry artifactorycred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>
  1. 在 pod 定义中指定 secret
apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: <your-private-image>
  imagePullSecrets:
  - name: artifactorycred

有关详细信息,请参阅以下文档: