update default EKS cluster entity transformer

This change has no functional effect, but it seems like a helpful illustration
for adopters embarking on writing the first EKS cluster entity transformer of
their own.

Signed-off-by: Jamie Klassen <jamie.klassen@broadcom.com>
This commit is contained in:
Jamie Klassen
2024-01-19 15:25:20 -05:00
parent daad57618e
commit a81b1ba7dd
3 changed files with 11 additions and 1 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/plugin-catalog-backend-module-aws': patch
---
The default EKS cluster entity transformer now sets the new
`kubernetes.io/x-k8s-aws-id` annotation.
@@ -18,6 +18,7 @@ import {
ANNOTATION_KUBERNETES_API_SERVER,
ANNOTATION_KUBERNETES_API_SERVER_CA,
ANNOTATION_KUBERNETES_AUTH_PROVIDER,
ANNOTATION_KUBERNETES_AWS_CLUSTER_ID,
} from '@backstage/plugin-kubernetes-common';
import type { EksClusterEntityTransformer } from '../processors/types';
import { ANNOTATION_AWS_ACCOUNT_ID, ANNOTATION_AWS_ARN } from '../constants';
@@ -29,6 +30,7 @@ import { ANNOTATION_AWS_ACCOUNT_ID, ANNOTATION_AWS_ARN } from '../constants';
export const defaultEksClusterEntityTransformer: EksClusterEntityTransformer =
async (cluster: Cluster, accountId: string) => {
const { arn, endpoint, certificateAuthority, name } = cluster;
const normalizedName = normalizeName(name as string);
return {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Resource',
@@ -40,8 +42,9 @@ export const defaultEksClusterEntityTransformer: EksClusterEntityTransformer =
[ANNOTATION_KUBERNETES_API_SERVER_CA]:
certificateAuthority?.data || '',
[ANNOTATION_KUBERNETES_AUTH_PROVIDER]: 'aws',
[ANNOTATION_KUBERNETES_AWS_CLUSTER_ID]: normalizedName,
},
name: normalizeName(name as string),
name: normalizedName,
namespace: 'default',
},
spec: {
@@ -67,6 +67,7 @@ describe('AwsEKSClusterProcessor', () => {
'kubernetes.io/api-server-certificate-authority':
cluster.cluster?.certificateAuthority?.data,
'kubernetes.io/auth-provider': 'aws',
'kubernetes.io/x-k8s-aws-id': 'backstage-test',
},
name: 'backstage-test',
namespace: 'default',