diff --git a/Cluster/Node_cs/ApiConfig.cs b/Cluster/Node_cs/ApiConfig.cs index 90ac038..7722d2e 100644 --- a/Cluster/Node_cs/ApiConfig.cs +++ b/Cluster/Node_cs/ApiConfig.cs @@ -15,8 +15,50 @@ public class ApiConfig public String hostname = Environment.GetEnvironmentVariable("HOSTNAME"); public String COORDINATOR_SERVICE_URL = "coordinator"; public int PORT = 8080; - + public string PODENV = Environment.GetEnvironmentVariable("PODENV"); public ushort ownerHash = 0; + Console.WriteLine("PODENV is: "+ this.PODENV); + + if (this.PODENV == "enabled"){ + try + { + Console.WriteLine("Attempting to get the pod IP address ..."); + // Start a new process to run the "hostname -i" command + ProcessStartInfo processStartInfo = new ProcessStartInfo() + { + FileName = "/bin/sh", + Arguments = "-c \"hostname -i\"", + RedirectStandardOutput = true, + UseShellExecute = false, + CreateNoWindow = true + }; + + using (Process process = new Process()) + { + process.StartInfo = processStartInfo; + process.Start(); + + // Read the output (which should be the pod IP address) + string podIP = process.StandardOutput.ReadToEnd().Trim(); + process.WaitForExit(); + + // Print or use the pod IP as needed + hostname = podIP; + Console.WriteLine("Pod IP: " + podIP); + + } + } + catch (Exception ex) + { + Console.WriteLine("Error: " + ex.Message); + } + } + + + + + + public int initializeConfigValues() { Console.WriteLine("hostname is: "+ this.hostname); diff --git a/deploy/deploy-nodes.yaml b/deploy/deploy-nodes.yaml index 62e51d3..e93027a 100644 --- a/deploy/deploy-nodes.yaml +++ b/deploy/deploy-nodes.yaml @@ -3,7 +3,7 @@ kind: Deployment metadata: name: d-nodecs spec: - replicas: 4 + replicas: 1 selector: matchLabels: app: d-nodecs @@ -28,16 +28,7 @@ spec: limits: memory: "100Mi" cpu: "100m" ---- -apiVersion: v1 -kind: Service -metadata: - name: d-nodecs -spec: - selector: - app: d-nodecs - ports: - - name: d-nodecs-p - protocol: TCP - port: 5552 - targetPort: d-nodecs-p + env: + - name: PODENV + value: "enabled" + diff --git a/deploy/headless-service.yaml b/deploy/headless-service.yaml new file mode 100644 index 0000000..12ca702 --- /dev/null +++ b/deploy/headless-service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: d-nodecs + namespace: default +spec: + clusterIP: None + selector: + app: d-nodecs + ports: + - protocol: TCP + port: 5552 + targetPort: d-nodecs-pe \ No newline at end of file