From 8c20ab4a1fad0fb7447f7e937cd59b3a6d105676 Mon Sep 17 00:00:00 2001 From: UniDesk Codex Date: Mon, 6 Jul 2026 16:52:11 +0800 Subject: [PATCH] fix: render jd01 v03 frpc public exposure --- deploy/deploy.yaml | 29 +++++++++++++++++++---- scripts/gitops-render.mjs | 48 +++++++++++++++++++++++++++++++-------- 2 files changed, 62 insertions(+), 15 deletions(-) diff --git a/deploy/deploy.yaml b/deploy/deploy.yaml index b7cc12d6..bf9cee77 100644 --- a/deploy/deploy.yaml +++ b/deploy/deploy.yaml @@ -320,12 +320,31 @@ lanes: - hyueapi.com - .hyueapi.com namespace: hwlab-v03 - endpoint: https://hwlab-v03.74-48-78-17.nip.io + endpoint: https://hwlab.pikapython.com publicEndpoints: - frontend: https://hwlab-v03.74-48-78-17.nip.io - api: https://hwlab-v03.74-48-78-17.nip.io - legacyFrontend: http://74.48.78.17:20666 - legacyApi: http://74.48.78.17:20667 + frontend: https://hwlab.pikapython.com + api: https://hwlab.pikapython.com + legacyFrontend: http://82.156.23.220:22090 + legacyApi: http://82.156.23.220:22088 + frp: + server: + address: 82.156.23.220 + bindPort: 22000 + proxies: + - name: hwlab-jd01-v03-cloud-web + endpointId: frontend + type: tcp + localServiceId: hwlab-cloud-web + localHost: hwlab-cloud-web.hwlab-v03.svc.cluster.local + localPort: 8080 + remotePort: 22090 + - name: hwlab-jd01-v03-edge-proxy + endpointId: api + type: tcp + localServiceId: hwlab-edge-proxy + localHost: hwlab-edge-proxy.hwlab-v03.svc.cluster.local + localPort: 6667 + remotePort: 22088 artifactCatalog: deploy/artifact-catalog.v03.json runtimePath: runtime-v03 imageTagMode: full diff --git a/scripts/gitops-render.mjs b/scripts/gitops-render.mjs index 18bde4e0..bc5584f5 100644 --- a/scripts/gitops-render.mjs +++ b/scripts/gitops-render.mjs @@ -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 }; }