Fix AWS quickstart bugs (#357)

Resolves https://github.com/crossplane/docs/issues/356
This commit is contained in:
Pete Lumbis 2023-02-11 11:00:23 -05:00 committed by GitHub
parent 5fc58271c1
commit b4bb9382cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 85 additions and 65 deletions

View File

@ -12,7 +12,9 @@ indicator that the kubectl Crossplane you're using is outdated. In other words
some Crossplane API has been graduated from alpha to beta or stable and the old some Crossplane API has been graduated from alpha to beta or stable and the old
plugin is not aware of this change. plugin is not aware of this change.
You can follow the [install Crossplane CLI] instructions to upgrade the plugin. You can follow the
[install Crossplane CLI]({{<ref "../getting-started/install-configure" >}})
instructions to upgrade the plugin.
## Resource Status and Conditions ## Resource Status and Conditions
@ -179,7 +181,7 @@ kubectl patch cloudsqlinstance my-db -p '{"metadata":{"finalizers": []}}' --type
## Installing Crossplane Package ## Installing Crossplane Package
After installing [Crossplane package], to verify the install results or After installing [Crossplane package]({{<ref "../concepts/packages" >}}), to verify the install results or
troubleshoot any issue spotted during the installation, there are a few things troubleshoot any issue spotted during the installation, there are a few things
you can do. you can do.
@ -260,7 +262,6 @@ spec:
<!-- Named Links --> <!-- Named Links -->
[Requested Resource Not Found]: #requested-resource-not-found [Requested Resource Not Found]: #requested-resource-not-found
[install Crossplane CLI]: "../getting-started/install-configure"
[Resource Status and Conditions]: #resource-status-and-conditions [Resource Status and Conditions]: #resource-status-and-conditions
[Resource Events]: #resource-events [Resource Events]: #resource-events
[Crossplane Logs]: #crossplane-logs [Crossplane Logs]: #crossplane-logs
@ -269,6 +270,5 @@ spec:
[Pausing Providers]: #pausing-providers [Pausing Providers]: #pausing-providers
[Deleting When a Resource Hangs]: #deleting-when-a-resource-hangs [Deleting When a Resource Hangs]: #deleting-when-a-resource-hangs
[Installing Crossplane Package]: #installing-crossplane-package [Installing Crossplane Package]: #installing-crossplane-package
[Crossplane package]: "../concepts/packages"
[Handling Crossplane Package Dependency]: #handling-crossplane-package-dependency [Handling Crossplane Package Dependency]: #handling-crossplane-package-dependency
[semver spec]: https://github.com/Masterminds/semver#basic-comparisons [semver spec]: https://github.com/Masterminds/semver#basic-comparisons

View File

@ -50,12 +50,14 @@ spec:
EOF EOF
``` ```
3. Create a file with your AWS keys 3. Create a file called `aws-credentials.txt` with your AWS keys
```ini {{< editCode >}}
```ini {copy-lines="all"}
[default] [default]
aws_access_key_id = <aws_access_key> aws_access_key_id = $$<aws_access_key>$$
aws_secret_access_key = <aws_secret_key> aws_secret_access_key = $$<aws_secret_key>$$
``` ```
{{</ editCode >}}
4. Create a Kubernetes secret from the AWS keys 4. Create a Kubernetes secret from the AWS keys
```shell {label="kube-create-secret",copy-lines="all"} ```shell {label="kube-create-secret",copy-lines="all"}
@ -100,6 +102,11 @@ To create a _composition_, first define each individual managed resource.
### Create an S3 bucket object ### Create an S3 bucket object
Define a `bucket` resource using the configuration from the previous section: Define a `bucket` resource using the configuration from the previous section:
{{< hint "note" >}}
Don't apply this configuration. This YAML is part of a larger
definition.
{{< /hint >}}
```yaml ```yaml
apiVersion: s3.aws.upbound.io/v1beta1 apiVersion: s3.aws.upbound.io/v1beta1
kind: Bucket kind: Bucket
@ -176,7 +183,7 @@ Create any {{<hover label="compName" line="4">}}name{{</ hover>}} for this _comp
apiVersion: apiextensions.crossplane.io/v1 apiVersion: apiextensions.crossplane.io/v1
kind: Composition kind: Composition
metadata: metadata:
name: dynamodb-with-s3 name: dynamodb-with-bucket
``` ```
Add the resources to the Add the resources to the
@ -193,7 +200,7 @@ key.
apiVersion: apiextensions.crossplane.io/v1 apiVersion: apiextensions.crossplane.io/v1
kind: Composition kind: Composition
metadata: metadata:
name: dynamodb-with-s3 name: dynamodb-with-bucket
spec: spec:
resources: resources:
- name: s3-bucket - name: s3-bucket
@ -235,6 +242,10 @@ _Compositions_ do this with the
{{<hover label="compRef" line="6">}}spec.compositeTypeRef{{</ hover>}} {{<hover label="compRef" line="6">}}spec.compositeTypeRef{{</ hover>}}
definition. definition.
{{< hint "tip" >}}
Crossplane recommends prefacing the `kind` with an `X` to show it's a Composition.
{{< /hint >}}
```yaml {label="compRef"} ```yaml {label="compRef"}
apiVersion: apiextensions.crossplane.io/v1 apiVersion: apiextensions.crossplane.io/v1
kind: Composition kind: Composition
@ -252,7 +263,7 @@ A _composite resource_ is actually a custom Kubernetes API type you define. The
platform team controls the kind, API endpoint and version. platform team controls the kind, API endpoint and version.
<!-- vale gitlab.SentenceLength = NO --> <!-- vale gitlab.SentenceLength = NO -->
<!-- Lenght is because of shortcodes, ignore --> <!-- Length is because of shortcodes, ignore -->
With this {{<hover label="compRef" line="6">}}spec.compositeTypeRef{{</ hover>}} With this {{<hover label="compRef" line="6">}}spec.compositeTypeRef{{</ hover>}}
Crossplane only allows _composite resources_ from the API group Crossplane only allows _composite resources_ from the API group
{{<hover label="compRef" line="7">}}custom-api.example.org{{</ hover>}} {{<hover label="compRef" line="7">}}custom-api.example.org{{</ hover>}}
@ -269,7 +280,7 @@ cat <<EOF | kubectl apply -f -
apiVersion: apiextensions.crossplane.io/v1 apiVersion: apiextensions.crossplane.io/v1
kind: Composition kind: Composition
metadata: metadata:
name: dynamo-with-bucket name: dynamodb-with-bucket
spec: spec:
compositeTypeRef: compositeTypeRef:
apiVersion: custom-api.example.org/v1alpha1 apiVersion: custom-api.example.org/v1alpha1
@ -281,9 +292,7 @@ spec:
kind: Bucket kind: Bucket
spec: spec:
forProvider: forProvider:
region: us-east-2 region: "us-east-2"
providerConfigRef:
name: default
- name: dynamodb - name: dynamodb
base: base:
apiVersion: dynamodb.aws.upbound.io/v1beta1 apiVersion: dynamodb.aws.upbound.io/v1beta1
@ -304,8 +313,8 @@ Confirm the _composition_ exists with `kubectl get composition`
```shell {copy-lines="1"} ```shell {copy-lines="1"}
kubectl get composition kubectl get composition
NAME AGE NAME AGE
dynamo-with-bucket 22s dynamodb-with-bucket 28s
``` ```
## Define a composite resource ## Define a composite resource
@ -335,6 +344,11 @@ API group.
The _XRD_ {{<hover label="xrdName" line="4" >}}name{{</hover>}} is the new The _XRD_ {{<hover label="xrdName" line="4" >}}name{{</hover>}} is the new
API endpoint. API endpoint.
{{< hint "tip" >}}
Crossplane recommends using a plural name for the _XRD_
{{<hover label="xrdName" line="4" >}}name{{</hover>}}.
{{< /hint >}}
```yaml {label="xrdName"} ```yaml {label="xrdName"}
apiVersion: apiextensions.crossplane.io/v1 apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition kind: CompositeResourceDefinition
@ -364,17 +378,11 @@ spec:
plural: xdatabases plural: xdatabases
``` ```
{{< hint "tip" >}}
This new API endpoint is a _Composite Resource_ (XR) API endpoint. It is
convention for Composite Resource kinds to start with `X`. For example
`XDatabase`. This is only convention and not required.
{{< /hint >}}
{{<hint "note" >}} {{<hint "note" >}}
The _XRD_ {{<hover label="xrdGroup" line="6" >}}group{{</hover>}} matches the _composition_ {{<hover label="noteComp" The _XRD_ {{<hover label="xrdGroup" line="6" >}}group{{</hover>}} matches the _composition_ {{<hover label="noteComp"
line="5">}}apiVersion{{</hover>}} and the line="5">}}apiVersion{{</hover>}} and the
_XRD_ {{<hover label="xrdGroup" line="8" >}}kind{{</hover>}} matches the _composition_ _XRD_ {{<hover label="xrdGroup" line="8" >}}kind{{</hover>}} matches the _composition_
{{<hover label="noteComp" line="6">}}kind{{</hover>}} under the {{<hover label="noteComp" line="4">}}compositeTypeRef{{</hover>}}. {{<hover label="noteComp" line="6">}}compositeTypeRef.kind{{</hover>}}.
```yaml {label="noteComp"} ```yaml {label="noteComp"}
kind: Composition kind: Composition
@ -387,14 +395,13 @@ spec:
{{< /hint >}} {{< /hint >}}
### Set the API version ### Set the API version
In Kubernetes, all API endpoints have a version to tell the stability of the API In Kubernetes, all API endpoints have a version to show the stability of the API
and track revisions. and track revisions.
Apply a version to the _XRD_ with a Apply a version to the _XRD_ with a
{{<hover label="xrdVersion" line="11">}}versions.name{{</hover>}}. {{<hover label="xrdVersion" line="11">}}versions.name{{</hover>}}.
This matches the {{<hover label="noteComp" This matches the
line="5">}}apiVersion{{</hover>}} used in the _composition's_ {{<hover label="noteComp"line="5">}}compositeTypeRef.apiVersion{{</hover>}}
{{<hover label="noteComp" line="4">}}compositeTypeRef{{</hover>}}.
_XRDs_ require both _XRDs_ require both
{{<hover label="xrdVersion" line="12">}}versions.served{{</hover>}} {{<hover label="xrdVersion" line="12">}}versions.served{{</hover>}}
@ -473,8 +480,8 @@ spec:
``` ```
{{< hint "tip" >}} {{< hint "tip" >}}
For more information on the values allowed in the _XRD_ view its schema with For more information on the values allowed in a _composite resource definition_ view its schema with
`kubectl explain compositeresourcedefinitions` `kubectl explain compositeresourcedefinition`
{{< /hint >}} {{< /hint >}}
Now, define the custom API. Your custom API continues under the last Now, define the custom API. Your custom API continues under the last
@ -518,6 +525,13 @@ required:
Tell this _XRD_ to offer a _claim_ by defining the _claim_ API endpoint under Tell this _XRD_ to offer a _claim_ by defining the _claim_ API endpoint under
the _XRD_ {{<hover label="XRDclaim" line="4">}}spec{{< /hover >}}. the _XRD_ {{<hover label="XRDclaim" line="4">}}spec{{< /hover >}}.
{{< hint "tip" >}}
Crossplane recommends a _Claim_ {{<hover label="XRDclaim" line="10" >}}kind{{</ hover>}} match the _Composite Resource_ (XR)
{{<hover label="XRDclaim" line="7" >}}kind{{</ hover>}},
without the preceding `X`.
{{< /hint >}}
```yaml {label="XRDclaim"} ```yaml {label="XRDclaim"}
apiVersion: apiextensions.crossplane.io/v1 apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition kind: CompositeResourceDefinition
@ -532,13 +546,6 @@ spec:
plural: databases plural: databases
``` ```
{{< hint "tip" >}}
This new API endpoint is a _Composite Resource Claim_ (XRC) API endpoint. It is
convention for _Claim_ kinds to match their _Composite Resource_ (XR) kinds,
without the preceding `X`. For example `Database`. This is only convention and
not required.
{{< /hint >}}
{{<hint "note" >}} {{<hint "note" >}}
The [Claims](#create-a-claim) section later in this guide discusses _claims_. The [Claims](#create-a-claim) section later in this guide discusses _claims_.
{{< /hint >}} {{< /hint >}}
@ -557,7 +564,7 @@ spec:
group: custom-api.example.org group: custom-api.example.org
names: names:
kind: XDatabase kind: XDatabase
plural: databases plural: xdatabases
versions: versions:
- name: v1alpha1 - name: v1alpha1
served: true served: true
@ -587,10 +594,9 @@ Verify Kubernetes created the XRD with `kubectl get xrd`
```shell {copy-lines="1",label="getXRD"} ```shell {copy-lines="1",label="getXRD"}
kubectl get xrd kubectl get xrd
NAME ESTABLISHED OFFERED AGE NAME ESTABLISHED OFFERED AGE
xdatabases.custom-api.example.org True True 9s xdatabases.custom-api.example.org True True 10s
``` ```
## Create a composite resource ## Create a composite resource
Creating an _XRD_ allows the creation _composite resources_. Creating an _XRD_ allows the creation _composite resources_.
@ -665,7 +671,7 @@ NAME SYNCED READY COMPOSITION AGE
my-composite-resource True True dynamo-with-bucket 31s my-composite-resource True True dynamo-with-bucket 31s
``` ```
The output mentions the _composite_ template that the _composite resource_ used. Both `SYNCED` and `READY` are `True` when Crossplane created the AWS resources.
Now look at the S3 `bucket` and DynmoDB `table` _managed resources_ with Now look at the S3 `bucket` and DynmoDB `table` _managed resources_ with
`kubectl get bucket` and `kubectl get table`. `kubectl get bucket` and `kubectl get table`.
@ -741,12 +747,19 @@ my-second-composite-resource-nsz6j True True my-second-composite-resour
Because the _composite resource_ is the `Owner` of the _managed resources_, when Because the _composite resource_ is the `Owner` of the _managed resources_, when
Crossplane deletes the _composite resource_, it also deletes the _managed resources_ automatically. Crossplane deletes the _composite resource_, it also deletes the _managed resources_ automatically.
Delete the new _composite resource_ with `kubectl delete xdatabase`. Delete the new _composite resource_ with `kubectl delete composition`.
Delete the first composition
```shell ```shell
kubectl delete xdatabase my-second-composite-resource kubectl delete composition dynamodb-with-bucket
``` ```
And the second composition
```shell
kubectl delete composition my-second-composite-resource
```
{{<hint "note">}} {{<hint "note">}}
There may a delay in deleting the _managed resources_. Crossplane is making API There may a delay in deleting the _managed resources_. Crossplane is making API
calls to AWS and waits for AWS to confirm they deleted the resources before calls to AWS and waits for AWS to confirm they deleted the resources before
@ -792,7 +805,7 @@ Create a new namespace with `kubectl create namespace`.
kubectl create namespace test kubectl create namespace test
``` ```
A _claim_ uses the same {{<hover label="XRDclaim2" line="7" >}}group{{</hover>}} A _claim_ uses the same {{<hover label="XRDclaim2" line="6" >}}group{{</hover>}}
a _composite resource_ uses but a different a _composite resource_ uses but a different
{{<hover label="XRDclaim2" line="8" >}}kind{{</hover>}}. {{<hover label="XRDclaim2" line="8" >}}kind{{</hover>}}.
@ -844,8 +857,8 @@ NAME SYNCED READY CONNECTION-SECRET AGE
claimed-database True True 35s claimed-database True True 35s
``` ```
When Crossplane creates a _claim_ a unique _composite resource_ is automatically When Crossplane creates a _claim_, a unique _composite resource_ is also
created too. View the new _composite resource_ with `kubectl get xdatabase`. created. View the new _composite resource_ with `kubectl get xdatabase`.
```shell {copy-lines="1"} ```shell {copy-lines="1"}
kubectl get xdatabase kubectl get xdatabase
@ -882,7 +895,7 @@ test2 claimed-database True True 43s
Now look at the _composite resources_ at the cluster scope. Now look at the _composite resources_ at the cluster scope.
```shell ```shell {copy-lines="1"}
kubectl get xdatabase kubectl get xdatabase
NAME SYNCED READY COMPOSITION AGE NAME SYNCED READY COMPOSITION AGE
claimed-database-6xsgq True True dynamo-with-bucket 8m37s claimed-database-6xsgq True True dynamo-with-bucket 8m37s
@ -921,7 +934,12 @@ Verify Crossplane removed all the _managed resources_.
```shell ```shell
kubectl get bucket kubectl get bucket
No resources found
```
```shell
kubectl get table kubectl get table
No resources found
``` ```
Claims are powerful tools to give users resources in their own isolated Claims are powerful tools to give users resources in their own isolated

View File

@ -50,12 +50,14 @@ spec:
EOF EOF
``` ```
3. Create a file with your AWS keys 3. Create a file called `aws-credentials.txt` with your AWS keys
```ini {{< editCode >}}
```ini {copy-lines="all"}
[default] [default]
aws_access_key_id = <aws_access_key> aws_access_key_id = $$<aws_access_key>$$
aws_secret_access_key = <aws_secret_key> aws_secret_access_key = $$<aws_secret_key>$$
``` ```
{{</ editCode >}}
4. Create a Kubernetes secret from the AWS keys 4. Create a Kubernetes secret from the AWS keys
```shell {label="kube-create-secret",copy-lines="all"} ```shell {label="kube-create-secret",copy-lines="all"}
@ -88,7 +90,7 @@ cat <<EOF | kubectl apply -f -
apiVersion: apiextensions.crossplane.io/v1 apiVersion: apiextensions.crossplane.io/v1
kind: Composition kind: Composition
metadata: metadata:
name: dynamo-with-bucket name: dynamodb-with-bucket
spec: spec:
compositeTypeRef: compositeTypeRef:
apiVersion: custom-api.example.org/v1alpha1 apiVersion: custom-api.example.org/v1alpha1
@ -98,8 +100,6 @@ spec:
base: base:
apiVersion: s3.aws.upbound.io/v1beta1 apiVersion: s3.aws.upbound.io/v1beta1
kind: Bucket kind: Bucket
metadata:
name: crossplane-quickstart-bucket
spec: spec:
forProvider: forProvider:
region: "us-east-2" region: "us-east-2"
@ -125,12 +125,12 @@ cat <<EOF | kubectl apply -f -
apiVersion: apiextensions.crossplane.io/v1 apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition kind: CompositeResourceDefinition
metadata: metadata:
name: databases.custom-api.example.org name: xdatabases.custom-api.example.org
spec: spec:
group: custom-api.example.org group: custom-api.example.org
names: names:
kind: XDatabase kind: XDatabase
plural: databases plural: xdatabases
versions: versions:
- name: v1alpha1 - name: v1alpha1
served: true served: true
@ -168,7 +168,7 @@ _managed resources_.
The _composition_ has two _managed resources_, a The _composition_ has two _managed resources_, a
{{<hover label="compResources" line="8">}}bucket{{</hover>}} and a {{<hover label="compResources" line="8">}}bucket{{</hover>}} and a
{{<hover label="compResources" line="19">}}table{{</hover>}}. {{<hover label="compResources" line="15">}}table{{</hover>}}.
```yaml {label="compResources"} ```yaml {label="compResources"}
apiVersion: apiextensions.crossplane.io/v1 apiVersion: apiextensions.crossplane.io/v1
@ -289,7 +289,7 @@ cat <<EOF | kubectl apply -f -
apiVersion: apiextensions.crossplane.io/v1 apiVersion: apiextensions.crossplane.io/v1
kind: Composition kind: Composition
metadata: metadata:
name: dynamo-with-bucket name: dynamodb-with-bucket
spec: spec:
compositeTypeRef: compositeTypeRef:
apiVersion: custom-api.example.org/v1alpha1 apiVersion: custom-api.example.org/v1alpha1
@ -353,7 +353,7 @@ EOF
View the _claim_ with `kubectl get claim` View the _claim_ with `kubectl get claim`
```shell ```shell {copy-lines="1"}
kubectl get claim -n test kubectl get claim -n test
NAME SYNCED READY CONNECTION-SECRET AGE NAME SYNCED READY CONNECTION-SECRET AGE
claimed-eu-database True True 18m claimed-eu-database True True 18m
@ -364,7 +364,7 @@ all the _managed resources_.
Describe the `Table` resource to see the AWS region is `eu-north-1`. Describe the `Table` resource to see the AWS region is `eu-north-1`.
```shell ```shell {copy-lines="1"}
kubectl describe table | grep arn:aws kubectl describe table | grep arn:aws
Arn: arn:aws:dynamodb:eu-north-1:622343227358:table/claimed-eu-database-2sh9w-dhvw6 Arn: arn:aws:dynamodb:eu-north-1:622343227358:table/claimed-eu-database-2sh9w-dhvw6
``` ```

View File

@ -1083,11 +1083,13 @@ The [AWS documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-con
Create a text file containing the AWS account `aws_access_key_id` and `aws_secret_access_key`. Create a text file containing the AWS account `aws_access_key_id` and `aws_secret_access_key`.
{{< editCode >}}
```ini {copy-lines="all"} ```ini {copy-lines="all"}
[default] [default]
aws_access_key_id = <aws_access_key> aws_access_key_id = $$<aws_access_key>$$
aws_secret_access_key = <aws_secret_key> aws_secret_access_key = $$<aws_secret_key>$$
``` ```
{{</ editCode >}}
Save this text file as `aws-credentials.txt`. Save this text file as `aws-credentials.txt`.
@ -1187,7 +1189,7 @@ Crossplane created the bucket when the values `READY` and `SYNCED` are `True`.
This may take up to 5 minutes. This may take up to 5 minutes.
{{< /hint >}} {{< /hint >}}
```shell ```shell {copy-lines="1"}
kubectl get buckets kubectl get buckets
NAME READY SYNCED EXTERNAL-NAME AGE NAME READY SYNCED EXTERNAL-NAME AGE
crossplane-bucket-lrxrf True True crossplane-bucket-lrxrf 61s crossplane-bucket-lrxrf True True crossplane-bucket-lrxrf 61s
@ -1199,11 +1201,11 @@ Before shutting down your Kubernetes cluster, delete the S3 bucket just created.
Use `kubectl delete bucket` to remove the bucket. Use `kubectl delete bucket` to remove the bucket.
{{<hint "tip" >}} {{<hint "tip" >}}
Use the `--label` flag to delete by label instead of by name. Use `--selector` to delete a Kubernetes object by label instead of by name.
{{</hint>}} {{</hint>}}
```shell {copy-lines="1"} ```shell {copy-lines="1"}
kubectl delete bucket --label docs.crossplane.io/example=provider-aws kubectl delete bucket --selector=docs.crossplane.io/example=provider-aws
bucket.s3.aws.upbound.io "crossplane-bucket-lrxrf" deleted bucket.s3.aws.upbound.io "crossplane-bucket-lrxrf" deleted
``` ```