Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update config to remove need for multiple Ingress objects #236

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/FSLibrary.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ type Tests(output: ITestOutputHelper) =
let peer1DNS = (nCfg.PeerDnsName coreSet 1).StringName
let peer2DNS = (nCfg.PeerDnsName coreSet 2).StringName
let nonceStr = nCfg.networkNonce.ToString()
let domain = nonceStr + "-stellar-core." + ctx.namespaceProperty + ".svc.cluster.local"
let domain = nonceStr + "-sts-core." + ctx.namespaceProperty + ".svc.cluster.local"
Assert.Equal(nonceStr + "-sts-test-0." + domain, peer0DNS)
Assert.Equal(nonceStr + "-sts-test-1." + domain, peer1DNS)
Assert.Equal(nonceStr + "-sts-test-2." + domain, peer2DNS)
Expand Down
3 changes: 2 additions & 1 deletion src/FSLibrary/StellarFormation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ type StellarFormation
override self.Finalize() = self.Cleanup(false)

override self.ToString() : string =
let name = networkCfg.ServiceName
// TODO: this one is just for display, don't care for now
let name = networkCfg.HeadlessServiceName
let ns = networkCfg.NamespaceProperty
sprintf "%s/%s" ns name
7 changes: 4 additions & 3 deletions src/FSLibrary/StellarKubeSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,10 @@ type NetworkCfg with
// then use to connect the peers to one another in their config files, and
// hook the per-Pod Services and Ingress up to). Getting all this to work
// requires that you install the DNS server component on your k8s cluster.
member self.ToService() : V1Service =
member self.ToService(coreSet: CoreSet) : V1Service =
let serviceSpec = V1ServiceSpec(clusterIP = "None", selector = CfgVal.labels)
V1Service(spec = serviceSpec, metadata = self.NamespacedMeta self.ServiceName)
let svcName =self.ServiceName(coreSet)
V1Service(spec = serviceSpec, metadata = self.NamespacedMeta svcName)


// Returns a StatefulSet object that will build stellar-core Pods named
Expand All @@ -815,7 +816,7 @@ type NetworkCfg with
let statefulSetSpec =
V1StatefulSetSpec(
selector = V1LabelSelector(matchLabels = CfgVal.labels),
serviceName = self.ServiceName,
serviceName = self.ServiceName(coreSet) , //self.HeadlessServiceName,
podManagementPolicy = "Parallel",
template = self.ToPodTemplateSpec coreSet,
replicas = System.Nullable<int>(coreSet.CurrentCount)
Expand Down
6 changes: 4 additions & 2 deletions src/FSLibrary/StellarNetworkCfg.fs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ type NetworkCfg =
member self.PeerShortName (cs: CoreSet) (n: int) : PeerShortName =
PeerShortName(sprintf "%s-%d" cs.name.StringName n)

member self.ServiceName : string = sprintf "%s-stellar-core" self.Nonce
member self.HeadlessServiceName : string = sprintf "%s-stellar-core" self.Nonce

member self.ServiceName(cs: CoreSet) : string = self.StatefulSetName(cs).StringName

member self.IngressName : string = sprintf "%s-stellar-core-ingress" self.Nonce

Expand All @@ -107,7 +109,7 @@ type NetworkCfg =

member self.PeerDnsName (cs: CoreSet) (n: int) : PeerDnsName =
let s =
sprintf "%s.%s.%s.svc.cluster.local" (self.PodName cs n).StringName self.ServiceName self.NamespaceProperty
sprintf "%s.%s.%s.svc.cluster.local" (self.PodName cs n).StringName (self.ServiceName cs) self.NamespaceProperty

PeerDnsName s

Expand Down
24 changes: 17 additions & 7 deletions src/FSLibrary/StellarSupercluster.fs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,20 @@ type Kubernetes with
let rps = nCfg.missionContext.apiRateLimit

try
let svc = nCfg.ToService()
LogInfo "Creating Service %s" svc.Metadata.Name
ApiRateLimit.sleepUntilNextRateLimitedApiCallTime (rps)
namespaceContent.Add(self.CreateNamespacedService(body = svc, namespaceParameter = nsStr))

// NB: I *think* this is the correct change for the headless service name.
// Previously it only creates a single service with a fixed name, despite potentially there are more than one coreSet.
// The headless service is needed to register local DNS names for each of the Pod names in the StatefulSet, which implies one-per-StatefulSEt.
let makePerStsServices coreSet =
let svc = nCfg.ToService(coreSet)
LogInfo "Creating Service %s" svc.Metadata.Name
ApiRateLimit.sleepUntilNextRateLimitedApiCallTime (rps)
self.CreateNamespacedService(body = svc, namespaceParameter = nsStr)

let headlessSvcs = List.map makePerStsServices nCfg.CoreSetList

for svc in headlessSvcs do
namespaceContent.Add(svc)

for cm in nCfg.ToConfigMaps() do
LogInfo "Creating ConfigMap %s" cm.Metadata.Name
Expand All @@ -145,10 +155,10 @@ type Kubernetes with

if not (List.isEmpty statefulSets) then
let ing = nCfg.ToIngress()
LogInfo "Creating Ingress %s" ing.Metadata.Name
LogInfo "Skipping creation of Ingress %s" ing.Metadata.Name
ApiRateLimit.sleepUntilNextRateLimitedApiCallTime (rps)
let ingress = self.CreateNamespacedIngress(namespaceParameter = nsStr, body = ing)
namespaceContent.Add(ingress)
//let ingress = self.CreateNamespacedIngress(namespaceParameter = nsStr, body = ing)
//namespaceContent.Add(ingress)

let formation =
new StellarFormation(
Expand Down
Loading