sigs.k8s.io/cluster-api-provider-aws@v1.5.5/docs/book/src/topics/failure-domains/worker-nodes.md (about) 1 # Failure domains in worker nodes 2 3 To ensure that the worker machines are spread across failure domains, we need to create N `MachineDeployment` for your N failure domains, scaling them independently. Resiliency to failures comes from having multiple `MachineDeployment`. 4 For example: 5 6 ```yaml 7 apiVersion: cluster.x-k8s.io/v1beta1 8 kind: MachineDeployment 9 metadata: 10 name: ${CLUSTER_NAME}-md-0 11 namespace: default 12 spec: 13 clusterName: ${CLUSTER_NAME} 14 replicas: ${WORKER_MACHINE_COUNT} 15 selector: 16 matchLabels: null 17 template: 18 spec: 19 bootstrap: 20 configRef: 21 apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 22 kind: KubeadmConfigTemplate 23 name: ${CLUSTER_NAME}-md-0 24 clusterName: ${CLUSTER_NAME} 25 infrastructureRef: 26 apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 27 kind: AWSMachineTemplate 28 name: ${CLUSTER_NAME}-md-0 29 version: ${KUBERNETES_VERSION} 30 failureDomain: "1" 31 --- 32 apiVersion: cluster.x-k8s.io/v1beta1 33 kind: MachineDeployment 34 metadata: 35 name: ${CLUSTER_NAME}-md-1 36 namespace: default 37 spec: 38 clusterName: ${CLUSTER_NAME} 39 replicas: ${WORKER_MACHINE_COUNT} 40 selector: 41 matchLabels: null 42 template: 43 spec: 44 bootstrap: 45 configRef: 46 apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 47 kind: KubeadmConfigTemplate 48 name: ${CLUSTER_NAME}-md-1 49 clusterName: ${CLUSTER_NAME} 50 infrastructureRef: 51 apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 52 kind: AWSMachineTemplate 53 name: ${CLUSTER_NAME}-md-1 54 version: ${KUBERNETES_VERSION} 55 failureDomain: "2" 56 --- 57 apiVersion: cluster.x-k8s.io/v1beta1 58 kind: MachineDeployment 59 metadata: 60 name: ${CLUSTER_NAME}-md-2 61 namespace: default 62 spec: 63 clusterName: ${CLUSTER_NAME} 64 replicas: ${WORKER_MACHINE_COUNT} 65 selector: 66 matchLabels: null 67 template: 68 spec: 69 bootstrap: 70 configRef: 71 apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 72 kind: KubeadmConfigTemplate 73 name: ${CLUSTER_NAME}-md-2 74 clusterName: ${CLUSTER_NAME} 75 infrastructureRef: 76 apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 77 kind: AWSMachineTemplate 78 name: ${CLUSTER_NAME}-md-2 79 version: ${KUBERNETES_VERSION} 80 failureDomain: "3" 81 ``` 82 83 >**IMPORTANT WARNING:** All the replicas within a `MachineDeployment` will reside in the same Availability Zone. 84 85 ### Using AWSMachinePool 86 87 You can use an `AWSMachinePool` object which automatically distributes worker machines across the configured availability zones. 88 Set the **FailureDomains** field to the list of availability zones that you want to use. Be aware that not all regions have the same availability zones. 89 90 ```yaml 91 apiVersion: cluster.x-k8s.io/v1beta1 92 kind: MachinePool 93 metadata: 94 labels: 95 cluster.x-k8s.io/cluster-name: my-cluster 96 name: ${CLUSTER_NAME}-mp-0 97 namespace: default 98 spec: 99 clusterName: my-cluster 100 failureDomains: 101 - "1" 102 - "3" 103 replicas: 3 104 template: 105 spec: 106 clusterName: my-cluster 107 bootstrap: 108 configRef: 109 apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 110 kind: KubeadmConfigTemplate 111 name: ${CLUSTER_NAME}-mp-0 112 infrastructureRef: 113 apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 114 kind: AWSMachinePool 115 name: ${CLUSTER_NAME}-mp-0 116 version: ${KUBERNETES_VERSION} 117 --- 118 apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 119 kind: AWSMachinePool 120 metadata: 121 labels: 122 cluster.x-k8s.io/cluster-name: my-cluster 123 name: ${CLUSTER_NAME}-mp-0 124 namespace: default 125 spec: 126 minSize: 1 127 maxSize: 4 128 awsLaunchTemplate: 129 instanceType: ${AWS_NODE_MACHINE_TYPE} 130 iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io" 131 sshKeyName: ${AWS_SSH_KEY_NAME} 132 ```