16export const k8sHarvExtIp = async () => { 18 const {accessByIp, klusterVipHostname, clusterVip, klustCertsH, k8sCloudName, dockLanHost, nodeIpsExtHost, cluster_name, cfApiKeySecretName, domainNames} = kcfg 19 const useLocalDocker = k8sCloudName === 'harvester' 20 // LAN registry only when the dev PC is actually on this cluster's LAN; otherwise the external dockreg (reachable from any network — avoids a cluster's internal hostname being used from another network) 21 const onLan = useLocalDocker && !!dockLanHost && await isOnSameLan({cluster_name, nodeIpsExtHost, clusterVip}) 22 const dockreg_host_override = onLan ? dockLanHost : undefined 23 if (dockreg_host_override) { 24 betLog(`k8sHarvExtIp: using docker + LAN registry ${dockreg_host_override}`) 25 process.stdout.write('waiting for docker registry') 27 const resp = await fetch(`https://${dockreg_host_override}/v2/`).catch(() => null) 28 const ok = resp?.status === 200 || resp?.status === 401 29 process.stdout.write(ok ? '.' : 'x') 31 }, {timeoutMs: 120_000, intervalMs: 5_000}) 32 if (recovered) console.log(' ready') 33 else console.log(chalkYellow(' not available after 2min, continuing anyway')) 34 } else if (useLocalDocker && dockLanHost) { 35 betLog({k8sHarvExtIp: 'off-LAN, using external dockreg'}) 39 ...(dockreg_host_override && {dockreg_host: dockreg_host_override}), 42 name: 'harvextipsync', 43 appPath: 'pt0/deployF', 45 envConf: {accessByIp, klusterVipHostname, clusterVip, klustCertsH, cfApiKeySecretName, domainNames}, 46 extraDockerSetupLine: 'RUN curl -LO "https://dl.k8s.io/release/v1.35.2/bin/linux/amd64/kubectl" && chmod +x kubectl && mv kubectl /usr/local/bin/', 49 schedule: '*/5 * * * *', 54 ...(cfApiKeySecretName ? [cfApiKeySecretName] : []), 57 if (useLocalDocker) await dockBuildCtx.run({dockName: 'docker'}, run)