Skip to content

Commit 2be6a11

Browse files
committed
build: Add AWS clusterclass example
1 parent eba58b0 commit 2be6a11

14 files changed

+334
-71
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,45 +26,45 @@ make SKIP_BUILD=true dev.run-on-kind
2626
To create the ClusterClass and it's Templates with this runtime extension enabled, run:
2727

2828
```shell
29-
kubectl apply --server-side -f examples/capi-quick-start/capd-cluster-class.yaml
29+
kubectl apply --server-side -f examples/capi-quick-start/docker-cluster-class.yaml
3030
```
3131

3232
To create a cluster, update `clusterConfig` variable and run:
3333

3434
```shell
35-
kubectl apply --server-side -f examples/capi-quick-start/capd-cluster.yaml
35+
kubectl apply --server-side -f examples/capi-quick-start/docker-cluster.yaml
3636
```
3737

3838
Wait until control plane is ready:
3939

4040
```shell
41-
kubectl wait clusters/capd-quick-start --for=condition=ControlPlaneInitialized --timeout=5m
41+
kubectl wait clusters/docker-quick-start --for=condition=ControlPlaneInitialized --timeout=5m
4242
```
4343

4444
To get the kubeconfig for the new cluster, run:
4545

4646
```shell
47-
clusterctl get kubeconfig capd-quick-start > capd-kubeconfig
47+
clusterctl get kubeconfig docker-quick-start > docker-kubeconfig
4848
```
4949

5050
If you are not on Linux, you will also need to fix the generated kubeconfig's `server`, run:
5151

5252
```shell
53-
kubectl config set-cluster capd-quick-start \
54-
--kubeconfig capd-kubeconfig \
55-
--server=https://$(docker port capd-quick-start-lb 6443/tcp)
53+
kubectl config set-cluster docker-quick-start \
54+
--kubeconfig docker-kubeconfig \
55+
--server=https://$(docker port docker-quick-start-lb 6443/tcp)
5656
```
5757

5858
Wait until all nodes are ready (this indicates that CNI has been deployed successfully):
5959

6060
```shell
61-
kubectl --kubeconfig capd-kubeconfig wait nodes --all --for=condition=Ready --timeout=5m
61+
kubectl --kubeconfig docker-kubeconfig wait nodes --all --for=condition=Ready --timeout=5m
6262
```
6363

6464
Show that Calico is running successfully on the workload cluster:
6565

6666
```shell
67-
kubectl --kubeconfig capd-kubeconfig get daemonsets -n calico-system
67+
kubectl --kubeconfig docker-kubeconfig get daemonsets -n calico-system
6868
```
6969

7070
Deploy kube-vip to provide service load-balancer:
@@ -78,29 +78,29 @@ kubectl create configmap \
7878
--namespace kube-system kubevip \
7979
--from-literal "range-global=${kind_subnet_prefix}100.0-${kind_subnet_prefix}100.20" \
8080
--dry-run=client -oyaml |
81-
kubectl --kubeconfig capd-kubeconfig apply --server-side -n kube-system -f -
81+
kubectl --kubeconfig docker-kubeconfig apply --server-side -n kube-system -f -
8282

8383
helm upgrade kube-vip-cloud-provider kube-vip/kube-vip-cloud-provider --version 0.2.2 \
8484
--install \
8585
--wait --wait-for-jobs \
8686
--namespace kube-system \
87-
--kubeconfig capd-kubeconfig \
87+
--kubeconfig docker-kubeconfig \
8888
--set-string=image.tag=v0.0.6
8989

9090
helm upgrade kube-vip kube-vip/kube-vip --version 0.4.2 \
9191
--install \
9292
--wait --wait-for-jobs \
9393
--namespace kube-system \
94-
--kubeconfig capd-kubeconfig \
94+
--kubeconfig docker-kubeconfig \
9595
--set-string=image.tag=v0.6.0
9696
```
9797

9898
Deploy traefik as a LB service:
9999

100100
```shell
101-
helm --kubeconfig capd-kubeconfig repo add traefik https://helm.traefik.io/traefik
101+
helm --kubeconfig docker-kubeconfig repo add traefik https://helm.traefik.io/traefik
102102
helm repo update &>/dev/null
103-
helm --kubeconfig capd-kubeconfig upgrade --install traefik traefik/traefik \
103+
helm --kubeconfig docker-kubeconfig upgrade --install traefik traefik/traefik \
104104
--version v10.9.1 \
105105
--wait --wait-for-jobs \
106106
--set ports.web.hostPort=80 \
@@ -111,13 +111,13 @@ helm --kubeconfig capd-kubeconfig upgrade --install traefik traefik/traefik \
111111
Watch for traefik LB service to get an external address:
112112

113113
```shell
114-
watch -n 0.5 kubectl --kubeconfig capd-kubeconfig get service/traefik
114+
watch -n 0.5 kubectl --kubeconfig docker-kubeconfig get service/traefik
115115
```
116116

117117
To delete the workload cluster, run:
118118

119119
```shell
120-
kubectl delete cluster capd-quick-start
120+
kubectl delete cluster docker-quick-start
121121
```
122122

123123
Notice that the traefik service is deleted before the cluster is actually finally deleted.

devbox.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"actionlint@latest",
44
55
"clusterctl@latest",
6+
"coreutils@latest",
67
"crane@latest",
78
"envsubst@latest",
89
"findutils@latest",

devbox.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
"source": "devbox-search",
2020
"version": "1.5.1"
2121
},
22+
"coreutils@latest": {
23+
"last_modified": "2023-09-17T10:54:49Z",
24+
"resolved": "github:NixOS/nixpkgs/5148520bfab61f99fd25fb9ff7bfbb50dad3c9db#coreutils",
25+
"source": "devbox-search",
26+
"version": "9.3"
27+
},
2228
"crane@latest": {
2329
"last_modified": "2023-08-08T03:07:33Z",
2430
"resolved": "github:NixOS/nixpkgs/844ffa82bbe2a2779c86ab3a72ff1b4176cec467#crane",
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Copyright 2023 D2iQ, Inc. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: cluster.x-k8s.io/v1beta1
5+
kind: ClusterClass
6+
metadata:
7+
labels:
8+
cluster.x-k8s.io/provider: aws
9+
name: aws-quick-start
10+
spec:
11+
controlPlane:
12+
machineInfrastructure:
13+
ref:
14+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
15+
kind: AWSMachineTemplate
16+
name: aws-quick-start-control-plane
17+
ref:
18+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
19+
kind: KubeadmControlPlaneTemplate
20+
name: aws-quick-start-control-plane
21+
infrastructure:
22+
ref:
23+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
24+
kind: AWSClusterTemplate
25+
name: aws-quick-start
26+
patches:
27+
- external:
28+
discoverVariablesExtension: clusterconfigvars.capi-runtime-extensions
29+
generateExtension: clusterconfigpatch.capi-runtime-extensions
30+
name: cluster-config
31+
workers:
32+
machineDeployments:
33+
- class: default-worker
34+
template:
35+
bootstrap:
36+
ref:
37+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
38+
kind: KubeadmConfigTemplate
39+
name: aws-quick-start-worker-bootstraptemplate
40+
infrastructure:
41+
ref:
42+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
43+
kind: AWSMachineTemplate
44+
name: aws-quick-start-worker-machinetemplate
45+
---
46+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
47+
kind: AWSClusterTemplate
48+
metadata:
49+
labels:
50+
cluster.x-k8s.io/provider: aws
51+
name: aws-quick-start
52+
spec:
53+
template:
54+
spec: {}
55+
---
56+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
57+
kind: KubeadmControlPlaneTemplate
58+
metadata:
59+
labels:
60+
cluster.x-k8s.io/provider: aws
61+
name: aws-quick-start-control-plane
62+
spec:
63+
template:
64+
spec:
65+
kubeadmConfigSpec:
66+
clusterConfiguration:
67+
apiServer:
68+
extraArgs:
69+
cloud-provider: aws
70+
controllerManager:
71+
extraArgs:
72+
cloud-provider: aws
73+
initConfiguration:
74+
nodeRegistration:
75+
kubeletExtraArgs:
76+
cloud-provider: aws
77+
name: '{{ ds.meta_data.local_hostname }}'
78+
joinConfiguration:
79+
nodeRegistration:
80+
kubeletExtraArgs:
81+
cloud-provider: aws
82+
name: '{{ ds.meta_data.local_hostname }}'
83+
---
84+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
85+
kind: AWSMachineTemplate
86+
metadata:
87+
labels:
88+
cluster.x-k8s.io/provider: aws
89+
name: aws-quick-start-control-plane
90+
spec:
91+
template:
92+
spec:
93+
iamInstanceProfile: control-plane.cluster-api-provider-aws.sigs.k8s.io
94+
instanceType: m5.xlarge
95+
---
96+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
97+
kind: AWSMachineTemplate
98+
metadata:
99+
labels:
100+
cluster.x-k8s.io/provider: aws
101+
name: aws-quick-start-worker-machinetemplate
102+
spec:
103+
template:
104+
spec:
105+
iamInstanceProfile: nodes.cluster-api-provider-aws.sigs.k8s.io
106+
instanceType: m5.2xlarge
107+
---
108+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
109+
kind: KubeadmConfigTemplate
110+
metadata:
111+
labels:
112+
cluster.x-k8s.io/provider: aws
113+
name: aws-quick-start-worker-bootstraptemplate
114+
spec:
115+
template:
116+
spec:
117+
joinConfiguration:
118+
nodeRegistration:
119+
kubeletExtraArgs:
120+
cloud-provider: aws
121+
name: '{{ ds.meta_data.local_hostname }}'

examples/capi-quick-start/capd-cluster.yaml renamed to examples/capi-quick-start/aws-cluster.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
apiVersion: cluster.x-k8s.io/v1beta1
55
kind: Cluster
66
metadata:
7-
name: capd-quick-start
7+
labels:
8+
cluster.x-k8s.io/provider: aws
9+
name: aws-quick-start
810
spec:
911
clusterNetwork:
1012
pods:
@@ -15,9 +17,8 @@ spec:
1517
cidrBlocks:
1618
- 10.128.0.0/12
1719
topology:
18-
class: capd-quick-start
20+
class: aws-quick-start
1921
controlPlane:
20-
metadata: {}
2122
replicas: 1
2223
variables:
2324
- name: clusterConfig

examples/capi-quick-start/capd-cluster-class.yaml renamed to examples/capi-quick-start/docker-cluster-class.yaml

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,30 @@
44
apiVersion: cluster.x-k8s.io/v1beta1
55
kind: ClusterClass
66
metadata:
7-
name: capd-quick-start
7+
labels:
8+
cluster.x-k8s.io/provider: docker
9+
name: docker-quick-start
810
spec:
911
controlPlane:
1012
machineInfrastructure:
1113
ref:
1214
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
1315
kind: DockerMachineTemplate
14-
name: capd-quick-start-control-plane
16+
name: aws-quick-start-control-plane
1517
ref:
1618
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
1719
kind: KubeadmControlPlaneTemplate
18-
name: capd-quick-start-control-plane
20+
name: docker-quick-start-control-plane
1921
infrastructure:
2022
ref:
2123
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
2224
kind: DockerClusterTemplate
23-
name: capd-quick-start-cluster
25+
name: docker-quick-start-cluster
2426
patches:
2527
- external:
2628
discoverVariablesExtension: clusterconfigvars.capi-runtime-extensions
2729
generateExtension: clusterconfigpatch.capi-runtime-extensions
2830
name: cluster-config
29-
- definitions:
30-
- jsonPatches:
31-
- op: add
32-
path: /spec/template/spec/customImage
33-
valueFrom:
34-
template: ghcr.io/mesosphere/kind-node:{{ .builtin.machineDeployment.version }}
35-
selector:
36-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
37-
kind: DockerMachineTemplate
38-
matchResources:
39-
machineDeploymentClass:
40-
names:
41-
- '*'
42-
- jsonPatches:
43-
- op: add
44-
path: /spec/template/spec/customImage
45-
valueFrom:
46-
template: ghcr.io/mesosphere/kind-node:{{ .builtin.controlPlane.version }}
47-
selector:
48-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
49-
kind: DockerMachineTemplate
50-
matchResources:
51-
controlPlane: true
52-
name: customKinDNodeImageForWorkers
5331
workers:
5432
machineDeployments:
5533
- class: default-worker
@@ -58,25 +36,29 @@ spec:
5836
ref:
5937
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
6038
kind: KubeadmConfigTemplate
61-
name: capd-quick-start-default-worker-bootstraptemplate
39+
name: docker-quick-start-default-worker-bootstraptemplate
6240
infrastructure:
6341
ref:
6442
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
6543
kind: DockerMachineTemplate
66-
name: capd-quick-start-default-worker-machinetemplate
44+
name: docker-quick-start-default-worker-machinetemplate
6745
---
6846
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
6947
kind: DockerClusterTemplate
7048
metadata:
71-
name: capd-quick-start-cluster
49+
labels:
50+
cluster.x-k8s.io/provider: docker
51+
name: docker-quick-start-cluster
7252
spec:
7353
template:
7454
spec: {}
7555
---
7656
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
7757
kind: KubeadmControlPlaneTemplate
7858
metadata:
79-
name: capd-quick-start-control-plane
59+
labels:
60+
cluster.x-k8s.io/provider: docker
61+
name: docker-quick-start-control-plane
8062
spec:
8163
template:
8264
spec:
@@ -99,7 +81,9 @@ spec:
9981
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
10082
kind: DockerMachineTemplate
10183
metadata:
102-
name: capd-quick-start-control-plane
84+
labels:
85+
cluster.x-k8s.io/provider: docker
86+
name: docker-quick-start-control-plane
10387
spec:
10488
template:
10589
spec:
@@ -110,7 +94,9 @@ spec:
11094
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
11195
kind: DockerMachineTemplate
11296
metadata:
113-
name: capd-quick-start-default-worker-machinetemplate
97+
labels:
98+
cluster.x-k8s.io/provider: docker
99+
name: docker-quick-start-default-worker-machinetemplate
114100
spec:
115101
template:
116102
spec:
@@ -121,7 +107,9 @@ spec:
121107
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
122108
kind: KubeadmConfigTemplate
123109
metadata:
124-
name: capd-quick-start-default-worker-bootstraptemplate
110+
labels:
111+
cluster.x-k8s.io/provider: docker
112+
name: docker-quick-start-default-worker-bootstraptemplate
125113
spec:
126114
template:
127115
spec:

0 commit comments

Comments
 (0)