Merge "vvp -- VNF Validation Platform"
[oom.git] / kubernetes / common / music / charts / zookeeper / README.md
1 # incubator/zookeeper
2
3 This helm chart provides an implementation of the ZooKeeper [StatefulSet](http://kubernetes.io/docs/concepts/abstractions/controllers/statefulsets/) found in Kubernetes Contrib [Zookeeper StatefulSet](https://github.com/kubernetes/contrib/tree/master/statefulsets/zookeeper).
4
5 ## Prerequisites
6 * Kubernetes 1.6+
7 * PersistentVolume support on the underlying infrastructure
8 * A dynamic provisioner for the PersistentVolumes
9 * A familiarity with [Apache ZooKeeper 3.4.x](https://zookeeper.apache.org/doc/current/)
10
11 ## Chart Components
12 This chart will do the following:
13
14 * Create a fixed size ZooKeeper ensemble using a [StatefulSet](http://kubernetes.io/docs/concepts/abstractions/controllers/statefulsets/).
15 * Create a [PodDisruptionBudget](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-disruption-budget/) so kubectl drain will respect the Quorum size of the ensemble.
16 * Create a [Headless Service](https://kubernetes.io/docs/concepts/services-networking/service/) to control the domain of the ZooKeeper ensemble.
17 * Create a Service configured to connect to the available ZooKeeper instance on the configured client port.
18 * Optionally apply a [Pod Anti-Affinity](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity-beta-feature) to spread the ZooKeeper ensemble across nodes.
19 * Optionally start JMX Exporter and Zookeeper Exporter containers inside Zookeeper pods.
20 * Optionally create a job which creates Zookeeper chroots (e.g. `/kafka1`).
21
22 ## Installing the Chart
23 You can install the chart with the release name `zookeeper` as below.
24
25 ```console
26 $ helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
27 $ helm install --name zookeeper incubator/zookeeper
28 ```
29
30 If you do not specify a name, helm will select a name for you.
31
32 ### Installed Components
33 You can use `kubectl get` to view all of the installed components.
34
35 ```console{%raw}
36 $ kubectl get all -l app=zookeeper
37 NAME:   zookeeper
38 LAST DEPLOYED: Wed Apr 11 17:09:48 2018
39 NAMESPACE: default
40 STATUS: DEPLOYED
41
42 RESOURCES:
43 ==> v1beta1/PodDisruptionBudget
44 NAME       MIN AVAILABLE  MAX UNAVAILABLE  ALLOWED DISRUPTIONS  AGE
45 zookeeper  N/A            1                1                    2m
46
47 ==> v1/Service
48 NAME                TYPE       CLUSTER-IP     EXTERNAL-IP  PORT(S)                     AGE
49 zookeeper-headless  ClusterIP  None           <none>       2181/TCP,3888/TCP,2888/TCP  2m
50 zookeeper           ClusterIP  10.98.179.165  <none>       2181/TCP                    2m
51
52 ==> v1beta1/StatefulSet
53 NAME       DESIRED  CURRENT  AGE
54 zookeeper  3        3        2m
55 ```
56
57 1. `statefulsets/zookeeper` is the StatefulSet created by the chart.
58 1. `po/zookeeper-<0|1|2>` are the Pods created by the StatefulSet. Each Pod has a single container running a ZooKeeper server.
59 1. `svc/zookeeper-headless` is the Headless Service used to control the network domain of the ZooKeeper ensemble.
60 1. `svc/zookeeper` is a Service that can be used by clients to connect to an available ZooKeeper server.
61
62 ## Configuration
63 You can specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.
64
65 Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,
66
67 ```console
68 $ helm install --name my-release -f values.yaml incubator/zookeeper
69 ```
70
71 ## Default Values
72
73 - You can find all user-configurable settings, their defaults and commentary about them in [values.yaml](values.yaml).
74
75 ## Deep Dive
76
77 ## Image Details
78 The image used for this chart is based on Ubuntu 16.04 LTS. This image is larger than Alpine or BusyBox, but it provides glibc, rather than ulibc or mucl, and a JVM release that is built against it. You can easily convert this chart to run against a smaller image with a JVM that is built against that image's libc. However, as far as we know, no Hadoop vendor supports, or has verified, ZooKeeper running on such a JVM.
79
80 ## JVM Details
81 The Java Virtual Machine used for this chart is the OpenJDK JVM 8u111 JRE (headless).
82
83 ## ZooKeeper Details
84 The ZooKeeper version is the latest stable version (3.4.10). The distribution is installed into /opt/zookeeper-3.4.10. This directory is symbolically linked to /opt/zookeeper. Symlinks are created to simulate a rpm installation into /usr.
85
86 ## Failover
87 You can test failover by killing the leader. Insert a key:
88 ```console
89 $ kubectl exec zookeeper-0 -- /opt/zookeeper/bin/zkCli.sh create /foo bar;
90 $ kubectl exec zookeeper-2 -- /opt/zookeeper/bin/zkCli.sh get /foo;
91 ```
92
93 Watch existing members:
94 ```console
95 $ kubectl run --attach bbox --image=busybox --restart=Never -- sh -c 'while true; do for i in 0 1 2; do echo zk-${i} $(echo stats | nc <pod-name>-${i}.<headless-service-name>:2181 | grep Mode); sleep 1; done; done';
96
97 zk-2 Mode: follower
98 zk-0 Mode: follower
99 zk-1 Mode: leader
100 zk-2 Mode: follower
101 ```
102
103 Delete Pods and wait for the StatefulSet controller to bring them back up:
104 ```console
105 $ kubectl delete po -l app=zookeeper
106 $ kubectl get po --watch-only
107 NAME          READY     STATUS    RESTARTS   AGE
108 zookeeper-0   0/1       Running   0          35s
109 zookeeper-0   1/1       Running   0         50s
110 zookeeper-1   0/1       Pending   0         0s
111 zookeeper-1   0/1       Pending   0         0s
112 zookeeper-1   0/1       ContainerCreating   0         0s
113 zookeeper-1   0/1       Running   0         19s
114 zookeeper-1   1/1       Running   0         40s
115 zookeeper-2   0/1       Pending   0         0s
116 zookeeper-2   0/1       Pending   0         0s
117 zookeeper-2   0/1       ContainerCreating   0         0s
118 zookeeper-2   0/1       Running   0         19s
119 zookeeper-2   1/1       Running   0         41s
120 ```
121
122 Check the previously inserted key:
123 ```console
124 $ kubectl exec zookeeper-1 -- /opt/zookeeper/bin/zkCli.sh get /foo
125 ionid = 0x354887858e80035, negotiated timeout = 30000
126
127 WATCHER::
128
129 WatchedEvent state:SyncConnected type:None path:null
130 bar
131 ```
132
133 ## Scaling
134 ZooKeeper can not be safely scaled in versions prior to 3.5.x. This chart currently uses 3.4.x. There are manual procedures for scaling a 3.4.x ensemble, but as noted in the [ZooKeeper 3.5.2 documentation](https://zookeeper.apache.org/doc/r3.5.2-alpha/zookeeperReconfig.html) these procedures require a rolling restart, are known to be error prone, and often result in a data loss.
135
136 While ZooKeeper 3.5.x does allow for dynamic ensemble reconfiguration (including scaling membership), the current status of the release is still alpha, and 3.5.x is therefore not recommended for production use.
137
138 ## Limitations
139 * StatefulSet and PodDisruptionBudget are beta resources.
140 * Only supports storage options that have backends for persistent volume claims.