From c6cb498f799fa335b8ad14a795aba9befdea97b7 Mon Sep 17 00:00:00 2001 From: Yinan Li Date: Fri, 15 Sep 2017 13:52:35 -0700 Subject: [PATCH 1/3] Updated Deployments concepts doc --- .../workloads/controllers/deployment.md | 23 +++++-------------- .../controllers/nginx-deployment.yaml | 5 ++++ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/docs/concepts/workloads/controllers/deployment.md b/docs/concepts/workloads/controllers/deployment.md index 51b395fd6242c..1fe4cda31631d 100644 --- a/docs/concepts/workloads/controllers/deployment.md +++ b/docs/concepts/workloads/controllers/deployment.md @@ -288,6 +288,8 @@ It is generally discouraged to make label selector updates and it is suggested t In any case, if you need to perform a label selector update, exercise great caution and make sure you have grasped all of the implications. +In Kubernetes 1.8 or later, after a Deployment gets created, its label selector is immutable. + * Selector additions require the pod template labels in the Deployment spec to be updated with the new label too, otherwise a validation error is returned. This change is a non-overlapping one, meaning that the new selector does not select ReplicaSets and Pods created with the old selector, resulting in orphaning all old ReplicaSets and @@ -850,9 +852,9 @@ allowed, which is the default if not specified. `.spec.selector` is an optional field that specifies a [label selector](/docs/concepts/overview/working-with-objects/labels/) for the Pods targeted by this deployment. -If specified, `.spec.selector` must match `.spec.template.metadata.labels`, or it will be rejected by -the API. If `.spec.selector` is unspecified, `.spec.selector.matchLabels` defaults to -`.spec.template.metadata.labels`. +`.spec.selector` must match `.spec.template.metadata.labels`, or it will be rejected by the API. + +In Kubernetes 1.8 or later, `.spec.selector` and `.metadata.labels` no longer default to `.spec.template.metadata.labels` if not set. So they must be set explicitly. Also note that `.spec.selector` is immutable after creation of the Deployment in Kubernetes 1.8 or later. A Deployment may terminate Pods whose labels match the selector if their template is different from `.spec.template` or if the total number of such Pods exceeds `.spec.replicas`. It brings up new @@ -926,20 +928,7 @@ a Pod is considered ready, see [Container Probes](/docs/concepts/workloads/pods/ ### Rollback To -`.spec.rollbackTo` is an optional field with the configuration the Deployment -should roll back to. Setting this field triggers a rollback, and this field will -be cleared by the server after a rollback is done. - -Because this field will be cleared by the server, it should not be used -declaratively. For example, you should not perform `kubectl apply` with a -manifest with `.spec.rollbackTo` field set. - -#### Revision - -`.spec.rollbackTo.revision` is an optional field specifying the revision to roll -back to. Setting to 0 means rolling back to the last revision in history; -otherwise, means rolling back to the specified revision. This defaults to 0 when -[`spec.rollbackTo`](#rollback-to) is set. +In Kubernetes 1.8 or later, field `.spec.rollbackTo` is deprecated. Instead, `kubectl rollout undo` as introduced in [Rolling Back to a Previous Revision](#rolling-back-to-a-previous-revision) should be used. ### Revision History Limit diff --git a/docs/concepts/workloads/controllers/nginx-deployment.yaml b/docs/concepts/workloads/controllers/nginx-deployment.yaml index 4ce71688f713b..1fc1b6701399c 100644 --- a/docs/concepts/workloads/controllers/nginx-deployment.yaml +++ b/docs/concepts/workloads/controllers/nginx-deployment.yaml @@ -2,8 +2,13 @@ apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1 kind: Deployment metadata: name: nginx-deployment + labels: + app: nginx spec: replicas: 3 + selector: + matchLabels: + app: nginx template: metadata: labels: From 63b9f0a5ed856c15861a7a42d7cf5d9a99ebe1f9 Mon Sep 17 00:00:00 2001 From: Yinan Li Date: Mon, 18 Sep 2017 15:12:09 -0700 Subject: [PATCH 2/3] Addressed comments --- docs/concepts/workloads/controllers/deployment.md | 6 +++--- docs/concepts/workloads/controllers/nginx-deployment.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/concepts/workloads/controllers/deployment.md b/docs/concepts/workloads/controllers/deployment.md index 1fe4cda31631d..168628c810359 100644 --- a/docs/concepts/workloads/controllers/deployment.md +++ b/docs/concepts/workloads/controllers/deployment.md @@ -288,7 +288,7 @@ It is generally discouraged to make label selector updates and it is suggested t In any case, if you need to perform a label selector update, exercise great caution and make sure you have grasped all of the implications. -In Kubernetes 1.8 or later, after a Deployment gets created, its label selector is immutable. +Note that in API version `apps/v1beta2`, a Deployment's label selector is immutable after it gets created. * Selector additions require the pod template labels in the Deployment spec to be updated with the new label too, otherwise a validation error is returned. This change is a non-overlapping one, meaning that the new selector does @@ -854,7 +854,7 @@ for the Pods targeted by this deployment. `.spec.selector` must match `.spec.template.metadata.labels`, or it will be rejected by the API. -In Kubernetes 1.8 or later, `.spec.selector` and `.metadata.labels` no longer default to `.spec.template.metadata.labels` if not set. So they must be set explicitly. Also note that `.spec.selector` is immutable after creation of the Deployment in Kubernetes 1.8 or later. +In API version `apps/v1beta2`, `.spec.selector` and `.metadata.labels` no longer default to `.spec.template.metadata.labels` if not set. So they must be set explicitly. Also note that `.spec.selector` is immutable after creation of the Deployment in `apps/v1beta2`. A Deployment may terminate Pods whose labels match the selector if their template is different from `.spec.template` or if the total number of such Pods exceeds `.spec.replicas`. It brings up new @@ -928,7 +928,7 @@ a Pod is considered ready, see [Container Probes](/docs/concepts/workloads/pods/ ### Rollback To -In Kubernetes 1.8 or later, field `.spec.rollbackTo` is deprecated. Instead, `kubectl rollout undo` as introduced in [Rolling Back to a Previous Revision](#rolling-back-to-a-previous-revision) should be used. +Field `.spec.rollbackTo` has been deprecated in API versions `extensions/v1beta1` and `apps/v1beta1`, and removed in API version `apps/v1beta2`. Instead, `kubectl rollout undo` as introduced in [Rolling Back to a Previous Revision](#rolling-back-to-a-previous-revision) should be used. ### Revision History Limit diff --git a/docs/concepts/workloads/controllers/nginx-deployment.yaml b/docs/concepts/workloads/controllers/nginx-deployment.yaml index 1fc1b6701399c..a4fc6678181f3 100644 --- a/docs/concepts/workloads/controllers/nginx-deployment.yaml +++ b/docs/concepts/workloads/controllers/nginx-deployment.yaml @@ -1,4 +1,4 @@ -apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1 +apiVersion: apps/v1beta2 # for versions before 1.7.0 use apps/v1beta1 kind: Deployment metadata: name: nginx-deployment From 10ec1247405db1d5634ec4f8d7dfe964524c8a21 Mon Sep 17 00:00:00 2001 From: Yinan Li Date: Tue, 19 Sep 2017 08:32:29 -0700 Subject: [PATCH 3/3] Addressed more comments --- docs/concepts/workloads/controllers/deployment.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/concepts/workloads/controllers/deployment.md b/docs/concepts/workloads/controllers/deployment.md index 168628c810359..eaf94fc3da120 100644 --- a/docs/concepts/workloads/controllers/deployment.md +++ b/docs/concepts/workloads/controllers/deployment.md @@ -288,7 +288,8 @@ It is generally discouraged to make label selector updates and it is suggested t In any case, if you need to perform a label selector update, exercise great caution and make sure you have grasped all of the implications. -Note that in API version `apps/v1beta2`, a Deployment's label selector is immutable after it gets created. +**Note:** In API version `apps/v1beta2`, a Deployment's label selector is immutable after it gets created. +{: .note} * Selector additions require the pod template labels in the Deployment spec to be updated with the new label too, otherwise a validation error is returned. This change is a non-overlapping one, meaning that the new selector does @@ -928,7 +929,7 @@ a Pod is considered ready, see [Container Probes](/docs/concepts/workloads/pods/ ### Rollback To -Field `.spec.rollbackTo` has been deprecated in API versions `extensions/v1beta1` and `apps/v1beta1`, and removed in API version `apps/v1beta2`. Instead, `kubectl rollout undo` as introduced in [Rolling Back to a Previous Revision](#rolling-back-to-a-previous-revision) should be used. +Field `.spec.rollbackTo` has been deprecated in API versions `extensions/v1beta1` and `apps/v1beta1`, and is no longer supported in API version `apps/v1beta2`. Instead, `kubectl rollout undo` as introduced in [Rolling Back to a Previous Revision](#rolling-back-to-a-previous-revision) should be used. ### Revision History Limit