@@ -3,9 +3,8 @@ title: Get Started With Managed Resources
3
3
weight : 200
4
4
---
5
5
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 ) .
9
8
10
9
11
10
## Prerequisites
@@ -16,10 +15,37 @@ This quickstart requires:
16
15
* An AWS account with permissions to create an S3 storage bucket
17
16
* AWS [ access keys] ( https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds )
18
17
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
+
19
45
## Install the AWS provider
20
46
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.
23
49
24
50
``` yaml {label="provider",copy-lines="all"}
25
51
cat <<EOF | kubectl apply -f -
@@ -28,55 +54,54 @@ kind: Provider
28
54
metadata :
29
55
name : provider-aws-s3
30
56
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
32
58
EOF
33
59
```
34
60
35
61
The Crossplane {{< hover label="provider" line="3" >}}Provider{{</hover >}}
36
62
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
38
64
Kubernetes.
39
65
40
- Verify the provider installed with ` kubectl get providers ` .
66
+ Verify the provider installed with ` kubectl get providers ` .
41
67
42
68
43
69
``` shell {copy-lines="1",label="getProvider"}
44
70
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
48
74
```
49
75
50
76
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 >}}.
52
78
The family provider manages authentication to AWS across all AWS family
53
- Providers.
79
+ Providers.
54
80
55
-
56
- You can view the new CRDs with ` kubectl get crds ` .
81
+ You can view the new CRDs with ` kubectl get crds ` .
57
82
Every CRD maps to a unique AWS service Crossplane can provision and manage.
58
83
59
84
{{< hint type="tip" >}}
60
- See details about all the supported CRDs in the
85
+ See details about all the supported CRDs in the
61
86
[ provider examples] ( https://github.com/crossplane-contrib/provider-upjet-aws/tree/main/examples ) .
62
87
{{< /hint >}}
63
88
64
89
## 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.
66
91
Providers use a Kubernetes _ Secret_ to connect the credentials to the provider.
67
92
68
- Generate a Kubernetes _ Secret_ from your AWS key-pair and
93
+ Generate a Kubernetes _ Secret_ from your AWS key-pair and
69
94
then configure the Provider to use it.
70
95
71
96
### 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.
73
98
74
99
{{< 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 )
76
101
provides information on how to generate AWS Access keys.
77
102
{{< /hint >}}
78
103
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 ` .
80
105
81
106
{{< editCode >}}
82
107
``` ini {copy-lines="all"}
@@ -93,12 +118,12 @@ The [Authentication](https://docs.upbound.io/providers/provider-aws/authenticati
93
118
{{< /hint >}}
94
119
95
120
### 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.
102
127
103
128
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.
104
129
@@ -131,10 +156,10 @@ creds: 114 bytes
131
156
132
157
## Create a ProviderConfig
133
158
A {{< hover label="providerconfig" line="3">}}ProviderConfig{{</ hover >}}
134
- customizes the settings of the AWS Provider.
159
+ customizes the settings of the AWS Provider.
135
160
136
- Apply the
137
- {{< hover label="providerconfig" line="3">}}ProviderConfig{{</ hover >}}
161
+ Apply the
162
+ {{< hover label="providerconfig" line="3">}}ProviderConfig{{</ hover >}}
138
163
with the this Kubernetes configuration file:
139
164
``` yaml {label="providerconfig",copy-lines="all"}
140
165
cat <<EOF | kubectl apply -f -
@@ -152,33 +177,34 @@ spec:
152
177
EOF
153
178
```
154
179
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
156
181
{{< hover label="providerconfig" line="9">}}secretRef{{</ hover>}}.
157
182
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
161
186
{{< hover label="providerconfig" line="10">}}spec.credentials.secretRef.namespace{{< /hover >}}.
162
187
188
+ ## Create a namespace
189
+ Before we can create our namespaced S3 bucket managed resource, we must create a
190
+ namespace for it.
163
191
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
+ ```
171
195
196
+ ## Create a managed resource
172
197
{{< 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.
174
199
Any unique name is acceptable.
175
200
{{< /hint >}}
176
201
177
202
``` yaml {label="xr"}
178
203
cat <<EOF | kubectl create -f -
179
- apiVersion : s3.aws.upbound.io/v1beta1
204
+ apiVersion : s3.aws.m. upbound.io/v1beta1
180
205
kind : Bucket
181
206
metadata :
207
+ namespace : crossplane-aws-app
182
208
generateName : crossplane-bucket-
183
209
spec :
184
210
forProvider :
@@ -188,44 +214,51 @@ spec:
188
214
EOF
189
215
```
190
216
191
- The {{< hover label="xr" line="2">}}apiVersion{{< /hover >}} and
217
+ The {{< hover label="xr" line="2">}}apiVersion{{< /hover >}} and
192
218
{{< hover label="xr" line="3">}}kind{{</hover >}} are from the provider's CRDs.
193
219
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> ` .
194
223
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.
202
226
203
- The region can be any
227
+ The region can be any
204
228
[ AWS Regional endpoint] ( https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints ) code.
205
229
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.
207
231
208
232
{{< 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.
211
235
{{< /hint >}}
212
236
213
237
``` 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
217
241
```
218
242
219
243
## Delete the managed resource
220
244
Before shutting down your Kubernetes cluster, delete the S3 bucket just created.
221
245
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.
223
247
224
248
``` 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
227
251
```
228
252
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
+
229
262
## 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
231
264
Crossplane users and contributors.
0 commit comments