You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2022/12/01 12:20:33 UTC

[streampipes] 01/01: Add nats to k8s installation config (#818)

This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch SP-818
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit e5f9c85c6f26f507384d74c9d888c4a12968449e
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Thu Dec 1 13:20:21 2022 +0100

    Add nats to k8s installation config (#818)
---
 .../k8s/templates/core/backend-deployment.yaml     |  4 ++--
 .../templates/external/kafka/kafka-deployment.yaml |  2 ++
 .../templates/external/kafka/kafka-service.yaml    |  2 ++
 .../nats-deployment.yaml}                          | 27 +++++++++++-----------
 .../kafka-service.yaml => nats/nats-service.yaml}  | 10 ++++----
 .../external/zookeeper/zookeeper-deployment.yaml   |  2 ++
 .../external/zookeeper/zookeeper-service.yaml      |  2 ++
 installer/k8s/values.yaml                          |  2 +-
 8 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/installer/k8s/templates/core/backend-deployment.yaml b/installer/k8s/templates/core/backend-deployment.yaml
index 592c569db..8bd00c891 100644
--- a/installer/k8s/templates/core/backend-deployment.yaml
+++ b/installer/k8s/templates/core/backend-deployment.yaml
@@ -44,8 +44,8 @@ spec:
           imagePullPolicy: {{ .Values.pullPolicy }}
           env:
             - name: SP_PRIORITIZED_PROTOCOL
-              {{ if (eq .Values.preferredBroker "mqtt") }}
-              value: "mqtt"
+              {{ if (eq .Values.preferredBroker "nats") }}
+              value: "nats"
               {{ else }}
               value: "kafka"
               {{ end }}
diff --git a/installer/k8s/templates/external/kafka/kafka-deployment.yaml b/installer/k8s/templates/external/kafka/kafka-deployment.yaml
index 4d451162b..da02d4543 100644
--- a/installer/k8s/templates/external/kafka/kafka-deployment.yaml
+++ b/installer/k8s/templates/external/kafka/kafka-deployment.yaml
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+{{- if eq .Values.preferredBroker "kafka" }}
 apiVersion: apps/v1
 kind: Deployment
 metadata:
@@ -65,3 +66,4 @@ spec:
               value: "5000012"
             - name: KAFKA_REPLICA_FETCH_MAX_BYTES
               value: "10000000"
+{{- end }}
diff --git a/installer/k8s/templates/external/kafka/kafka-service.yaml b/installer/k8s/templates/external/kafka/kafka-service.yaml
index 1e1c265e3..aa63f3f43 100644
--- a/installer/k8s/templates/external/kafka/kafka-service.yaml
+++ b/installer/k8s/templates/external/kafka/kafka-service.yaml
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+{{- if eq .Values.preferredBroker "kafka" }}
 apiVersion: v1
 kind: Service
 metadata:
@@ -26,3 +27,4 @@ spec:
     - name: main
       protocol: TCP
       port: 9092
+{{- end }}
diff --git a/installer/k8s/templates/external/zookeeper/zookeeper-deployment.yaml b/installer/k8s/templates/external/nats/nats-deployment.yaml
similarity index 66%
copy from installer/k8s/templates/external/zookeeper/zookeeper-deployment.yaml
copy to installer/k8s/templates/external/nats/nats-deployment.yaml
index 756ae4e7d..d9c27cf75 100644
--- a/installer/k8s/templates/external/zookeeper/zookeeper-deployment.yaml
+++ b/installer/k8s/templates/external/nats/nats-deployment.yaml
@@ -13,32 +13,33 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+{{- if eq .Values.preferredBroker "nats" }}
 apiVersion: apps/v1
 kind: Deployment
 metadata:
-  name: zookeeper
+  name: nats
 spec:
   selector:
     matchLabels:
-      app: zookeeper
+      app: nats
   replicas: 1
   template:
     metadata:
       labels:
-        app: zookeeper
+        app: nats
     spec:
+      initContainers:
+        - name: init-wait-consul
+          image: alpine
+          command: ["sh", "-c", "for i in $(seq 1 300); do nc -zvw1 consul 8500 && exit 0 || sleep 3; done; exit 1"]
       volumes:
-        - name: zookeeper-pv
+        - name: kafka-pv
           persistentVolumeClaim:
-            claimName: zookeeper-pvc
+            claimName: kafka-pvc
       containers:
-        #TODO: wurstmeister/zookeeper:latest is running ZK 3.4.13. Once this
-        #      changes, the mount path needs to be adapted
-        - name: zookeeper
-          image: fogsyio/zookeeper:{{ .Values.external.zookeeperVersion }}
+        - name: nats
+          image: nats
           imagePullPolicy: {{ .Values.pullPolicy }}
           ports:
-            - containerPort: 2181
-          volumeMounts:
-            - mountPath: "/opt/zookeeper-{{ .Values.external.zookeeperVersion }}/data"
-              name: zookeeper-pv
+            - containerPort: 4222
+{{- end }}
diff --git a/installer/k8s/templates/external/kafka/kafka-service.yaml b/installer/k8s/templates/external/nats/nats-service.yaml
similarity index 88%
copy from installer/k8s/templates/external/kafka/kafka-service.yaml
copy to installer/k8s/templates/external/nats/nats-service.yaml
index 1e1c265e3..a243534dd 100644
--- a/installer/k8s/templates/external/kafka/kafka-service.yaml
+++ b/installer/k8s/templates/external/nats/nats-service.yaml
@@ -13,16 +13,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+{{- if eq .Values.preferredBroker "nats" }}
 apiVersion: v1
 kind: Service
 metadata:
-  name: kafka
+  name: nats
   labels:
-    name: kafka
+    name: nats
 spec:
   selector:
-    app: kafka
+    app: nats
   ports:
     - name: main
       protocol: TCP
-      port: 9092
+      port: 4222
+{{- end }}
diff --git a/installer/k8s/templates/external/zookeeper/zookeeper-deployment.yaml b/installer/k8s/templates/external/zookeeper/zookeeper-deployment.yaml
index 756ae4e7d..72ad397a3 100644
--- a/installer/k8s/templates/external/zookeeper/zookeeper-deployment.yaml
+++ b/installer/k8s/templates/external/zookeeper/zookeeper-deployment.yaml
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+{{- if eq .Values.preferredBroker "kafka" }}
 apiVersion: apps/v1
 kind: Deployment
 metadata:
@@ -42,3 +43,4 @@ spec:
           volumeMounts:
             - mountPath: "/opt/zookeeper-{{ .Values.external.zookeeperVersion }}/data"
               name: zookeeper-pv
+{{- end }}
diff --git a/installer/k8s/templates/external/zookeeper/zookeeper-service.yaml b/installer/k8s/templates/external/zookeeper/zookeeper-service.yaml
index d65bdb9d4..8d5440d94 100644
--- a/installer/k8s/templates/external/zookeeper/zookeeper-service.yaml
+++ b/installer/k8s/templates/external/zookeeper/zookeeper-service.yaml
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+{{- if eq .Values.preferredBroker "kafka" }}
 apiVersion: v1
 kind: Service
 metadata:
@@ -25,3 +26,4 @@ spec:
       protocol: TCP
       port: 2181
       targetPort: 2181
+{{- end }}
diff --git a/installer/k8s/values.yaml b/installer/k8s/values.yaml
index cbbfd9b58..b10b3adcb 100644
--- a/installer/k8s/values.yaml
+++ b/installer/k8s/values.yaml
@@ -15,7 +15,7 @@
 
 # lite or full (default: lite)
 deployment: lite
-preferredBroker: "kafka"
+preferredBroker: "nats"
 pullPolicy: "IfNotPresent"
 persistentVolumeReclaimPolicy: "Delete"
 persistentVolumeAccessModes: "ReadWriteOnce"