Docker VotingApp在Kubernetes上构build/发布Jenkins不是幂等的

我正在通过Jenkins和Docker投票应用程序尝试部署Kubernetes。 我使用Azure容器registry作为Docker镜像的存储库。 首先尝试所有部署好: 在这里输入图像说明

当我重新运行pipe道而不更改某些内容时,出现以下错误: 在这里输入图像说明

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: {} --- 

docker图像是用“最新”标签构build的。

 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' } 

您的定义包含由apiserver自动生成/pipe理的字段。 其中一些是在创build对象时创build的,之后不能更新。 从您的文件中删除以下字段,使其感到高兴:

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