Skip to content

Commit ef1bf9e

Browse files
committed
📖 Add MachineDeployment example
Signed-off-by: Vince Prignano <[email protected]>
1 parent 1cf80a3 commit ef1bf9e

File tree

2 files changed

+168
-7
lines changed

2 files changed

+168
-7
lines changed

docs/book/src/images/management-cluster.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/book/src/user/quick-start.md

Lines changed: 167 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ In this tutorial we'll cover the basics of how to use Cluster API to create one
55
## Prerequisites
66

77
- Install and setup [kubectl] in your local environment.
8-
- A Kubernetes cluster to be used as [management cluster](../reference/glossary.md#management-cluster), for the purpose of this quick start, we suggest you to use [kind].
8+
- A Kubernetes cluster to be used as [management cluster](../reference/glossary.md#management-cluster), for the purpose of this quick start we suggest you to use [kind] as a non production-ready solution.
99
```bash
1010
kind create cluster --name=clusterapi
1111
export KUBECONFIG="$(kind get kubeconfig-path --name="clusterapi")"
@@ -48,7 +48,7 @@ Check the [AWS provider releases](https://github.com/kubernetes-sigs/cluster-api
4848
For more information about prerequisites, credentials management, and or permissions for AWS, visit the [getting started guide](https://github.com/kubernetes-sigs/cluster-api-provider-aws/blob/master/docs/getting-started.md).
4949
5050
```bash
51-
kubectl create -f https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v0.4.0/infrastructure-components.yaml
51+
kubectl create -f https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v0.4.1/infrastructure-components.yaml
5252
```
5353
5454
{{#/tab }}
@@ -80,7 +80,6 @@ For the purpose of this tutorial, we'll name our cluster `capi-quickstart`.
8080
{{#tab AWS}}
8181

8282
```yaml
83-
---
8483
apiVersion: cluster.x-k8s.io/v1alpha2
8584
kind: Cluster
8685
metadata:
@@ -114,7 +113,6 @@ These examples include environment variables that you should substitute before c
114113
</aside>
115114

116115
```yaml
117-
---
118116
apiVersion: cluster.x-k8s.io/v1alpha2
119117
kind: Cluster
120118
metadata:
@@ -159,7 +157,6 @@ Now that we've created the cluster object, we can create a control plane Machine
159157
{{#tab AWS}}
160158
161159
```yaml
162-
---
163160
apiVersion: cluster.x-k8s.io/v1alpha2
164161
kind: Machine
165162
metadata:
@@ -218,7 +215,6 @@ These examples include environment variables that you should substitute before c
218215
</aside>
219216
220217
```yaml
221-
---
222218
apiVersion: cluster.x-k8s.io/v1alpha2
223219
kind: Machine
224220
metadata:
@@ -307,6 +303,171 @@ spec:
307303
{{#/tab }}
308304
{{#/tabs }}
309305
306+
After the controlplane is up and running, we should apply the addons to install Calico.
307+
308+
{{#tabs name:"tab-usage-addons" tabs:"AWS,vSphere"}}
309+
{{#tab AWS}}
310+
311+
```bash
312+
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/cluster-api-provider-aws/v0.4.1/examples/addons.yaml
313+
```
314+
{{#/tab }}
315+
{{#tab vSphere}}
316+
317+
```bash
318+
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/cluster-api-provider-vsphere/v0.5.0/examples/addons.yaml
319+
```
320+
321+
{{#/tab }}
322+
{{#/tabs }}
323+
324+
At this point, our control plane should be up and in `Ready` state, check the status using `kubectl get nodes`.
325+
326+
Finishing up, we'll create a single node _MachineDeployment_.
327+
328+
{{#tabs name:"tab-usage-machinedeployment" tabs:"AWS,vSphere"}}
329+
{{#tab AWS}}
330+
331+
```yaml
332+
apiVersion: cluster.x-k8s.io/v1alpha2
333+
kind: MachineDeployment
334+
metadata:
335+
name: capi-quickstart-md-0
336+
labels:
337+
cluster.x-k8s.io/cluster-name: capi-quickstart
338+
nodepool: nodepool-0
339+
spec:
340+
replicas: 1
341+
selector:
342+
matchLabels:
343+
cluster.x-k8s.io/cluster-name: capi-quickstart
344+
nodepool: nodepool-0
345+
template:
346+
metadata:
347+
labels:
348+
cluster.x-k8s.io/cluster-name: capi-quickstart
349+
nodepool: nodepool-0
350+
spec:
351+
version: v1.15.3
352+
bootstrap:
353+
configRef:
354+
name: capi-quickstart-md-0
355+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
356+
kind: KubeadmConfigTemplate
357+
infrastructureRef:
358+
name: capi-quickstart-md-0
359+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
360+
kind: AWSMachineTemplate
361+
---
362+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
363+
kind: AWSMachineTemplate
364+
metadata:
365+
name: capi-quickstart-md-0
366+
spec:
367+
template:
368+
spec:
369+
instanceType: t3.large
370+
iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io" # This IAM profile is part of the pre-requisites.
371+
sshKeyName: default # Change this value to a valid SSH Key Pair present in your AWS Account.
372+
---
373+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
374+
kind: KubeadmConfigTemplate
375+
metadata:
376+
name: capi-quickstart-md-0
377+
spec:
378+
template:
379+
spec:
380+
joinConfiguration:
381+
nodeRegistration:
382+
name: '{{ ds.meta_data.hostname }}'
383+
kubeletExtraArgs:
384+
cloud-provider: aws
385+
```
386+
387+
{{#/tab }}
388+
{{#tab vSphere}}
389+
390+
<aside class="note warning">
391+
392+
<h1>Action Required</h1>
393+
394+
These examples include environment variables that you should substitute before creating the resources.
395+
396+
</aside>
397+
398+
```yaml
399+
apiVersion: cluster.x-k8s.io/v1alpha2
400+
kind: MachineDeployment
401+
metadata:
402+
name: capi-quickstart-md-0
403+
labels:
404+
cluster.x-k8s.io/cluster-name: capi-quickstart
405+
spec:
406+
replicas: 1
407+
selector:
408+
matchLabels:
409+
cluster.x-k8s.io/cluster-name: capi-quickstart
410+
template:
411+
metadata:
412+
labels:
413+
cluster.x-k8s.io/cluster-name: capi-quickstart
414+
spec:
415+
version: v1.15.3
416+
bootstrap:
417+
configRef:
418+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
419+
kind: KubeadmConfigTemplate
420+
name: capi-quickstart-md-0
421+
infrastructureRef:
422+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
423+
kind: VSphereMachineTemplate
424+
name: capi-quickstart-md-0
425+
---
426+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
427+
kind: VSphereMachineTemplate
428+
metadata:
429+
name: capi-quickstart-md-0
430+
spec:
431+
template:
432+
spec:
433+
datacenter: "${VSPHERE_DATACENTER}"
434+
network:
435+
devices:
436+
- networkName: "${VSPHERE_NETWORK}"
437+
dhcp4: true
438+
dhcp6: false
439+
numCPUs: ${VSPHERE_NUM_CPUS}
440+
memoryMiB: ${VSPHERE_MEM_MIB}
441+
diskGiB: ${VSPHERE_DISK_GIB}
442+
template: "${VSPHERE_TEMPLATE}"
443+
---
444+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
445+
kind: KubeadmConfigTemplate
446+
metadata:
447+
name: capi-quickstart-md-0
448+
spec:
449+
template:
450+
spec:
451+
joinConfiguration:
452+
nodeRegistration:
453+
name: "{{ ds.meta_data.hostname }}"
454+
criSocket: "/var/run/containerd/containerd.sock"
455+
kubeletExtraArgs:
456+
cloud-provider: vsphere
457+
users:
458+
- name: capv
459+
sudo: "ALL=(ALL) NOPASSWD:ALL"
460+
sshAuthorizedKeys:
461+
- "${SSH_AUTHORIZED_KEY}"
462+
preKubeadmCommands:
463+
- hostname "{{ ds.meta_data.hostname }}"
464+
- echo "::1 ipv6-localhost ipv6-loopback" >/etc/hosts
465+
- echo "127.0.0.1 localhost {{ ds.meta_data.hostname }}" >>/etc/hosts
466+
- echo "{{ ds.meta_data.hostname }}" >/etc/hostname
467+
```
468+
469+
{{#/tab }}
470+
{{#/tabs }}
310471

311472
<!-- links -->
312473
[kubectl]: https://kubernetes.io/docs/tasks/tools/install-kubectl/

0 commit comments

Comments
 (0)