Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terrajet VPC example update with docs #4

Merged
merged 8 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions compositions/README.md
Original file line number Diff line number Diff line change
@@ -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
```
22 changes: 19 additions & 3 deletions compositions/aws-provider/vpc/vpc-composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ spec:
kind: VPC
spec:
forProvider:
enableDnsSupport: ""
enableDnsHostNames: ""
cidrBlock: ""
amazonProvidedIpv6CidrBlock:
enableDnsSupport:
enableDnsHostNames:
cidrBlock:
instanceTenancy:
ipv6CidrBlock:
ipv6Pool:
tags:
- key: Name
patches:
Expand All @@ -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

14 changes: 13 additions & 1 deletion compositions/aws-provider/vpc/vpc-xrd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions compositions/terrajet-aws-provider/vpc/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
53 changes: 36 additions & 17 deletions compositions/terrajet-aws-provider/vpc/vpc-composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,61 @@
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:
apiVersion: ec2.aws.jet.crossplane.io/v1alpha2
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

67 changes: 52 additions & 15 deletions compositions/terrajet-aws-provider/vpc/vpc-xrd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
apiVersion: apiextensions.crossplane.io/v1
vara-bonthu marked this conversation as resolved.
Show resolved Hide resolved
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
Expand All @@ -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
- parameters
- resourceConfig
required:
- spec
51 changes: 46 additions & 5 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion examples/aws-provider/composite-resources/vpc/vpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
apiVersion: network.awsblueprints.io/v1alpha1
kind: amazonVpc
metadata:
name: crossplane-amazon-vpc
name: xplane-amazon-vpc
namespace: default
spec:
compositionSelector:
Expand All @@ -21,4 +21,5 @@ spec:
parameters:
vpcName: aws-provider-vpc
vpccidrBlock: "10.20.0.0/16"
amazonProvidedIpv6CidrBlock: true

Loading