11---
22title : Get Started With Managed Resources
3- weight : 200
3+ weight : 300
44---
55
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.
89
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.
1112
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>}}
1329
1430## Prerequisites
15- This quickstart requires:
31+
32+ This guide requires:
1633
1734* A Kubernetes cluster with at least 2 GB of RAM
1835* The Crossplane v2 preview [installed on the Kubernetes cluster]({{<ref "install">}})
1936* An AWS account with permissions to create an S3 storage bucket
2037* AWS [access keys](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds)
2138
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 :
2556
2657` ` ` yaml {label="provider",copy-lines="all"}
2758apiVersion: pkg.crossplane.io/v1
2859kind: Provider
2960metadata:
30- name : provider-aws-s3
61+ name: crossplane-contrib- provider-aws-s3
3162spec:
3263 package: xpkg.crossplane.io/crossplane-contrib/provider-aws-s3:v1.22.0-crossplane-v2-preview.0
3364` ` `
3465
35- Save this to a file called ` provider.yaml`, then apply it with:
66+ Save this as `provider.yaml` and apply it :
67+
3668` ` ` shell {label="kube-apply-provider",copy-lines="all"}
3769kubectl apply -f provider.yaml
3870` ` `
3971
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 :
4773
4874` ` ` shell {copy-lines="1",label="getProvider"}
4975kubectl get providers
5076NAME INSTALLED HEALTHY PACKAGE AGE
5177crossplane-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
5379` ` `
5480
55- The S3 Provider installs a second Provider, the
81+ {{<hint "note">}}
82+ The S3 provider installs a second provider, the
5683{{<hover label="getProvider" line="4">}}crossplane-contrib-provider-family-aws{{</hover >}}.
5784The 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>}}
6287
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).
6792
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
7194
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 .
7497
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.
7799
78- {{< hint "tip" >}}
100+ {{<hint "tip">}}
79101The [AWS documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds)
80102provides information on how to generate AWS Access keys.
81- {{< /hint >}}
103+ {{</hint>}}
82104
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` :
84107
85108{{< editCode >}}
86109` ` ` ini {copy-lines="all"}
@@ -90,32 +113,36 @@ aws_secret_access_key = $@<aws_secret_key>$@
90113` ` `
91114{{< /editCode >}}
92115
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`.
98117
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>}}
106122
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:
108124
109125` ` ` 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
114129` ` `
115130
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 :
119146
120147` ` ` yaml {label="providerconfig",copy-lines="all"}
121148apiVersion: aws.upbound.io/v1beta1
@@ -131,20 +158,21 @@ spec:
131158 key: creds
132159` ` `
133160
134- Save this to a file called `providerconfig.yaml`, then apply it with :
161+ Save the provider configuration as `providerconfig.yaml` and apply it :
135162
136163` ` ` shell {label="kube-apply-providerconfig",copy-lines="all"}
137164kubectl apply -f providerconfig.yaml
138165` ` `
139166
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) .
142169
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>}}
148176
149177` ` ` yaml {label="bucket"}
150178apiVersion: s3.aws.m.upbound.io/v1beta1
@@ -155,57 +183,48 @@ metadata:
155183spec:
156184 forProvider:
157185 region: us-east-2
158- providerConfigRef:
159- name: default
160186` ` `
161187
162- Save this to a file called `bucket.yaml`, then apply it with :
188+ Save the bucket to `bucket.yaml` and apply it :
163189
164190` ` ` shell {label="kube-create-bucket",copy-lines="all"}
165191kubectl create -f bucket.yaml
166192` ` `
167193
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 :
178195
179196` ` ` shell {copy-lines="1"}
180- kubectl -n default get buckets.s3.aws.m.upbound.io
197+ kubectl get buckets.s3.aws.m.upbound.io
181198NAME SYNCED READY EXTERNAL-NAME AGE
182199crossplane-bucket-7tfcj True True crossplane-bucket-7tfcj 3m4s
183200` ` `
184201
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 :
188207
189208` ` ` 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
191210bucket.s3.aws.m.upbound.io "crossplane-bucket-7tfcj" deleted
192211` ` `
193212
194- {{< hint "important" >}}
213+ When you delete the bucket managed resource, Crossplane deletes the S3 bucket
214+ from AWS.
215+
216+ {{<hint "important">}}
195217Make sure to delete the S3 bucket before uninstalling the provider or shutting
196218down your control plane. If those are no longer running, they can't clean up any
197219managed resources and you would need to do so manually.
198- {{< /hint >}}
220+ {{</hint>}}
199221
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
202225your users, which includes managed resources. Enjoy the freedom that Crossplane
203226gives you to compose the diverse set of resources your applications need for
204227their unique environments, scenarios, and requirements.
205228
206229Follow [Get Started with Composition]({{<ref "../get-started/get-started-with-composition">}})
207230to 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