diff --git a/compositions/README.md b/compositions/README.md index 6ca411dc..76e38044 100644 --- a/compositions/README.md +++ b/compositions/README.md @@ -1,2 +1,40 @@ # Composition library +Compositions folder contains the Composite files and the XRD files to deploy the Composites for each AWS service. + +Compositions and XRD definition files split into dedicated folders for each AWS Provider. + +- AWS Provider +- Terrajet AWS Provider + +## Option1 - AWS Provider +The following steps demonstrate the example to deploy the composition to create VPC with AWS Provider + +### Deploy Composition and XRD +Deploys VPC Composition file and XRD definition file + +```shell +kubectl apply -f compositions/aws-provider/vpc +``` + +### Deploy Application example +Deploys VPC claim resource which uses the above composition. + +```shell +kubectl apply -f examples/aws-provider/composite-resources/vpc/vpc.yaml +``` + +## Option2: Jet AWS Provider +The following steps demonstrate the example to deploy the VPC with Jet AWS Provider + +### Deploy Composition and XRD +Deploys VPC Composition file and XRD definition file +```shell +kubectl apply -f compositions/terrajet-aws-provider/vpc +``` + +### Deploy Application example +Deploys VPC claim resource which uses the above composition. +```shell +kubectl apply -f examples/terrajet-aws-provider/composition-resources/vpc.yaml +``` diff --git a/compositions/aws-provider/vpc/vpc-composition.yaml b/compositions/aws-provider/vpc/vpc-composition.yaml index d284311f..ea94db9f 100644 --- a/compositions/aws-provider/vpc/vpc-composition.yaml +++ b/compositions/aws-provider/vpc/vpc-composition.yaml @@ -40,9 +40,13 @@ spec: kind: VPC spec: forProvider: - enableDnsSupport: "" - enableDnsHostNames: "" - cidrBlock: "" + amazonProvidedIpv6CidrBlock: + enableDnsSupport: + enableDnsHostNames: + cidrBlock: + instanceTenancy: + ipv6CidrBlock: + ipv6Pool: tags: - key: Name patches: @@ -60,4 +64,16 @@ spec: - type: FromCompositeFieldPath fromFieldPath: spec.parameters.enableDnsHostNames toFieldPath: spec.forProvider.enableDnsHostNames + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.amazonProvidedIpv6CidrBlock + toFieldPath: spec.forProvider.amazonProvidedIpv6CidrBlock + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.instanceTenancy + toFieldPath: spec.forProvider.instanceTenancy + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.ipv6CidrBlock + toFieldPath: spec.forProvider.ipv6CidrBlock + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.ipv6Pool + toFieldPath: spec.forProvider.ipv6Pool diff --git a/compositions/aws-provider/vpc/vpc-xrd.yaml b/compositions/aws-provider/vpc/vpc-xrd.yaml index 344115f0..2d91a441 100644 --- a/compositions/aws-provider/vpc/vpc-xrd.yaml +++ b/compositions/aws-provider/vpc/vpc-xrd.yaml @@ -54,7 +54,19 @@ spec: description: enable DNS Hostnames type: boolean default: true - + amazonProvidedIpv6CidrBlock: + description: Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC. You cannot specify the range of IP addresses, or the size of the CIDR block. + type: boolean + default: false + instanceTenancy: + description: The allowed tenancy of instances launched into the VPC. + type: string + ipv6CidrBlock: + description: The IPv6 CIDR block from the IPv6 address pool. You must also specify Ipv6Pool in the request. To let Amazon choose the IPv6 CIDR block for you, omit this parameter. + type: string + ipv6Pool: + description: The ID of an IPv6 address pool from which to allocate the IPv6 CIDR block. + type: string required: - vpccidrBlock - vpcName diff --git a/compositions/terrajet-aws-provider/vpc/README.md b/compositions/terrajet-aws-provider/vpc/README.md index 7b1452de..a36ad7ac 100644 --- a/compositions/terrajet-aws-provider/vpc/README.md +++ b/compositions/terrajet-aws-provider/vpc/README.md @@ -1,14 +1,17 @@ # Crossplane Configuration ## Steps to build and deploy Crossplane Configuration packages - +`vpc-composition.yaml` and `vpc-xrd.yaml` can be deployed using `kubectl apply` + +Alternatively, you can use the following steps to package the composition and deploy + ### Step1 - Create a `crossplane.yaml` file where Composition and CompositeResourceDefinition resource files are available -### Step2: Build Configuraiton file +### Step2: Build Configuration file ```shell kubectl crossplane build configuration diff --git a/compositions/terrajet-aws-provider/vpc/vpc-composition.yaml b/compositions/terrajet-aws-provider/vpc/vpc-composition.yaml index 9583e7a1..47082444 100644 --- a/compositions/terrajet-aws-provider/vpc/vpc-composition.yaml +++ b/compositions/terrajet-aws-provider/vpc/vpc-composition.yaml @@ -5,22 +5,35 @@ apiVersion: apiextensions.crossplane.io/v1 kind: Composition metadata: - name: amazon-vpc + name: xvpcs.network.jet.awsblueprints.io labels: - provider: jet-aws-provider + awsblueprints.io/provider: jet-aws + awsblueprints.io/environment: dev + crossplane.io/xrd: xamazonvpcs.network.jet.awsblueprints.io service: vpc compute: managedamazon-vpc spec: writeConnectionSecretsToNamespace: crossplane-system compositeTypeRef: - apiVersion: vpc.awsblueprints.io/v1beta1 - kind: AmazonVpc + apiVersion: network.jet.awsblueprints.io/v1alpha1 + kind: XAmazonVpc patchSets: - name: common-parameters patches: - - fromFieldPath: "spec.parameters.region" - toFieldPath: "spec.forProvider.region" + - type: FromCompositeFieldPath + fromFieldPath: spec.resourceConfig.providerConfigName + toFieldPath: spec.providerConfigRef.name + - type: FromCompositeFieldPath + fromFieldPath: spec.resourceConfig.deletionPolicy + toFieldPath: spec.deletionPolicy + - type: FromCompositeFieldPath + fromFieldPath: spec.resourceConfig.region + toFieldPath: spec.forProvider.region +# - type: FromCompositeFieldPath +# fromFieldPath: spec.resourceConfig.name +# toFieldPath: metadata.annotations[crossplane.io/external-name] + resources: - name: vpc base: @@ -28,19 +41,25 @@ spec: kind: VPC spec: forProvider: -# enableDnsSupport: true # Disabled due to Open defect with Terrajet Crossplane provider -# enableDnsHostNames: true -# tags: -# Name: jet-aws-provider-vpc - providerConfigRef: - name: jet-aws-provider-config + enableDnsSupport: "" + enableDnsHostNames: "" + cidrBlock: "" + tags: + Name: "" + patches: - type: PatchSet patchSetName: common-parameters - - fromFieldPath: spec.parameters.vpc-cidrBlock + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.vpccidrBlock toFieldPath: spec.forProvider.cidrBlock - - fromFieldPath: spec.parameters.vpc-tags - toFieldPath: spec.forProvider.tags[0].key - - fromFieldPath: spec.parameters.vpc-tags - toFieldPath: spec.forProvider.tags[0].value + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.vpcName + toFieldPath: spec.forProvider.tags.Name + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.enableDnsSupport + toFieldPath: spec.forProvider.enableDnsSupport + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.enableDnsHostNames + toFieldPath: spec.forProvider.enableDnsHostNames diff --git a/compositions/terrajet-aws-provider/vpc/vpc-xrd.yaml b/compositions/terrajet-aws-provider/vpc/vpc-xrd.yaml index d5155f17..e0b62d3f 100644 --- a/compositions/terrajet-aws-provider/vpc/vpc-xrd.yaml +++ b/compositions/terrajet-aws-provider/vpc/vpc-xrd.yaml @@ -5,14 +5,18 @@ apiVersion: apiextensions.crossplane.io/v1 kind: CompositeResourceDefinition metadata: - name: amazonvpcs.vpc.awsblueprints.io + name: xamazonvpcs.network.jet.awsblueprints.io # must be spec.names.plural+"."+spec.group spec: - group: vpc.awsblueprints.io + group: network.jet.awsblueprints.io names: - kind: AmazonVpc + kind: XAmazonVpc # cluster scope type + plural: xamazonvpcs + claimNames: # namespace scope type + kind: amazonVpc plural: amazonvpcs + versions: - - name: v1beta1 + - name: v1alpha1 additionalPrinterColumns: - jsonPath: .status.conditions[?(@.type=='Ready')].status name: READY @@ -33,21 +37,54 @@ spec: type: object properties: parameters: + description: VPC Input parameters type: object properties: - region: - description: Geographic location of this VPC - type: string - enum: ["eu-west-1", "eu-west-2"] - vpc-cidrBlock: + + vpccidrBlock: description: CIDR block for VPC type: string - vpc-tags: - description: VPC tags - type: map + vpcName: + description: Name of the VPC + type: string + enableDnsSupport: + description: enable DNS Support + type: boolean + default: true + enableDnsHostNames: + description: enable DNS Hostnames + type: boolean + default: true + + required: + - vpccidrBlock + - vpcName + resourceConfig: + description: ResourceConfig defines general properties of this AWS + resource. + type: object + properties: + + deletionPolicy: + description: Defaults to Delete + enum: + - Delete + - Orphan + type: string + name: + description: Set the name of this resource in AWS to the value + provided by this field. + type: string + providerConfigName: + type: string + region: + type: string + required: + - providerConfigName - region - - vpc-tags - - vpc-cidrBlock required: - - parameters \ No newline at end of file + - parameters + - resourceConfig + required: + - spec \ No newline at end of file diff --git a/examples/README.md b/examples/README.md index 7282e75a..c157b016 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,17 +1,58 @@ # Crossplane Blueprint examples - -This folder contains example for deploying AWS resources using the following providers +This folder contains examples for deploying AWS resources using the following providers - [AWS Provider](https://github.com/crossplane/provider-aws) - [Terrajet AWS Provider](https://github.com/crossplane-contrib/provider-jet-aws) -## Usage +## Pre-requisites: + - EKS Cluster bootstrap deployment + - Crossplane deployment in bootstrap cluster + - AWS Provider and Terrajet AWS Provider deployment + - ProviderConfig deployment with injected identity + +Follow these links to bootstrap the cluster +- Bootstrap the cluster with [Terraform](../bootstrap/terraform/README.md) +- Bootstrap the cluster with [eksctl](../bootstrap/eksctl/README.md) + + +## Option1 - AWS Provider +The following steps demonstrates VPC example composition deployment with **AWS Provider** + +### Deploy Composition and XRD +Deploys VPC Composition file and XRD definition file + +```shell +kubectl apply -f compositions/aws-provider/vpc +``` + +### Deploy Application example +Deploys VPC claim resource which uses the above composition. + +```shell +kubectl apply -f examples/aws-provider/composite-resources/vpc/vpc.yaml +``` + +## Option2: Jet AWS Provider +The following steps demonstrates VPC example composition deployment with **Jet AWS Provider** + +### Deploy Composition and XRD +Deploys VPC Composition file and XRD definition file +```shell +kubectl apply -f compositions/terrajet-aws-provider/vpc +``` + +### Deploy Application example +Deploys VPC claim resource which uses the above composition. +```shell +kubectl apply -f examples/terrajet-aws-provider/composition-resources/vpc.yaml +``` + +## Option3: Deploy Managed resource for AWS Provider The following shows the deployment of VPC using AWS Provider ```shell -cd ~/aws-crossplane-blueprints/examples/aws-provider/managed-resources -kubectl apply -f vpc.yaml +kubectl apply -f examples/aws-provider/managed-resources/vpc.yaml # Verify the resource. When provisioning is complete, you should see READY: True in the output kubectl get VPC aws-provider-vpc diff --git a/examples/aws-provider/composite-resources/vpc/vpc.yaml b/examples/aws-provider/composite-resources/vpc/vpc.yaml index 6aaa078c..39ad29e1 100644 --- a/examples/aws-provider/composite-resources/vpc/vpc.yaml +++ b/examples/aws-provider/composite-resources/vpc/vpc.yaml @@ -6,7 +6,7 @@ apiVersion: network.awsblueprints.io/v1alpha1 kind: amazonVpc metadata: - name: crossplane-amazon-vpc + name: xplane-amazon-vpc namespace: default spec: compositionSelector: @@ -21,4 +21,5 @@ spec: parameters: vpcName: aws-provider-vpc vpccidrBlock: "10.20.0.0/16" + amazonProvidedIpv6CidrBlock: true diff --git a/examples/terrajet-aws-provider/composite-resources/vpc.yaml b/examples/terrajet-aws-provider/composite-resources/vpc.yaml index 8153c596..8b7897bb 100644 --- a/examples/terrajet-aws-provider/composite-resources/vpc.yaml +++ b/examples/terrajet-aws-provider/composite-resources/vpc.yaml @@ -3,19 +3,22 @@ # Run `kubectl apply -f vpc.yaml` to test this example once you bootstrap the EKS cluster with Crossplane and Terrajet AWS Provider --- -apiVersion: vpc.awsblueprints.io/v1beta1 -kind: AmazonVpc +apiVersion: network.awsblueprints.io/v1alpha1 +kind: amazonVpc metadata: - name: crossplane-amazon-vpc + name: xplane-jet-amazon-vpc + namespace: default spec: - parameters: + compositionSelector: + matchLabels: + awsblueprints.io/provider: jet-aws + awsblueprints.io/environment: dev + service: vpc + compute: managedamazon-vpc + resourceConfig: + providerConfigName: jet-aws-provider-config region: eu-west-1 - vpc-tags: - Name: aws-provider-vpc - vpc-cidrBlock: "10.20.0.0/16" - compositionRef: - name: amazon-vpc + parameters: + vpcName: jet-aws-provider-vpc + vpccidrBlock: "10.30.0.0/16" -# writeConnectionSecretToRef: -# namespace: cplane-vpc -# name: crossplane-prod-cluster-connection \ No newline at end of file