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