Skip to content

Commit

Permalink
Merge pull request #29 from Saetch/25-kubernetes-integration
Browse files Browse the repository at this point in the history
updated nodecs behavior for kubernetes
  • Loading branch information
Saetch authored Jun 27, 2024
2 parents dbf5342 + 1c863a6 commit 3369760
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 15 deletions.
44 changes: 43 additions & 1 deletion Cluster/Node_cs/ApiConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 5 additions & 14 deletions deploy/deploy-nodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Deployment
metadata:
name: d-nodecs
spec:
replicas: 4
replicas: 1
selector:
matchLabels:
app: d-nodecs
Expand All @@ -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"

13 changes: 13 additions & 0 deletions deploy/headless-service.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3369760

Please sign in to comment.