Skip to content

Commit 331a8c3

Browse files
committed
build: add AWSClusterStaticIdentity in example file
1 parent 5942830 commit 331a8c3

File tree

6 files changed

+74
-2
lines changed

6 files changed

+74
-2
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ To create the ClusterClass and it's Templates with this runtime extension enable
2929
kubectl apply --server-side -f examples/capi-quick-start/docker-cluster-class.yaml
3030
```
3131

32+
If creating an AWS cluster using the files in `examples/`, you will also need to create a secret with your AWS credentials:
33+
34+
```shell
35+
kubectl apply --server-side -f - <<EOF
36+
apiVersion: v1
37+
kind: Secret
38+
metadata:
39+
name: "aws-quick-start-creds"
40+
namespace: capa-system
41+
stringData:
42+
AccessKeyID: ${AWS_ACCESS_KEY_ID}
43+
SecretAccessKey: ${AWS_SECRET_ACCESS_KEY}
44+
SessionToken: ${AWS_SESSION_TOKEN}
45+
EOF
46+
```
47+
3248
To create a cluster, update `clusterConfig` variable and run:
3349

3450
```shell

examples/capi-quick-start/aws-cluster-class.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ spec:
3939
infrastructureCluster: true
4040
description: aws region to target for cluster creation
4141
name: region
42+
- definitions:
43+
- jsonPatches:
44+
- op: add
45+
path: /spec/template/spec/identityRef
46+
valueFrom:
47+
template: |
48+
kind: AWSClusterStaticIdentity
49+
name: {{ .builtin.cluster.name }}
50+
selector:
51+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
52+
kind: AWSClusterTemplate
53+
matchResources:
54+
infrastructureCluster: true
55+
description: AWSClusterStaticIdentity identityRef to use when creating the cluster
56+
name: identityRef
4257
variables:
4358
- name: region
4459
schema:

examples/capi-quick-start/aws-cluster.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,15 @@ spec:
2828
- class: default-worker
2929
name: md-0
3030
replicas: 1
31+
---
32+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
33+
kind: AWSClusterStaticIdentity
34+
metadata:
35+
labels:
36+
cluster.x-k8s.io/provider: aws
37+
name: aws-quick-start
38+
spec:
39+
allowedNamespaces:
40+
list:
41+
- default
42+
secretRef: aws-quick-start-creds
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2023 D2iQ, Inc. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
---
5+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
6+
kind: AWSClusterStaticIdentity
7+
metadata:
8+
name: "quick-start"
9+
spec:
10+
secretRef: aws-quick-start-creds
11+
allowedNamespaces:
12+
list:
13+
- "default"

hack/examples/bases/aws/kustomization.yaml.tmpl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ kind: Kustomization
66

77
resources:
88
- https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/${CAPA_VERSION}/cluster-template-simple-clusterclass.yaml
9+
- AWSClusterStaticIdentity.yaml
910

1011
namePrefix: aws-
1112

@@ -61,6 +62,21 @@ patches:
6162
matchResources:
6263
infrastructureCluster: true
6364
description: aws region to target for cluster creation
65+
- name: identityRef
66+
definitions:
67+
- jsonPatches:
68+
- op: add
69+
path: /spec/template/spec/identityRef
70+
valueFrom:
71+
template: |
72+
kind: AWSClusterStaticIdentity
73+
name: {{ .builtin.cluster.name }}
74+
selector:
75+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
76+
kind: AWSClusterTemplate
77+
matchResources:
78+
infrastructureCluster: true
79+
description: AWSClusterStaticIdentity identityRef to use when creating the cluster
6480
- op: "add"
6581
path: "/spec/variables"
6682
value:

hack/examples/sync.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ mkdir -p examples/capi-quick-start
1919
kustomize build ./hack/examples |
2020
tee >(gojq --yaml-input --yaml-output '. | select(.metadata.labels["cluster.x-k8s.io/provider"] == "docker" and .kind != "Cluster")' >examples/capi-quick-start/docker-cluster-class.yaml) \
2121
>(gojq --yaml-input --yaml-output '. | select(.metadata.labels["cluster.x-k8s.io/provider"] == "docker" and .kind == "Cluster")' >examples/capi-quick-start/docker-cluster.yaml) \
22-
>(gojq --yaml-input --yaml-output '. | select(.metadata.labels["cluster.x-k8s.io/provider"] == "aws" and .kind != "Cluster")' >examples/capi-quick-start/aws-cluster-class.yaml) \
23-
>(gojq --yaml-input --yaml-output '. | select(.metadata.labels["cluster.x-k8s.io/provider"] == "aws" and .kind == "Cluster")' >examples/capi-quick-start/aws-cluster.yaml) \
22+
>(gojq --yaml-input --yaml-output '. | select(.metadata.labels["cluster.x-k8s.io/provider"] == "aws" and ( .kind != "Cluster" and .kind != "AWSClusterStaticIdentity"))' >examples/capi-quick-start/aws-cluster-class.yaml) \
23+
>(gojq --yaml-input --yaml-output '. | select(.metadata.labels["cluster.x-k8s.io/provider"] == "aws" and ( .kind == "Cluster" or .kind == "AWSClusterStaticIdentity"))' >examples/capi-quick-start/aws-cluster.yaml) \
2424
>/dev/null

0 commit comments

Comments
 (0)