azure devops发布管道在kubectl应用程序方面持续失败吗?

时间:2019-05-30 12:18:28

标签: kubernetes azure-devops azure-kubernetes

在azure devops门户中,我的发布管道在kubectl apply时一直失败。它说服务器找不到请求的资源。

注意:我尚未在azure门户中创建kubernetes集群。因此,当我进入门户创建门户时,它要求付费订阅。

发布管道的日志

2019-05-30T06:07:09.1230513Z ##[section]Starting: kubectl apply
2019-05-30T06:07:09.1348192Z ==============================================================================
2019-05-30T06:07:09.1348303Z Task         : Deploy to Kubernetes
2019-05-30T06:07:09.1348381Z Description  : Deploy, configure, update your Kubernetes cluster in Azure Container Service by running kubectl commands.
2019-05-30T06:07:09.1348441Z Version      : 0.151.2
2019-05-30T06:07:09.1348510Z Author       : Microsoft Corporation
2019-05-30T06:07:09.1348566Z Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=851275)
2019-05-30T06:07:09.1348638Z ==============================================================================
2019-05-30T06:07:12.7827969Z [command]d:\a\_temp\kubectlTask\1559196429507\kubectl.exe --kubeconfig d:\a\_temp\kubectlTask\1559196429507\config apply -f d:\a\r1\a\_devops-sample-CI\drop\Tomcat.yaml
2019-05-30T06:07:15.1191531Z deployment "tomcat-deployment" configured
2019-05-30T06:07:15.1300152Z error: error validating "d:\\a\\r1\\a\\_devops-sample-CI\\drop\\Tomcat.yaml": error validating data: the server could not find the requested resource; if you choose to ignore these errors, turn validation off with --validate=false
2019-05-30T06:07:15.1454497Z ##[error]d:\a\_temp\kubectlTask\1559196429507\kubectl.exe failed with return code: 1
2019-05-30T06:07:15.1634357Z ##[section]Finishing: kubectl apply

Tomcat.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: tomcat-deployment
  labels:
    app: tomcat
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tomcat
  template:
    metadata:
      labels:
        app: tomcat
    spec:
      containers:
      - name: tomcat
        image: suji165475/devops-sample:113
        ports:
        - containerPort: 80

---

kind: Service
apiVersion: v1
metadata:
  name: tomcat-service
spec:
  type: LoadBalancer
  selector:
    app: tomcat
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80

为什么服务器说即使我已确保从构建ci管道正确创建了构建构件(在drop folder中包含tomcat.yaml),也找不到所需的资源?这可能是由于我尚未创建kubernetes集群的事实,还是由于其他原因?

还可以使用nodeport代替LoadBalancer来处理天蓝色devops?

1 个答案:

答案 0 :(得分:0)

我非常确定您是否正在使用本地kubernetes群集并给出此错误-问题在于Azure Devops无法访问您的kubernetes群集。您应该确保群集在某个IP上公开,并且端口没有被阻塞。