简体   繁体   English

Azure DevOps 管道 AKS 发布部署

[英]Azure DevOps Pipeline AKS Release Deploy

在此处输入图像描述 I use Release pipelines to deploy my apps to AKS.我使用发布管道将我的应用程序部署到 AKS。 After the build pipeline is finished then trigger release.I saw that all artifacts are already there.The deploy release pipeline is simple.构建管道完成后触发发布。我看到所有工件都已经存在。部署发布管道很简单。 Agency Job, Create Secret Job, and deploy to Kube.netes job.The error happens in the Deployment job Agency Job,Create Secret Job,部署到Kube.netes job。错误发生在Deployment job

2022-12-04T15:28:24.9668012Z ##[error]error: must specify one of -f and -k [command]/usr/local/bin/kubectl apply -f --namespace dev 2022-12-04T15:28:24.9668012Z ##[错误]错误:必须指定 -f 和 -k [命令]/usr/local/bin/kubectl apply -f --namespace dev 之一

The app is based on.Net6 and I use the Manifests folder with one yml.该应用程序基于.Net6,我使用带有一个yml 的Manifests 文件夹。 Why apply -f does not find my deployment.yml.为什么apply -f 找不到我的deployment.yml。 I put him here in input Manifests field $(System.DefaultWorkingDirectory)/_Service/Manifests/dev/deployment.yml deployment:我把他这里的input Manifests字段$(System.DefaultWorkingDirectory)/_Service/Manifests/dev/deployment.yml deployment:

    apiVersion: apps/v1
kind: Deployment
metadata:
  name: service-deployment-dev
spec:
  selector:
    matchLabels:
      app: service-dev
  template:
    metadata:
      labels:
        app: service-dev
    spec:
      containers:
      - name: service-dev
        image: registry.azurecr.io/service-dev
        resources:
            limits:
              memory: "128Mi"
              cpu: "200m"
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: service-cluster-dev
  namespace: dev
spec:
  selector:
    app: service-dev
  type: ClusterIP
  ports:
  - name: service-dev
    protocol: TCP
    port: 80

I can reproduce the same issue when using the Kubectl task and apply command.使用 Kubectl 任务和应用命令时,我可以重现同样的问题。

The cause of the issue could be that you specified the deployment.yml file in the wrong field of task.问题的原因可能是您在错误的任务字段中指定了 deployment.yml 文件。

在此处输入图像描述

To solve this issue, you need to enable the Use configuration option and set the deployment.yml path.要解决此问题,您需要启用Use configuration选项并设置 deployment.yml 路径。

For example:例如:

在此处输入图像描述

Or you can change to use the task: Deploy to Kube.netes to deploy to AKS.或者您可以更改为使用任务:部署到 Kube.netes以部署到 AKS。 In this task, you can directly define the deployment.yml file in the task.在这个任务中,你可以直接在任务中定义 deployment.yml 文件。 And this is required.这是必需的。

For example:例如:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM