Skip to content

Commit 6a4cf06

Browse files
authored
Merge pull request #900 from jbw976/mr-go
full walkthrough for get started with managed resources guide
2 parents 4fcbeb8 + 3462331 commit 6a4cf06

File tree

1 file changed

+85
-105
lines changed

1 file changed

+85
-105
lines changed

content/v2.0-preview/get-started/get-started-with-managed-resources.md

Lines changed: 85 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ title: Get Started With Managed Resources
33
weight: 200
44
---
55

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).
98

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_.
1013

1114
## Prerequisites
1215
This quickstart requires:
@@ -17,66 +20,67 @@ This quickstart requires:
1720
* AWS [access keys](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds)
1821

1922
## 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.
2325

2426
```yaml {label="provider",copy-lines="all"}
25-
cat <<EOF | kubectl apply -f -
2627
apiVersion: pkg.crossplane.io/v1
2728
kind: Provider
2829
metadata:
2930
name: provider-aws-s3
3031
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
3338
```
3439

35-
The Crossplane {{< hover label="provider" line="3" >}}Provider{{</hover>}}
40+
The Crossplane {{< hover label="provider" line="2" >}}Provider{{</hover>}}
3641
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
3843
Kubernetes.
3944

40-
Verify the provider installed with `kubectl get providers`.
45+
Verify the provider installed with `kubectl get providers`.
4146

4247

4348
```shell {copy-lines="1",label="getProvider"}
4449
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
4853
```
4954

5055
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 >}}.
5257
The family provider manages authentication to AWS across all AWS family
53-
Providers.
58+
Providers.
5459

55-
56-
You can view the new CRDs with `kubectl get crds`.
60+
You can view the new CRDs with `kubectl get crds`.
5761
Every CRD maps to a unique AWS service Crossplane can provision and manage.
5862

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
6165
[provider examples](https://github.com/crossplane-contrib/provider-upjet-aws/tree/main/examples).
6266
{{< /hint >}}
6367

6468
## 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.
6670
Providers use a Kubernetes _Secret_ to connect the credentials to the provider.
6771

68-
Generate a Kubernetes _Secret_ from your AWS key-pair and
72+
Generate a Kubernetes _Secret_ from your AWS key-pair and
6973
then configure the Provider to use it.
7074

7175
### 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.
7377

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)
7680
provides information on how to generate AWS Access keys.
7781
{{< /hint >}}
7882

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`.
8084

8185
{{< editCode >}}
8286
```ini {copy-lines="all"}
@@ -88,17 +92,17 @@ aws_secret_access_key = $@<aws_secret_key>$@
8892

8993
Save this text file as `aws-credentials.txt`.
9094

91-
{{< hint type="note" >}}
95+
{{< hint "note" >}}
9296
The [Authentication](https://docs.upbound.io/providers/provider-aws/authentication/) section of the AWS Provider documentation describes other authentication methods.
9397
{{< /hint >}}
9498

9599
### 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.
102106

103107
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.
104108

@@ -109,35 +113,11 @@ generic aws-secret \
109113
--from-file=creds=./aws-credentials.txt
110114
```
111115

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-
132116
## 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:
135119

136-
Apply the
137-
{{< hover label="providerconfig" line="3">}}ProviderConfig{{</ hover >}}
138-
with the this Kubernetes configuration file:
139120
```yaml {label="providerconfig",copy-lines="all"}
140-
cat <<EOF | kubectl apply -f -
141121
apiVersion: aws.upbound.io/v1beta1
142122
kind: ProviderConfig
143123
metadata:
@@ -149,83 +129,83 @@ spec:
149129
namespace: crossplane-system
150130
name: aws-secret
151131
key: creds
152-
EOF
153132
```
154133

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:
157135

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+
```
162139

140+
This attaches the AWS credentials, saved as a Kubernetes secret, as a
141+
{{< hover label="providerconfig" line="8">}}secretRef{{</ hover>}}.
163142

164143
## 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.
174146
Any unique name is acceptable.
175147
{{< /hint >}}
176148

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
180151
kind: Bucket
181152
metadata:
153+
namespace: default
182154
generateName: crossplane-bucket-
183155
spec:
184156
forProvider:
185157
region: us-east-2
186158
providerConfigRef:
187159
name: default
188-
EOF
189160
```
190161

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:
199163

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+
```
202167

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>`.
205171

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.
207173

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.
211177
{{< /hint >}}
212178

213179
```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
217183
```
218184

219185
## 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.
223188

224189
```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
227192
```
228193

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+
229209
## 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
231211
Crossplane users and contributors.

0 commit comments

Comments
 (0)