Release 1.8 (#5659)
* GC now supports non-core resources * Add two examples about how to analysis audits of kube-apiserver (#4264) * Deprecate system:nodes binding * [1.8] StatefulSet `initialized` annotation is now ignored. * inits the kubeadm upgrade docs addresses kubernetes/kubernetes.github.io/issues/4689 * adds kubeadm upgrade cmd to ToC addresses kubernetes/kubernetes.github.io/issues/4689 * add workload placement docs * ScaleIO - document udpate for 1.8 * Add documentation on storageClass.mountOptions and PV.mountOptions (#5254) * Add documentation on storageClass.mountOptions and PV.mountOptions * convert notes into callouts * Add docs for CustomResource validation add info about supported fields * advanced audit beta features (#5300) * Update job workload doc with backoff failure policy (#5319) Add to the Jobs documentation how to use the new backoffLimit field that limit the number of Pod failure before considering the Job as failed. * Documented additional AWS Service annotations (#4864) * Add device plugin doc under concepts/cluster-administration. (#5261) * Add device plugin doc under concepts/cluster-administration. * Update device-plugins.md * Update device-plugins.md Add meta description. Fix typo. Change bare metal deployment to manual deployment. * Update device-plugins.md Fix typo again. * Update page.version. (#5341) * Add documentation on storageClass.reclaimPolicy (#5171) * [Advanced audit] use new herf for audit-api (#5349) This tag contains all the changes in v1beta1 version. Update it now. * Added documentation around creating the InitializerConfiguration for the persistent volume label controller in the cloud-controller-manager (#5255) * Documentation for kubectl plugins (#5294) * Documentation for kubectl plugins * Update kubectl-plugins.md * Update kubectl-plugins.md * Updated CPU manager docs to match implementation. (#5332) * Noted limitation of alpha static cpumanager. * Updated CPU manager docs to match implementation. - Removed references to CPU pressure node condition and evictions. - Added note about new --cpu-manager-reconcile-period flag. - Added note about node allocatable requirements for static policy. - Noted limitation of alpha static cpumanager. * Move cpu-manager task link to rsc mgmt section. * init containers annotation removed in 1.8 (#5390) * Add documentation for TaintNodesByCondition (#5352) * Add documentation for TaintNodesByCondition * Update nodes.md * Update taint-and-toleration.md * Update daemonset.md * Update nodes.md * Update taint-and-toleration.md * Update daemonset.md * Fix deployments (#5421) * Document extended resources and OIR deprecation. (#5399) * Document extended resources and OIR deprecation. * Updated extended resources doc per reviews. * reverts extra spacing in _data/tasks.yml * addresses `kubeadm upgrade` review comments Feedback from @chenopis, @luxas, and @steveperry-53 addressed with this commit * HugePages documentation (#5419) * Update cpu-management-policies.md (#5407) Fixed the bad link. Modified "cpu" to "CPU". Added more 'yaml' as supplement. * Update RBAC docs for v1 (#5445) * Add user docs for pod priority and preemption (#5328) * Add user docs for pod priority and preemption * Update pod-priority-preemption.md * More updates * Update docs/admin/kubeadm.md for 1.8 (#5440) - Made a couple of minor wording changes (not strictly 1.8 related). - Did some reformatting (not strictly 1.8 related). - Updated references to the default token TTL (was infinite, now 24 hours). - Documented the new `--discovery-token-ca-cert-hash` and `--discovery-token-unsafe-skip-ca-verification` flags for `kubeadm join`. - Added references to the new `--discovery-token-ca-cert-hash` flag in all the default examples. - Added a new _Security model_ section that describes the security tradeoffs of the various discovery modes. - Documented the new `--groups` flag for `kubeadm token create`. - Added a note of caution under _Automating kubeadm_ that references the _Security model_ section. - Updated the component version table to drop 1.6 and add 1.8. - Update `_data/reference.yml` to try to get the sidebar fixed up and more consistent with `kubefed`. * Update StatefulSet Basics for 1.8 release (#5398) * addresses `kubeadm upgrade` review comments 2nd iteration review comments by @luxas * adds kubelet upgrade section to kubeadm upgrade * Fix a bulleted list on docs/admin/kubeadm.md. (#5458) I updated this doc yesterday and I was absolutely sure I fixed this, but I just saw that this commit got lost somehow. This was introduced recently in https://github.com/kubernetes/kubernetes.github.io/pull/5440. * Clarify the API to check for device plugins * Moving Flexvolume to separate out-of-tree section * addresses `kubeadm upgrade` review comments CC: @luxas * fixes kubeadm upgrade index * Update Stackdriver Logging documentation (#5495) * Re-update WordPress and MySQL PV doc to use apps/v1beta2 APIs (#5526) * Update statefulset concepts doc to use apps/v1beta2 APIs (#5420) * add document on kubectl's behavior regarding initializers (#5505) * Update docs/admin/kubeadm.md to cover self-hosting in 1.8. (#5497) This is a new beta feature in 1.8. * Update kubectl patch doc to use apps/v1beta2 APIs (#5422) * [1.8] Update "Run Applications" tasks to apps/v1beta2. (#5525) * Update replicated stateful application task for 1.8. * Update single instance stateful app task for 1.8. * Update stateless app task for 1.8. * Update kubectl patch task for 1.8. * fix the link of persistent storage (#5515) * update the admission-controllers.md index.md what-is-kubernetes.md link * fix the link of persistent storage * Add quota support for local ephemeral storage (#5493) * Add quota support for local ephemeral storage update the doc to this alpha feature * Update resource-quotas.md * Updated Deployments concepts doc (#5491) * Updated Deployments concepts doc * Addressed comments * Addressed more comments * Modify allocatable storage to ephemeral-storage (#5490) Update the doc to use ephemeral-storage instead of storage * Revamped concepts doc for ReplicaSet (#5463) * Revamped concepts doc for ReplicaSet * Minor changes to call out specific versions for selector defaulting and immutability * Addressed doc review comments * Remove petset documentations (#5395) * Update docs to use batch/v1beta1 cronjobs (#5475) * add federation job doc (#5485) * add federation job doc * Update job.md Edits for clarity and consistency * Update job.md Fixed a typo * update DaemonSet concept for 1.8 release (#5397) * update DaemonSet concept for 1.8 release * Update daemonset.md Fix typo. than -> then * Update bootstrap tokens doc for 1.8. (#5479) * Update bootstrap tokens doc for 1.8. This has some changes I missed when I was updating the main kubeadm documention: - Bootstrap tokens are now beta, not alpha (https://github.com/kubernetes/features/issues/130) - The apiserver flag to enable the authenticator changedin 1.8 (https://github.com/kubernetes/kubernetes/pull/51198) - Added `auth-extra-groups` documentaion (https://github.com/kubernetes/kubernetes/pull/50933) - Updated the _Token Management with `kubeadm`_ section to link to the main kubeadm docs, since it was just duplicated information. * Update bootstrap-tokens.md * Updated the Cassandra tutorial to use apps/v1beta2 (#5548) * add docs for AllowPrivilegeEscalation (#5448) Signed-off-by: Jess Frazelle <acidburn@microsoft.com> * Add local ephemeral storage alpha feature in managing compute resource (#5522) * Add local ephemeral storage alpha feature in managing compute resource Since 1.8, we add the local ephemeral storage alpha feature as one resource type to manage. Add this feature into the doc. * Update manage-compute-resources-container.md * Update manage-compute-resources-container.md * Update manage-compute-resources-container.md * Update manage-compute-resources-container.md * Update manage-compute-resources-container.md * Update manage-compute-resources-container.md * Added documentation for Metrics Server (#5560) * authorization: improve authorization debugging docs (#5549) * Document mount propagation (#5544) * Update /docs/setup/independent/create-cluster-kubeadm.md for 1.8. (#5524) This introduction needed a couple of small tweaks to cover the `--discovery-token-ca-cert-hash` flag added in https://github.com/kubernetes/kubernetes/pull/49520 and some version bumps. * Add task doc for alpha dynamic kubelet configuration (#5523) * Fix input/output of selfsubjectaccess review (#5593) * Add docs for implementing resize (#5528) * Add docs for implementing resize * Update admission-controllers.md * Added link to PVC section * minor typo fixes * Update NetworkPolicy concept guide with egress and CIDR changes (#5529) * update zookeeper tutorial for 1.8 release * add doc for hostpath type (#5503) * Federated Hpa feature doc (#5487) * Federated Hpa feature doc * Federated Hpa feature doc review fixes * Update hpa.md * Update hpa.md * update cloud controller manager docs for v1.8 * Update cronjob with defaults information (#5556) * Kubernetes 1.8 reference docs (#5632) * Kubernetes 1.8 reference docs * Kubectl reference docs for 1.8 * Update side bar with 1.8 kubectl and api ref docs links * remove petset.md * update on state of HostAlias in 1.8 with hostNetwork Pod support (#5644) * Fix cron job deletion section (#5655) * update imported docs (#5656) * Add documentation for certificate rotation. (#5639) * Link to using kubeadm page * fix the command output fix the command output * fix typo in api/resources reference: "Worloads" * Add documentation for certificate rotation. * Create TOC entry for cloud controller manager. (#5662) * Updates for new versions of API types * Followup 5655: fix link to garbage collection (#5666) * Temporarily redirect resources-reference to api-reference. (#5668) * Update config for 1.8 release. (#5661) * Update config for 1.8 release. * Address reviewer comments. * Switch references in HPA docs from alpha to beta (#5671) The HPA docs still referenced the alpha version. This switches them to talk about v2beta1, which is the appropriate version for Kubernetes 1.8 * Deprecate openstack heat (#5670) * Fix typo in pod preset conflict example Move container port definition to the correct line. * Highlight openstack-heat provider deprecation The openstack-heat provider for kube-up is being deprecated and will be removed in a future release. * Temporarily fix broken links by redirecting. (#5672) * Fix broken links. (#5675) * Fix render of code block (#5674) * Fix broken links. (#5677) * Add a small note about auto-bootstrapped CSR ClusterRoles (#5660) * Update kubeadm install doc for v1.8 (#5676) * add draft workloads api content for 1.8 (#5650) * add draft workloads api content for 1.8 * edits per review, add tables, for 1.8 workloads api doc * fix typo * Minor fixes to kubeadm 1.8 upgrade guide. (#5678) - The kubelet upgrade instructions should be done on every host, not just worker nodes. - We should just upgrade all packages, instead of calling out kubelet specifically. This will also upgrade kubectl, kubeadm, and kubernetes-cni, if installed. - Draining nodes should also ignore daemonsets, and master errors can be ignored. - Make sure that the new kubeadm download is chmoded correctly. - Add a step to run `kubeadm version` to verify after downloading. - Manually approve new kubelet CSRs if rotation is enabled (known issue). * Release 1.8 (#5680) * Fix versions for 1.8 API ref docs * Updates for 1.8 kubectl reference docs * Kubeadm /docs/admin/kubeadm.md cleanup, editing. (#5681) * Update docs/admin/kubeadm.md (mostly 1.8 related). This is Fabrizio's work, which I'm committing along with my edits (in a commit on top of this). * A few of my own edits to clarify and clean up some Markdown.
This commit is contained in:
@@ -442,100 +442,12 @@ When exploring a Pod's [stable storage](#writing-to-stable-storage), we saw that
|
||||
|
||||
## Updating StatefulSets
|
||||
|
||||
In Kubernetes 1.7, the StatefulSet controller supports automated updates. The
|
||||
In Kubernetes 1.7 and later, the StatefulSet controller supports automated updates. The
|
||||
strategy used is determined by the `spec.updateStrategy` field of the
|
||||
StatefulSet API Object. This feature can be used to upgrade the container
|
||||
images, resource requests and/or limits, labels, and annotations of the Pods in a
|
||||
StatefulSet. There are two valid update strategies, `OnDelete` and
|
||||
`RollingUpdate`.
|
||||
|
||||
### On Delete
|
||||
The `OnDelete` update strategy implements the legacy (prior to 1.7) behavior,
|
||||
and it is the default update strategy. When you select this update strategy,
|
||||
the StatefulSet controller will not automatically update Pods when a
|
||||
modification is made to the StatefulSet's `.spec.template` field.
|
||||
|
||||
Patch the container image for the `web` StatefulSet.
|
||||
|
||||
```shell
|
||||
kubectl patch statefulset web --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value":"gcr.io/google_containers/nginx-slim:0.7"}]'
|
||||
statefulset "web" patched
|
||||
```
|
||||
|
||||
Delete the `web-0` Pod.
|
||||
|
||||
```shell
|
||||
kubectl delete pod web-0
|
||||
pod "web-0" deleted
|
||||
```
|
||||
|
||||
Watch the `web-0` Pod, and wait for it to transition to Running and Ready.
|
||||
|
||||
```shell
|
||||
kubectl get pod web-0 -w
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
web-0 1/1 Running 0 54s
|
||||
web-0 1/1 Terminating 0 1m
|
||||
web-0 0/1 Terminating 0 1m
|
||||
web-0 0/1 Terminating 0 1m
|
||||
web-0 0/1 Terminating 0 1m
|
||||
web-0 0/1 Pending 0 0s
|
||||
web-0 0/1 Pending 0 0s
|
||||
web-0 0/1 ContainerCreating 0 0s
|
||||
web-0 1/1 Running 0 3s
|
||||
```
|
||||
|
||||
Get the `web` StatefulSet's Pods to view their container images.
|
||||
|
||||
```shell{% raw %}
|
||||
kubectl get pod -l app=nginx -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[0].image}{"\n"}{end}'
|
||||
web-0 gcr.io/google_containers/nginx-slim:0.7
|
||||
web-1 gcr.io/google_containers/nginx-slim:0.8
|
||||
web-2 gcr.io/google_containers/nginx-slim:0.8
|
||||
{% endraw %}```
|
||||
|
||||
`web-0` has had its image updated, but `web-1` and `web-2` still have the original
|
||||
image. Complete the update by deleting the remaining Pods.
|
||||
|
||||
```shell
|
||||
kubectl delete pod web-1 web-2
|
||||
pod "web-1" deleted
|
||||
pod "web-2" deleted
|
||||
```
|
||||
|
||||
Watch the StatefulSet's Pods, and wait for all of them to transition to Running and Ready.
|
||||
|
||||
```
|
||||
kubectl get pods -w -l app=nginx
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
web-0 1/1 Running 0 8m
|
||||
web-1 1/1 Running 0 4h
|
||||
web-2 1/1 Running 0 23m
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
web-1 1/1 Terminating 0 4h
|
||||
web-1 1/1 Terminating 0 4h
|
||||
web-1 0/1 Pending 0 0s
|
||||
web-1 0/1 Pending 0 0s
|
||||
web-1 0/1 ContainerCreating 0 0s
|
||||
web-2 1/1 Terminating 0 23m
|
||||
web-2 1/1 Terminating 0 23m
|
||||
web-1 1/1 Running 0 4s
|
||||
web-2 0/1 Pending 0 0s
|
||||
web-2 0/1 Pending 0 0s
|
||||
web-2 0/1 ContainerCreating 0 0s
|
||||
web-2 1/1 Running 0 36s
|
||||
```
|
||||
|
||||
Get the Pods to view their container images.
|
||||
|
||||
```shell{% raw %}
|
||||
kubectl get pod -l app=nginx -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[0].image}{"\n"}{end}'
|
||||
web-0 gcr.io/google_containers/nginx-slim:0.7
|
||||
web-1 gcr.io/google_containers/nginx-slim:0.7
|
||||
web-2 gcr.io/google_containers/nginx-slim:0.7
|
||||
{% endraw %}```
|
||||
|
||||
All the Pods in the StatefulSet are now running a new container image.
|
||||
StatefulSet. There are two valid update strategies, `RollingUpdate` and
|
||||
`OnDelete`.
|
||||
|
||||
### Rolling Update
|
||||
|
||||
@@ -792,6 +704,15 @@ gcr.io/google_containers/nginx-slim:0.7
|
||||
By moving the `partition` to `0`, you allowed the StatefulSet controller to
|
||||
continue the update process.
|
||||
|
||||
### On Delete
|
||||
|
||||
The `OnDelete` update strategy implements the legacy (1.6 and prior) behavior,
|
||||
When you select this update strategy, the StatefulSet controller will not
|
||||
automatically update Pods when a modification is made to the StatefulSet's
|
||||
`.spec.template` field. This strategy can be selected by setting the
|
||||
`.spec.template.updateStrategy.type` to `OnDelete`.
|
||||
|
||||
|
||||
## Deleting StatefulSets
|
||||
|
||||
StatefulSet supports both Non-Cascading and Cascading deletion. In a
|
||||
|
||||
@@ -159,7 +159,7 @@ Use `kubectl edit` to modify the size of of a Cassandra StatefulSet.
|
||||
# and an empty file will abort the edit. If an error occurs while saving this file will be
|
||||
# reopened with the relevant failures.
|
||||
#
|
||||
apiVersion: apps/v1beta1
|
||||
apiVersion: apps/v1beta2
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
creationTimestamp: 2016-08-13T18:40:58Z
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
apiVersion: "apps/v1beta1"
|
||||
apiVersion: apps/v1beta2
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: cassandra
|
||||
labels:
|
||||
app: cassandra
|
||||
spec:
|
||||
serviceName: cassandra
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: cassandra
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
|
||||
+5
-1
@@ -25,13 +25,17 @@ spec:
|
||||
requests:
|
||||
storage: 20Gi
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: wordpress-mysql
|
||||
labels:
|
||||
app: wordpress
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: wordpress
|
||||
tier: mysql
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
|
||||
+5
-1
@@ -25,13 +25,17 @@ spec:
|
||||
requests:
|
||||
storage: 20Gi
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: wordpress
|
||||
labels:
|
||||
app: wordpress
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: wordpress
|
||||
tier: frontend
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
|
||||
@@ -13,13 +13,16 @@ spec:
|
||||
selector:
|
||||
app: nginx
|
||||
---
|
||||
apiVersion: apps/v1beta1
|
||||
apiVersion: apps/v1beta2
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: web
|
||||
spec:
|
||||
serviceName: "nginx"
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nginx
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
|
||||
@@ -13,7 +13,7 @@ spec:
|
||||
selector:
|
||||
app: nginx
|
||||
---
|
||||
apiVersion: apps/v1beta1
|
||||
apiVersion: apps/v1beta2
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: web
|
||||
@@ -21,6 +21,9 @@ spec:
|
||||
serviceName: "nginx"
|
||||
podManagementPolicy: "Parallel"
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nginx
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
|
||||
@@ -27,7 +27,6 @@ Kubernetes concepts.
|
||||
* [Headless Services](/docs/concepts/services-networking/service/#headless-services)
|
||||
* [PersistentVolumes](/docs/concepts/storage/volumes/)
|
||||
* [PersistentVolume Provisioning](https://github.com/kubernetes/examples/tree/{{page.githubbranch}}/staging/persistent-volume-provisioning/)
|
||||
* [ConfigMaps](/docs/tasks/configure-pod-container/configmap/)
|
||||
* [StatefulSets](/docs/concepts/abstractions/controllers/statefulsets/)
|
||||
* [PodDisruptionBudgets](/docs/concepts/workloads/pods/disruptions/#specifying-a-poddisruptionbudget)
|
||||
* [PodAntiAffinity](/docs/user-guide/node-selection/#inter-pod-affinity-and-anti-affinity-beta-feature)
|
||||
@@ -90,27 +89,27 @@ safely discarded.
|
||||
|
||||
The manifest below contains a
|
||||
[Headless Service](/docs/concepts/services-networking/service/#headless-services),
|
||||
a [ConfigMap](/docs/tasks/configure-pod-container/configmap/),
|
||||
a [Service](/docs/concepts/services-networking/service),
|
||||
a [PodDisruptionBudget](/docs/concepts/workloads/pods/disruptions//#specifying-a-poddisruptionbudget),
|
||||
and a [StatefulSet](/docs/concepts/abstractions/controllers/statefulsets/).
|
||||
|
||||
{% include code.html language="yaml" file="zookeeper.yaml" ghlink="/docs/tutorials/stateful-application/zookeeper.yaml" %}
|
||||
|
||||
Open a command terminal, and use
|
||||
[`kubectl create`](/docs/user-guide/kubectl/{{page.version}}/#create) to create the
|
||||
[`kubectl apply`](/docs/user-guide/kubectl/{{page.version}}/#apply) to create the
|
||||
manifest.
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tutorials/stateful-application/zookeeper.yaml
|
||||
kubectl apply -f https://k8s.io/docs/tutorials/stateful-application/zookeeper.yaml
|
||||
```
|
||||
|
||||
This creates the `zk-headless` Headless Service, the `zk-config` ConfigMap,
|
||||
the `zk-budget` PodDisruptionBudget, and the `zk` StatefulSet.
|
||||
This creates the `zk-hs` Headless Service, the `zk-cs` Service,
|
||||
the `zk-pdb` PodDisruptionBudget, and the `zk` StatefulSet.
|
||||
|
||||
```shell
|
||||
service "zk-headless" created
|
||||
configmap "zk-config" created
|
||||
poddisruptionbudget "zk-budget" created
|
||||
service "zk-hs" created
|
||||
service "zk-cs" created
|
||||
poddisruptionbudget "zk-pdb" created
|
||||
statefulset "zk" created
|
||||
```
|
||||
|
||||
@@ -200,13 +199,13 @@ Get the FQDN (Fully Qualified Domain Name) of each Pod in the `zk` StatefulSet.
|
||||
for i in 0 1 2; do kubectl exec zk-$i -- hostname -f; done
|
||||
```
|
||||
|
||||
The `zk-headless` Service creates a domain for all of the Pods,
|
||||
The `zk-hs` Service creates a domain for all of the Pods,
|
||||
`zk-headless.default.svc.cluster.local`.
|
||||
|
||||
```shell
|
||||
zk-0.zk-headless.default.svc.cluster.local
|
||||
zk-1.zk-headless.default.svc.cluster.local
|
||||
zk-2.zk-headless.default.svc.cluster.local
|
||||
zk-0.zk-hs.default.svc.cluster.local
|
||||
zk-1.zk-hs.default.svc.cluster.local
|
||||
zk-2.zk-hs.default.svc.cluster.local
|
||||
```
|
||||
|
||||
The A records in [Kubernetes DNS](/docs/concepts/services-networking/dns-pod-service/) resolve the FQDNs to the Pods' IP addresses.
|
||||
@@ -251,10 +250,6 @@ which processes have committed which data. If two Pods were launched with the
|
||||
same ordinal, two ZooKeeper servers would both identify themselves as the same
|
||||
server.
|
||||
|
||||
When you created the `zk` StatefulSet, the StatefulSet's controller created
|
||||
each Pod sequentially, in the order defined by the Pods' ordinal indices, and it
|
||||
waited for each Pod to be Running and Ready before creating the next Pod.
|
||||
|
||||
```shell
|
||||
kubectl get pods -w -l app=zk
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
@@ -281,18 +276,18 @@ endpoint will be the unique ZooKeeper server claiming the identity configured
|
||||
in its `myid` file.
|
||||
|
||||
```shell
|
||||
zk-0.zk-headless.default.svc.cluster.local
|
||||
zk-1.zk-headless.default.svc.cluster.local
|
||||
zk-2.zk-headless.default.svc.cluster.local
|
||||
zk-0.zk-hs.default.svc.cluster.local
|
||||
zk-1.zk-hs.default.svc.cluster.local
|
||||
zk-2.zk-hs.default.svc.cluster.local
|
||||
```
|
||||
|
||||
This ensures that the `servers` properties in the ZooKeepers' `zoo.cfg` files
|
||||
represents a correctly configured ensemble.
|
||||
|
||||
```shell
|
||||
server.1=zk-0.zk-headless.default.svc.cluster.local:2888:3888
|
||||
server.2=zk-1.zk-headless.default.svc.cluster.local:2888:3888
|
||||
server.3=zk-2.zk-headless.default.svc.cluster.local:2888:3888
|
||||
server.1=zk-0.zk-hs.default.svc.cluster.local:2888:3888
|
||||
server.2=zk-1.zk-hs.default.svc.cluster.local:2888:3888
|
||||
server.3=zk-2.zk-hsdefault.svc.cluster.local:2888:3888
|
||||
```
|
||||
|
||||
When the servers use the Zab protocol to attempt to commit a value, they will
|
||||
@@ -395,13 +390,6 @@ kubectl apply -f https://k8s.io/docs/tutorials/stateful-application/zookeeper.ya
|
||||
The `zk` StatefulSet will be created, but, as they already exist, the other API
|
||||
Objects in the manifest will not be modified.
|
||||
|
||||
```shell
|
||||
statefulset "zk" created
|
||||
Error from server (AlreadyExists): error when creating "zookeeper.yaml": services "zk-headless" already exists
|
||||
Error from server (AlreadyExists): error when creating "zookeeper.yaml": configmaps "zk-config" already exists
|
||||
Error from server (AlreadyExists): error when creating "zookeeper.yaml": poddisruptionbudgets.policy "zk-budget" already exists
|
||||
```
|
||||
|
||||
Watch the StatefulSet controller recreate the StatefulSet's Pods.
|
||||
|
||||
```shell
|
||||
@@ -513,143 +501,42 @@ As noted in the [Facilitating Leader Election](#facilitating-leader-election) an
|
||||
[Achieving Consensus](#achieving-consensus) sections, the servers in a
|
||||
ZooKeeper ensemble require consistent configuration in order to elect a leader
|
||||
and form a quorum. They also require consistent configuration of the Zab protocol
|
||||
in order for the protocol to work correctly over a network. You can use
|
||||
ConfigMaps to achieve this.
|
||||
in order for the protocol to work correctly over a network. In our example we
|
||||
achive consistent configuration by embedding the configuration directly into
|
||||
the manifest.
|
||||
|
||||
Get the `zk-config` ConfigMap.
|
||||
Get the `zk` StatefulSet.
|
||||
|
||||
```shell
|
||||
kubectl get cm zk-config -o yaml
|
||||
apiVersion: v1
|
||||
data:
|
||||
client.cnxns: "60"
|
||||
ensemble: zk-0;zk-1;zk-2
|
||||
init: "10"
|
||||
jvm.heap: 2G
|
||||
purge.interval: "0"
|
||||
snap.retain: "3"
|
||||
sync: "5"
|
||||
tick: "2000"
|
||||
```
|
||||
|
||||
The `env` field of the `zk` StatefulSet's Pod `template` reads the ConfigMap
|
||||
into environment variables. These variables are injected into the containers
|
||||
environment.
|
||||
|
||||
```yaml
|
||||
env:
|
||||
- name : ZK_ENSEMBLE
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: ensemble
|
||||
- name : ZK_HEAP_SIZE
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: jvm.heap
|
||||
- name : ZK_TICK_TIME
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: tick
|
||||
- name : ZK_INIT_LIMIT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: init
|
||||
- name : ZK_SYNC_LIMIT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: tick
|
||||
- name : ZK_MAX_CLIENT_CNXNS
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: client.cnxns
|
||||
- name: ZK_SNAP_RETAIN_COUNT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: snap.retain
|
||||
- name: ZK_PURGE_INTERVAL
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: purge.interval
|
||||
```
|
||||
|
||||
The entry point of the container invokes a bash script, `zkGenConfig.sh`, prior to
|
||||
launching the ZooKeeper server process. This bash script generates the
|
||||
ZooKeeper configuration files from the supplied environment variables.
|
||||
|
||||
```yaml
|
||||
```shell{% raw %}
|
||||
kubectl get sts zk -o yaml
|
||||
...
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- zkGenConfig.sh && zkServer.sh start-foreground
|
||||
```
|
||||
- "start-zookeeper \
|
||||
--servers=3 \
|
||||
--data_dir=/var/lib/zookeeper/data \
|
||||
--data_log_dir=/var/lib/zookeeper/data/log \
|
||||
--conf_dir=/opt/zookeeper/conf \
|
||||
--client_port=2181 \
|
||||
--election_port=3888 \
|
||||
--server_port=2888 \
|
||||
--tick_time=2000 \
|
||||
--init_limit=10 \
|
||||
--sync_limit=5 \
|
||||
--heap=512M \
|
||||
--max_client_cnxns=60 \
|
||||
--snap_retain_count=3 \
|
||||
--purge_interval=12 \
|
||||
--max_session_timeout=40000 \
|
||||
--min_session_timeout=4000 \
|
||||
--log_level=INFO"
|
||||
...
|
||||
```{% endraw %}
|
||||
|
||||
Examine the environment of all of the Pods in the `zk` StatefulSet.
|
||||
|
||||
```shell
|
||||
for i in 0 1 2; do kubectl exec zk-$i env | grep ZK_*;echo""; done
|
||||
```
|
||||
|
||||
All of the variables populated from `zk-config` contain identical values. This
|
||||
allows the `zkGenConfig.sh` script to create consistent configurations for all
|
||||
of the ZooKeeper servers in the ensemble.
|
||||
|
||||
```shell
|
||||
ZK_ENSEMBLE=zk-0;zk-1;zk-2
|
||||
ZK_HEAP_SIZE=2G
|
||||
ZK_TICK_TIME=2000
|
||||
ZK_INIT_LIMIT=10
|
||||
ZK_SYNC_LIMIT=2000
|
||||
ZK_MAX_CLIENT_CNXNS=60
|
||||
ZK_SNAP_RETAIN_COUNT=3
|
||||
ZK_PURGE_INTERVAL=0
|
||||
ZK_CLIENT_PORT=2181
|
||||
ZK_SERVER_PORT=2888
|
||||
ZK_ELECTION_PORT=3888
|
||||
ZK_USER=zookeeper
|
||||
ZK_DATA_DIR=/var/lib/zookeeper/data
|
||||
ZK_DATA_LOG_DIR=/var/lib/zookeeper/log
|
||||
ZK_LOG_DIR=/var/log/zookeeper
|
||||
|
||||
ZK_ENSEMBLE=zk-0;zk-1;zk-2
|
||||
ZK_HEAP_SIZE=2G
|
||||
ZK_TICK_TIME=2000
|
||||
ZK_INIT_LIMIT=10
|
||||
ZK_SYNC_LIMIT=2000
|
||||
ZK_MAX_CLIENT_CNXNS=60
|
||||
ZK_SNAP_RETAIN_COUNT=3
|
||||
ZK_PURGE_INTERVAL=0
|
||||
ZK_CLIENT_PORT=2181
|
||||
ZK_SERVER_PORT=2888
|
||||
ZK_ELECTION_PORT=3888
|
||||
ZK_USER=zookeeper
|
||||
ZK_DATA_DIR=/var/lib/zookeeper/data
|
||||
ZK_DATA_LOG_DIR=/var/lib/zookeeper/log
|
||||
ZK_LOG_DIR=/var/log/zookeeper
|
||||
|
||||
ZK_ENSEMBLE=zk-0;zk-1;zk-2
|
||||
ZK_HEAP_SIZE=2G
|
||||
ZK_TICK_TIME=2000
|
||||
ZK_INIT_LIMIT=10
|
||||
ZK_SYNC_LIMIT=2000
|
||||
ZK_MAX_CLIENT_CNXNS=60
|
||||
ZK_SNAP_RETAIN_COUNT=3
|
||||
ZK_PURGE_INTERVAL=0
|
||||
ZK_CLIENT_PORT=2181
|
||||
ZK_SERVER_PORT=2888
|
||||
ZK_ELECTION_PORT=3888
|
||||
ZK_USER=zookeeper
|
||||
ZK_DATA_DIR=/var/lib/zookeeper/data
|
||||
ZK_DATA_LOG_DIR=/var/lib/zookeeper/log
|
||||
ZK_LOG_DIR=/var/log/zookeeper
|
||||
```
|
||||
Notice that the command used to start the ZooKeeper servers passed the configuration
|
||||
as command line parameter. Enviornment variables are another, equally good, way to
|
||||
pass configuration to ensemble.
|
||||
|
||||
### Configuring Logging
|
||||
|
||||
@@ -783,6 +670,54 @@ common pattern. When deploying an application in Kubernetes, rather than using
|
||||
an external utility as a supervisory process, you should use Kubernetes as the
|
||||
watchdog for your application.
|
||||
|
||||
### Updating the Ensemble
|
||||
|
||||
The `zk` StatefulSet is configured to use the RollingUpdate update strategy.
|
||||
|
||||
You can use `kubectl patch` to update the number of `cpus` allocated to the servers.
|
||||
|
||||
```shell{% raw %}
|
||||
kubectl patch sts zk --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/resources/requests/cpu", "value":"0.3"}]'
|
||||
|
||||
statefulset "zk" patched
|
||||
```{% endraw %}
|
||||
|
||||
Use `kubectl rollout status` to watch the status of the update.
|
||||
|
||||
```shell
|
||||
kubectl rollout status sts/zk
|
||||
waiting for statefulset rolling update to complete 0 pods at revision zk-5db4499664...
|
||||
Waiting for 1 pods to be ready...
|
||||
Waiting for 1 pods to be ready...
|
||||
waiting for statefulset rolling update to complete 1 pods at revision zk-5db4499664...
|
||||
Waiting for 1 pods to be ready...
|
||||
Waiting for 1 pods to be ready...
|
||||
waiting for statefulset rolling update to complete 2 pods at revision zk-5db4499664...
|
||||
Waiting for 1 pods to be ready...
|
||||
Waiting for 1 pods to be ready...
|
||||
statefulset rolling update complete 3 pods at revision zk-5db4499664...
|
||||
```
|
||||
|
||||
The Pods are terminated, one at a time, in reverse ordinal order, and they
|
||||
are recreated with the new configuration. This ensures that quorum is maintained
|
||||
during a rolling update.
|
||||
|
||||
Use `kubectl rollout history` to view a history or previous configurations.
|
||||
|
||||
```shell
|
||||
kubectl rollout history sts/zk
|
||||
statefulsets "zk"
|
||||
REVISION
|
||||
1
|
||||
2
|
||||
```
|
||||
Use `kubectl rollout undo` to roll back the modification.
|
||||
|
||||
```shell
|
||||
kubectl rollout undo sts/zk
|
||||
statefulset "zk" rolled back
|
||||
```
|
||||
|
||||
### Handling Process Failure
|
||||
|
||||
|
||||
@@ -1022,19 +957,25 @@ Get the nodes in your cluster.
|
||||
kubectl get nodes
|
||||
```
|
||||
|
||||
Get the `zk-budget` PodDisruptionBudget.
|
||||
Use [`kubectl cordon`](/docs/user-guide/kubectl/{{page.version}}/#cordon) to
|
||||
cordon all but four of the nodes in your cluster.
|
||||
|
||||
```shell{% raw %}
|
||||
kubectl cordon < node name >
|
||||
```{% endraw %}
|
||||
|
||||
Get the `zk-pdb` PodDisruptionBudget.
|
||||
|
||||
```shell
|
||||
kubectl get poddisruptionbudget zk-budget
|
||||
kubectl get pdb zk-pdb
|
||||
```
|
||||
|
||||
The `min-available` field indicates to Kubernetes that at least two Pods from
|
||||
`zk` StatefulSet must be available at any time.
|
||||
|
||||
```yaml
|
||||
NAME MIN-AVAILABLE ALLOWED-DISRUPTIONS AGE
|
||||
zk-budget 2 1 1h
|
||||
The `max-unavailable` field indicates to Kubernetes that at most one Pod from
|
||||
`zk` StatefulSet can be unavailable at any time.
|
||||
|
||||
```shell
|
||||
NAME MIN-AVAILABLE MAX-UNAVAILABLE ALLOWED-DISRUPTIONS AGE
|
||||
zk-pdb N/A 1 1
|
||||
```
|
||||
|
||||
In one terminal, watch the Pods in the `zk` StatefulSet.
|
||||
@@ -1053,13 +994,6 @@ kubernetes-minion-group-i4c4
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Use [`kubectl cordon`](/docs/user-guide/kubectl/{{page.version}}/#cordon) to
|
||||
cordon the three nodes that the Pods are currently scheduled on.
|
||||
|
||||
```shell{% raw %}
|
||||
kubectl cordon < node name >
|
||||
{% endraw %}```
|
||||
|
||||
Use [`kubectl drain`](/docs/user-guide/kubectl/{{page.version}}/#drain) to cordon and
|
||||
drain the node on which the `zk-0` Pod is scheduled.
|
||||
|
||||
@@ -1095,8 +1029,7 @@ Keep watching the StatefulSet's Pods in the first terminal and drain the node on
|
||||
`zk-1` is scheduled.
|
||||
|
||||
```shell{% raw %}
|
||||
kubectl drain $(kubectl get pod zk-1 --template {{.spec.nodeName}}) --ignore-daemonsets --force --delete-local-data
|
||||
node "kubernetes-minion-group-ixsl" cordoned
|
||||
kubectl drain $(kubectl get pod zk-1 --template {{.spec.nodeName}}) --ignore-daemonsets --force --delete-local-data "kubernetes-minion-group-ixsl" cordoned
|
||||
WARNING: Deleting pods not managed by ReplicationController, ReplicaSet, Job, or DaemonSet: fluentd-cloud-logging-kubernetes-minion-group-ixsl, kube-proxy-kubernetes-minion-group-ixsl; Ignoring DaemonSet-managed pods: node-problem-detector-v0.1-voc74
|
||||
pod "zk-1" deleted
|
||||
node "kubernetes-minion-group-ixsl" drained
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: zk-headless
|
||||
name: zk-hs
|
||||
labels:
|
||||
app: zk-headless
|
||||
app: zk
|
||||
spec:
|
||||
ports:
|
||||
- port: 2888
|
||||
@@ -15,43 +16,45 @@ spec:
|
||||
app: zk
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
kind: Service
|
||||
metadata:
|
||||
name: zk-config
|
||||
data:
|
||||
ensemble: "zk-0;zk-1;zk-2"
|
||||
jvm.heap: "2G"
|
||||
tick: "2000"
|
||||
init: "10"
|
||||
sync: "5"
|
||||
client.cnxns: "60"
|
||||
snap.retain: "3"
|
||||
purge.interval: "1"
|
||||
name: zk-cs
|
||||
labels:
|
||||
app: zk
|
||||
spec:
|
||||
ports:
|
||||
- port: 2181
|
||||
name: client
|
||||
selector:
|
||||
app: zk
|
||||
---
|
||||
apiVersion: policy/v1beta1
|
||||
kind: PodDisruptionBudget
|
||||
metadata:
|
||||
name: zk-budget
|
||||
name: zk-pdb
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: zk
|
||||
minAvailable: 2
|
||||
maxUnavailable: 1
|
||||
---
|
||||
apiVersion: apps/v1beta1
|
||||
apiVersion: apps/v1beta2
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: zk
|
||||
spec:
|
||||
serviceName: zk-headless
|
||||
selector:
|
||||
matchLabels:
|
||||
app: zk
|
||||
serviceName: zk-hs
|
||||
replicas: 3
|
||||
updateStrategy:
|
||||
type: RollingUpdate
|
||||
podManagementPolicy: Parallel
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: zk
|
||||
annotations:
|
||||
pod.alpha.kubernetes.io/initialized: "true"
|
||||
|
||||
spec:
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
@@ -60,17 +63,17 @@ spec:
|
||||
matchExpressions:
|
||||
- key: "app"
|
||||
operator: In
|
||||
values:
|
||||
- zk-headless
|
||||
values:
|
||||
- zk
|
||||
topologyKey: "kubernetes.io/hostname"
|
||||
containers:
|
||||
- name: k8szk
|
||||
- name: kubernetes-zookeeper
|
||||
imagePullPolicy: Always
|
||||
image: gcr.io/google_samples/k8szk:v1
|
||||
image: "gcr.io/google_containers/kubernetes-zookeeper:1.0-3.4.10"
|
||||
resources:
|
||||
requests:
|
||||
memory: "4Gi"
|
||||
cpu: "1"
|
||||
memory: "1Gi"
|
||||
cpu: "0.5"
|
||||
ports:
|
||||
- containerPort: 2181
|
||||
name: client
|
||||
@@ -78,68 +81,42 @@ spec:
|
||||
name: server
|
||||
- containerPort: 3888
|
||||
name: leader-election
|
||||
env:
|
||||
- name : ZK_ENSEMBLE
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: ensemble
|
||||
- name : ZK_HEAP_SIZE
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: jvm.heap
|
||||
- name : ZK_TICK_TIME
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: tick
|
||||
- name : ZK_INIT_LIMIT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: init
|
||||
- name : ZK_SYNC_LIMIT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: tick
|
||||
- name : ZK_MAX_CLIENT_CNXNS
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: client.cnxns
|
||||
- name: ZK_SNAP_RETAIN_COUNT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: snap.retain
|
||||
- name: ZK_PURGE_INTERVAL
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: zk-config
|
||||
key: purge.interval
|
||||
- name: ZK_CLIENT_PORT
|
||||
value: "2181"
|
||||
- name: ZK_SERVER_PORT
|
||||
value: "2888"
|
||||
- name: ZK_ELECTION_PORT
|
||||
value: "3888"
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- zkGenConfig.sh && zkServer.sh start-foreground
|
||||
- "start-zookeeper \
|
||||
--servers=3 \
|
||||
--data_dir=/var/lib/zookeeper/data \
|
||||
--data_log_dir=/var/lib/zookeeper/data/log \
|
||||
--conf_dir=/opt/zookeeper/conf \
|
||||
--client_port=2181 \
|
||||
--election_port=3888 \
|
||||
--server_port=2888 \
|
||||
--tick_time=2000 \
|
||||
--init_limit=10 \
|
||||
--sync_limit=5 \
|
||||
--heap=512M \
|
||||
--max_client_cnxns=60 \
|
||||
--snap_retain_count=3 \
|
||||
--purge_interval=12 \
|
||||
--max_session_timeout=40000 \
|
||||
--min_session_timeout=4000 \
|
||||
--log_level=INFO"
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- "zkOk.sh"
|
||||
initialDelaySeconds: 15
|
||||
- sh
|
||||
- -c
|
||||
- "zookeeper-ready 2181"
|
||||
initialDelaySeconds: 10
|
||||
timeoutSeconds: 5
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- "zkOk.sh"
|
||||
initialDelaySeconds: 15
|
||||
- sh
|
||||
- -c
|
||||
- "zookeeper-ready 2181"
|
||||
initialDelaySeconds: 10
|
||||
timeoutSeconds: 5
|
||||
volumeMounts:
|
||||
- name: datadir
|
||||
@@ -154,4 +131,4 @@ spec:
|
||||
accessModes: [ "ReadWriteOnce" ]
|
||||
resources:
|
||||
requests:
|
||||
storage: 20Gi
|
||||
storage: 10Gi
|
||||
|
||||
Reference in New Issue
Block a user