2

Here is my deploment template:

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
4

1 回答 1

5

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

现有 Replica Set 控制标签匹配.spec.selector但模板不匹配.spec.template的 Pod 被缩小。最终,新的 Replica Set 将被缩放到.spec.replicas,所有旧的 Replica Set 将被缩放到 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

其余标签可以保持不变

于 2016-09-13T15:41:10.327 回答