@@ -5,15 +5,16 @@ 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] .
9- ``` bash
10- kind create cluster --name=clusterapi
11- export KUBECONFIG=" $( kind get kubeconfig-path --name=" clusterapi" ) "
12- ```
8+ - A Kubernetes cluster to be used as [ management cluster] .
9+ For the purpose of this quick start we suggest you to use [ kind] as a _ non production-ready_ solution.
10+ ``` bash
11+ kind create cluster --name=clusterapi
12+ export KUBECONFIG=" $( kind get kubeconfig-path --name=" clusterapi" ) "
13+ ```
1314
1415## Installation
1516
16- Using [kubectl], let' s create the components on the management cluster:
17+ Using [ kubectl] , let's create the components on the [ management cluster] :
1718
1819#### Install Cluster API Components
1920
@@ -45,7 +46,7 @@ kubectl create -f https://github.com/kubernetes-sigs/cluster-api-bootstrap-provi
4546
4647Check the [ AWS provider releases] ( https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases ) for an up-to-date components file.
4748
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).
49+ 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 ) .
4950
5051``` bash
5152kubectl create -f https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v0.4.0/infrastructure-components.yaml
@@ -56,7 +57,7 @@ kubectl create -f https://github.com/kubernetes-sigs/cluster-api-provider-aws/re
5657
5758Check the [ vSphere provider releases] ( https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/releases ) for an up-to-date components file.
5859
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).
60+ 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 ) .
6061
6162``` bash
6263kubectl create -f https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/releases/download/v0.5.0/infrastructure-components.yaml
@@ -80,7 +81,6 @@ For the purpose of this tutorial, we'll name our cluster `capi-quickstart`.
8081{{#tab AWS}}
8182
8283``` yaml
83- ---
8484apiVersion : cluster.x-k8s.io/v1alpha2
8585kind : Cluster
8686metadata :
@@ -99,8 +99,10 @@ kind: AWSCluster
9999metadata :
100100 name : capi-quickstart
101101spec :
102- region: us-east-1 # Change this value to the region you want to deploy the cluster in.
103- sshKeyName: default # Change this value to a valid SSH Key Pair present in your AWS Account.
102+ # Change this value to the region you want to deploy the cluster in.
103+ region : us-east-1
104+ # Change this value to a valid SSH Key Pair present in your AWS Account.
105+ sshKeyName : default
104106` ` `
105107{{#/tab }}
106108{{#tab vSphere}}
@@ -114,7 +116,6 @@ These examples include environment variables that you should substitute before c
114116</aside>
115117
116118` ` ` yaml
117- ---
118119apiVersion : cluster.x-k8s.io/v1alpha2
119120kind : Cluster
120121metadata :
@@ -159,7 +160,6 @@ Now that we've created the cluster object, we can create a control plane Machine
159160{{#tab AWS}}
160161
161162` ` ` yaml
162- ---
163163apiVersion : cluster.x-k8s.io/v1alpha2
164164kind : Machine
165165metadata :
@@ -185,14 +185,18 @@ metadata:
185185 name : capi-quickstart-controlplane-0
186186spec :
187187 instanceType : t3.large
188- iamInstanceProfile: "controllers.cluster-api-provider-aws.sigs.k8s.io" # This IAM profile is part of the pre-requisites.
189- sshKeyName: default # Change this value to a valid SSH Key Pair present in your AWS Account.
188+ # This IAM profile is part of the pre-requisites.
189+ iamInstanceProfile : " controllers.cluster-api-provider-aws.sigs.k8s.io"
190+ # Change this value to a valid SSH Key Pair present in your AWS Account.
191+ sshKeyName : default
190192---
191193apiVersion : bootstrap.cluster.x-k8s.io/v1alpha2
192194kind : KubeadmConfig
193195metadata :
194196 name : capi-quickstart-controlplane-0
195197spec :
198+ # For more information about these values,
199+ # refer to the Kubeadm Bootstrap Provider documentation.
196200 initConfiguration :
197201 nodeRegistration :
198202 name : ' {{ ds.meta_data.hostname }}'
@@ -218,7 +222,6 @@ These examples include environment variables that you should substitute before c
218222</aside>
219223
220224` ` ` yaml
221- ---
222225apiVersion : cluster.x-k8s.io/v1alpha2
223226kind : Machine
224227metadata :
@@ -259,6 +262,8 @@ kind: KubeadmConfig
259262metadata :
260263 name : capi-quickstart-controlplane-0
261264spec :
265+ # For more information about these values,
266+ # refer to the Kubeadm Bootstrap Provider documentation.
262267 initConfiguration :
263268 nodeRegistration :
264269 name : " {{ ds.meta_data.hostname }}"
@@ -307,10 +312,201 @@ spec:
307312{{#/tab }}
308313{{#/tabs }}
309314
315+ After the controlplane is up and running, let's retrieve the [target cluster] Kubeconfig:
316+
317+ ` ` ` bash
318+ kubectl --namespace=default get secret/capi-quickstart-kubeconfig -o json \
319+ | jq -r .data.value \
320+ | base64 --decode \
321+ > ./capi-quickstart.kubeconfig
322+ ```
323+
324+ Deploy a CNI solution, Calico is used here as an example.
325+
326+ {{#tabs name:"tab-usage-addons" tabs:"Calico"}}
327+ {{#tab Calico}}
328+
329+ ``` bash
330+ kubectl --kubeconfig=./capi-quickstart.kubeconfig \
331+ apply -f https://docs.projectcalico.org/v3.8/manifests/calico.yaml
332+ ```
333+
334+ {{#/tab }}
335+ {{#/tabs }}
336+
337+ After a short while, our control plane should be up and in ` Ready ` state,
338+ let's check the status using ` kubectl get nodes ` :
339+
340+ ``` bash
341+ kubectl --kubeconfig=./capi-quickstart.kubeconfig get nodes
342+ ```
343+
344+ Finishing up, we'll create a single node _ MachineDeployment_ .
345+
346+ {{#tabs name:"tab-usage-machinedeployment" tabs:"AWS,vSphere"}}
347+ {{#tab AWS}}
348+
349+ ``` yaml
350+ apiVersion : cluster.x-k8s.io/v1alpha2
351+ kind : MachineDeployment
352+ metadata :
353+ name : capi-quickstart-worker
354+ labels :
355+ cluster.x-k8s.io/cluster-name : capi-quickstart
356+ # Labels beyond this point are for example purposes,
357+ # feel free to add more or change with something more meaningful.
358+ # Sync these values with spec.selector.matchLabels and spec.template.metadata.labels.
359+ nodepool : nodepool-0
360+ spec :
361+ replicas : 1
362+ selector :
363+ matchLabels :
364+ cluster.x-k8s.io/cluster-name : capi-quickstart
365+ nodepool : nodepool-0
366+ template :
367+ metadata :
368+ labels :
369+ cluster.x-k8s.io/cluster-name : capi-quickstart
370+ nodepool : nodepool-0
371+ spec :
372+ version : v1.15.3
373+ bootstrap :
374+ configRef :
375+ name : capi-quickstart-worker
376+ apiVersion : bootstrap.cluster.x-k8s.io/v1alpha2
377+ kind : KubeadmConfigTemplate
378+ infrastructureRef :
379+ name : capi-quickstart-worker
380+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha2
381+ kind : AWSMachineTemplate
382+ ---
383+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha2
384+ kind : AWSMachineTemplate
385+ metadata :
386+ name : capi-quickstart-worker
387+ spec :
388+ template :
389+ spec :
390+ instanceType : t3.large
391+ # This IAM profile is part of the pre-requisites.
392+ iamInstanceProfile : " nodes.cluster-api-provider-aws.sigs.k8s.io"
393+ # Change this value to a valid SSH Key Pair present in your AWS Account.
394+ sshKeyName : default
395+ ---
396+ apiVersion : bootstrap.cluster.x-k8s.io/v1alpha2
397+ kind : KubeadmConfigTemplate
398+ metadata :
399+ name : capi-quickstart-worker
400+ spec :
401+ template :
402+ spec :
403+ # For more information about these values,
404+ # refer to the Kubeadm Bootstrap Provider documentation.
405+ joinConfiguration :
406+ nodeRegistration :
407+ name : ' {{ ds.meta_data.hostname }}'
408+ kubeletExtraArgs :
409+ cloud-provider : aws
410+ ` ` `
411+
412+ {{#/tab }}
413+ {{#tab vSphere}}
414+
415+ <aside class="note warning">
416+
417+ <h1>Action Required</h1>
418+
419+ These examples include environment variables that you should substitute before creating the resources.
420+
421+ </aside>
422+
423+ ` ` ` yaml
424+ apiVersion : cluster.x-k8s.io/v1alpha2
425+ kind : MachineDeployment
426+ metadata :
427+ name : capi-quickstart-worker
428+ labels :
429+ cluster.x-k8s.io/cluster-name : capi-quickstart
430+ # Labels beyond this point are for example purposes,
431+ # feel free to add more or change with something more meaningful.
432+ # Sync these values with spec.selector.matchLabels and spec.template.metadata.labels.
433+ nodepool : nodepool-0
434+ spec :
435+ replicas : 1
436+ selector :
437+ matchLabels :
438+ cluster.x-k8s.io/cluster-name : capi-quickstart
439+ nodepool : nodepool-0
440+ template :
441+ metadata :
442+ labels :
443+ cluster.x-k8s.io/cluster-name : capi-quickstart
444+ nodepool : nodepool-0
445+ spec :
446+ version : v1.15.3
447+ bootstrap :
448+ configRef :
449+ apiVersion : bootstrap.cluster.x-k8s.io/v1alpha2
450+ kind : KubeadmConfigTemplate
451+ name : capi-quickstart-worker
452+ infrastructureRef :
453+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha2
454+ kind : VSphereMachineTemplate
455+ name : capi-quickstart-worker
456+ ---
457+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha2
458+ kind : VSphereMachineTemplate
459+ metadata :
460+ name : capi-quickstart-worker
461+ spec :
462+ template :
463+ spec :
464+ datacenter : " ${VSPHERE_DATACENTER}"
465+ network :
466+ devices :
467+ - networkName : " ${VSPHERE_NETWORK}"
468+ dhcp4 : true
469+ dhcp6 : false
470+ numCPUs : ${VSPHERE_NUM_CPUS}
471+ memoryMiB : ${VSPHERE_MEM_MIB}
472+ diskGiB : ${VSPHERE_DISK_GIB}
473+ template : " ${VSPHERE_TEMPLATE}"
474+ ---
475+ apiVersion : bootstrap.cluster.x-k8s.io/v1alpha2
476+ kind : KubeadmConfigTemplate
477+ metadata :
478+ name : capi-quickstart-worker
479+ spec :
480+ template :
481+ spec :
482+ # For more information about these values,
483+ # refer to the Kubeadm Bootstrap Provider documentation.
484+ joinConfiguration :
485+ nodeRegistration :
486+ name : " {{ ds.meta_data.hostname }}"
487+ criSocket : " /var/run/containerd/containerd.sock"
488+ kubeletExtraArgs :
489+ cloud-provider : vsphere
490+ users :
491+ - name : capv
492+ sudo : " ALL=(ALL) NOPASSWD:ALL"
493+ sshAuthorizedKeys :
494+ - " ${SSH_AUTHORIZED_KEY}"
495+ preKubeadmCommands :
496+ - hostname "{{ ds.meta_data.hostname }}"
497+ - echo "::1 ipv6-localhost ipv6-loopback" >/etc/hosts
498+ - echo "127.0.0.1 localhost {{ ds.meta_data.hostname }}" >>/etc/hosts
499+ - echo "{{ ds.meta_data.hostname }}" >/etc/hostname
500+ ` ` `
501+
502+ {{#/tab }}
503+ {{#/tabs }}
310504
311505<!-- links -->
312506[kubectl]: https://kubernetes.io/docs/tasks/tools/install-kubectl/
313507[components]: ../reference/glossary.md#provider-components
314508[kind]: https://sigs.k8s.io/kind
509+ [management cluster]: ../reference/glossary.md#management-cluster
510+ [target cluster]: ../reference/glossary.md#target-cluster
315511
316512
0 commit comments