From 2d4e393ca64523ef0cd00247769ef8bfbca13432 Mon Sep 17 00:00:00 2001 From: Sebastian Florek Date: Mon, 16 Dec 2024 12:46:49 +0100 Subject: [PATCH] set PR automatin for EKS cluster w/ external credentials --- catalogs/infra/cluster/{ => aws}/stack.yaml | 11 ++++- setup/catalogs/infra/cluster-eks.yaml | 49 +++++++++++++++++++ setup/catalogs/infra/cluster.yaml | 53 --------------------- 3 files changed, 59 insertions(+), 54 deletions(-) rename catalogs/infra/cluster/{ => aws}/stack.yaml (67%) create mode 100644 setup/catalogs/infra/cluster-eks.yaml delete mode 100644 setup/catalogs/infra/cluster.yaml diff --git a/catalogs/infra/cluster/stack.yaml b/catalogs/infra/cluster/aws/stack.yaml similarity index 67% rename from catalogs/infra/cluster/stack.yaml rename to catalogs/infra/cluster/aws/stack.yaml index bde2b6b1..7baafd71 100644 --- a/catalogs/infra/cluster/stack.yaml +++ b/catalogs/infra/cluster/aws/stack.yaml @@ -2,6 +2,7 @@ apiVersion: deployments.plural.sh/v1alpha1 kind: InfrastructureStack metadata: name: cluster-{{ context.name }} + namespace: infra spec: name: cluster-{{ context.name }} detach: false @@ -19,7 +20,7 @@ spec: namespace: infra git: ref: main - folder: terraform/modules/clusters/{{ context.cloud }} + folder: terraform/modules/clusters/aws environment: - name: TF_VAR_cluster value: {{ context.name }} @@ -29,3 +30,11 @@ spec: value: {{ context.tier }} - name: TF_VAR_region value: {{ context.region }} + - name: AWS_ACCESS_KEY_ID + secretKeyRef: + name: {{ context.credentialSecret }} + key: AWS_ACCESS_KEY_ID + - name: AWS_SECRET_ACCESS_KEY + secretKeyRef: + name: {{ context.credentialSecret }} + key: AWS_SECRET_ACCESS_KEY diff --git a/setup/catalogs/infra/cluster-eks.yaml b/setup/catalogs/infra/cluster-eks.yaml new file mode 100644 index 00000000..a1fef043 --- /dev/null +++ b/setup/catalogs/infra/cluster-eks.yaml @@ -0,0 +1,49 @@ +apiVersion: deployments.plural.sh/v1alpha1 +kind: PrAutomation +metadata: + name: cluster-eks +spec: + name: cluster-eks + documentation: | + Sets up a PR to provision EKS cluster for a fleet + stage + creates: + git: + ref: sebastian/prod-2981-set-up-catalog-pipeline # TODO set to main + folder: catalogs/infra/cluster + templates: + - source: aws/stack.yaml + destination: "services/infra/clusters/aws/stacks/{{ context.name }}.yaml" + external: true + - source: cluster.yaml + destination: "services/infra/clusters/aws/{{ context.name }}.yaml" + external: true + - source: servicedeployment.yaml + destination: "bootstrap/infra/clusters/servicedeployment.yaml" + external: true + repositoryRef: + name: scaffolds + catalogRef: + name: infra + scmConnectionRef: + name: plural # you'll need to add this ScmConnection manually before this is functional + title: "Adding EKS cluster: {{ context.name }}" + message: "Adding EKS cluster {{ context.name }} and registering it with Plural" + configuration: + - name: name + type: STRING + documentation: Name of the cluster. + - name: fleet + type: STRING + documentation: Name for the fleet you want this cluster to belong to. + - name: tier + type: ENUM + documentation: What tier to place this cluster in. + values: + - dev + - prd + - name: region + type: STRING + documentation: Region where the cluster should be created. + - name: credentialSecret + type: STRING + documentation: Name of the Kubernetes secret on the mgmt cluster in the infra namespace with the credentials that can be used to access the AWS cloud. It should contain 'AWS_ACCESS_KEY_ID' and 'AWS_SECRET_ACCESS_KEY' keys. diff --git a/setup/catalogs/infra/cluster.yaml b/setup/catalogs/infra/cluster.yaml deleted file mode 100644 index fc94b888..00000000 --- a/setup/catalogs/infra/cluster.yaml +++ /dev/null @@ -1,53 +0,0 @@ -#apiVersion: deployments.plural.sh/v1alpha1 -#kind: PrAutomation -#metadata: -# name: cluster -#spec: -# name: cluster -# documentation: | -# Sets up a PR to provision a cluster for a fleet + stage -# creates: -# git: -# ref: sebastian/prod-2981-set-up-catalog-pipeline # TODO set to main -# folder: catalogs/infra/cluster -# templates: -# - source: stack.yaml -# destination: "services/infra/clusters/{{ context.cloud }}/stacks/{{ context.name }}.yaml" -# external: true -# - source: cluster.yaml -# destination: "services/infra/clusters/{{ context.cloud }}/{{ context.name }}.yaml" -# external: true -# - source: servicedeployment.yaml -# destination: "bootstrap/infra/clusters/servicedeployment.yaml" -# external: true -# repositoryRef: -# name: scaffolds -# catalogRef: -# name: infra -# scmConnectionRef: -# name: plural # you'll need to add this ScmConnection manually before this is functional -# title: "Adding {{ context.cloud }} cluster: {{ context.name }}" -# message: "Adding {{ context.cloud }} cluster {{ context.name }} and registering it with Plural" -# configuration: -# - name: name -# type: STRING -# documentation: Name of the cluster. -# - name: cloud -# type: ENUM -# documentation: The cloud provider you'll host on. -# values: -# - aws -# - gcp -# - azure -# - name: fleet -# type: STRING -# documentation: Name for the fleet you want this cluster to belong to. -# - name: tier -# type: ENUM -# documentation: What tier to place this cluster in. -# values: -# - dev -# - prd -# - name: region -# type: STRING -# documentation: Region where the cluster should be created.