@@ -6,6 +6,10 @@ weight: 200
6
6
Connect Crossplane to AWS to create and manage cloud resources from Kubernetes
7
7
with [ provider-upjet-aws] ( https://github.com/crossplane-contrib/provider-upjet-aws ) .
8
8
9
+ A _ managed resource_ is anything Crossplane creates and manages outside of the
10
+ control plane.
11
+
12
+ This guide creates an AWS S3 bucket with Crossplane. The S3 bucket is a _ managed resource_ .
9
13
10
14
## Prerequisites
11
15
This quickstart requires:
@@ -15,50 +19,25 @@ This quickstart requires:
15
19
* An AWS account with permissions to create an S3 storage bucket
16
20
* AWS [ access keys] ( https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds )
17
21
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
-
45
22
## Install the AWS provider
46
-
47
23
Install the AWS S3 provider into the Kubernetes cluster with a Kubernetes
48
24
configuration file.
49
25
50
26
``` yaml {label="provider",copy-lines="all"}
51
- cat <<EOF | kubectl apply -f -
52
27
apiVersion : pkg.crossplane.io/v1
53
28
kind : Provider
54
29
metadata :
55
30
name : provider-aws-s3
56
31
spec :
57
32
package : xpkg.crossplane.io/crossplane-contrib/provider-aws-s3:v1.22.0-crossplane-v2-preview.0
58
- EOF
59
33
` ` `
60
34
61
- The Crossplane {{< hover label="provider" line="3" >}}Provider{{</hover >}}
35
+ Save this to a file called ` provider.yaml`, then apply it with:
36
+ ` ` ` shell {label="kube-apply-provider",copy-lines="all"}
37
+ kubectl apply -f provider.yaml
38
+ ` ` `
39
+
40
+ The Crossplane {{< hover label="provider" line="2" >}}Provider{{</hover>}}
62
41
installs the Kubernetes _Custom Resource Definitions_ (CRDs) representing AWS S3
63
42
services. These CRDs allow you to create AWS resources directly inside
64
43
Kubernetes.
@@ -81,7 +60,7 @@ Providers.
81
60
You can view the new CRDs with `kubectl get crds`.
82
61
Every CRD maps to a unique AWS service Crossplane can provision and manage.
83
62
84
- {{< hint type= "tip" >}}
63
+ {{< hint "tip" >}}
85
64
See details about all the supported CRDs in the
86
65
[provider examples](https://github.com/crossplane-contrib/provider-upjet-aws/tree/main/examples).
87
66
{{< /hint >}}
@@ -96,7 +75,7 @@ then configure the Provider to use it.
96
75
# ## Generate an AWS key-pair file
97
76
For basic user authentication, use an AWS Access keys key-pair file.
98
77
99
- {{< hint type= "tip" >}}
78
+ {{< hint "tip" >}}
100
79
The [AWS documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds)
101
80
provides information on how to generate AWS Access keys.
102
81
{{< /hint >}}
@@ -113,7 +92,7 @@ aws_secret_access_key = $@<aws_secret_key>$@
113
92
114
93
Save this text file as `aws-credentials.txt`.
115
94
116
- {{< hint type= "note" >}}
95
+ {{< hint "note" >}}
117
96
The [Authentication](https://docs.upbound.io/providers/provider-aws/authentication/) section of the AWS Provider documentation describes other authentication methods.
118
97
{{< /hint >}}
119
98
@@ -135,14 +114,10 @@ generic aws-secret \
135
114
` ` `
136
115
137
116
# # Create a ProviderConfig
138
- A {{< hover label="providerconfig" line="3 ">}}ProviderConfig{{</ hover >}}
139
- customizes the settings of the AWS Provider.
117
+ A {{< hover label="providerconfig" line="2 ">}}ProviderConfig{{</ hover >}}
118
+ customizes the settings of the AWS Provider :
140
119
141
- Apply the
142
- {{< hover label="providerconfig" line="3">}}ProviderConfig{{</ hover >}}
143
- with the this Kubernetes configuration file:
144
120
` ` ` yaml {label="providerconfig",copy-lines="all"}
145
- cat <<EOF | kubectl apply -f -
146
121
apiVersion: aws.upbound.io/v1beta1
147
122
kind: ProviderConfig
148
123
metadata:
@@ -154,73 +129,79 @@ spec:
154
129
namespace: crossplane-system
155
130
name: aws-secret
156
131
key: creds
157
- EOF
158
132
` ` `
159
133
160
- This attaches the AWS credentials, saved as a Kubernetes secret, as a
161
- {{< hover label="providerconfig" line="9">}}secretRef{{</ hover>}}.
162
-
163
- ## Create a namespace
164
- Before we can create our namespaced S3 bucket managed resource, we must create a
165
- namespace for it.
134
+ Save this to a file called `providerconfig.yaml`, then apply it with :
166
135
167
- ``` shell {label="kube-create-namespace ",copy-lines="all"}
168
- kubectl create namespace crossplane-aws-app
136
+ ` ` ` shell {label="kube-apply-providerconfig ",copy-lines="all"}
137
+ kubectl apply -f providerconfig.yaml
169
138
` ` `
170
139
140
+ This attaches the AWS credentials, saved as a Kubernetes secret, as a
141
+ {{< hover label="providerconfig" line="8">}}secretRef{{</ hover>}}.
142
+
171
143
# # Create a managed resource
172
- {{< hint type= "note" >}}
144
+ {{< hint "note" >}}
173
145
AWS S3 bucket names must be globally unique. To generate a unique name the example uses a random hash.
174
146
Any unique name is acceptable.
175
147
{{< /hint >}}
176
148
177
- ``` yaml {label="xr"}
178
- cat <<EOF | kubectl create -f -
149
+ ` ` ` yaml {label="bucket"}
179
150
apiVersion: s3.aws.m.upbound.io/v1beta1
180
151
kind: Bucket
181
152
metadata:
182
- namespace : crossplane-aws-app
153
+ namespace: default
183
154
generateName: crossplane-bucket-
184
155
spec:
185
156
forProvider:
186
157
region: us-east-2
187
158
providerConfigRef:
188
159
name: default
189
- EOF
190
160
` ` `
191
161
192
- The {{< hover label="xr" line="6">}}metadata.generateName{{< /hover >}} gives a
193
- pattern that the provider will use to create a unique name for the bucket in S3.
162
+ Save this to a file called `bucket.yaml`, then apply it with :
163
+
164
+ ` ` ` shell {label="kube-create-bucket",copy-lines="all"}
165
+ kubectl create -f bucket.yaml
166
+ ` ` `
167
+
168
+ The {{< hover label="bucket" line="5">}}metadata.generateName{{< /hover >}} gives a
169
+ pattern that Kubernetes will use to create a unique name for the bucket in S3.
194
170
The generated name will look like `crossplane-bucket-<hash>`.
195
171
196
- Use ` kubectl -n crossplane-aws-app get buckets.s3.aws.m.upbound.io ` to verify Crossplane created the bucket.
172
+ Use `kubectl -n default get buckets.s3.aws.m.upbound.io` to verify Crossplane created the bucket.
197
173
198
- {{< hint type= "tip" >}}
174
+ {{< hint "tip" >}}
199
175
Crossplane created the bucket when the values `READY` and `SYNCED` are `True`.
200
176
This may take up to 5 minutes.
201
177
{{< /hint >}}
202
178
203
179
` ` ` shell {copy-lines="1"}
204
- kubectl -n crossplane-aws-app get buckets.s3.aws.m.upbound.io
180
+ kubectl -n default get buckets.s3.aws.m.upbound.io
205
181
NAME SYNCED READY EXTERNAL-NAME AGE
206
182
crossplane-bucket-7tfcj True True crossplane-bucket-7tfcj 3m4s
207
183
` ` `
208
184
209
185
# # Delete the managed resource
210
- Before shutting down your Kubernetes cluster, delete the S3 bucket that was just created.
211
-
212
- Use ` kubectl -n crossplane-aws-app delete buckets.s3.aws.m.upbound.io <bucketname> ` to remove the bucket.
186
+ When you are finished with your S3 bucket, use `kubectl -n default
187
+ delete buckets.s3.aws.m.upbound.io <bucketname>` to remove the bucket.
213
188
214
189
` ` ` shell {copy-lines="1"}
215
- kubectl -n crossplane-aws-app delete buckets.s3.aws.m.upbound.io crossplane-bucket-7tfcj
190
+ kubectl -n default delete buckets.s3.aws.m.upbound.io crossplane-bucket-7tfcj
216
191
bucket.s3.aws.m.upbound.io "crossplane-bucket-7tfcj" deleted
217
192
` ` `
218
193
194
+ {{< hint "important" >}}
195
+ Make sure to delete the S3 bucket before uninstalling the provider or shutting
196
+ down your control plane. If those are no longer running, they can't clean up any
197
+ managed resources and you would need to do so manually.
198
+ {{< /hint >}}
199
+
219
200
# # Composing managed resources
220
- Crossplane v2 allows you to compose ** any type of resource** into custom APIs
221
- for your users, which includes managed resources. Enjoy the freedom that
222
- Crossplane v2 gives you to compose the diverse set of resources your
223
- applications need for their unique environments, scenarios, and requirements.
201
+ Crossplane allows you to compose **any type of resource** into custom APIs for
202
+ your users, which includes managed resources. Enjoy the freedom that Crossplane
203
+ gives you to compose the diverse set of resources your applications need for
204
+ their unique environments, scenarios, and requirements.
224
205
225
206
Follow [Get Started with Composition]({{<ref "../get-started/get-started-with-composition">}})
226
207
to learn more about how composition works.
0 commit comments