Added zookeeper package for kubernetes. Some bugfixes for cattle packages

This commit is contained in:
Raul Sanchez 2016-09-29 22:37:12 +02:00
parent 5d4849f5f0
commit 37dba8043b
9 changed files with 222 additions and 8 deletions

View File

@ -0,0 +1,31 @@
# Apache Zookeeper (Experimental)
### Info:
This template creates, scale in and scale out a multinodes zk (zookeeper) cluster on top of k8s. The configuration is generated with confd watching k8s metadata.
Cluster size are variable after deployment, and get reconfigured if you scale.
The services generates ZKID's (saving them as pod labels) and start the zookeeper cluster.
### Usage:
Select Apache Zookeeper from catalog.
Change the following zookeeper default parameters, if you need:
- zk_name="zookeeper" # Name of the k8s rc and service.
- zk_namespace="default" # Name of the k8s namespace
- zk_scale="3" # Number of zk replicas
- zk_mem="512" # Mem to configure zk.
- zk_data_dir="/opt/zk/data" # Zk dataDir param value
- zk_init_limit="10" # zk initLimit param value
- zk_max_client_cxns="500" # zk maxClientCnxns param value
- zk_sync_limit="5" # zk syncLimit param value
- zk_tick_time="2000" # zk tickTime param value
Click deploy.
Zookeeper can now be accessed over the Rancher network.
Testing Feature: When you scale the cluster, zero downtime is expected...

View File

@ -0,0 +1,73 @@
.catalog:
name: Zookeeper
version: 3.4.8-k8s1
description: |
(Experimental) Apache Zookeeper cluster.
minimum_rancher_version: v0.59.0
maintainer: "Raul Sanchez <rawmind@gmail.com>"
uuid: zk-0
questions:
- variable: "zk_name"
description: "Name of zookeeper rc and service."
label: "K8s rc name:"
required: true
default: "zookeeper"
type: "string"
- variable: "zk_namespace"
description: "Name of zookeeper namespace."
label: "K8s namespace:"
required: true
default: "default"
type: "string"
- variable: "zk_scale"
description: "Number of zk nodes. Note: Recommended an odd number"
label: "Zk Nodes:"
required: true
default: 3
type: "int"
- variable: "zk_mem"
description: "Amount of memory to config zk."
label: "Zk Memory (mb):"
required: true
default: 512
type: "int"
- variable: "zk_init_limit"
description: "Time to allow followers to connect and sync with leader"
label: "Zk init limit (ticks):"
required: true
default: 10
type: "int"
- variable: "zk_data_dir"
description: "Directory where zookeeper store data"
label: "Zk data dir:"
required: true
default: "/opt/zk/data"
type: "string"
- variable: "zk_max_client_cxns"
description: "Max client concurrent connections"
label: "Zk max client cxns:"
required: true
default: 500
type: "int"
- variable: "zk_sync_limit"
description: "Time to allow followers to sync with leader"
label: "Zk sync limit (ticks):"
required: true
default: 5
type: "int"
- variable: "zk_tick_time"
description: "Tick time length"
label: "Zk tick time (ms):"
required: true
default: 2000
type: "int"
zk:
scale: ${zk_scale}
retain_ip: true
health_check:
port: 2181
interval: 5000
unhealthy_threshold: 3
request_line: ''
healthy_threshold: 2
response_timeout: 5000

View File

@ -0,0 +1,80 @@
apiVersion: v1
kind: ReplicationController
metadata:
name: "${zk_name}"
namespace: "${zk_namespace}"
labels:
name: "${zk_name}"
spec:
replicas: ${zk_scale}
selector:
name: "${zk_name}"
template:
metadata:
labels:
name: "${zk_name}"
annotations:
spec:
containers:
- name: "zk-conf"
image: "rawmind/k8s-zk:3.4.8-10"
volumeMounts:
- mountPath: "/opt/tools"
name: "zk-conf"
ports:
imagePullPolicy: "IfNotPresent"
- name: "zk-volume"
image: "rawmind/alpine-volume:0.0.2-1"
env:
- name: SERVICE_UID
value: "10002"
- name: SERVICE_GID
value: "10002"
- name: SERVICE_VOLUME
value: "${kafka_log_dir}"
- name: KEEP_ALIVE
value: "1"
volumeMounts:
- mountPath: "${zk_data_dir}"
name: "zk-data"
ports:
imagePullPolicy: "IfNotPresent"
- name: "zk-service"
image: "rawmind/alpine-zk:3.4.8-16"
env:
- name: JVMFLAGS
value: "-Xmx${zk_mem}m -Xms${zk_mem}m"
- name: ZK_DATA_DIR
value: "${zk_data_dir}"
- name: ZK_INIT_LIMIT
value: "${zk_init_limit}"
- name: ZK_MAX_CLIENT_CXNS
value: "${zk_max_client_cxns}"
- name: ZK_SYNC_LIMIT
value: "${zk_sync_limit}"
- name: ZK_TICK_TIME
value: "${zk_tick_time}"
- name: POD_NAMESPACE
value: "${zk_namespace}"
volumeMounts:
- mountPath: "${zk_data_dir}"
name: "zk-data"
- mountPath: "/opt/tools"
name: "zk-conf"
ports:
- containerPort: 2181
name: "zk-client"
protocol: "TCP"
- containerPort: 2888
name: "zk-server"
protocol: "TCP"
- containerPort: 3888
name: "zk-leader"
protocol: "TCP"
imagePullPolicy: "IfNotPresent"
restartPolicy: "Always"
volumes:
- name: "zk-data"
emptyDir: {}
- name: "zk-conf"
emptyDir: {}

View File

@ -0,0 +1,23 @@
apiVersion: v1
kind: Service
metadata:
name: "${zk_name}"
namespace: "${zk_namespace}"
labels:
name: "${zk_name}"
spec:
ports:
- port: 2181
targetPort: 2181
name: "zk-client"
protocol: "TCP"
- port: 2888
targetPort: 2888
name: "zk-server"
protocol: "TCP"
- port: 3888
targetPort: 3888
name: "zk-leader"
protocol: "TCP"
selector:
name: "${zk_name}"

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -0,0 +1,7 @@
name: Apache Zookeeper
description: |
(Experimental) Zookeeper cluster
version: 3.4.8-k8s1
category: Clustering
maintainer: "Raul Sanchez <rawmind@gmail.com>"
projectURL: https://github.com/rawmind0/alpine-zk

View File

@ -24,4 +24,4 @@
Zookeeper can now be accessed over the Rancher network.
Note: When you scale the cluster, zero downtime is not guaranteed..yet..
Note: When you scale the cluster, zero downtime is expected...

View File

@ -1,6 +1,6 @@
zk:
tty: true
image: rawmind/alpine-zk:3.4.8-4
image: rawmind/alpine-zk:3.4.8-16
volumes_from:
- zk-volume
- zk-conf
@ -21,7 +21,9 @@ zk-conf:
io.rancher.scheduler.affinity:container_label_soft_ne: io.rancher.stack_service.name=$${stack_name}/$${service_name}
io.rancher.container.hostname_override: container_name
io.rancher.container.start_once: true
image: rawmind/rancher-zk:0.3.3
image: rawmind/rancher-zk:3.4.8-5
volumes:
- /opt/tools
zk-volume:
net: none
labels:
@ -29,12 +31,10 @@ zk-volume:
io.rancher.container.hostname_override: container_name
io.rancher.container.start_once: true
environment:
- SERVICE_USER=zookeeper
- SERVICE_UID=10002
- SERVICE_GROUP=zookeeper
- SERVICE_GID=10002
- SERVICE_VOLUME=${zk_data_dir}
volumes:
- ${zk_data_dir}
volume_driver: local
image: rawmind/alpine-volume:0.0.1-1
image: rawmind/alpine-volume:0.0.2-1

View File

@ -4,5 +4,5 @@ description: |
version: 3.4.8-rancher1
category: Clustering
maintainer: "Raul Sanchez <rawmind@gmail.com>"
minimum_rancher_version: v0.59.0
license:
projectURL: https://github.com/rawmind0/alpine-zk
license: