diff --git a/plugins/kubernetes-backend/src/cluster-locator/CatalogClusterLocator.ts b/plugins/kubernetes-backend/src/cluster-locator/CatalogClusterLocator.ts index 124a53a72a..03fa347e5f 100644 --- a/plugins/kubernetes-backend/src/cluster-locator/CatalogClusterLocator.ts +++ b/plugins/kubernetes-backend/src/cluster-locator/CatalogClusterLocator.ts @@ -34,19 +34,21 @@ export class CatalogClusterLocator implements KubernetesClustersSupplier { } async getClusters(): Promise { + const apiServerKey = `metadata.annotations.${ANNOTATION_KUBERNETES_API_SERVER}`; + const apiServerCaKey = `metadata.annotations.${ANNOTATION_KUBERNETES_API_SERVER_CA}`; + const authProviderKey = `metadata.annotations.${ANNOTATION_KUBERNETES_AUTH_PROVIDER}`; + + const filter: Record = { + kind: 'Resource', + 'spec.type': 'kubernetes-cluster', + }; + + filter[apiServerKey] = CATALOG_FILTER_EXISTS; + filter[apiServerCaKey] = CATALOG_FILTER_EXISTS; + filter[authProviderKey] = CATALOG_FILTER_EXISTS; + const clusters = await this.catalogClient.getEntities({ - filter: [ - { - kind: 'Resource', - 'spec.type': 'kubernetes-cluster', - 'metadata.annotations.kubernetes.io/api-server': - CATALOG_FILTER_EXISTS, - 'metadata.annotations.kubernetes.io/api-server-certificate-authority': - CATALOG_FILTER_EXISTS, - 'metadata.annotations.kubernetes.io/auth-provider': - CATALOG_FILTER_EXISTS, - }, - ], + filter: [filter], }); return clusters.items.map(entity => { const clusterDetails: ClusterDetails = {