From cb8eb2dc4e153dd4b0a7f3ef46cda7f8f854f64a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Ara=C3=BAjo?= <davidaraujo@av.it.pt>
Date: Wed, 31 Jan 2024 16:29:09 +0000
Subject: [PATCH] CRDB and NATS cluter mode

Restore default values
---
 deploy/all.sh                       |  1 -
 deploy/nats.sh                      |  4 ++--
 manifests/cockroachdb/cluster.yaml  | 11 ++++-------
 manifests/cockroachdb/operator.yaml |  1 -
 manifests/nats/cluster.yaml         |  8 ++++----
 manifests/webuiservice.yaml         |  1 -
 my_deploy.sh                        |  3 +--
 7 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/deploy/all.sh b/deploy/all.sh
index 50a6c0816..63d202960 100755
--- a/deploy/all.sh
+++ b/deploy/all.sh
@@ -107,7 +107,6 @@ export NATS_EXT_PORT_CLIENT=${NATS_EXT_PORT_CLIENT:-"4222"}
 # If not already set, set the external port NATS HTTP Mgmt GUI interface will be exposed to.
 export NATS_EXT_PORT_HTTP=${NATS_EXT_PORT_HTTP:-"8222"}
 
-# TESTING
 # If not already set, set NATS installation mode. Accepted values are: 'single' and 'cluster'.
 # - If NATS_DEPLOY_MODE is "single", NATS is deployed in single node mode. It is convenient for
 #   development and testing purposes and should fit in a VM. IT SHOULD NOT BE USED IN PRODUCTION ENVIRONMENTS.
diff --git a/deploy/nats.sh b/deploy/nats.sh
index d6922d86b..02e22965e 100755
--- a/deploy/nats.sh
+++ b/deploy/nats.sh
@@ -31,7 +31,6 @@ export NATS_EXT_PORT_CLIENT=${NATS_EXT_PORT_CLIENT:-"4222"}
 # If not already set, set the external port NATS HTTP Mgmt GUI interface will be exposed to.
 export NATS_EXT_PORT_HTTP=${NATS_EXT_PORT_HTTP:-"8222"}
 
-# TESTING
 # If not already set, set NATS installation mode. Accepted values are: 'single' and 'cluster'.
 # - If NATS_DEPLOY_MODE is "single", NATS is deployed in single node mode. It is convenient for
 #   development and testing purposes and should fit in a VM. IT SHOULD NOT BE USED IN PRODUCTION ENVIRONMENTS.
@@ -73,7 +72,8 @@ function nats_deploy_single() {
         echo ">>> NATS is present; skipping step."
     else
         echo ">>> Deploy NATS"
-        helm3 install ${NATS_NAMESPACE} nats/nats --namespace ${NATS_NAMESPACE} --set nats.image=nats:2.9-alpine
+        helm3 install ${NATS_NAMESPACE} nats/nats --namespace ${NATS_NAMESPACE} --set nats.image=nats:2.9-alpine --set config.cluster.enabled=true --set config.cluster.tls.enabled=true
+
 
         echo ">>> Waiting NATS statefulset to be created..."
         while ! kubectl get --namespace ${NATS_NAMESPACE} statefulset/${NATS_NAMESPACE} &> /dev/null; do
diff --git a/manifests/cockroachdb/cluster.yaml b/manifests/cockroachdb/cluster.yaml
index 73875ca3f..bcb0c7049 100644
--- a/manifests/cockroachdb/cluster.yaml
+++ b/manifests/cockroachdb/cluster.yaml
@@ -33,13 +33,11 @@ spec:
   resources:
     requests:
       # This is intentionally low to make it work on local k3d clusters.
-      # TESTING
-      cpu: 1 #4
-      memory: 500Mi #4Gi
+      cpu: 4
+      memory: 4Gi
     limits:
-      # TESTING
-      cpu: 1 #8
-      memory: 1Gi #8Gi
+      cpu: 8
+      memory: 8Gi
   tlsEnabled: true
   # You can set either a version of the db or a specific image name
   # cockroachDBVersion: v22.2.8
@@ -54,7 +52,6 @@ spec:
   # disabled by default. To enable please see the operator.yaml file.
 
   # The affinity field will accept any podSpec affinity rule.
-  # TESTING: Force one pod per node, if possible
   topologySpreadConstraints:
   - maxSkew: 1
     topologyKey: kubernetes.io/hostname  
diff --git a/manifests/cockroachdb/operator.yaml b/manifests/cockroachdb/operator.yaml
index 0d578410c..d8e691308 100644
--- a/manifests/cockroachdb/operator.yaml
+++ b/manifests/cockroachdb/operator.yaml
@@ -381,7 +381,6 @@ spec:
     spec:
       containers:
       - args:
-        # TESTING
         - -feature-gates=TolerationRules=true,AffinityRules=true,TopologySpreadRules=true
         - -zap-log-level
         - info
diff --git a/manifests/nats/cluster.yaml b/manifests/nats/cluster.yaml
index 39e41958f..491c86628 100644
--- a/manifests/nats/cluster.yaml
+++ b/manifests/nats/cluster.yaml
@@ -9,11 +9,11 @@ container:
     # recommended limit is at least 2 CPU cores and 8Gi Memory for production JetStream clusters
     resources:
       requests:
-        cpu: 1 # 2
-        memory: 500Mi # 4Gi
+        cpu: 1
+        memory: 500Mi
       limits:
-        cpu: 1 # 4
-        memory: 1Gi # 8Gi 
+        cpu: 1
+        memory: 1Gi
 
 config:
   cluster:
diff --git a/manifests/webuiservice.yaml b/manifests/webuiservice.yaml
index 87fe57719..d7e7c9777 100644
--- a/manifests/webuiservice.yaml
+++ b/manifests/webuiservice.yaml
@@ -117,7 +117,6 @@ spec:
   - name: grafana
     port: 3000
     targetPort: 3000
-# TESTING
 ---
 apiVersion: autoscaling/v2
 kind: HorizontalPodAutoscaler
diff --git a/my_deploy.sh b/my_deploy.sh
index 92a1bfb63..bc8ff56a9 100755
--- a/my_deploy.sh
+++ b/my_deploy.sh
@@ -101,7 +101,7 @@ export CRDB_DATABASE="tfs"
 
 # Set CockroachDB installation mode to 'single'. This option is convenient for development and testing.
 # See ./deploy/all.sh or ./deploy/crdb.sh for additional details
-export CRDB_DEPLOY_MODE="cluster"
+export CRDB_DEPLOY_MODE="single"
 
 # Disable flag for dropping database, if it exists.
 export CRDB_DROP_DATABASE_IF_EXISTS=""
@@ -121,7 +121,6 @@ export NATS_EXT_PORT_CLIENT="4222"
 # Set the external port NATS HTTP Mgmt GUI interface will be exposed to.
 export NATS_EXT_PORT_HTTP="8222"
 
-# TESTING
 # Set NATS installation mode to 'single'. This option is convenient for development and testing.
 # See ./deploy/all.sh or ./deploy/nats.sh for additional details
 export NATS_DEPLOY_MODE="single"
-- 
GitLab