openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msciaba...@apache.org
Subject [incubator-openwhisk-deploy-kube] branch master updated: Add Helm chart support for replicated Kafka instances (#451)
Date Tue, 30 Apr 2019 20:05:19 GMT
This is an automated email from the ASF dual-hosted git repository.

msciabarra pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-deploy-kube.git


The following commit(s) were added to refs/heads/master by this push:
     new d48dd35  Add Helm chart support for replicated Kafka instances (#451)
d48dd35 is described below

commit d48dd359dc31ebfcdbf715030afe95ca7ab8592e
Author: David Grove <dgrove-oss@users.noreply.github.com>
AuthorDate: Tue Apr 30 16:05:13 2019 -0400

    Add Helm chart support for replicated Kafka instances (#451)
    
    Fixes #354.
---
 docs/configurationChoices.md                 | 16 ++++++-------
 helm/openwhisk/templates/_helpers.tpl        | 20 +++++++++++-----
 helm/openwhisk/templates/controller-pod.yaml |  4 +---
 helm/openwhisk/templates/invoker-pod.yaml    |  2 +-
 helm/openwhisk/templates/kafka-pod.yaml      | 36 +++++++++++++++++-----------
 helm/openwhisk/templates/kafka-pvc.yaml      |  2 +-
 helm/openwhisk/templates/kafka-svc.yaml      |  5 ++--
 helm/openwhisk/values.yaml                   |  1 -
 8 files changed, 50 insertions(+), 36 deletions(-)

diff --git a/docs/configurationChoices.md b/docs/configurationChoices.md
index 1ca7df5..b5dbcbd 100644
--- a/docs/configurationChoices.md
+++ b/docs/configurationChoices.md
@@ -36,14 +36,14 @@ controller:
   replicaCount: 2
 ```
 
-NOTE: The Helm-based deployment does not yet support setting the replicaCount
-to be greater than 1 for the following components:
-- apigateway
-- couchdb
-- kafka
-- kafkaprovider
-- redis
-We are actively working on reducing this list and would welcome PRs to help.
+NOTE: setting the replicaCount to be greater than 1 for the following
+components is not currently supported:
+- apigateway and redis. Running only a single replica of these services is
+  unlikely to be a significant scalability bottleneck.
+- couchdb. For production deployments of OpenWhisk on Kubernetes, we strongly recomend running
+  CouchDB externally to OpenWhisk as described below. An external CouchDB instance enables
+  better management of the database and decouples its lifecycle from that of the OpenWhisk
deployment.
+- The event providers: alarmprovider, cloudantprovider, and kafkaprovider.
 
 ### Using an external database
 
diff --git a/helm/openwhisk/templates/_helpers.tpl b/helm/openwhisk/templates/_helpers.tpl
index 9929801..2cd28ba 100644
--- a/helm/openwhisk/templates/_helpers.tpl
+++ b/helm/openwhisk/templates/_helpers.tpl
@@ -41,17 +41,12 @@ app: {{ template "openwhisk.fullname" . }}
 {{ .Values.db.auth.username }}:{{ .Values.db.auth.password }}
 {{- end -}}
 
-{{/* hostname for kafka */}}
-{{- define "openwhisk.kafka_host" -}}
-{{ .Release.Name }}-kafka.{{ .Release.Namespace }}.svc.{{ .Values.k8s.domain }}
-{{- end -}}
-
 {{/* hostname for redis */}}
 {{- define "openwhisk.redis_host" -}}
 {{ .Release.Name }}-redis.{{ .Release.Namespace }}.svc.{{ .Values.k8s.domain }}
 {{- end -}}
 
-{{/* client connection string for zookeeper cluster (server1:port server2:port ... serverN:port)*/}}
+{{/* client connection string for zookeeper cluster (server1:port,server2:port, ... serverN:port)*/}}
 {{- define "openwhisk.zookeeper_connect" -}}
 {{- $zkname := printf "%s-zookeeper" .Release.Name }}
 {{- $zkport := .Values.zookeeper.port }}
@@ -65,6 +60,19 @@ app: {{ template "openwhisk.fullname" . }}
 {{ $zkname }}-0.{{ $zkname }}.{{ $.Release.Namespace }}.svc.{{ .Values.k8s.domain }}
 {{- end -}}
 
+{{/* client connection string for kafka cluster (server1:port,server2:port, ... serverN:port)*/}}
+{{- define "openwhisk.kafka_connect" -}}
+{{- $kname := printf "%s-kafka" .Release.Name }}
+{{- $kport := .Values.kafka.port }}
+{{- $kubeDomain := .Values.k8s.domain }}
+{{- range $i, $e := until (int .Values.kafka.replicaCount) -}}{{ if ne $i 0 }},{{ end }}{{
$kname }}-{{ . }}.{{ $kname }}.{{ $.Release.Namespace }}.svc.{{ $kubeDomain }}:{{ $kport }}{{
end }}
+{{- end -}}
+
+{{/* host name for server.0 in kafka cluster */}}
+{{- define "openwhisk.kafka_zero_host" -}}
+{{- $kname := printf "%s-kafka" .Release.Name }}
+{{ $kname }}-0.{{ $kname }}.{{ $.Release.Namespace }}.svc.{{ .Values.k8s.domain }}
+{{- end -}}
 
 {{/* Runtimes manifest */}}
 {{- define "openwhisk.runtimes_manifest" -}}
diff --git a/helm/openwhisk/templates/controller-pod.yaml b/helm/openwhisk/templates/controller-pod.yaml
index 56e5caf..95b134f 100644
--- a/helm/openwhisk/templates/controller-pod.yaml
+++ b/helm/openwhisk/templates/controller-pod.yaml
@@ -96,9 +96,7 @@ spec:
 
         # Kafka properties
         - name: "KAFKA_HOSTS"
-          value: "{{ include "openwhisk.kafka_host" . }}:{{ .Values.kafka.port }}"
-        - name: "KAFKA_HOST_PORT"
-          value: {{ .Values.kafka.port | quote }}
+          value: "{{ include "openwhisk.kafka_connect" . }}"
 {{ include "openwhisk.kafkaConfigEnvVars" . | indent 8 }}
 
         # properties for DB connection
diff --git a/helm/openwhisk/templates/invoker-pod.yaml b/helm/openwhisk/templates/invoker-pod.yaml
index 64b7766..0eebbe6 100644
--- a/helm/openwhisk/templates/invoker-pod.yaml
+++ b/helm/openwhisk/templates/invoker-pod.yaml
@@ -163,7 +163,7 @@ spec:
 
           # properties for kafka connection
           - name: "KAFKA_HOSTS"
-            value: "{{ include "openwhisk.kafka_host" . }}:{{ .Values.kafka.port }}"
+            value: "{{ include "openwhisk.kafka_connect" . }}"
 {{ include "openwhisk.kafkaConfigEnvVars" . | indent 10 }}
 
           # properties for zookeeper connection
diff --git a/helm/openwhisk/templates/kafka-pod.yaml b/helm/openwhisk/templates/kafka-pod.yaml
index f19e043..504e53a 100644
--- a/helm/openwhisk/templates/kafka-pod.yaml
+++ b/helm/openwhisk/templates/kafka-pod.yaml
@@ -29,11 +29,11 @@ spec:
 {{ include "openwhisk.affinity.selfAntiAffinity" ( printf "%s-kafka" .Release.Name ) | indent
8 }}
       {{- end }}
 
-{{- if .Values.k8s.persistence.enabled }}
+{{- if and .Values.k8s.persistence.enabled (eq (int .Values.kafka.replicaCount) 1) }}
       volumes:
-      - name: kafka-data
+      - name: "{{ .Release.Name }}-kafka-pvc"
         persistentVolumeClaim:
-          claimName: {{ .Release.Name }}-kafka-pvc
+          claimName: "{{ .Release.Name }}-kafka-pvc"
 {{- end }}
 
       initContainers:
@@ -43,28 +43,36 @@ spec:
       - name: kafka
         image: "{{- .Values.docker.registry.name -}}{{- .Values.kafka.imageName -}}:{{- .Values.kafka.imageTag
-}}"
         imagePullPolicy: {{ .Values.kafka.imagePullPolicy | quote }}
+        command: ["/bin/bash", "-c", "export KAFKA_BROKER_ID=`hostname | cut -d'-' -f3`;
export KAFKA_ADVERTISED_HOST_NAME=`hostname -f`; /usr/bin/start-kafka.sh"]
 {{- if .Values.k8s.persistence.enabled }}
         volumeMounts:
         - mountPath: /kafka
-          name: kafka-data
+          name: "{{ .Release.Name }}-kafka-pvc"
 {{- end }}
         ports:
         - containerPort: {{ .Values.kafka.port }}
           name: kafka
         env:
-        - name: "KAFKA_BROKER_ID"
-          value: "0"
-        - name: "KAFKA_ADVERTISED_HOST_NAME"
-          value: {{ .Release.Name }}-kafka
         - name: "KAFKA_ADVERTISED_PORT"
           value: "{{ .Values.kafka.port }}"
-        - name: "KAFKA_HOST_NAME"
-          valueFrom:
-            fieldRef:
-              fieldPath: status.podIP
-        - name: "KAFKA_PORT"
-          value: "{{ .Values.kafka.port }}"
 
         # zookeeper info
         - name: "KAFKA_ZOOKEEPER_CONNECT"
           value: "{{ include "openwhisk.zookeeper_connect" . }}"
+
+
+{{/* PVCs created by volumeClaimTemplates must be manually removed; only create them if we
absolutely need them */}}
+{{- if and .Values.k8s.persistence.enabled (gt (int .Values.kafka.replicaCount) 1) }}
+  volumeClaimTemplates:
+  - metadata:
+      name: "{{ .Release.Name }}-kafka-pvc"
+    spec:
+{{- if not .Values.k8s.persistence.hasDefaultStorageClass }}
+      storageClassName: {{ .Values.k8s.persistence.explicitStorageClass }}
+{{- end }}
+      accessModes:
+        - ReadWriteOnce
+      resources:
+        requests:
+          storage: {{ .Values.kafka.persistence.size }}
+{{- end }}
diff --git a/helm/openwhisk/templates/kafka-pvc.yaml b/helm/openwhisk/templates/kafka-pvc.yaml
index 4539b2b..a315b29 100644
--- a/helm/openwhisk/templates/kafka-pvc.yaml
+++ b/helm/openwhisk/templates/kafka-pvc.yaml
@@ -1,7 +1,7 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor
 # license agreements; and to You under the Apache License, Version 2.0.
 
-{{- if .Values.k8s.persistence.enabled }}
+{{ if and .Values.k8s.persistence.enabled (eq (int .Values.kafka.replicaCount) 1 ) }}
 apiVersion: v1
 kind: PersistentVolumeClaim
 metadata:
diff --git a/helm/openwhisk/templates/kafka-svc.yaml b/helm/openwhisk/templates/kafka-svc.yaml
index 25a32e1..9b14f1c 100644
--- a/helm/openwhisk/templates/kafka-svc.yaml
+++ b/helm/openwhisk/templates/kafka-svc.yaml
@@ -9,8 +9,9 @@ metadata:
     name: {{ .Release.Name }}-kafka
 {{ include "openwhisk.label_boilerplate" . | indent 4 }}
 spec:
+  selector:
+    name: {{ .Release.Name }}-kafka
+  clusterIP: None
   ports:
   - name: broker
     port: {{ .Values.kafka.port }}
-  selector:
-    name: {{ .Release.Name }}-kafka
diff --git a/helm/openwhisk/values.yaml b/helm/openwhisk/values.yaml
index 4ed0832..9521f2d 100644
--- a/helm/openwhisk/values.yaml
+++ b/helm/openwhisk/values.yaml
@@ -173,7 +173,6 @@ kafka:
   imageName: "wurstmeister/kafka"
   imageTag: "0.11.0.1"
   imagePullPolicy: "IfNotPresent"
-  # NOTE: setting replicaCount > 1 will not work (Issue #354)
   replicaCount: 1
   restartPolicy: "Always"
   port: 9092


Mime
View raw message