From 29e7e72e46d3d3fcb4d394d9d1f1cf726c4d7680 Mon Sep 17 00:00:00 2001 From: harsh goyal Date: Tue, 11 Jun 2024 12:03:55 +0100 Subject: [PATCH] feat: Added aws-rds promise and operators --- README.md | 3 +- internal/configure-pipeline/execute-pipeline | 30 +++++++++++-------- ...{rds-postgresql.yaml => rds-instance.yaml} | 1 + promise.yaml | 7 +++++ resource-request.yaml | 9 ++++++ 5 files changed, 37 insertions(+), 13 deletions(-) rename internal/configure-pipeline/resources/{rds-postgresql.yaml => rds-instance.yaml} (94%) create mode 100644 resource-request.yaml diff --git a/README.md b/README.md index 9b8c191..24b461f 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# aws-rds-kratix-promise \ No newline at end of file +# aws-rds-kratix-promise + diff --git a/internal/configure-pipeline/execute-pipeline b/internal/configure-pipeline/execute-pipeline index c6b56db..aa50903 100644 --- a/internal/configure-pipeline/execute-pipeline +++ b/internal/configure-pipeline/execute-pipeline @@ -10,18 +10,24 @@ if [ "$KRATIX_WORKFLOW_TYPE" = "promise" ]; then elif [ "$KRATIX_WORKFLOW_TYPE" = "resource" ]; then echo "Executing resource workflow" -# base_instance="/tmp/transfer/resources/flink-basic.yaml" -# -# # Read current values from the provided resource request -# name="$(yq eval '.spec.name' /kratix/input/object.yaml)" -# namespace="$(yq eval '.spec.namespace // "default"' /kratix/input/object.yaml)" -# -# # Replace defaults with user provided values -# cat ${base_instance} | -# yq eval " -# .metadata.namespace = \"${namespace}\" | -# .metadata.name = \"${name}\" -# " - > /kratix/output/flink-instance.yaml + base_instance="/tmp/transfer/resources/rds-instance.yaml" + + # Read current values from the provided resource request + name="$(yq eval '.spec.name' /kratix/input/object.yaml)" + namespace="$(yq eval '.spec.namespace // "default"' /kratix/input/object.yaml)" + engine="$(yq eval '.spec.engine // "postgres"' /kratix/input/object.yaml)" + engineVersion="$(yq eval '.spec.engineVersion' /kratix/input/object.yaml)" + + # Replace defaults with user provided values + cat ${base_instance} | + yq eval " + .metadata.namespace = \"${namespace}\" | + .metadata.name = \"${name}\" | + .spec.dbInstanceIdentifier = ${name} | + .spec.masterUsername = ${name} | + .spec.engine = \"${engine}\" | + .spec.engineVersion = \"${engineVersion}\" + " - > /kratix/output/rds-instance.yaml else diff --git a/internal/configure-pipeline/resources/rds-postgresql.yaml b/internal/configure-pipeline/resources/rds-instance.yaml similarity index 94% rename from internal/configure-pipeline/resources/rds-postgresql.yaml rename to internal/configure-pipeline/resources/rds-instance.yaml index 45efa6b..c9e0446 100644 --- a/internal/configure-pipeline/resources/rds-postgresql.yaml +++ b/internal/configure-pipeline/resources/rds-instance.yaml @@ -2,6 +2,7 @@ apiVersion: rds.services.k8s.aws/v1alpha1 kind: DBInstance metadata: name: "test-postgres-instance" + namespace: default spec: allocatedStorage: 20 dbInstanceClass: db.t4g.micro diff --git a/promise.yaml b/promise.yaml index f95cd30..203639e 100644 --- a/promise.yaml +++ b/promise.yaml @@ -35,6 +35,13 @@ spec: name: type: string description: AWS RDS instance name + engine: + default: postgres + type: string + description: Choose aws rds engine(examples aurora, postgres, mysql etc) + engineVersion: + type: string + description: Aws rds engine version workflows: promise: configure: diff --git a/resource-request.yaml b/resource-request.yaml new file mode 100644 index 0000000..2de19bb --- /dev/null +++ b/resource-request.yaml @@ -0,0 +1,9 @@ +apiVersion: example.promise.syntasso.io/v1 +kind: AWSRDS +metadata: + name: "PostgresRDSInstance" +spec: + name: "PostgresRDSInstance" + namespace: default + engine: "postgres" + engineVersion: "14" \ No newline at end of file