diff --git a/.changeset/slow-suits-rescue.md b/.changeset/slow-suits-rescue.md new file mode 100644 index 0000000000..96a963f19f --- /dev/null +++ b/.changeset/slow-suits-rescue.md @@ -0,0 +1,8 @@ +--- +'@backstage/plugin-catalog-backend-module-gcp': patch +--- + +Fix GKE endpoint parsing + +Endpoint is an IP, not url. It is always https on default (443) port +ref: https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.locations.clusters#Cluster diff --git a/plugins/catalog-backend-module-gcp/src/providers/GkeEntityProvider.test.ts b/plugins/catalog-backend-module-gcp/src/providers/GkeEntityProvider.test.ts index 20e91a85bf..76df12e4e4 100644 --- a/plugins/catalog-backend-module-gcp/src/providers/GkeEntityProvider.test.ts +++ b/plugins/catalog-backend-module-gcp/src/providers/GkeEntityProvider.test.ts @@ -83,9 +83,9 @@ describe('GkeEntityProvider', () => { clusters: [ { name: 'some-cluster', - endpoint: 'http://127.0.0.1:1234', + endpoint: '127.0.0.1', location: 'some-location', - selfLink: 'http://127.0.0.1/some-link', + selfLink: 'https://127.0.0.1/some-link', masterAuth: { clusterCaCertificate: 'abcdefg', }, @@ -99,9 +99,9 @@ describe('GkeEntityProvider', () => { clusters: [ { name: 'some-other-cluster', - endpoint: 'http://127.0.0.1:5678', + endpoint: '127.0.0.1', location: 'some-other-location', - selfLink: 'http://127.0.0.1/some-other-link', + selfLink: 'https://127.0.0.1/some-other-link', masterAuth: { // no CA cert is ok }, @@ -124,7 +124,7 @@ describe('GkeEntityProvider', () => { kind: 'Resource', metadata: { annotations: { - [ANNOTATION_KUBERNETES_API_SERVER]: 'http://127.0.0.1:1234', + [ANNOTATION_KUBERNETES_API_SERVER]: 'https://127.0.0.1', [ANNOTATION_KUBERNETES_API_SERVER_CA]: 'abcdefg', [ANNOTATION_KUBERNETES_AUTH_PROVIDER]: 'google', 'backstage.io/managed-by-location': 'gcp-gke:some-location', @@ -147,7 +147,7 @@ describe('GkeEntityProvider', () => { kind: 'Resource', metadata: { annotations: { - [ANNOTATION_KUBERNETES_API_SERVER]: 'http://127.0.0.1:5678', + [ANNOTATION_KUBERNETES_API_SERVER]: 'https://127.0.0.1', [ANNOTATION_KUBERNETES_API_SERVER_CA]: '', [ANNOTATION_KUBERNETES_AUTH_PROVIDER]: 'google', 'backstage.io/managed-by-location': @@ -175,7 +175,7 @@ describe('GkeEntityProvider', () => { [ 'no-cluster-name', { - endpoint: 'http://127.0.0.1:1234', + endpoint: '127.0.0.1', location: 'some-location', selfLink: 'http://127.0.0.1/some-link', masterAuth: { @@ -188,7 +188,7 @@ describe('GkeEntityProvider', () => { { // no selfLink name: 'some-name', - endpoint: 'http://127.0.0.1:1234', + endpoint: '127.0.0.1', location: 'some-location', masterAuth: { clusterCaCertificate: 'abcdefg', @@ -210,7 +210,7 @@ describe('GkeEntityProvider', () => { 'no-location', { name: 'some-name', - endpoint: 'http://127.0.0.1:1234', + endpoint: '127.0.0.1', selfLink: 'http://127.0.0.1/some-link', masterAuth: { clusterCaCertificate: 'abcdefg', diff --git a/plugins/catalog-backend-module-gcp/src/providers/GkeEntityProvider.ts b/plugins/catalog-backend-module-gcp/src/providers/GkeEntityProvider.ts index 0130955737..384cd839b2 100644 --- a/plugins/catalog-backend-module-gcp/src/providers/GkeEntityProvider.ts +++ b/plugins/catalog-backend-module-gcp/src/providers/GkeEntityProvider.ts @@ -138,7 +138,7 @@ export class GkeEntityProvider implements EntityProvider { kind: 'Resource', metadata: { annotations: { - [ANNOTATION_KUBERNETES_API_SERVER]: cluster.endpoint, + [ANNOTATION_KUBERNETES_API_SERVER]: `https://${cluster.endpoint}`, [ANNOTATION_KUBERNETES_API_SERVER_CA]: cluster.masterAuth?.clusterCaCertificate || '', [ANNOTATION_KUBERNETES_AUTH_PROVIDER]: 'google',