Kubectl申请部署与revHistoryLimit 0不删除旧的副本集,这里是我的deploment模板

时间:2016-09-12 07:06:21

标签: kubernetes kubectl

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    name: XXX
    version: {{ xxx-version }}
    deploy_time: "{{ xxx-time }}"
  name: XXX
spec:
  replicas: 1
  revisionHistoryLimit : 0
  strategy:
    type : "RollingUpdate"
    rollingUpdate:
      maxUnavailable : 0%
      maxSurge : 100%
  selector:
    matchLabels:
      name: XXX
      version: {{ xxx-version }}
      deploy_time: "{{ xxx-time }}"
  template:
    metadata:
      labels:
        name: XXX
        version: {{ xxx-version }}
        deploy_time: "{{ xxx-time }}"
    spec:
      containers:
      - image: docker-registry:{{ xxx-version }}
        name: XXX
        ports:
        - name: XXX
          containerPort: 9000

1 个答案:

答案 0 :(得分:4)

文档中与此问题相关的关键部分是:

  

现有的副本集控制其标签与.spec.selector匹配但其模板与.spec.template不匹配的窗格缩小。最终,新的副本集将缩放为.spec.replicas,所有旧的副本集将缩放为0.

http://kubernetes.io/docs/user-guide/deployments/

因此spec.selector不应在多个部署中发生变化:

selector:
    matchLabels:
      name: XXX
      version: {{ xxx-version }}
      deploy_time: "{{ xxx-time }}"

应该成为:

selector:
    matchLabels:
      name: XXX

其余标签可以保持不变