Kubernetes 1.6 Updates for ZooKeeper (#936)

* Removes alpha annotations for affinity and storage class. These are
replaced with beta feilds.
Removes configuration map. This causes conflicts when helm delete is
used charts that depend on zookeeper as a client. Also, in Kubernetes
1.7, it will be possible to perform rolling configuration updates on
StatefulSets that embed configuration in the manifest.
Adds a service for clients to detect a running ZooKeeper instance. This
is useful for dependent charts and client applications to connect their
ZooKeeper clients directly to any running instance of the ensemble.
Increments Chart version to 0.3.0.
Updates connection notes to include connnection information in for the
client service.

* Modifies README to reflect all pods as running and fix typo
Corrects service name of StatefulSet
This commit is contained in:
Kenneth Owens
2017-05-10 11:11:01 -07:00
committed by Vic Iglesias
parent 56381c5260
commit 820c69bb2e
8 changed files with 102 additions and 116 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
name: zookeeper
home: https://zookeeper.apache.org/
version: 0.2.2
version: 0.3.0
description: Centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services.
icon: https://zookeeper.apache.org/images/zookeeper_small.gif
sources:
+39 -12
View File
@@ -2,11 +2,10 @@
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/statefulset/zookeeper).
[Zookeeper StatefulSet](https://github.com/kubernetes/contrib/tree/master/statefulsets/zookeeper).
## Prerequisites
* Kubernetes 1.5
* If you use spreading, the cluster will require alpha features to be enabled.
* Kubernetes 1.6
* PersistentVolume support on the underlying infrastructure
* A dynamic provisioner for the PersistentVolumes
* A familiarity with [Apache ZooKeeper 3.4.x](https://zookeeper.apache.org/doc/current/)
@@ -16,31 +15,58 @@ This chart will do the following:
* Create a fixed size ZooKeeper ensemble using a
[StatefulSet](http://kubernetes.io/docs/concepts/abstractions/controllers/statefulsets/).
* Create a [ConfigMap](http://kubernetes.io/docs/user-guide/configmap/) to provide configuration parameters to the Pods
in the ensemble.
* Create a [PodDisruptionBudget](http://kubernetes.io/docs/admin/disruptions/) so kubectl drain will respect the Quorum
* 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.
* Optionally, apply a [Pod Anti-Affinity](http://kubernetes.io/docs/user-guide/node-selection/) annotation to spread the
* Create a [Headless Service](https://kubernetes.io/docs/concepts/services-networking/service/) to control the domain of the ZooKeeper ensemble.
* Create a Service configured to connect to the available ZooKeeper instance on the configured client port.
* 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.
## Installing the Chart
You can install the chart with the release name `my-release` as below.
You can install the chart with the release name `my-zk` as below.
```bash
```console
$ helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
$ helm install --name my-release incubator/zookeeper
$ helm install --name my-zk incubator/zookeeper
```
If you do not specify a name, helm will select a name for you.
### Installed Components
You can use `kubectl get` to view all of the installed components.
```console{%raw}
$ kubectl get all -l component=zk-my-zk
NAME READY STATUS RESTARTS AGE
po/zk-my-zk-0 1/1 Running 0 1m
po/zk-my-zk-1 1/1 Running 0 59s
po/zk-my-zk-2 1/1 Running 0 12s
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/zk-csvc-my-zk 10.0.60.195 <none> 2181/TCP 1m
svc/zk-hsvc-my-zk None <none> 2888/TCP,3888/TCP 1m
NAME DESIRED CURRENT AGE
statefulsets/zk-my-zk 3 2 1m
```
1. `zy-my-zk` is the StatefulSet created by the chart.
1. `zk-my-zk-0` - `zk-my-zk-2` are the Pods created by the StatefulSet. Each Pod has a single
container running a ZooKeeper server.
1. `zk-hsvc-my-zk` is the Headless Server used to control the network domain of the ZooKeeper
ensemble.
1. `zk-csvc-my-zk` is a Service that can be used by clients to connect to an available ZooKeeper
server.
## Configuration
You can specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart.
For example,
```bash
```console
$ helm install --name my-release -f values.yaml incubator/zookeeper
```
@@ -148,7 +174,8 @@ $ kubectl exec <RELEASE-NAME>-2 -- /opt/zookeeper/bin/zkCli.sh get /foo;
Watch existing members:
```console
$ 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>.<headless-service-name>:2181 | grep Mode); sleep 1; done; done';
$ 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>.<headless-service-name>:2181 | grep Mode); sleep 1; done; done';
zk-2 Mode: follower
zk-0 Mode: follower
zk-1 Mode: leader
+3 -1
View File
@@ -19,4 +19,6 @@ server, you should provide multiple servers in the connection string to allow
for the client to continue to function in the presence of individual server
failures. It is important that you do not use IP addresses and instead use the
DNS entries for the domain established by the StatefulSet's HeadlessService.
Your connection string should look like {{.Release.Name | trunc 24 }}-0.{{ printf "hs-%s" .Release.Name | trunc 24 }}:{{.Values.ClientPort}},{{.Release.Name | trunc 24 }}-1.{{ printf "hs-%s" .Release.Name | trunc 24 }}:{{.Values.ClientPort}},... .
Your connection string should look like zk-{{.Release.Name | trunc 24 }}-0.{{ printf "zk-hsvc-%s" .Release.Name | trunc 24 }}:{{.Values.ClientPort}},zk-{{.Release.Name | trunc 24 }}-1.{{ printf "zk-hsvc-%s" .Release.Name | trunc 24 }}:{{.Values.ClientPort}},... .
You can also use the client Service zk-csvc:{{.Values.ClientPort}} to
connect to an available ZooKeeper server.
-20
View File
@@ -1,20 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ printf "cm-zk-%s" .Release.Name | trunc 24 }}"
annotations:
helm.sh/created: {{.Release.Time.Seconds | quote }}
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}"
data:
jvm.heap: {{.Values.Heap}}
tick: "{{.Values.TickTimeMs}}"
init: "{{.Values.InitTicks}}"
sync: "{{.Values.SyncTicks}}"
client.cnxns: "{{.Values.ClientCnxns}}"
snap.retain: "{{.Values.SnapRetain}}"
purge.interval: "{{.Values.PurgeHours}}"
log.level: {{.Values.LogLevel}}
+15
View File
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: "{{ printf "zk-csvc-%s" .Release.Name | trunc 24 }}"
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{ printf "zk-%s" .Release.Name | trunc 24 }}"
spec:
ports:
- port: {{.Values.ClientPort}}
name: client
selector:
component: "{{ printf "zk-%s" .Release.Name | trunc 24 }}"
+3 -3
View File
@@ -1,18 +1,18 @@
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: "{{ printf "pd-zk-%s" .Release.Name | trunc 24 }}"
name: "{{ printf "zk-pdb-%s" .Release.Name | trunc 24 }}"
annotations:
helm.sh/created: {{.Release.Time.Seconds | quote }}
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}"
component: "{{ printf "zk-%s" .Release.Name | trunc 24 }}"
spec:
selector:
matchLabels:
component: "{{.Release.Name}}"
component: "{{ printf "zk-%s" .Release.Name | trunc 24 }}"
{{- if .Values.MinAvailable}}
minAvailable: {{.Values.MinAvailable}}
{{- else}}
+38 -76
View File
@@ -8,50 +8,39 @@ metadata:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}"
component: "{{ printf "zk-%s" .Release.Name | trunc 24 }}"
spec:
serviceName: "{{ printf "hs-zk-%s" .Release.Name | trunc 24 }}"
serviceName: "{{ printf "zk-hsvc-%s" .Release.Name | trunc 24 }}"
replicas: {{.Values.Servers}}
template:
metadata:
labels:
component: "{{.Release.Name}}"
annotations:
pod.alpha.kubernetes.io/initialized: "true"
{{- if eq .Values.AntiAffinity "hard"}}
scheduler.alpha.kubernetes.io/affinity: >
{
"podAntiAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": [{
"labelSelector": {
"matchExpressions": [{
"key": "component",
"operator": "In",
"values": ["{{.Release.Name}}"]
}]
},
"topologyKey": "kubernetes.io/hostname"
}]
}
}
{{- else if eq .Values.AntiAffinity "soft"}}
scheduler.alpha.kubernetes.io/affinity: >
{
"podAntiAffinity": {
"prefferedDuringSchedulingIgnoredDuringExecution": [{
"labelSelector": {
"matchExpressions": [{
"key": "component",
"operator": "In",
"values": ["{{.Release.Name}}"]
}]
},
"topologyKey": "kubernetes.io/hostname"
}]
}
}
{{- end}}
component: "{{ printf "zk-%s" .Release.Name | trunc 24 }}"
spec:
{{- if eq .Values.AntiAffinity "hard"}}
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "component"
operator: In
values:
- "{{ printf "zk-%s" .Release.Name | trunc 24 }}"
topologyKey: "kubernetes.io/hostname"
{{- else if eq .Values.AntiAffinity "soft"}}
affinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAntiAffinityTerm:
labelSelector:
matchExpressions:
- key: "component"
operator: In
values:
- "{{ printf "zk-%s" .Release.Name | trunc 24 }}"
topologyKey: "kubernetes.io/hostname"
{{- end}}
containers:
- name: k8szk
imagePullPolicy: {{.Values.ImagePullPolicy}}
@@ -71,45 +60,21 @@ spec:
- name : ZK_REPLICAS
value: "{{.Values.Servers}}"
- name : ZK_HEAP_SIZE
valueFrom:
configMapKeyRef:
name: "{{ printf "cm-zk-%s" .Release.Name | trunc 24 }}"
key: jvm.heap
value: "{{.Values.Heap}}"
- name : ZK_TICK_TIME
valueFrom:
configMapKeyRef:
name: "{{ printf "cm-zk-%s" .Release.Name | trunc 24 }}"
key: tick
value: "{{.Values.TickTimeMs}}"
- name : ZK_INIT_LIMIT
valueFrom:
configMapKeyRef:
name: "{{ printf "cm-zk-%s" .Release.Name | trunc 24 }}"
key: init
value: "{{.Values.InitTicks}}"
- name : ZK_SYNC_LIMIT
valueFrom:
configMapKeyRef:
name: "{{ printf "cm-zk-%s" .Release.Name | trunc 24 }}"
key: tick
value: "{{.Values.SyncTicks}}"
- name : ZK_MAX_CLIENT_CNXNS
valueFrom:
configMapKeyRef:
name: "{{ printf "cm-zk-%s" .Release.Name | trunc 24 }}"
key: client.cnxns
value: "{{.Values.ClientCnxns}}"
- name: ZK_SNAP_RETAIN_COUNT
valueFrom:
configMapKeyRef:
name: "{{ printf "cm-zk-%s" .Release.Name | trunc 24 }}"
key: snap.retain
value: "{{.Values.SnapRetain}}"
- name: ZK_PURGE_INTERVAL
valueFrom:
configMapKeyRef:
name: "{{ printf "cm-zk-%s" .Release.Name | trunc 24 }}"
key: purge.interval
value: "{{.Values.PurgeHours}}"
- name: ZK_LOG_LEVEL
valueFrom:
configMapKeyRef:
name: "{{ printf "cm-zk-%s" .Release.Name | trunc 24 }}"
key: log.level
value: {{.Values.LogLevel}}
- name: ZK_CLIENT_PORT
value: "{{.Values.ClientPort}}"
- name: ZK_SERVER_PORT
@@ -141,14 +106,11 @@ spec:
volumeClaimTemplates:
- metadata:
name: datadir
annotations:
{{- if .Values.StorageClass}}
volume.beta.kubernetes.io/storage-class: {{.Values.StorageClass | quote}}
{{- else}}
volume.alpha.kubernetes.io/storage-class: "default"
{{- end}}
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{.Values.Storage}}
{{- if .Values.StorageClass}}
storageClassName: {{.Values.StorageClass | quote}}
{{- end}}
+3 -3
View File
@@ -1,12 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: "{{ printf "hs-zk-%s" .Release.Name | trunc 24 }}"
name: "{{ printf "zk-hsvc-%s" .Release.Name | trunc 24 }}"
labels:
heritage: {{.Release.Service | quote }}
release: {{.Release.Name | quote }}
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
component: "{{.Release.Name}}"
component: "{{ printf "zk-%s" .Release.Name | trunc 24 }}"
spec:
ports:
- port: {{.Values.ServerPort}}
@@ -15,4 +15,4 @@ spec:
name: leader-election
clusterIP: None
selector:
component: "{{.Release.Name}}"
component: "{{ printf "zk-%s" .Release.Name | trunc 24 }}"