diff --git a/src/main/cluster-detectors/cluster-id-detector.ts b/src/main/cluster-detectors/cluster-id-detector.ts index efeb2badf2..558e52d43c 100644 --- a/src/main/cluster-detectors/cluster-id-detector.ts +++ b/src/main/cluster-detectors/cluster-id-detector.ts @@ -6,7 +6,18 @@ export class ClusterIdDetector extends BaseClusterDetector { key = ClusterMetadataKey.CLUSTER_ID public async detect() { - const id = createHash("sha256").update(this.cluster.apiUrl).digest("hex") - return { value: id, accuracy: 100 } + let id: string + try { + id = await this.getDefaultNamespaceId() + } catch(_) { + id = this.cluster.apiUrl + } + const value = createHash("sha256").update(id).digest("hex") + return { value: value, accuracy: 100 } + } + + protected async getDefaultNamespaceId() { + const response = await this.k8sRequest("/api/v1/namespaces/default") + return response.metadata.uid } } \ No newline at end of file