【问题标题】:Docker VotingApp build/release Jenkins on Kubernetes not idempotentDocker VotingApp 在 Kubernetes 上构建/发布 Jenkins 不是幂等的
【发布时间】:2018-01-23 07:19:51
【问题描述】:

我正在尝试使用 Docker 投票应用程序通过 Jenkins 在 Kubernetes 上进行部署。我使用 Azure 容器注册表作为 docker 映像的存储库。在第一次尝试时,一切都部署好了:

当我重新运行管道而不更改某些内容时,我收到以下错误:

Redis 服务定义:

---
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: redis
    version: alpine
  name: redis
  selfLink: /api/v1/namespaces//services/redis
spec:
  clusterIP: 
  ports:
  - name: 
    port: 6379
    protocol: TCP
    targetPort: 6379
  selector:
    app: redis
    version: alpine
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}
---

泊坞窗图像是使用“最新”标签构建的。

stage 'Checkout'
node {
    git 'https://github.com/*****/example-voting-app.git' // Checks out example votiung app repository
   stage 'Docker Builds'
   docker.withRegistry('https://*****.azurecr.io', 'private-login') {
        parallel(
            "Build Worker App":{def myEnv = docker.build('*****.azurecr.io/example-voting-app-worker:latest', 'worker').push('latest')},
            "Build Result App":{def myEnv = docker.build('*****.azurecr.io/example-voting-app-result:latest', 'result').push('latest')},
            "Build Vote App":{def myEnv = docker.build('*****.azurecr.io/example-voting-app-vote:latest', 'vote').push('latest')}
            )
    }
    stage 'Kubernetes Deployment'
    sh 'kubectl apply -f kubernetes/basic-full-deployment.yml'
    sh 'kubectl delete pods -l app=vote'
    sh 'kubectl delete pods -l app=result'
    stage 'Smoke Test'
    sh 'kubectl get deployments'
}

【问题讨论】:

    标签: azure docker jenkins kubernetes


    【解决方案1】:

    您的定义包含由 apiserver 自动生成/管理的字段。其中一些是在对象创建时创建的,之后无法更新。从您的文件中删除以下字段以使其满意:

    metadata:
      creationTimestamp: null
      selfLink: /api/v1/namespaces//services/redis
    status:
      loadBalancer: {}
    

    【讨论】:

      猜你喜欢
      • 2020-09-04
      • 2018-10-31
      • 1970-01-01
      • 2020-08-01
      • 1970-01-01
      • 2016-10-05
      • 2017-06-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多