detect host ip
This commit is contained in:
@ -1,7 +1,21 @@
|
||||
import { TASK_ID, namespaceWrapper } from "@_koii/namespace-wrapper";
|
||||
import "dotenv/config";
|
||||
import os from "os";
|
||||
|
||||
const imageUrl = "docker.io/hermanyiqunliang/summarizer-agent:0.2";
|
||||
const imageUrl = "docker.io/labrocadabro/prometheus-summarizer:0.2";
|
||||
|
||||
function getHostIP() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
for (const name of Object.keys(interfaces)) {
|
||||
for (const iface of interfaces[name] || []) {
|
||||
// Skip over internal (i.e., 127.0.0.1) and non-IPv4 addresses
|
||||
if (iface.family === "IPv4" && !iface.internal) {
|
||||
return iface.address;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error("Unable to determine host IP address");
|
||||
}
|
||||
|
||||
async function createPodSpec(): Promise<string> {
|
||||
const basePath = await namespaceWrapper.getBasePath();
|
||||
@ -29,6 +43,10 @@ spec:
|
||||
hostPath:
|
||||
path: ${basePath}/orca/data
|
||||
type: DirectoryOrCreate
|
||||
hostAliases:
|
||||
- ip: "${getHostIP()}"
|
||||
hostnames:
|
||||
- "host.docker.internal"
|
||||
`;
|
||||
return podSpec;
|
||||
}
|
||||
@ -37,10 +55,12 @@ export async function getConfig(): Promise<{
|
||||
imageURL: string;
|
||||
customPodSpec: string;
|
||||
rootCA: string | null;
|
||||
timeout: number;
|
||||
}> {
|
||||
return {
|
||||
imageURL: imageUrl,
|
||||
customPodSpec: await createPodSpec(),
|
||||
rootCA: null,
|
||||
timeout: 900000,
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user