Skip to content

Commit

Permalink
#12: Beginning to integrate the upbound official Upjet generated AWS …
Browse files Browse the repository at this point in the history
…provider
  • Loading branch information
jonashackt committed May 8, 2023
1 parent 3d4a682 commit d54bb40
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 20 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,17 @@ jobs:
- name: AWS -> Create XRD, Composite & Claim to create S3 Bucket
run: |
echo "### Create CompositeResourceDefinition (XRD)"
kubectl apply -f aws/s3/definition.yaml
kubectl apply -f provider-aws-crossplane-contrib/s3/definition.yaml
kubectl get xrd
echo "### Wait for XRD to become Offered"
kubectl wait --for=condition=Offered --timeout=120s xrd xobjectstorages.crossplane.jonashackt.io
echo "### Create Composition"
kubectl apply -f aws/s3/composition.yaml
kubectl apply -f provider-aws-crossplane-contrib/s3/composition.yaml
echo "### Create Claim, which should create S3 Bucket"
kubectl apply -f aws/s3/claim.yaml
kubectl apply -f provider-aws-crossplane-contrib/s3/claim.yaml
echo "### Wait until Claim & XR (Composite) are ready"
kubectl wait --for=condition=ready --timeout=120s claim managed-s3
Expand All @@ -156,17 +156,17 @@ jobs:
- name: Azure -> Create XRD, Composite & Claim to create ResourceGroup & StorageAccount
run: |
echo "### Create CompositeResourceDefinition (XRD)"
kubectl apply -f azure/storageaccount/definition.yaml
kubectl apply -f provider-azure-crossplane-contrib/storageaccount/definition.yaml
kubectl get xrd
echo "### Wait for XRD to become Offered"
kubectl wait --for=condition=Offered --timeout=120s xrd xobjectstorages.crossplane.jonashackt.io
echo "### Create Composition"
kubectl apply -f azure/storageaccount/composition.yaml
kubectl apply -f provider-azure-crossplane-contrib/storageaccount/composition.yaml
echo "### Create Claim, which should create ResourceGroup & StorageAccount"
kubectl apply -f azure/storageaccount/claim.yaml
kubectl apply -f provider-azure-crossplane-contrib/storageaccount/claim.yaml
echo "### Show crossplane overall status"
kubectl get crossplane
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ Note that Crossplane will be automatically extended this section. Therefore the
status.connectionDetails


So our Composite Resource Definition (XRD) for our S3 Bucket could look like [aws/s3/definition.yaml](aws/s3/definition.yaml):
So our Composite Resource Definition (XRD) for our S3 Bucket could look like [provider-aws-crossplane-contrib/s3/definition.yaml](provider-aws-crossplane-contrib/s3/definition.yaml):

```yaml
---
Expand Down Expand Up @@ -402,7 +402,7 @@ spec:
Install the XRD into our cluster with:

```shell
kubectl apply -f aws/s3/definition.yaml
kubectl apply -f provider-aws-crossplane-contrib/s3/definition.yaml
```

We can double check the CRDs beeing created with `kubectl get crds` and filter them using `grep` to our group name `crossplane.jonashackt.io`:
Expand All @@ -420,7 +420,7 @@ The main work in Crossplane has to be done crafting the Compositions. This is be

Detailled docs to many of the possible manifest configurations can be found here https://crossplane.io/docs/v1.8/reference/composition.html#compositions

A Composite to manage an S3 Bucket in AWS with public access for static website hosting could for example look like this [aws/s3/composition.yaml](aws/s3/composition.yaml):
A Composite to manage an S3 Bucket in AWS with public access for static website hosting could for example look like this [provider-aws-crossplane-contrib/s3/composition.yaml](provider-aws-crossplane-contrib/s3/composition.yaml):

```yaml
---
Expand Down Expand Up @@ -482,7 +482,7 @@ spec:
Install our Composition with

```shell
kubectl apply -f aws/s3/composition.yaml
kubectl apply -f provider-aws-crossplane-contrib/s3/composition.yaml
```


Expand All @@ -493,7 +493,7 @@ Crossplane could look quite intimidating when having a first look. There are few

https://crossplane.io/docs/v1.8/reference/composition.html#composite-resources-and-claims

Since we want to create a S3 Bucket, here's an suggestion for an [claim.yaml](aws/s3/claim.yaml):
Since we want to create a S3 Bucket, here's an suggestion for an [claim.yaml](provider-aws-crossplane-contrib/s3/claim.yaml):

```yaml
---
Expand Down Expand Up @@ -521,7 +521,7 @@ spec:
Testdrive with:

```shell
kubectl apply -f aws/s3/claim.yaml
kubectl apply -f provider-aws-crossplane-contrib/s3/claim.yaml
```

When somthing goes wrong with the validation, this could look like this:
Expand Down Expand Up @@ -822,7 +822,7 @@ https://doc.crds.dev/github.com/crossplane/provider-azure/azure.crossplane.io/Re

### Defining a CompositeResourceDefinition (XRD) for our Storage Account

So our Composite Resource Definition (XRD) for our Storage Account could look like [azure/storageaccount/definition.yaml](azure/storageaccount/definition.yaml):
So our Composite Resource Definition (XRD) for our Storage Account could look like [provider-azure-crossplane-contrib/storageaccount/definition.yaml](provider-azure-crossplane-contrib/storageaccount/definition.yaml):

```yaml
---
Expand Down Expand Up @@ -872,7 +872,7 @@ spec:
Install the XRD into our cluster with:

```shell
kubectl apply -f azure/storageaccount/definition.yaml
kubectl apply -f provider-azure-crossplane-contrib/storageaccount/definition.yaml
```

Let's wait for the XRD to become `Offered`:
Expand All @@ -884,7 +884,7 @@ kubectl wait --for=condition=Offered --timeout=120s xrd xstoragesazure.crossplan

### Craft a Composition to manage our needed cloud resources

A Composite to manage an Storage Account in Azure with public access for static website hosting could for example look like this [azure/storageaccount/composition.yaml](azure/storageaccount/composition.yaml):
A Composite to manage an Storage Account in Azure with public access for static website hosting could for example look like this [provider-azure-crossplane-contrib/storageaccount/composition.yaml](provider-azure-crossplane-contrib/storageaccount/composition.yaml):

```yaml
---
Expand Down Expand Up @@ -939,14 +939,14 @@ spec:
Install our Composition with

```shell
kubectl apply -f azure/storageaccount/composition.yaml
kubectl apply -f provider-azure-crossplane-contrib/storageaccount/composition.yaml
```



### Craft a Composite Resource (XR) or Claim (XRC)

Since we want to create a Storage Account, here's an suggestion for an [claim.yaml](azure/storageaccount/claim.yaml):
Since we want to create a Storage Account, here's an suggestion for an [claim.yaml](provider-azure-crossplane-contrib/storageaccount/claim.yaml):

```yaml
---
Expand All @@ -968,7 +968,7 @@ spec:
Testdrive with

```shell
kubectl apply -f azure/storageaccount/claim.yaml
kubectl apply -f provider-azure-crossplane-contrib/storageaccount/claim.yaml
```

Now have a look into the Azure Portal. Our Resource Group should show up:
Expand Down Expand Up @@ -1047,7 +1047,7 @@ Therefore we need a `crossplane.yaml` file as described in https://crossplane.io

See also https://crossplane.io/docs/v1.8/concepts/packages.html#configuration-packages

Our [aws/s3/crossplane.yaml](aws/s3/crossplane.yaml) is of `kind: Configuration` and defines the minimum crossplane version needed alongside the crossplane AWS provider:
Our [provider-aws-crossplane-contrib/s3/crossplane.yaml](provider-aws-crossplane-contrib/s3/crossplane.yaml) is of `kind: Configuration` and defines the minimum crossplane version needed alongside the crossplane AWS provider:

```yaml
apiVersion: meta.pkg.crossplane.io/v1
Expand Down Expand Up @@ -1075,7 +1075,7 @@ Really strange, getting

```shell
kubectl crossplane build configuration
kubectl crossplane: error: failed to build package: failed to parse package: {path:/Users/jonashecht/dev/kubernetes/crossplane-kind-eks/aws/s3/composition.yaml position:0}: no kind "S3Bucket" is registered for version "crossplane.jonashackt.io/v1alpha1" in scheme "/home/runner/work/crossplane/crossplane/internal/xpkg/scheme.go:47"
kubectl crossplane: error: failed to build package: failed to parse package: {path:/Users/jonashecht/dev/kubernetes/crossplane-awws-azure/provider-aws-crossplane-contrib/s3/composition.yaml position:0}: no kind "S3Bucket" is registered for version "crossplane.jonashackt.io/v1alpha1" in scheme "/home/runner/work/crossplane/crossplane/internal/xpkg/scheme.go:47"
```


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions provider-aws-upbound/s3/claim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
# Use the spec.group/spec.versions[0].name defined in the XRD
apiVersion: crossplane.jonashackt.io/v1alpha1
# Use the spec.claimName or spec.name specified in the XRD
kind: ObjectStorage
metadata:
# Only claims are namespaced, unlike XRs.
namespace: default
name: managed-s3
spec:
# The compositionRef specifies which Composition this XR will use to compose
# resources when it is created, updated, or deleted.
compositionRef:
name: objectstorage-composition

# Parameters for the Composition to provide the Managed Resources (MR) with
# to create the actual infrastructure components
parameters:
bucketName: microservice-ui-nuxt-js-static-bucket2
region: eu-central-1
10 changes: 10 additions & 0 deletions provider-aws-upbound/s3/crossplane.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: meta.pkg.crossplane.io/v1
kind: Configuration
metadata:
name: s3-bucket-example
spec:
crossplane:
version: ">=v1.9"
dependsOn:
- provider: crossplanecontrib/provider-aws
version: ">=v0.33.0"
52 changes: 52 additions & 0 deletions provider-aws-upbound/s3/definition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
# XRDs must be named 'x<plural>.<group>'
name: xobjectstorages.crossplane.jonashackt.io
spec:
# This XRD defines an XR in the 'crossplane.jonashackt.io' API group.
# The XR or Claim must use this group together with the spec.versions[0].name as it's apiVersion, like this:
# 'crossplane.jonashackt.io/v1alpha1'
group: crossplane.jonashackt.io

# XR names should always be prefixed with an 'X'
names:
kind: XObjectStorage
plural: xobjectstorages
# This type of XR offers a claim, which should have the same name without the 'X' prefix
claimNames:
kind: ObjectStorage
plural: objectstorages

# default Composition when none is specified (must match metadata.name of a provided Composition)
# e.g. in composition.yaml
defaultCompositionRef:
name: objectstorage-composition

versions:
- name: v1alpha1
served: true
referenceable: true
# OpenAPI schema (like the one used by Kubernetes CRDs). Determines what fields
# the XR (and claim) will have. Will be automatically extended by crossplane.
# See https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/
# for full CRD documentation and guide on how to write OpenAPI schemas
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
# We define 2 needed parameters here one has to provide as XR or Claim spec.parameters
properties:
parameters:
type: object
properties:
bucketName:
type: string
region:
type: string
required:
- bucketName
- region
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d54bb40

Please sign in to comment.