Skip to content

Instantly share code, notes, and snippets.

@matzew
Created October 17, 2017 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matzew/38e9433083c6bf2cd2767081179fcb97 to your computer and use it in GitHub Desktop.
Save matzew/38e9433083c6bf2cd2767081179fcb97 to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: Template
metadata:
name: barnabas
parameters:
- description: Number of Zookeper cluster nodes which will be deployed (odd number of nodes is recomended)
displayName: Number of Zookeper cluster nodes (odd number of nodes is recomended)
name: ZOOKEEPER_NODE_COUNT
required: true
value: "3"
- description: Number of Kafka cluster nodes which will be deployed
displayName: Number of Kafka cluster nodes
name: KAFKA_NODE_COUNT
required: true
value: "3"
- description: Volume space available for Zookeeper data, e.g. 512Mi, 2Gi.
displayName: Zookeeper Volume Capacity
name: ZOOKEEPER_VOLUME_CAPACITY
required: true
value: 1Gi
- description: Volume space available for Kafka data, e.g. 512Mi, 2Gi.
displayName: Kafka Volume Capacity
name: KAFKA_VOLUME_CAPACITY
required: true
value: 1Gi
- description: Image repository name
displayName: Repository Name
name: IMAGE_REPO_NAME
value: scholzj
- description: Kafka image name
displayName: Kafka image Name
name: KAFKA_IMAGE_NAME
value: kafka-statefulsets
- description: Kafka image tag
displayName: Kafka image tag
name: KAFKA_IMAGE_TAG
value: latest
- description: Zookeeper image name
displayName: Zookeeper image Name
name: ZOOKEEPER_IMAGE_NAME
value: zookeeper
- description: Zookeeper image tag
displayName: Zookeeper image tag
name: ZOOKEEPER_IMAGE_TAG
value: latest
- description: Number of seconds after the container has started before healthcheck probes are initiated.
displayName: Zookeeper healthcheck initial delay
name: ZOOKEEPER_HEALTHCHECK_DELAY
value: "15"
- description: Number of seconds after which the probe times out.
displayName: Zookeeper healthcheck timeout
name: ZOOKEEPER_HEALTHCHECK_TIMEOUT
value: "5"
- description: Number of seconds after the container has started before healthcheck probes are initiated.
displayName: Kafka healthcheck initial delay
name: KAFKA_HEALTHCHECK_DELAY
value: "15"
- description: Number of seconds after which the probe times out.
displayName: Kafka healthcheck timeout
name: KAFKA_HEALTHCHECK_TIMEOUT
value: "5"
objects:
- apiVersion: v1
kind: Service
metadata:
name: kafka
spec:
ports:
- name: kafka
port: 9092
protocol: TCP
targetPort: 9092
selector:
name: kafka
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
name: kafka-headless
spec:
clusterIP: None
ports:
- name: kafka
port: 9092
protocol: TCP
targetPort: 9092
selector:
name: kafka
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
name: zookeeper
spec:
ports:
- name: clientport
port: 2181
protocol: TCP
targetPort: 2181
selector:
name: zookeeper
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
name: zookeeper-headless
spec:
clusterIP: None
ports:
- name: clientport
port: 2181
protocol: TCP
targetPort: 2181
- port: 2888
name: clustering
targetPort : 2888
protocol: TCP
- port: 3888
name: leaderelection
targetPort : 3888
protocol: TCP
selector:
name: zookeeper
sessionAffinity: None
type: ClusterIP
- apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
labels:
name: kafka
name: kafka
spec:
replicas: ${KAFKA_NODE_COUNT}
selector:
matchLabels:
name: kafka
serviceName: kafka-headless
template:
metadata:
labels:
name: kafka
spec:
containers:
- name: kafka
image: ${IMAGE_REPO_NAME}/${KAFKA_IMAGE_NAME}:${KAFKA_IMAGE_TAG}
imagePullPolicy: Always
ports:
- containerPort: 9092
name: kafka
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/lib/kafka/
name: kafka-storage
livenessProbe:
exec:
command:
- "/opt/kafka/kafka_healthcheck.sh"
initialDelaySeconds: ${ZOOKEEPER_HEALTHCHECK_DELAY}
timeoutSeconds: ${ZOOKEEPER_HEALTHCHECK_TIMEOUT}
readinessProbe:
exec:
command:
- "/opt/kafka/kafka_healthcheck.sh"
initialDelaySeconds: ${ZOOKEEPER_HEALTHCHECK_DELAY}
timeoutSeconds: ${ZOOKEEPER_HEALTHCHECK_TIMEOUT}
dnsPolicy: ClusterFirst
restartPolicy: Always
volumeClaimTemplates:
- metadata:
name: kafka-storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "${KAFKA_VOLUME_CAPACITY}"
- apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
labels:
name: zookeeper
name: zookeeper
spec:
replicas: ${ZOOKEEPER_NODE_COUNT}
selector:
matchLabels:
name: zookeeper
serviceName: zookeeper-headless
template:
metadata:
labels:
name: zookeeper
spec:
containers:
- name: zookeeper
image: ${IMAGE_REPO_NAME}/${ZOOKEEPER_IMAGE_NAME}:${ZOOKEEPER_IMAGE_TAG}
imagePullPolicy: Always
ports:
- containerPort: 2181
name: clientport
protocol: TCP
- containerPort: 2888
name: clustering
protocol: TCP
- containerPort: 3888
name: leaderelection
protocol: TCP
env:
- name: ZOOKEEPER_NODE_COUNT
value: ${ZOOKEEPER_NODE_COUNT}
volumeMounts:
- mountPath: /var/lib/zookeeper
name: zookeeper-storage
livenessProbe:
exec:
command:
- "/opt/zookeeper/zookeeper_healthcheck.sh"
initialDelaySeconds: ${KAFKA_HEALTHCHECK_DELAY}
timeoutSeconds: ${KAFKA_HEALTHCHECK_TIMEOUT}
readinessProbe:
exec:
command:
- "/opt/zookeeper/zookeeper_healthcheck.sh"
initialDelaySeconds: ${KAFKA_HEALTHCHECK_DELAY}
timeoutSeconds: ${KAFKA_HEALTHCHECK_TIMEOUT}
dnsPolicy: ClusterFirst
restartPolicy: Always
volumeClaimTemplates:
- metadata:
name: zookeeper-storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "${ZOOKEEPER_VOLUME_CAPACITY}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment