@@ -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,192 @@ spec:
307312{{#/tab }}
308313{{#/tabs }}
309314
315+ After the controlplane is up and running, deploy a CNI solution. Calico is used here as an example.
316+
317+ {{#tabs name:"tab-usage-addons" tabs:"Calico"}}
318+ {{#tab Calicl}}
319+
320+ ` ` ` bash
321+ kubectl apply -f https://docs.projectcalico.org/v3.8/manifests/calico.yaml
322+ ```
323+ {{#/tab }}
324+ {{#/tabs }}
325+
326+ After a short while, our control plane should be up and in ` Ready ` state.
327+
328+ To check its status, let's retrieve the [ target cluster] Kubeconfig and check the status using ` kubectl get nodes ` :
329+
330+ ``` bash
331+ kubectl --namespace=default get secret/capi-quickstart-kubeconfig -o json | jq -r .data.value | base64 --decode > ./capi-quickstart.kubeconfig
332+ kubectl --kubeconfig=./capi-quickstart.kubeconfig get nodes
333+ ```
334+
335+ Finishing up, we'll create a single node _ MachineDeployment_ .
336+
337+ {{#tabs name:"tab-usage-machinedeployment" tabs:"AWS,vSphere"}}
338+ {{#tab AWS}}
339+
340+ ``` yaml
341+ apiVersion : cluster.x-k8s.io/v1alpha2
342+ kind : MachineDeployment
343+ metadata :
344+ name : capi-quickstart-worker
345+ labels :
346+ cluster.x-k8s.io/cluster-name : capi-quickstart
347+ # Labels beyond this point are for example purposes,
348+ # feel free to add more or change with something more meaningful.
349+ # Sync these values with spec.selector.matchLabels and spec.template.metadata.labels.
350+ nodepool : nodepool-0
351+ spec :
352+ replicas : 1
353+ selector :
354+ matchLabels :
355+ cluster.x-k8s.io/cluster-name : capi-quickstart
356+ nodepool : nodepool-0
357+ template :
358+ metadata :
359+ labels :
360+ cluster.x-k8s.io/cluster-name : capi-quickstart
361+ nodepool : nodepool-0
362+ spec :
363+ version : v1.15.3
364+ bootstrap :
365+ configRef :
366+ name : capi-quickstart-worker
367+ apiVersion : bootstrap.cluster.x-k8s.io/v1alpha2
368+ kind : KubeadmConfigTemplate
369+ infrastructureRef :
370+ name : capi-quickstart-worker
371+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha2
372+ kind : AWSMachineTemplate
373+ ---
374+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha2
375+ kind : AWSMachineTemplate
376+ metadata :
377+ name : capi-quickstart-worker
378+ spec :
379+ template :
380+ spec :
381+ instanceType : t3.large
382+ # This IAM profile is part of the pre-requisites.
383+ iamInstanceProfile : " nodes.cluster-api-provider-aws.sigs.k8s.io"
384+ # Change this value to a valid SSH Key Pair present in your AWS Account.
385+ sshKeyName : default
386+ ---
387+ apiVersion : bootstrap.cluster.x-k8s.io/v1alpha2
388+ kind : KubeadmConfigTemplate
389+ metadata :
390+ name : capi-quickstart-worker
391+ spec :
392+ template :
393+ spec :
394+ # For more information about these values,
395+ # refer to the Kubeadm Bootstrap Provider documentation.
396+ joinConfiguration :
397+ nodeRegistration :
398+ name : ' {{ ds.meta_data.hostname }}'
399+ kubeletExtraArgs :
400+ cloud-provider : aws
401+ ` ` `
402+
403+ {{#/tab }}
404+ {{#tab vSphere}}
405+
406+ <aside class="note warning">
407+
408+ <h1>Action Required</h1>
409+
410+ These examples include environment variables that you should substitute before creating the resources.
411+
412+ </aside>
413+
414+ ` ` ` yaml
415+ apiVersion : cluster.x-k8s.io/v1alpha2
416+ kind : MachineDeployment
417+ metadata :
418+ name : capi-quickstart-worker
419+ labels :
420+ cluster.x-k8s.io/cluster-name : capi-quickstart
421+ # Labels beyond this point are for example purposes,
422+ # feel free to add more or change with something more meaningful.
423+ # Sync these values with spec.selector.matchLabels and spec.template.metadata.labels.
424+ nodepool : nodepool-0
425+ spec :
426+ replicas : 1
427+ selector :
428+ matchLabels :
429+ cluster.x-k8s.io/cluster-name : capi-quickstart
430+ nodepool : nodepool-0
431+ template :
432+ metadata :
433+ labels :
434+ cluster.x-k8s.io/cluster-name : capi-quickstart
435+ nodepool : nodepool-0
436+ spec :
437+ version : v1.15.3
438+ bootstrap :
439+ configRef :
440+ apiVersion : bootstrap.cluster.x-k8s.io/v1alpha2
441+ kind : KubeadmConfigTemplate
442+ name : capi-quickstart-worker
443+ infrastructureRef :
444+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha2
445+ kind : VSphereMachineTemplate
446+ name : capi-quickstart-worker
447+ ---
448+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha2
449+ kind : VSphereMachineTemplate
450+ metadata :
451+ name : capi-quickstart-worker
452+ spec :
453+ template :
454+ spec :
455+ datacenter : " ${VSPHERE_DATACENTER}"
456+ network :
457+ devices :
458+ - networkName : " ${VSPHERE_NETWORK}"
459+ dhcp4 : true
460+ dhcp6 : false
461+ numCPUs : ${VSPHERE_NUM_CPUS}
462+ memoryMiB : ${VSPHERE_MEM_MIB}
463+ diskGiB : ${VSPHERE_DISK_GIB}
464+ template : " ${VSPHERE_TEMPLATE}"
465+ ---
466+ apiVersion : bootstrap.cluster.x-k8s.io/v1alpha2
467+ kind : KubeadmConfigTemplate
468+ metadata :
469+ name : capi-quickstart-worker
470+ spec :
471+ template :
472+ spec :
473+ # For more information about these values,
474+ # refer to the Kubeadm Bootstrap Provider documentation.
475+ joinConfiguration :
476+ nodeRegistration :
477+ name : " {{ ds.meta_data.hostname }}"
478+ criSocket : " /var/run/containerd/containerd.sock"
479+ kubeletExtraArgs :
480+ cloud-provider : vsphere
481+ users :
482+ - name : capv
483+ sudo : " ALL=(ALL) NOPASSWD:ALL"
484+ sshAuthorizedKeys :
485+ - " ${SSH_AUTHORIZED_KEY}"
486+ preKubeadmCommands :
487+ - hostname "{{ ds.meta_data.hostname }}"
488+ - echo "::1 ipv6-localhost ipv6-loopback" >/etc/hosts
489+ - echo "127.0.0.1 localhost {{ ds.meta_data.hostname }}" >>/etc/hosts
490+ - echo "{{ ds.meta_data.hostname }}" >/etc/hostname
491+ ` ` `
492+
493+ {{#/tab }}
494+ {{#/tabs }}
310495
311496<!-- links -->
312497[kubectl]: https://kubernetes.io/docs/tasks/tools/install-kubectl/
313498[components]: ../reference/glossary.md#provider-components
314499[kind]: https://sigs.k8s.io/kind
500+ [management cluster]: ../reference/glossary.md#management-cluster
501+ [target cluster]: ../reference/glossary.md#target-cluster
315502
316503
0 commit comments