fix: render jd01 v03 frpc public exposure
This commit is contained in:
+38
-10
@@ -1148,6 +1148,33 @@ function runtimePrometheusOperatorResourcesEnabled(deploy, profile) {
|
||||
return enabled !== false;
|
||||
}
|
||||
|
||||
function runtimeFrpConfigForProfile(deploy, profile) {
|
||||
const fallbackWebRemotePort = isRuntimeLane(profile) ? defaultPortForRuntimeLane(profile) : profile === "prod" ? 18666 : 17666;
|
||||
const fallbackEdgeRemotePort = isRuntimeLane(profile) ? fallbackWebRemotePort + 1 : profile === "prod" ? 18667 : 17667;
|
||||
const frp = isRuntimeLane(profile) ? runtimeLaneConfig(deploy, profile)?.frp : deploy?.frp;
|
||||
const server = frp && typeof frp === "object" && !Array.isArray(frp) ? frp.server : null;
|
||||
const proxies = Array.isArray(frp?.proxies) ? frp.proxies : [];
|
||||
const proxyByEndpoint = new Map(proxies
|
||||
.filter((proxy) => proxy && typeof proxy === "object" && !Array.isArray(proxy))
|
||||
.map((proxy) => [String(proxy.endpointId || proxy.name || ""), proxy]));
|
||||
const proxyValue = (endpointId, key, fallback) => {
|
||||
const value = proxyByEndpoint.get(endpointId)?.[key];
|
||||
return typeof value === "string" && value.trim().length > 0 ? value.trim() : fallback;
|
||||
};
|
||||
const proxyPort = (endpointId, fallback) => {
|
||||
const value = proxyByEndpoint.get(endpointId)?.remotePort;
|
||||
return Number.isInteger(value) ? value : fallback;
|
||||
};
|
||||
return {
|
||||
serverAddr: typeof server?.address === "string" && server.address.trim().length > 0 ? server.address.trim() : "74.48.78.17",
|
||||
serverPort: Number.isInteger(server?.bindPort) ? server.bindPort : 7000,
|
||||
webRemotePort: proxyPort("frontend", fallbackWebRemotePort),
|
||||
edgeRemotePort: proxyPort("api", fallbackEdgeRemotePort),
|
||||
webProxyName: proxyValue("frontend", "name", null),
|
||||
edgeProxyName: proxyValue("api", "name", null)
|
||||
};
|
||||
}
|
||||
|
||||
function runtimeStoreEnvForProfile(deploy, profile, serviceId) {
|
||||
if (!isRuntimeLane(profile) || serviceId !== "hwlab-cloud-api") return {};
|
||||
const postgres = runtimeLaneConfig(deploy, profile)?.runtimeStore?.postgres;
|
||||
@@ -4494,14 +4521,15 @@ function argoApplication(args, profile = "dev") {
|
||||
};
|
||||
}
|
||||
|
||||
function nodeFrpcManifest({ profile = "dev", source = null } = {}) {
|
||||
function nodeFrpcManifest({ profile = "dev", source = null, deploy = null } = {}) {
|
||||
const namespace = namespaceNameForProfile(profile);
|
||||
const profileLabel = runtimeLabelForProfile(profile);
|
||||
const deploymentName = isRuntimeLane(profile) ? `hwlab-${profile}-frpc` : profile === "prod" ? "hwlab-node-prod-frpc" : "hwlab-node-frpc";
|
||||
const configName = `${deploymentName}-config`;
|
||||
const proxyPrefix = isRuntimeLane(profile) ? `hwlab-${profile}` : profile === "prod" ? "hwlab-node-prod" : "hwlab-node";
|
||||
const webRemotePort = isRuntimeLane(profile) ? defaultPortForRuntimeLane(profile) : profile === "prod" ? 18666 : 17666;
|
||||
const edgeRemotePort = isRuntimeLane(profile) ? webRemotePort + 1 : profile === "prod" ? 18667 : 17667;
|
||||
const frpConfig = runtimeFrpConfigForProfile(deploy, profile);
|
||||
const webProxyName = frpConfig.webProxyName || `${proxyPrefix}-cloud-web`;
|
||||
const edgeProxyName = frpConfig.edgeProxyName || `${proxyPrefix}-edge-proxy`;
|
||||
const labels = {
|
||||
"app.kubernetes.io/name": deploymentName,
|
||||
"app.kubernetes.io/part-of": "hwlab",
|
||||
@@ -4515,23 +4543,23 @@ function nodeFrpcManifest({ profile = "dev", source = null } = {}) {
|
||||
hostNetwork: true,
|
||||
dnsPolicy: "ClusterFirstWithHostNet"
|
||||
} : {};
|
||||
const configText = `serverAddr = "74.48.78.17"
|
||||
serverPort = 7000
|
||||
const configText = `serverAddr = "${frpConfig.serverAddr}"
|
||||
serverPort = ${frpConfig.serverPort}
|
||||
loginFailExit = true
|
||||
|
||||
[[proxies]]
|
||||
name = "${proxyPrefix}-cloud-web"
|
||||
name = "${webProxyName}"
|
||||
type = "tcp"
|
||||
localIP = "hwlab-cloud-web.${namespace}.svc.cluster.local"
|
||||
localPort = 8080
|
||||
remotePort = ${webRemotePort}
|
||||
remotePort = ${frpConfig.webRemotePort}
|
||||
|
||||
[[proxies]]
|
||||
name = "${proxyPrefix}-edge-proxy"
|
||||
name = "${edgeProxyName}"
|
||||
type = "tcp"
|
||||
localIP = "hwlab-edge-proxy.${namespace}.svc.cluster.local"
|
||||
localPort = 6667
|
||||
remotePort = ${edgeRemotePort}
|
||||
remotePort = ${frpConfig.edgeRemotePort}
|
||||
`;
|
||||
const configSha256 = createHash("sha256").update(configText).digest("hex");
|
||||
const templateLabels = { ...labels, "hwlab.pikastech.local/config-sha256": k8sLabelHash(configSha256) };
|
||||
@@ -5948,7 +5976,7 @@ async function plannedFiles(args) {
|
||||
if (isRuntimeLane(profile)) putJson(`${runtimePath}/observability.yaml`, observabilityManifest({ deploy, profile, namespace, labels: profileLabels, annotations, metricsSidecarScript }));
|
||||
if (isRuntimeLane(profile)) putJson(`${runtimePath}/opencode.yaml`, opencodeServerManifest({ profile, source, deploy, catalog: artifactCatalog, registryPrefix: args.registryPrefix, useDeployImages: args.useDeployImages, sourceBranch: args.sourceBranch, gitReadUrl: args.gitReadUrl, sourceRepo: args.sourceRepo }));
|
||||
if (includeDeviceAgent) putJson(`${runtimePath}/device-agent-71-freq.yaml`, deviceAgent71FreqManifest({ profile, source, registryPrefix: args.registryPrefix, catalog: artifactCatalog, useDeployImages: args.useDeployImages }));
|
||||
putJson(`${runtimePath}/node-frpc.yaml`, nodeFrpcManifest({ profile, source }));
|
||||
putJson(`${runtimePath}/node-frpc.yaml`, nodeFrpcManifest({ profile, source, deploy }));
|
||||
}
|
||||
return { files, source };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user