changes for kube
authorJeroen van der Heijden <jeroen@transceptor.technology>
Tue, 3 Nov 2020 14:00:10 +0000 (15:00 +0100)
committerJeroen van der Heijden <jeroen@transceptor.technology>
Tue, 3 Nov 2020 14:00:10 +0000 (15:00 +0100)
Kubernetes/statefulset.yaml [new file with mode: 0644]
src/siri/net/tcp.c

diff --git a/Kubernetes/statefulset.yaml b/Kubernetes/statefulset.yaml
new file mode 100644 (file)
index 0000000..6d56ca7
--- /dev/null
@@ -0,0 +1,84 @@
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: thingsdb
+  labels:
+    app: thingsdb
+spec:
+  selector:
+    matchLabels:
+      app: thingsdb
+  serviceName: thingsdb
+  replicas: 2
+  updateStrategy:
+    type: RollingUpdate
+  podManagementPolicy: Parallel
+  template:
+    metadata:
+      labels:
+        app: thingsdb
+    spec:
+      terminationGracePeriodSeconds: 90
+      dnsConfig:
+        searches:
+        - thingsdb.default.svc.cluster.local
+      containers:
+      - name: thingsdb
+        image: thingsdb/node:gcloud-v0.9.19
+        imagePullPolicy: Always
+        args: ["--deploy"]
+        env:
+        - name: SIRIDB_HTTP_STATUS_PORT
+          value: "8080"
+        - name: SIRIDB_HTTP_API_PORT
+          value: "80"
+        - name: SIRIDB_ENABLE_SHARD_COMPRESSION
+          value: "1"
+        - name: SIRIDB_BUFFER_SYNC_INTERVAL
+          value: "500"
+        - name: SIRIDB_DEFAULT_DB_PATH
+          value: /mnt/thingsdb/
+        - name: SIRIDB_BIND_SERVER_ADDRESS
+          value: "0.0.0.0"
+        - name: SIRIDB_BIND_CLIENT_ADDRESS
+          value: "0.0.0.0"
+        - name: SIRIDB_SERVER_NAME
+          valueFrom:
+            fieldRef:
+              fieldPath: metadata.name
+        ports:
+        - name: status
+          containerPort: 8080
+        - name: client
+          containerPort: 9200
+        - name: http
+          containerPort: 9210
+        - name: node
+          containerPort: 9220
+        volumeMounts:
+        - name: data
+          mountPath: /mnt/siridb/
+        resources:
+          requests:
+            memory: 100M
+        livenessProbe:
+          httpGet:
+            path: /healthy
+            port: 8080
+          periodSeconds: 10
+          timeoutSeconds: 5
+        readinessProbe:
+          httpGet:
+            path: /ready
+            port: 8080
+          initialDelaySeconds: 5
+          periodSeconds: 10
+          timeoutSeconds: 2
+  volumeClaimTemplates:
+  - metadata:
+      name: data
+    spec:
+      accessModes: ["ReadWriteOnce"]
+      resources:
+        requests:
+          storage: 20Gi
index 76ce0beef6ca245636413de7039ca451f280ff1d..06a7cb8333c0c98827ecb60404a17696ce4a5849 100644 (file)
@@ -132,34 +132,35 @@ int sirinet_extract_addr_port(
         }
     }
 
-    if (    !strlen(address) ||
-            strlen(address) >= SIRI_CFG_MAX_LEN_ADDRESS ||
-            !xstr_is_int(strport) ||
-            strcpy(addr, address) == NULL ||
-            xstr_replace_str(
-                    addr,
-                    "%HOSTNAME",
-                    hostname,
-                    SIRI_CFG_MAX_LEN_ADDRESS))
+    if (!strlen(address) || strlen(address) >= SIRI_CFG_MAX_LEN_ADDRESS)
     {
-        log_critical(
-                "error: got an unexpected value '%s:%s'.",
-                address,
-                strport);
+        log_critical("error: got an unexpected address value '%s'.", s);
         return -1;
     }
 
-    test_port = atoi(strport);
-
-    if (test_port < 1 || test_port > 65535)
+    if (strcpy(addr, address) == NULL || xstr_replace_str(
+            addr,
+            "%HOSTNAME",
+            hostname,
+            SIRI_CFG_MAX_LEN_ADDRESS))
     {
-        log_critical(
-                "error: port should be between 1 and 65535, got '%d'.",
-                test_port);
+        log_critical("error: memory allocation while copying address");
         return -1;
     }
 
-    *addrport = (uint16_t) test_port;
+    if (xstr_is_int(strport))
+    {
+        test_port = atoi(strport);
+        if (test_port < 1 || test_port > 65535)
+        {
+            log_critical(
+                    "error: port should be between 1 and 65535, got '%d'.",
+                    test_port);
+            return -1;
+        }
+
+        *addrport = (uint16_t) test_port;
+    }
 
     log_debug("Read '%s': %s:%d",
             s,