Skip to content

Commit 0fd8146

Browse files
committed
full walkthrough for get started with managed resources guide
Signed-off-by: Jared Watts <[email protected]>
1 parent 4fcbeb8 commit 0fd8146

File tree

1 file changed

+95
-62
lines changed

1 file changed

+95
-62
lines changed

content/v2.0-preview/get-started/get-started-with-managed-resources.md

Lines changed: 95 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ title: Get Started With Managed Resources
33
weight: 200
44
---
55

6-
Connect Crossplane to AWS to create and manage cloud resources from Kubernetes
7-
with
8-
[provider-upjet-aws](https://github.com/crossplane-contrib/provider-upjet-aws).
6+
Connect Crossplane to AWS to create and manage cloud resources from Kubernetes
7+
with [provider-upjet-aws](https://github.com/crossplane-contrib/provider-upjet-aws).
98

109

1110
## Prerequisites
@@ -16,10 +15,37 @@ This quickstart requires:
1615
* An AWS account with permissions to create an S3 storage bucket
1716
* AWS [access keys](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds)
1817

18+
## About Managed Resources in Crossplane v2
19+
A _managed resource_ is anything Crossplane creates and manages outside of the
20+
Kubernetes cluster.
21+
22+
This guide creates an AWS S3 bucket with Crossplane.
23+
24+
The S3 bucket is a _managed resource_.
25+
26+
Crossplane v2 allows you to compose namespaced resources. To better support this
27+
new ability, managed resources (MRs) are now namespaced in Providers that have
28+
been updated for Crossplane v2.
29+
30+
To support backwards compatibility while users are adopting Crossplane v2, each
31+
provider will offer the legacy cluster scoped MRs in addition to the new
32+
namespaced MRs.
33+
34+
For example, when the AWS provider that has been upated to support Crossplane v2
35+
is installed during this guide, you will see two CRDs for each type of managed
36+
resource:
37+
38+
1. A legacy cluster scoped MR in the `*.aws.upbound.io` API group
39+
1. A namespaced MR in the `*.aws.m.upbound.io` API group
40+
41+
{{< hint type="tip" >}}
42+
More about namespaced managed resources can be read in the [Crossplane v2 proposal](https://github.com/crossplane/crossplane/pull/6255).
43+
{{< /hint >}}
44+
1945
## Install the AWS provider
2046

21-
Install the AWS S3 provider into the Kubernetes cluster with a Kubernetes
22-
configuration file.
47+
Install the AWS S3 provider into the Kubernetes cluster with a Kubernetes
48+
configuration file.
2349

2450
```yaml {label="provider",copy-lines="all"}
2551
cat <<EOF | kubectl apply -f -
@@ -28,55 +54,54 @@ kind: Provider
2854
metadata:
2955
name: provider-aws-s3
3056
spec:
31-
package: xpkg.crossplane.io/crossplane-contrib/provider-aws-s3:v1.21.1
57+
package: xpkg.crossplane.io/crossplane-contrib/provider-aws-s3:v1.22.0-crossplane-v2-preview.0
3258
EOF
3359
```
3460

3561
The Crossplane {{< hover label="provider" line="3" >}}Provider{{</hover>}}
3662
installs the Kubernetes _Custom Resource Definitions_ (CRDs) representing AWS S3
37-
services. These CRDs allow you to create AWS resources directly inside
63+
services. These CRDs allow you to create AWS resources directly inside
3864
Kubernetes.
3965

40-
Verify the provider installed with `kubectl get providers`.
66+
Verify the provider installed with `kubectl get providers`.
4167

4268

4369
```shell {copy-lines="1",label="getProvider"}
4470
kubectl get providers
45-
NAME INSTALLED HEALTHY PACKAGE AGE
46-
crossplane-contrib-provider-family-aws True True xpkg.crossplane.io/crossplane-contrib/provider-family-aws:v1.21.1 30s
47-
provider-aws-s3 True True xpkg.crossplane.io/crossplane-contrib/provider-aws-s3:v1.21.1 34s
71+
NAME INSTALLED HEALTHY PACKAGE AGE
72+
crossplane-contrib-provider-family-aws True True xpkg.crossplane.io/crossplane-contrib/provider-family-aws:v1.22.0-crossplane-v2-preview.0 27s
73+
provider-aws-s3 True True xpkg.crossplane.io/crossplane-contrib/provider-aws-s3:v1.22.0-crossplane-v2-preview.0 31s
4874
```
4975

5076
The S3 Provider installs a second Provider, the
51-
{{<hover label="getProvider" line="4">}}crossplane-contrib-provider-family-aws{{</hover >}}.
77+
{{<hover label="getProvider" line="4">}}crossplane-contrib-provider-family-aws{{</hover >}}.
5278
The family provider manages authentication to AWS across all AWS family
53-
Providers.
79+
Providers.
5480

55-
56-
You can view the new CRDs with `kubectl get crds`.
81+
You can view the new CRDs with `kubectl get crds`.
5782
Every CRD maps to a unique AWS service Crossplane can provision and manage.
5883

5984
{{< hint type="tip" >}}
60-
See details about all the supported CRDs in the
85+
See details about all the supported CRDs in the
6186
[provider examples](https://github.com/crossplane-contrib/provider-upjet-aws/tree/main/examples).
6287
{{< /hint >}}
6388

6489
## Create a Kubernetes secret for AWS
65-
The provider requires credentials to create and manage AWS resources.
90+
The provider requires credentials to create and manage AWS resources.
6691
Providers use a Kubernetes _Secret_ to connect the credentials to the provider.
6792

68-
Generate a Kubernetes _Secret_ from your AWS key-pair and
93+
Generate a Kubernetes _Secret_ from your AWS key-pair and
6994
then configure the Provider to use it.
7095

7196
### Generate an AWS key-pair file
72-
For basic user authentication, use an AWS Access keys key-pair file.
97+
For basic user authentication, use an AWS Access keys key-pair file.
7398

7499
{{< hint type="tip" >}}
75-
The [AWS documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds)
100+
The [AWS documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds)
76101
provides information on how to generate AWS Access keys.
77102
{{< /hint >}}
78103

79-
Create a text file containing the AWS account `aws_access_key_id` and `aws_secret_access_key`.
104+
Create a text file containing the AWS account `aws_access_key_id` and `aws_secret_access_key`.
80105

81106
{{< editCode >}}
82107
```ini {copy-lines="all"}
@@ -93,12 +118,12 @@ The [Authentication](https://docs.upbound.io/providers/provider-aws/authenticati
93118
{{< /hint >}}
94119

95120
### Create a Kubernetes secret with the AWS credentials
96-
A Kubernetes generic secret has a name and contents.
97-
Use
98-
{{< hover label="kube-create-secret" line="1">}}kubectl create secret{{</hover >}}
99-
to generate the secret object named
100-
{{< hover label="kube-create-secret" line="2">}}aws-secret{{< /hover >}}
101-
in the {{< hover label="kube-create-secret" line="3">}}crossplane-system{{</ hover >}} namespace.
121+
A Kubernetes generic secret has a name and contents.
122+
Use
123+
{{< hover label="kube-create-secret" line="1">}}kubectl create secret{{</hover >}}
124+
to generate the secret object named
125+
{{< hover label="kube-create-secret" line="2">}}aws-secret{{< /hover >}}
126+
in the {{< hover label="kube-create-secret" line="3">}}crossplane-system{{</ hover >}} namespace.
102127

103128
Use the {{< hover label="kube-create-secret" line="4">}}--from-file={{</hover>}} argument to set the value to the contents of the {{< hover label="kube-create-secret" line="4">}}aws-credentials.txt{{< /hover >}} file.
104129

@@ -131,10 +156,10 @@ creds: 114 bytes
131156

132157
## Create a ProviderConfig
133158
A {{< hover label="providerconfig" line="3">}}ProviderConfig{{</ hover >}}
134-
customizes the settings of the AWS Provider.
159+
customizes the settings of the AWS Provider.
135160

136-
Apply the
137-
{{< hover label="providerconfig" line="3">}}ProviderConfig{{</ hover >}}
161+
Apply the
162+
{{< hover label="providerconfig" line="3">}}ProviderConfig{{</ hover >}}
138163
with the this Kubernetes configuration file:
139164
```yaml {label="providerconfig",copy-lines="all"}
140165
cat <<EOF | kubectl apply -f -
@@ -152,33 +177,34 @@ spec:
152177
EOF
153178
```
154179

155-
This attaches the AWS credentials, saved as a Kubernetes secret, as a
180+
This attaches the AWS credentials, saved as a Kubernetes secret, as a
156181
{{< hover label="providerconfig" line="9">}}secretRef{{</ hover>}}.
157182

158-
The
159-
{{< hover label="providerconfig" line="11">}}spec.credentials.secretRef.name{{< /hover >}}
160-
value is the name of the Kubernetes secret containing the AWS credentials in the
183+
The
184+
{{< hover label="providerconfig" line="11">}}spec.credentials.secretRef.name{{< /hover >}}
185+
value is the name of the Kubernetes secret containing the AWS credentials in the
161186
{{< hover label="providerconfig" line="10">}}spec.credentials.secretRef.namespace{{< /hover >}}.
162187

188+
## Create a namespace
189+
Before we can create our namespaced S3 bucket managed resource, we must create a
190+
namespace for it.
163191

164-
## Create a managed resource
165-
A _managed resource_ is anything Crossplane creates and manages outside of the
166-
Kubernetes cluster.
167-
168-
This guide creates an AWS S3 bucket with Crossplane.
169-
170-
The S3 bucket is a _managed resource_.
192+
```shell {label="kube-create-namespace",copy-lines="all"}
193+
kubectl create namespace crossplane-aws-app
194+
```
171195

196+
## Create a managed resource
172197
{{< hint type="note" >}}
173-
AWS S3 bucket names must be globally unique. To generate a unique name the example uses a random hash.
198+
AWS S3 bucket names must be globally unique. To generate a unique name the example uses a random hash.
174199
Any unique name is acceptable.
175200
{{< /hint >}}
176201

177202
```yaml {label="xr"}
178203
cat <<EOF | kubectl create -f -
179-
apiVersion: s3.aws.upbound.io/v1beta1
204+
apiVersion: s3.aws.m.upbound.io/v1beta1
180205
kind: Bucket
181206
metadata:
207+
namespace: crossplane-aws-app
182208
generateName: crossplane-bucket-
183209
spec:
184210
forProvider:
@@ -188,44 +214,51 @@ spec:
188214
EOF
189215
```
190216

191-
The {{< hover label="xr" line="2">}}apiVersion{{< /hover >}} and
217+
The {{< hover label="xr" line="2">}}apiVersion{{< /hover >}} and
192218
{{< hover label="xr" line="3">}}kind{{</hover >}} are from the provider's CRDs.
193219

220+
The {{< hover label="xr" line="6">}}metadata.generateName{{< /hover >}} gives a
221+
pattern that the provider will use to create a unique name for the bucket in S3.
222+
The generated name will look like `crossplane-bucket-<hash>`.
194223

195-
The {{< hover label="xr" line="5">}}metadata.generateName{{< /hover >}} value is the
196-
name of the created S3 bucket in AWS.
197-
This example uses the generated name `crossplane-bucket-<hash>` in the
198-
{{< hover label="xr" line="5">}}$bucket{{</hover >}} variable.
199-
200-
The {{< hover label="xr" line="8">}}spec.forProvider.region{{< /hover >}} tells
201-
AWS which AWS region to use when deploying resources.
224+
The {{< hover label="xr" line="9">}}spec.forProvider.region{{< /hover >}} tells
225+
AWS which AWS region to use when deploying resources.
202226

203-
The region can be any
227+
The region can be any
204228
[AWS Regional endpoint](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints) code.
205229

206-
Use `kubectl get buckets` to verify Crossplane created the bucket.
230+
Use `kubectl -n crossplane-aws-app get buckets.s3.aws.m.upbound.io` to verify Crossplane created the bucket.
207231

208232
{{< hint type="tip" >}}
209-
Crossplane created the bucket when the values `READY` and `SYNCED` are `True`.
210-
This may take up to 5 minutes.
233+
Crossplane created the bucket when the values `READY` and `SYNCED` are `True`.
234+
This may take up to 5 minutes.
211235
{{< /hint >}}
212236

213237
```shell {copy-lines="1"}
214-
kubectl get buckets
215-
NAME READY SYNCED EXTERNAL-NAME AGE
216-
crossplane-bucket-hhdzh True True crossplane-bucket-hhdzh 5s
238+
kubectl -n crossplane-aws-app get buckets.s3.aws.m.upbound.io
239+
NAME SYNCED READY EXTERNAL-NAME AGE
240+
crossplane-bucket-7tfcj True True crossplane-bucket-7tfcj 3m4s
217241
```
218242

219243
## Delete the managed resource
220244
Before shutting down your Kubernetes cluster, delete the S3 bucket just created.
221245

222-
Use `kubectl delete bucket <bucketname>` to remove the bucket.
246+
Use `kubectl -n crossplane-aws-app delete buckets.s3.aws.m.upbound.io <bucketname>` to remove the bucket.
223247

224248
```shell {copy-lines="1"}
225-
kubectl delete bucket crossplane-bucket-hhdzh
226-
bucket.s3.aws.upbound.io "crossplane-bucket-hhdzh" deleted
249+
kubectl -n crossplane-aws-app delete buckets.s3.aws.m.upbound.io crossplane-bucket-7tfcj
250+
bucket.s3.aws.m.upbound.io "crossplane-bucket-7tfcj" deleted
227251
```
228252

253+
## Composing managed resources
254+
Crossplane v2 allows you to compose **any type of resource** into custom APIs
255+
for your users, which includes managed resources. Enjoy the freedom that
256+
Crossplane v2 gives you to compose the diverse set of resources your
257+
applications need for their unique environments, scenarios, and requirements.
258+
259+
Follow [Get Started with Composition]({{<ref "../get-started/get-started-with-composition">}})
260+
to learn more about how composition works.
261+
229262
## Next steps
230-
* Join the [Crossplane Slack](https://slack.crossplane.io/) and connect with
263+
* Join the [Crossplane Slack](https://slack.crossplane.io/) and connect with
231264
Crossplane users and contributors.

0 commit comments

Comments
 (0)