Skip to content

Commit 5b6155b

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

File tree

2 files changed

+181
-9
lines changed

2 files changed

+181
-9
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: 180 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ 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], 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")"
1212
```
1313

1414
## Installation
1515

16-
Using [kubectl], let's create the components on the management cluster:
16+
Using [kubectl], let's create the components on the [management cluster]:
1717
1818
#### Install Cluster API Components
1919
@@ -45,7 +45,7 @@ kubectl create -f https://github.com/kubernetes-sigs/cluster-api-bootstrap-provi
4545
4646
Check the [AWS provider releases](https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases) for an up-to-date components file.
4747
48-
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).
48+
For more information about prerequisites, credentials management, 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
5151
kubectl create -f https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v0.4.0/infrastructure-components.yaml
@@ -56,7 +56,7 @@ kubectl create -f https://github.com/kubernetes-sigs/cluster-api-provider-aws/re
5656
5757
Check the [vSphere provider releases](https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/releases) for an up-to-date components file.
5858
59-
For more information about prerequisites, credentials management, and or permissions for vSphere, visit the [getting started guide](https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/master/docs/getting_started.md).
59+
For more information about prerequisites, credentials management, or permissions for vSphere, visit the [getting started guide](https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/master/docs/getting_started.md).
6060
6161
```bash
6262
kubectl create -f https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/releases/download/v0.5.0/infrastructure-components.yaml
@@ -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,10 +303,186 @@ spec:
307303
{{#/tab }}
308304
{{#/tabs }}
309305
306+
After the controlplane is up and running, deploy a CNI solution. Calico is used here as an example.
307+
308+
{{#tabs name:"tab-usage-addons" tabs:"Calico"}}
309+
{{#tab Calicl}}
310+
311+
```bash
312+
kubectl apply -f https://docs.projectcalico.org/v3.8/manifests/calico.yaml
313+
```
314+
{{#/tab }}
315+
{{#/tabs }}
316+
317+
After a short while, our control plane should be up and in `Ready` state.
318+
319+
To check its status, let's retrieve the [target cluster] Kubeconfig and check the status using `kubectl get nodes`:
320+
321+
```bash
322+
kubectl --namespace=default get secret/capi-quickstart-kubeconfig -o json | jq -r .data.value | base64 --decode > ./capi-quickstart.kubeconfig
323+
kubectl --kubeconfig=./capi-quickstart.kubeconfig get nodes
324+
```
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-worker
336+
labels:
337+
cluster.x-k8s.io/cluster-name: capi-quickstart
338+
# Labels beyond this point are for example purposes,
339+
# feel free to add more or change with something more meaningful.
340+
# Sync these values with spec.selector.matchLabels and spec.template.metadata.labels.
341+
nodepool: nodepool-0
342+
spec:
343+
replicas: 1
344+
selector:
345+
matchLabels:
346+
cluster.x-k8s.io/cluster-name: capi-quickstart
347+
nodepool: nodepool-0
348+
template:
349+
metadata:
350+
labels:
351+
cluster.x-k8s.io/cluster-name: capi-quickstart
352+
nodepool: nodepool-0
353+
spec:
354+
version: v1.15.3
355+
bootstrap:
356+
configRef:
357+
name: capi-quickstart-worker
358+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
359+
kind: KubeadmConfigTemplate
360+
infrastructureRef:
361+
name: capi-quickstart-worker
362+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
363+
kind: AWSMachineTemplate
364+
---
365+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
366+
kind: AWSMachineTemplate
367+
metadata:
368+
name: capi-quickstart-worker
369+
spec:
370+
template:
371+
spec:
372+
instanceType: t3.large
373+
iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io" # This IAM profile is part of the pre-requisites.
374+
sshKeyName: default # Change this value to a valid SSH Key Pair present in your AWS Account.
375+
---
376+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
377+
kind: KubeadmConfigTemplate
378+
metadata:
379+
name: capi-quickstart-worker
380+
spec:
381+
template:
382+
spec:
383+
joinConfiguration:
384+
nodeRegistration:
385+
name: '{{ ds.meta_data.hostname }}'
386+
kubeletExtraArgs:
387+
cloud-provider: aws
388+
```
389+
390+
{{#/tab }}
391+
{{#tab vSphere}}
392+
393+
<aside class="note warning">
394+
395+
<h1>Action Required</h1>
396+
397+
These examples include environment variables that you should substitute before creating the resources.
398+
399+
</aside>
400+
401+
```yaml
402+
apiVersion: cluster.x-k8s.io/v1alpha2
403+
kind: MachineDeployment
404+
metadata:
405+
name: capi-quickstart-worker
406+
labels:
407+
cluster.x-k8s.io/cluster-name: capi-quickstart
408+
# Labels beyond this point are for example purposes,
409+
# feel free to add more or change with something more meaningful.
410+
# Sync these values with spec.selector.matchLabels and spec.template.metadata.labels.
411+
nodepool: nodepool-0
412+
spec:
413+
replicas: 1
414+
selector:
415+
matchLabels:
416+
cluster.x-k8s.io/cluster-name: capi-quickstart
417+
nodepool: nodepool-0
418+
template:
419+
metadata:
420+
labels:
421+
cluster.x-k8s.io/cluster-name: capi-quickstart
422+
nodepool: nodepool-0
423+
spec:
424+
version: v1.15.3
425+
bootstrap:
426+
configRef:
427+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
428+
kind: KubeadmConfigTemplate
429+
name: capi-quickstart-worker
430+
infrastructureRef:
431+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
432+
kind: VSphereMachineTemplate
433+
name: capi-quickstart-worker
434+
---
435+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
436+
kind: VSphereMachineTemplate
437+
metadata:
438+
name: capi-quickstart-worker
439+
spec:
440+
template:
441+
spec:
442+
datacenter: "${VSPHERE_DATACENTER}"
443+
network:
444+
devices:
445+
- networkName: "${VSPHERE_NETWORK}"
446+
dhcp4: true
447+
dhcp6: false
448+
numCPUs: ${VSPHERE_NUM_CPUS}
449+
memoryMiB: ${VSPHERE_MEM_MIB}
450+
diskGiB: ${VSPHERE_DISK_GIB}
451+
template: "${VSPHERE_TEMPLATE}"
452+
---
453+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
454+
kind: KubeadmConfigTemplate
455+
metadata:
456+
name: capi-quickstart-worker
457+
spec:
458+
template:
459+
spec:
460+
joinConfiguration:
461+
nodeRegistration:
462+
name: "{{ ds.meta_data.hostname }}"
463+
criSocket: "/var/run/containerd/containerd.sock"
464+
kubeletExtraArgs:
465+
cloud-provider: vsphere
466+
users:
467+
- name: capv
468+
sudo: "ALL=(ALL) NOPASSWD:ALL"
469+
sshAuthorizedKeys:
470+
- "${SSH_AUTHORIZED_KEY}"
471+
preKubeadmCommands:
472+
- hostname "{{ ds.meta_data.hostname }}"
473+
- echo "::1 ipv6-localhost ipv6-loopback" >/etc/hosts
474+
- echo "127.0.0.1 localhost {{ ds.meta_data.hostname }}" >>/etc/hosts
475+
- echo "{{ ds.meta_data.hostname }}" >/etc/hostname
476+
```
477+
478+
{{#/tab }}
479+
{{#/tabs }}
310480
311481
<!-- links -->
312482
[kubectl]: https://kubernetes.io/docs/tasks/tools/install-kubectl/
313483
[components]: ../reference/glossary.md#provider-components
314484
[kind]: https://sigs.k8s.io/kind
485+
[management cluster]: ../reference/glossary.md#management-cluster
486+
[target cluster]: ../reference/glossary.md#target-cluster
315487
316488

0 commit comments

Comments
 (0)