|
| 1 | +--- |
| 2 | +title: Segregate worker nodes into different subnets |
| 3 | +description: Discover how to segregate worker nodes into different subnets in an Azure Red Hat OpenShift (ARO) deployment |
| 4 | +author: johnmarco |
| 5 | +ms.author: johnmarc |
| 6 | +ms.service: azure-redhat-openshift |
| 7 | +keywords: aro, machine set, openshift, red hat |
| 8 | +ms.topic: how-to |
| 9 | +ms.date: 03/01/2023 |
| 10 | +ms.custom: template-how-to |
| 11 | +--- |
| 12 | + |
| 13 | +# Segregate worker nodes into different subnets with Azure Red Hat OpenShift |
| 14 | + |
| 15 | +This article shows you how to segregate worker nodes into different private subnets as part of an ARO deployment. Separating worker nodes into different private subnets allows you to meet specific access control requirements for various services and applications deployed on ARO. |
| 16 | + |
| 17 | +For example, you might want to run specific ingress controllers on dedicated worker nodes within a specific subnet, while the rest of the Kubernetes nodes for workloads (infra and other workers) are within a different subnet, as shown below: |
| 18 | + |
| 19 | +:::image type="content" source="media/howto-segregate-machinesets/subnet-configuration.png" alt-text="Screenshot of an example subnet configuration." lightbox="media/howto-segregate-machinesets/subnet-configuration.png"::: |
| 20 | + |
| 21 | +> [!NOTE] |
| 22 | +> As part of ARO, master and worker nodes cannot be deployed in the same private subnet. |
| 23 | +
|
| 24 | +In order to segregate worker nodes into different subnets, two main steps need to be performed: |
| 25 | + |
| 26 | +1. Deploy an ARO cluster. |
| 27 | + |
| 28 | +1. Create the appropriate subnets and machine sets associated with those subnets. |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +## Deploy an ARO cluster |
| 33 | + |
| 34 | +See [Create an Azure Red Hat OpenShift 4 cluster](tutorial-create-cluster.md) for instructions on performing this step. |
| 35 | + |
| 36 | +## Create the subnets and associated machine sets |
| 37 | + |
| 38 | +Once you've deployed your ARO cluster, you'll need to create extra subnets as part of the same overall virtual network and create new machine sets for those subnets. |
| 39 | + |
| 40 | +### Step 1: Create the subnets |
| 41 | + |
| 42 | +Create the subnets as part of the current virtual network in which ARO is deployed. Make sure that all the subnets are updated to the `Microsoft.ContainerRegistry` for **Service Endpoints**. |
| 43 | + |
| 44 | +:::image type="content" source="media/howto-segregate-machinesets/subnets-window.png" alt-text="Screenshot of the Subnets window with service endpoints highlighted." lightbox="media/howto-segregate-machinesets/subnets-window.png"::: |
| 45 | + |
| 46 | +### Step 2: Sign-in to the jumphost |
| 47 | + |
| 48 | +> [!NOTE] |
| 49 | +> This step is optional if you have an alternate method for logging into the ARO cluster. |
| 50 | +
|
| 51 | +Use the following command to log into the jumphost: |
| 52 | + |
| 53 | +`oc login $apiServer -u kubeadmin -p <kubeadmin password>` |
| 54 | + |
| 55 | +Verify the number of nodes and machine sets using the `oc get nodes` and `oc get machineSets -n openshift-machine-api` commands, as shown in the following examples: |
| 56 | + |
| 57 | +``` |
| 58 | +$ oc get nodes |
| 59 | +NAME STATUS ROLES AGE VERSION |
| 60 | +simon-aro-st5rm-master-0 Ready master 66m v1.19.0+e405995 |
| 61 | +simon-aro-st5rm-master-1 Ready master 67m v1.19.0+e405995 |
| 62 | +simon-aro-st5rm-master-2 Ready master 67m v1.19.0+e405995 |
| 63 | +simon-aro-st5rm-worker-useast1-h6kzn Ready worker 59m v1.19.0+e405995 |
| 64 | +simon-aro-st5rm-worker-useast2-48zsm Ready worker 59m v1.19.0+e405995 |
| 65 | +simon-aro-st5rm-worker-useast3-rvzpn Ready worker 59m v1.19.0+e405995 |
| 66 | +``` |
| 67 | + |
| 68 | +``` |
| 69 | +# oc get machineSets --all-namespaces |
| 70 | +NAMESPACE NAME DESIRED CURRENT READY AVAILABLE AGE |
| 71 | +openshift-machine-api simon-aro-st5rm-worker-useast1 1 1 1 1 69m |
| 72 | +openshift-machine-api simon-aro-st5rm-worker-useast2 1 1 1 1 69m |
| 73 | +openshift-machine-api simon-aro-st5rm-worker-useast3 1 1 1 1 69m |
| 74 | +``` |
| 75 | + |
| 76 | +### Step 3: Retrieve the machine sets in the `openshift-machine-api project/namespace` |
| 77 | + |
| 78 | +Retrieving the machine sets allows you to get all of the relevant parameters into the machineSet template used in the following step. |
| 79 | + |
| 80 | +`oc describe machineSet simon-aro-st5rm-worker-useast1 > aro-worker-az1.yaml` |
| 81 | + |
| 82 | +### Step 4: Create a new machineSet YAML file and apply it to the cluster |
| 83 | + |
| 84 | +Use the template below for your machineSet YAML file. Change the parameters shown with **Xs** according to the values retrieved in the previous section. For example, `machine.openshift.io/cluster-api-cluster: XXX-XXX-XXX` might be `machine.openshift.io/cluster-api-cluster: machine-aro-st3mr` |
| 85 | + |
| 86 | +```yml |
| 87 | +==============MachineSet Template==================== |
| 88 | +apiVersion: machine.openshift.io/v1beta1 |
| 89 | +kind: MachineSet |
| 90 | +metadata: |
| 91 | + labels: |
| 92 | + machine.openshift.io/cluster-api-cluster: XXX-XXX-XXX |
| 93 | + machine.openshift.io/cluster-api-machine-role: worker |
| 94 | + machine.openshift.io/cluster-api-machine-type: worker |
| 95 | + name: XXX-XXX-XXX-XXX-XXX |
| 96 | + namespace: openshift-machine-api |
| 97 | +spec: |
| 98 | + replicas: 1 |
| 99 | + selector: |
| 100 | + matchLabels: |
| 101 | + machine.openshift.io/cluster-api-cluster: XXX-XXX-XXX |
| 102 | + machine.openshift.io/cluster-api-machineset: XXX-XXX-XXX-XXX-XXX |
| 103 | + template: |
| 104 | + metadata: |
| 105 | + creationTimestamp: null |
| 106 | + labels: |
| 107 | + machine.openshift.io/cluster-api-cluster: XXX-XXX-XXX |
| 108 | + machine.openshift.io/cluster-api-machine-role: worker |
| 109 | + machine.openshift.io/cluster-api-machine-type: worker |
| 110 | + machine.openshift.io/cluster-api-machineset: XXX-XXX-XXX-XXX-XXX |
| 111 | + spec: |
| 112 | + metadata: |
| 113 | + creationTimestamp: null |
| 114 | + labels: |
| 115 | + node-role.kubernetes.io/<role>: "" |
| 116 | + providerSpec: |
| 117 | + value: |
| 118 | + apiVersion: azureproviderconfig.openshift.io/v1beta1 |
| 119 | + credentialsSecret: |
| 120 | + name: azure-cloud-credentials |
| 121 | + namespace: openshift-machine-api |
| 122 | + image: |
| 123 | + offer: aro4 |
| 124 | + publisher: azureopenshift |
| 125 | + resourceID: "" |
| 126 | + sku: XXX_XX |
| 127 | + version: XX.XX.XXX |
| 128 | + internalLoadBalancer: "" |
| 129 | + kind: AzureMachineProviderSpec |
| 130 | + location: useast |
| 131 | + metadata: |
| 132 | + creationTimestamp: null |
| 133 | + natRule: null |
| 134 | + networkResourceGroup: XX-XXXXXX |
| 135 | + osDisk: |
| 136 | + diskSizeGB: 128 |
| 137 | + managedDisk: |
| 138 | + storageAccountType: Premium_LRS |
| 139 | + osType: Linux |
| 140 | + publicIP: false |
| 141 | + publicLoadBalancer: XXX-XXX-XXX |
| 142 | + resourceGroup: aro-fq5v3vye |
| 143 | + sshPrivateKey: "" |
| 144 | + sshPublicKey: "" |
| 145 | + subnet: XXX-XXX |
| 146 | + userDataSecret: |
| 147 | + name: worker-user-data |
| 148 | + vmSize: Standard_D4s_v3 |
| 149 | + vnet: XXX-XXX |
| 150 | + zone: "X" |
| 151 | +``` |
| 152 | +
|
| 153 | +### Step 5: Apply the machine set |
| 154 | +
|
| 155 | +Apply the machine set created in the previous section using the `oc apply -f <filename.yaml>` command, as in the following example: |
| 156 | + |
| 157 | +``` |
| 158 | +[root@jumphost-new ARO-cluster-Private]# oc apply -f aro-new-worker-az1.yaml |
| 159 | +machineset.machine.openshift.io/simon-aro-qpsl5-worker-useast4 created |
| 160 | +``` |
| 161 | +
|
| 162 | +### Step 6: Verify the machine set and nodes |
| 163 | +
|
| 164 | +Once you've applied the YAML file, you can verify the creation of the machine set and nodes using the `oc get machineSets` and `oc get nodes` commands, as shown in the following examples: |
| 165 | +
|
| 166 | +
|
| 167 | +`[root@jumphost-new ARO-cluster-Private]# oc get machineSet` |
| 168 | +
|
| 169 | +``` |
| 170 | +NAME DESIRED CURRENT READY AVAILABLE AGE |
| 171 | +simon-aro-st5rm-worker-useast1 1 1 1 1 142m |
| 172 | +simon-aro-st5rm-worker-useast2 1 1 1 1 142m |
| 173 | +simon-aro-st5rm-worker-useast3 1 1 1 1 142m |
| 174 | +simon-aro-st5rm-worker-useast4 1 1 46s |
| 175 | +``` |
| 176 | +
|
| 177 | +After a few more minutes, the new machine set and nodes will appear: |
| 178 | +
|
| 179 | +`[root@jumphost-new ARO-cluster-Private]# oc get machineSet` |
| 180 | +
|
| 181 | +``` |
| 182 | +NAME DESIRED CURRENT READY AVAILABLE AGE |
| 183 | +simon-aro-st5rm-worker-useast1 1 1 1 1 148m |
| 184 | +simon-aro-st5rm-worker-useast2 1 1 1 1 148m |
| 185 | +simon-aro-st5rm-worker-useast3 1 1 1 1 148m |
| 186 | +simon-aro-st5rm-worker-useast4 1 1 1 1 6m11s |
| 187 | +``` |
| 188 | +
|
| 189 | +`[root@jumphost-new ARO-cluster-Private]# oc get nodes` |
| 190 | +
|
| 191 | +``` |
| 192 | +NAME STATUS ROLES AGE VERSION |
| 193 | +simon-aro-st5rm-master-0 Ready master 147m v1.19.0+e405995 |
| 194 | +simon-aro-st5rm-master-1 Ready master 147m v1.19.0+e405995 |
| 195 | +simon-aro-st5rm-master-2 Ready master 147m v1.19.0+e405995 |
| 196 | +simon-aro-st5rm-worker-useast1-h6kzn Ready worker 139m v1.19.0+e405995 |
| 197 | +simon-aro-st5rm-worker-useast2-48zsm Ready worker 139m v1.19.0+e405995 |
| 198 | +simon-aro-st5rm-worker-useast3-rvzpn Ready worker 139m v1.19.0+e405995 |
| 199 | +simon-aro-st5rm-worker-useast4-qrsgx Ready worker 104s v1.19.0+e405995 |
| 200 | +``` |
| 201 | +
|
| 202 | +
|
| 203 | +
|
0 commit comments