Skip to content

Commit 0d794d7

Browse files
committed
feat: provision
1 parent 2c581c9 commit 0d794d7

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

infrastructure/evault-provisioner/src/templates/evault.nomad.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export async function provisionEVault(w3id: string, eVaultId: string) {
183183
kind: "Service",
184184
metadata: { name: "evault-service" },
185185
spec: {
186-
type: "NodePort",
186+
type: "LoadBalancer",
187187
selector: { app: "evault" },
188188
ports: [
189189
{
@@ -195,24 +195,20 @@ export async function provisionEVault(w3id: string, eVaultId: string) {
195195
},
196196
});
197197

198-
// Get the service to retrieve the assigned NodePort
199-
const svc = await coreApi.readNamespacedService({
200-
name: "evault-service",
201-
namespace: namespaceName,
202-
});
203-
const nodePort = svc.spec?.ports?.[0]?.nodePort;
204-
if (!nodePort) throw new Error("No NodePort assigned");
205-
206-
// Try getting minikube IP first
207-
try {
208-
const minikubeIP = execSync("minikube ip").toString().trim();
209-
return `http://${minikubeIP}:${nodePort}`;
210-
} catch (e) {
211-
// Fallback to node IP
212-
const nodes = await coreApi.listNode();
213-
const nodeIP = nodes?.items?.[0]?.status?.addresses?.find(
214-
(a) => a.type === "ExternalIP" || a.type === "InternalIP"
215-
)?.address || "127.0.0.1";
216-
return `http://${nodeIP}:${nodePort}`;
198+
// Wait for LoadBalancer IP
199+
let externalIP = null;
200+
for (let i = 0; i < 30; i++) {
201+
const svc = await coreApi.readNamespacedService({
202+
name: "evault-service",
203+
namespace: namespaceName,
204+
});
205+
const ingress = svc.status?.loadBalancer?.ingress?.[0];
206+
if (ingress?.ip || ingress?.hostname) {
207+
externalIP = ingress.ip || ingress.hostname;
208+
const port = svc.spec?.ports?.[0]?.port;
209+
return `http://${externalIP}:${port}`;
210+
}
211+
await new Promise((r) => setTimeout(r, 2000));
217212
}
213+
throw new Error("Failed to get LoadBalancer IP after 60 seconds");
218214
}

0 commit comments

Comments
 (0)