@@ -3,10 +3,13 @@ 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
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_ .
10
13
11
14
## Prerequisites
12
15
This quickstart requires:
@@ -17,66 +20,67 @@ This quickstart requires:
17
20
* AWS [ access keys] ( https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds )
18
21
19
22
## Install the AWS provider
20
-
21
- Install the AWS S3 provider into the Kubernetes cluster with a Kubernetes
22
- configuration file.
23
+ Install the AWS S3 provider into the Kubernetes cluster with a Kubernetes
24
+ configuration file.
23
25
24
26
``` yaml {label="provider",copy-lines="all"}
25
- cat <<EOF | kubectl apply -f -
26
27
apiVersion : pkg.crossplane.io/v1
27
28
kind : Provider
28
29
metadata :
29
30
name : provider-aws-s3
30
31
spec :
31
- package : xpkg.crossplane.io/crossplane-contrib/provider-aws-s3:v1.21.1
32
- EOF
32
+ package : xpkg.crossplane.io/crossplane-contrib/provider-aws-s3:v1.22.0-crossplane-v2-preview.0
33
+ ` ` `
34
+
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
33
38
` ` `
34
39
35
- The Crossplane {{< hover label="provider" line="3 " >}}Provider{{</hover >}}
40
+ The Crossplane {{< hover label="provider" line="2 " >}}Provider{{</hover>}}
36
41
installs the Kubernetes _Custom Resource Definitions_ (CRDs) representing AWS S3
37
- services. These CRDs allow you to create AWS resources directly inside
42
+ services. These CRDs allow you to create AWS resources directly inside
38
43
Kubernetes.
39
44
40
- Verify the provider installed with ` kubectl get providers ` .
45
+ Verify the provider installed with `kubectl get providers`.
41
46
42
47
43
48
` ` ` shell {copy-lines="1",label="getProvider"}
44
49
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
50
+ NAME INSTALLED HEALTHY PACKAGE AGE
51
+ crossplane-contrib-provider-family-aws True True xpkg.crossplane.io/crossplane-contrib/provider-family-aws:v1.22.0-crossplane-v2-preview.0 27s
52
+ provider-aws-s3 True True xpkg.crossplane.io/crossplane-contrib/provider-aws-s3:v1.22.0-crossplane-v2-preview.0 31s
48
53
` ` `
49
54
50
55
The S3 Provider installs a second Provider, the
51
- {{<hover label =" getProvider " line =" 4 " >}}crossplane-contrib-provider-family-aws{{</hover >}}.
56
+ {{<hover label="getProvider" line="4">}}crossplane-contrib-provider-family-aws{{</hover >}}.
52
57
The family provider manages authentication to AWS across all AWS family
53
- Providers.
58
+ Providers.
54
59
55
-
56
- You can view the new CRDs with ` kubectl get crds ` .
60
+ You can view the new CRDs with `kubectl get crds`.
57
61
Every CRD maps to a unique AWS service Crossplane can provision and manage.
58
62
59
- {{< hint type= "tip" >}}
60
- See details about all the supported CRDs in the
63
+ {{< hint "tip" >}}
64
+ See details about all the supported CRDs in the
61
65
[provider examples](https://github.com/crossplane-contrib/provider-upjet-aws/tree/main/examples).
62
66
{{< /hint >}}
63
67
64
68
# # Create a Kubernetes secret for AWS
65
- The provider requires credentials to create and manage AWS resources.
69
+ The provider requires credentials to create and manage AWS resources.
66
70
Providers use a Kubernetes _Secret_ to connect the credentials to the provider.
67
71
68
- Generate a Kubernetes _ Secret_ from your AWS key-pair and
72
+ Generate a Kubernetes _Secret_ from your AWS key-pair and
69
73
then configure the Provider to use it.
70
74
71
75
# ## Generate an AWS key-pair file
72
- For basic user authentication, use an AWS Access keys key-pair file.
76
+ For basic user authentication, use an AWS Access keys key-pair file.
73
77
74
- {{< hint type= "tip" >}}
75
- The [ AWS documentation] ( https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds )
78
+ {{< hint "tip" >}}
79
+ The [AWS documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds)
76
80
provides information on how to generate AWS Access keys.
77
81
{{< /hint >}}
78
82
79
- Create a text file containing the AWS account ` aws_access_key_id ` and ` aws_secret_access_key ` .
83
+ Create a text file containing the AWS account `aws_access_key_id` and `aws_secret_access_key`.
80
84
81
85
{{< editCode >}}
82
86
` ` ` ini {copy-lines="all"}
@@ -88,17 +92,17 @@ aws_secret_access_key = $@<aws_secret_key>$@
88
92
89
93
Save this text file as `aws-credentials.txt`.
90
94
91
- {{< hint type= "note" >}}
95
+ {{< hint "note" >}}
92
96
The [Authentication](https://docs.upbound.io/providers/provider-aws/authentication/) section of the AWS Provider documentation describes other authentication methods.
93
97
{{< /hint >}}
94
98
95
99
# ## 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.
100
+ A Kubernetes generic secret has a name and contents.
101
+ Use
102
+ {{< hover label="kube-create-secret" line="1">}}kubectl create secret{{</hover >}}
103
+ to generate the secret object named
104
+ {{< hover label="kube-create-secret" line="2">}}aws-secret{{< /hover >}}
105
+ in the {{< hover label="kube-create-secret" line="3">}}crossplane-system{{</ hover >}} namespace.
102
106
103
107
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
108
@@ -109,35 +113,11 @@ generic aws-secret \
109
113
--from-file=creds=./aws-credentials.txt
110
114
` ` `
111
115
112
- View the secret with ` kubectl describe secret `
113
-
114
- {{< hint type="note" >}}
115
- The size may be larger if there are extra blank spaces in your text file.
116
- {{< /hint >}}
117
-
118
- ``` shell {copy-lines="1"}
119
- kubectl describe secret aws-secret -n crossplane-system
120
- Name: aws-secret
121
- Namespace: crossplane-system
122
- Labels: < none>
123
- Annotations: < none>
124
-
125
- Type: Opaque
126
-
127
- Data
128
- ====
129
- creds: 114 bytes
130
- ```
131
-
132
116
# # Create a ProviderConfig
133
- A {{< hover label="providerconfig" line="3 ">}}ProviderConfig{{</ hover >}}
134
- customizes the settings of the AWS Provider.
117
+ A {{< hover label="providerconfig" line="2 ">}}ProviderConfig{{</ hover >}}
118
+ customizes the settings of the AWS Provider :
135
119
136
- Apply the
137
- {{< hover label="providerconfig" line="3">}}ProviderConfig{{</ hover >}}
138
- with the this Kubernetes configuration file:
139
120
` ` ` yaml {label="providerconfig",copy-lines="all"}
140
- cat <<EOF | kubectl apply -f -
141
121
apiVersion: aws.upbound.io/v1beta1
142
122
kind: ProviderConfig
143
123
metadata:
@@ -149,83 +129,83 @@ spec:
149
129
namespace: crossplane-system
150
130
name: aws-secret
151
131
key: creds
152
- EOF
153
132
` ` `
154
133
155
- This attaches the AWS credentials, saved as a Kubernetes secret, as a
156
- {{< hover label="providerconfig" line="9">}}secretRef{{</ hover>}}.
134
+ Save this to a file called `providerconfig.yaml`, then apply it with :
157
135
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
161
- {{< hover label="providerconfig" line="10">}}spec.credentials.secretRef.namespace{{< /hover >}}.
136
+ ` ` ` shell {label="kube-apply-providerconfig",copy-lines="all"}
137
+ kubectl apply -f providerconfig.yaml
138
+ ` ` `
162
139
140
+ This attaches the AWS credentials, saved as a Kubernetes secret, as a
141
+ {{< hover label="providerconfig" line="8">}}secretRef{{</ hover>}}.
163
142
164
143
# # 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_ .
171
-
172
- {{< hint type="note" >}}
173
- AWS S3 bucket names must be globally unique. To generate a unique name the example uses a random hash.
144
+ {{< hint "note" >}}
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 -
179
- apiVersion : s3.aws.upbound.io/v1beta1
149
+ ` ` ` yaml {label="bucket"}
150
+ apiVersion: s3.aws.m.upbound.io/v1beta1
180
151
kind: Bucket
181
152
metadata:
153
+ namespace: default
182
154
generateName: crossplane-bucket-
183
155
spec:
184
156
forProvider:
185
157
region: us-east-2
186
158
providerConfigRef:
187
159
name: default
188
- EOF
189
160
` ` `
190
161
191
- The {{< hover label="xr" line="2">}}apiVersion{{< /hover >}} and
192
- {{< hover label="xr" line="3">}}kind{{</hover >}} are from the provider's CRDs.
193
-
194
-
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.
162
+ Save this to a file called `bucket.yaml`, then apply it with :
199
163
200
- The {{< hover label="xr" line="8">}}spec.forProvider.region{{< /hover >}} tells
201
- AWS which AWS region to use when deploying resources.
164
+ ` ` ` shell {label="kube-create-bucket",copy-lines="all"}
165
+ kubectl create -f bucket.yaml
166
+ ` ` `
202
167
203
- The region can be any
204
- [ AWS Regional endpoint] ( https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints ) code.
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.
170
+ The generated name will look like `crossplane-bucket-<hash>`.
205
171
206
- Use ` kubectl get buckets ` to verify Crossplane created the bucket.
172
+ Use `kubectl -n default get buckets.s3.aws.m.upbound.io ` to verify Crossplane created the bucket.
207
173
208
- {{< hint type= "tip" >}}
209
- Crossplane created the bucket when the values ` READY ` and ` SYNCED ` are ` True ` .
210
- This may take up to 5 minutes.
174
+ {{< hint "tip" >}}
175
+ Crossplane created the bucket when the values `READY` and `SYNCED` are `True`.
176
+ This may take up to 5 minutes.
211
177
{{< /hint >}}
212
178
213
179
` ` ` 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
180
+ kubectl -n default get buckets.s3.aws.m.upbound.io
181
+ NAME SYNCED READY EXTERNAL-NAME AGE
182
+ crossplane-bucket-7tfcj True True crossplane-bucket-7tfcj 3m4s
217
183
` ` `
218
184
219
185
# # Delete the managed resource
220
- Before shutting down your Kubernetes cluster, delete the S3 bucket just created.
221
-
222
- Use ` kubectl delete bucket <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.
223
188
224
189
` ` ` shell {copy-lines="1"}
225
- kubectl delete bucket crossplane-bucket-hhdzh
226
- bucket.s3.aws.upbound.io " crossplane-bucket-hhdzh " deleted
190
+ kubectl -n default delete buckets.s3.aws.m.upbound.io crossplane-bucket-7tfcj
191
+ bucket.s3.aws.m. upbound.io "crossplane-bucket-7tfcj " deleted
227
192
` ` `
228
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
+
200
+ # # Composing managed resources
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.
205
+
206
+ Follow [Get Started with Composition]({{<ref "../get-started/get-started-with-composition">}})
207
+ to learn more about how composition works.
208
+
229
209
# # Next steps
230
- * Join the [ Crossplane Slack] ( https://slack.crossplane.io/ ) and connect with
210
+ * Join the [Crossplane Slack](https://slack.crossplane.io/) and connect with
231
211
Crossplane users and contributors.
0 commit comments