From 9f590be6ceadc934b738e5e024d8c409ab42c266 Mon Sep 17 00:00:00 2001 From: Jun Xiang Tee Date: Mon, 18 Sep 2017 17:33:50 -0700 Subject: [PATCH] Update statefulset concepts doc to use apps/v1beta2 APIs (#5420) --- .../workloads/controllers/statefulset.md | 23 +++++++++++-------- .../workloads/controllers/statefulset.md | 21 +++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/cn/docs/concepts/workloads/controllers/statefulset.md b/cn/docs/concepts/workloads/controllers/statefulset.md index d52a8c1e1f2e3..689fea6255f3d 100644 --- a/cn/docs/concepts/workloads/controllers/statefulset.md +++ b/cn/docs/concepts/workloads/controllers/statefulset.md @@ -10,10 +10,8 @@ title: StatefulSets --- {% capture overview %} -**StatefulSets are a beta feature in 1.7. This feature replaces the -PetSets feature from 1.4. Users of PetSets are referred to the 1.5 -[Upgrade Guide](/docs/tasks/manage-stateful-set/upgrade-pet-set-to-stateful-set/) -for further information on how to upgrade existing PetSets to StatefulSets.** +**StatefulSet is the workload API object used to manage stateful applications. +StatefulSets are beta in 1.8.** {% include templates/glossary/snippet.md term="statefulset" length="long" %} {% endcapture %} @@ -42,7 +40,7 @@ provides a set of stateless replicas. Controllers such as * StatefulSet is a beta resource, not available in any Kubernetes release prior to 1.5. * As with all alpha/beta resources, you can disable StatefulSet through the `--runtime-config` option passed to the apiserver. -* The storage for a given Pod must either be provisioned by a [PersistentVolume Provisioner](http://releases.k8s.io/{{page.githubbranch}}/examples/persistent-volume-provisioning/README.md) based on the requested `storage class`, or pre-provisioned by an admin. +* The storage for a given Pod must either be provisioned by a [PersistentVolume Provisioner](https://github.com/kubernetes/examples/tree/{{page.githubbranch}}/staging/persistent-volume-provisioning/README.md) based on the requested `storage class`, or pre-provisioned by an admin. * Deleting and/or scaling a StatefulSet down will *not* delete the volumes associated with the StatefulSet. This is done to ensure data safety, which is generally more valuable than an automatic purge of all related StatefulSet resources. * StatefulSets currently require a [Headless Service](/docs/concepts/services-networking/service/#headless-services) to be responsible for the network identity of the Pods. You are responsible for creating this Service. @@ -51,8 +49,7 @@ The example below demonstrates the components of a StatefulSet. * A Headless Service, named nginx, is used to control the network domain. * The StatefulSet, named web, has a Spec that indicates that 3 replicas of the nginx container will be launched in unique Pods. -* The volumeClaimTemplates will provide stable storage using [PersistentVolumes](/docs/concepts/storage/volumes/) provisioned by a - PersistentVolume Provisioner. +* The volumeClaimTemplates will provide stable storage using [PersistentVolumes](/docs/concepts/storage/volumes/) provisioned by a PersistentVolume Provisioner. ```yaml apiVersion: v1 @@ -69,17 +66,20 @@ spec: selector: app: nginx --- -apiVersion: apps/v1beta1 +apiVersion: apps/v1beta2 kind: StatefulSet metadata: name: web spec: + selector: + matchLabels: + app: nginx # has to match .spec.template.metadata.labels serviceName: "nginx" - replicas: 3 + replicas: 3 # by default is 1 template: metadata: labels: - app: nginx + app: nginx # has to match .spec.selector.matchLabels spec: terminationGracePeriodSeconds: 10 containers: @@ -102,6 +102,9 @@ spec: storage: 1Gi ``` +## Pod Selector +You must set the `spec.selector` field of a StatefulSet to match the labels of its `.spec.template.metadata.labels`. Prior to Kubernetes 1.8, the `spec.selector` field was defaulted when omitted. In 1.8 and later versions, failing to specify a matching Pod Selector will result in a validation error during StatefulSet creation. + ## Pod Identity StatefulSet Pods have a unique identity that is comprised of an ordinal, a stable network identity, and stable storage. The identity sticks to the Pod, diff --git a/docs/concepts/workloads/controllers/statefulset.md b/docs/concepts/workloads/controllers/statefulset.md index e06551d6d43c7..841d11119ac57 100644 --- a/docs/concepts/workloads/controllers/statefulset.md +++ b/docs/concepts/workloads/controllers/statefulset.md @@ -10,10 +10,8 @@ title: StatefulSets --- {% capture overview %} -**StatefulSets are a beta feature in 1.7. This feature replaces the -PetSets feature from 1.4. Users of PetSets are referred to the 1.5 -[Upgrade Guide](/docs/tasks/manage-stateful-set/upgrade-pet-set-to-stateful-set/) -for further information on how to upgrade existing PetSets to StatefulSets.** +**StatefulSet is the workload API object used to manage stateful applications. +StatefulSets are beta in 1.8.** {% include templates/glossary/snippet.md term="statefulset" length="long" %} {% endcapture %} @@ -51,8 +49,7 @@ The example below demonstrates the components of a StatefulSet. * A Headless Service, named nginx, is used to control the network domain. * The StatefulSet, named web, has a Spec that indicates that 3 replicas of the nginx container will be launched in unique Pods. -* The volumeClaimTemplates will provide stable storage using [PersistentVolumes](/docs/concepts/storage/volumes/) provisioned by a - PersistentVolume Provisioner. +* The volumeClaimTemplates will provide stable storage using [PersistentVolumes](/docs/concepts/storage/volumes/) provisioned by a PersistentVolume Provisioner. ```yaml apiVersion: v1 @@ -69,17 +66,20 @@ spec: selector: app: nginx --- -apiVersion: apps/v1beta1 +apiVersion: apps/v1beta2 kind: StatefulSet metadata: name: web spec: + selector: + matchLabels: + app: nginx # has to match .spec.template.metadata.labels serviceName: "nginx" - replicas: 3 + replicas: 3 # by default is 1 template: metadata: labels: - app: nginx + app: nginx # has to match .spec.selector.matchLabels spec: terminationGracePeriodSeconds: 10 containers: @@ -102,6 +102,9 @@ spec: storage: 1Gi ``` +## Pod Selector +You must set the `spec.selector` field of a StatefulSet to match the labels of its `.spec.template.metadata.labels`. Prior to Kubernetes 1.8, the `spec.selector` field was defaulted when omitted. In 1.8 and later versions, failing to specify a matching Pod Selector will result in a validation error during StatefulSet creation. + ## Pod Identity StatefulSet Pods have a unique identity that is comprised of an ordinal, a stable network identity, and stable storage. The identity sticks to the Pod,