|
| 1 | +--- |
| 2 | +title: "OVHCloud" |
| 3 | +description: "Creating a cluster via the OpenStack CLI on OVHCloud." |
| 4 | +aliases: |
| 5 | + - ../../../cloud-platforms/ovhcloud |
| 6 | +--- |
| 7 | + |
| 8 | +import { VersionWarningBanner } from "/snippets/version-warning-banner.jsx" |
| 9 | + |
| 10 | +<VersionWarningBanner /> |
| 11 | + |
| 12 | +## Creating a cluster via the OpenStack CLI on OVHCloud |
| 13 | + |
| 14 | +In this guide, we will create an HA Kubernetes cluster in OVHCloud with 1 worker node. |
| 15 | +We will assume an existing some familiarity with OpenStack. |
| 16 | +If you need more information on OpenStack specifics, please see the [official OVHCloud documentation](https://docs.ovh.com/). |
| 17 | + |
| 18 | +### Environment setup |
| 19 | + |
| 20 | +You should have an existing openrc file. |
| 21 | +This file will provide environment variables necessary to talk to your OVHCloud. |
| 22 | +See [here](https://help.ovhcloud.com/csm/en-gb-public-cloud-compute-openstack-tokens?id=kb_article_view&sysparm_article=KB0057950) for instructions on fetching this file. |
| 23 | + |
| 24 | +Set environment variables: |
| 25 | + |
| 26 | +```bash |
| 27 | +export PRIVATE_NETWORK_NAME=private-network-001 |
| 28 | +export SUBNET_NAME=subnet-001 |
| 29 | +export SUBNET_CIDR=10.0.0.0/16 |
| 30 | +export GATEWAY_NAME=gateway-001 |
| 31 | +export COMPUTE_FLAVOR_NAME=b3-8 |
| 32 | +export IMAGE_NAME=talos |
| 33 | +export LOADBALANCER_NAME=loadbalancer-001 |
| 34 | +export LOADBALANCER_FLAVOR_NAME=small |
| 35 | +``` |
| 36 | + |
| 37 | +### Create the image |
| 38 | + |
| 39 | +First, download the OpenStack image from [Image Factory](https://factory.talos.dev/). |
| 40 | +These images are called `openstack-$ARCH.raw.xz`. |
| 41 | + |
| 42 | +Decompress this file with `unxz openstack-$ARCH.raw.xz`. |
| 43 | +The resulting file will be called `openstack-$ARCH.raw`. |
| 44 | + |
| 45 | +#### Upload the image |
| 46 | + |
| 47 | +Once you have the image, you can upload to OpenStack with: |
| 48 | + |
| 49 | +```bash |
| 50 | +openstack image create $IMAGE_NAME \ |
| 51 | + --disk-format raw \ |
| 52 | + --file openstack-amd64.raw \ |
| 53 | + --progress |
| 54 | +``` |
| 55 | + |
| 56 | +### Network infrastructure (Optional) |
| 57 | +If you have an existing network infrastructure, you can skip this step. |
| 58 | +If not, you can follow the instructions below to create the necessary network infrastructure for your cluster. |
| 59 | +We will create a private network, subnet, and gateway for our cluster. |
| 60 | +This will allow our cluster to communicate with the outside world and with each other. |
| 61 | + |
| 62 | +#### Private network, subnet, gateway |
| 63 | + |
| 64 | +```bash |
| 65 | +# Create private network |
| 66 | +openstack network create \ |
| 67 | + --provider-network-type vrack \ |
| 68 | + --provider-segment 1 \ |
| 69 | + --mtu 1500 \ |
| 70 | + --enable-port-security \ |
| 71 | + --internal \ |
| 72 | + $PRIVATE_NETWORK_NAME |
| 73 | + |
| 74 | +export PRIVATE_NETWORK_ID=$(openstack network show $PRIVATE_NETWORK_NAME -f value -c id) |
| 75 | + |
| 76 | +# Create subnet |
| 77 | +openstack subnet create \ |
| 78 | + --network $PRIVATE_NETWORK_ID \ |
| 79 | + --subnet-range $SUBNET_CIDR \ |
| 80 | + --dns-nameserver 1.1.1.1 \ |
| 81 | + --dns-nameserver 8.8.8.8 \ |
| 82 | + $SUBNET_NAME |
| 83 | + |
| 84 | +# Create Gateway |
| 85 | +openstack router create $GATEWAY_NAME --external-gateway Ext-Net |
| 86 | + |
| 87 | +# Add the subnet to the router |
| 88 | +openstack router add subnet \ |
| 89 | + $GATEWAY_NAME \ |
| 90 | + $SUBNET_NAME |
| 91 | +``` |
| 92 | + |
| 93 | +#### Security groups |
| 94 | + |
| 95 | +This example uses the default security group in OpenStack. |
| 96 | +Ports have been opened to ensure that connectivity from both inside and outside the group is possible. |
| 97 | +You will want to allow, at a minimum, ports 6443 (Kubernetes API server) and 50000 (Talos API) from external sources. |
| 98 | +It is also recommended to allow communication over all ports from within the subnet. |
| 99 | + |
| 100 | +### Compute |
| 101 | + |
| 102 | +Once the image is uploaded and the network infrastructure is in place, we can create our compute instances. |
| 103 | +We will create 3 control plane nodes. |
| 104 | + |
| 105 | +```bash |
| 106 | +# Create control planes 2 and 3, substituting the same info. |
| 107 | +for i in $( seq 1 3 ); do |
| 108 | + openstack server create talos-control-plane-$i --flavor $COMPUTE_FLAVOR_NAME --nic net-id=$PRIVATE_NETWORK_ID --image $IMAGE_NAME |
| 109 | +done |
| 110 | +``` |
| 111 | + |
| 112 | +We have now created our compute instances, but we still need to add floating IPs to allow for communication with the control plane nodes. |
| 113 | + |
| 114 | +```bash |
| 115 | +# Create floating IPs and associate them with the control plane nodes |
| 116 | +for i in $( seq 1 3 ); do |
| 117 | + openstack floating ip create --port $(openstack port list --server talos-control-plane-$i -f value -c ID) Ext-Net |
| 118 | +done |
| 119 | +``` |
| 120 | + |
| 121 | +### Load balancer |
| 122 | + |
| 123 | +Once the compute instances are created, we need to create a load balancer to load balance traffic to the control plane nodes. |
| 124 | + |
| 125 | +```bash |
| 126 | +# Create a Load Balancer |
| 127 | +export SUBNET_ID=$(openstack subnet show $SUBNET_NAME -f value -c id) |
| 128 | +openstack loadbalancer create --name $LOADBALANCER_NAME --vip-subnet-id $SUBNET_ID --flavor $LOADBALANCER_FLAVOR_NAME |
| 129 | +openstack floating ip create --port $(openstack loadbalancer show $LOADBALANCER_NAME -f value -c VIP_PORT_ID) Ext-Net |
| 130 | + |
| 131 | +# Create a listener for the load balancer |
| 132 | +openstack loadbalancer listener create --name talos-control-plane-listener --protocol TCP --protocol-port 6443 $LOADBALANCER_NAME --wait |
| 133 | + |
| 134 | +# Create a pool and health monitor for the load balancer |
| 135 | +openstack loadbalancer pool create --name talos-control-plane-pool --lb-algorithm ROUND_ROBIN --listener talos-control-plane-listener --protocol TCP --wait |
| 136 | +openstack loadbalancer healthmonitor create --delay 5 --max-retries 4 --timeout 10 --type TCP talos-control-plane-pool |
| 137 | + |
| 138 | +# Add members to the load balancer pool, substituting the private IPs of the control plane nodes and the protocol port (6443) |
| 139 | +for i in $( seq 1 3 ); do |
| 140 | + openstack loadbalancer member create --subnet-id $SUBNET_ID --address $(openstack floating ip list --port $(openstack port list --server talos-control-plane-$i -f value -c ID) -f value -c "Floating IP Address") --protocol-port 6443 talos-control-plane-pool --wait |
| 141 | +done |
| 142 | +``` |
| 143 | + |
| 144 | +### Cluster configuration |
| 145 | + |
| 146 | +Now that we have our compute instances and load balancer set up, we can generate our cluster configuration files with `talosctl`. |
| 147 | +We need to get the Public IP of the Load Balancer as this is our Kubernetes API endpoint, and the Public IPs of the control plane nodes as addional-sans for the API certificate. |
| 148 | + |
| 149 | +```bash |
| 150 | +# Get the Public IP of the Load Balancer |
| 151 | +export LOADBALANCER_VIP=$(openstack floating ip list --port $(openstack loadbalancer show $LOADBALANCER_NAME -f value -c VIP_PORT_ID) -f value -c "Floating IP Address") |
| 152 | + |
| 153 | +# Get the Public IPs of the control plane nodes |
| 154 | +for i in $( seq 1 3 ); do |
| 155 | + echo "talos-control-plane-$i:" $(openstack floating ip list --port $(openstack port list --server talos-control-plane-$i -f value -c ID) -f value -c "Floating IP Address") |
| 156 | +done |
| 157 | +``` |
| 158 | + |
| 159 | +Generate the cluster configuration file, substituting the Load Balancer VIP and control plane IPs as additional SANs for the API certificate. |
| 160 | +```bash |
| 161 | +talosctl gen config talos-ovhcloud https://$LOADBALANCER_VIP:6443 \ |
| 162 | + --additional-sans <CP1_IP>,<CP2_IP>,<CP3_IP> |
| 163 | +``` |
| 164 | + |
| 165 | +### Applying configuration and bootstrapping the cluster |
| 166 | +With our configuration file generated, we can now apply it to our control plane nodes and bootstrap the cluster. |
| 167 | + |
| 168 | +```bash |
| 169 | +# Apply the configuration to the control plane nodes, substituting the Public IPs of the control plane nodes. |
| 170 | +talosctl apply-config -f controlplane.yaml --insecure -n <CP1_IP> |
| 171 | +talosctl apply-config -f controlplane.yaml --insecure -n <CP2_IP> |
| 172 | +talosctl apply-config -f controlplane.yaml --insecure -n <CP3_IP> |
| 173 | + |
| 174 | +# Bootstrap the cluster using one of the control plane nodes |
| 175 | +talosctl bootstrap -n <CP1_IP> -e <CP1_IP> --talosconfig talosconfig |
| 176 | +``` |
| 177 | + |
| 178 | +Update the talosconfig file with the endpoint and node information for one of the control plane nodes: |
| 179 | + |
| 180 | +```bash |
| 181 | +talosctl config endpoint <CP1_IP> --talosconfig talosconfig |
| 182 | +talosctl config node <CP1_IP> --talosconfig talosconfig |
| 183 | +``` |
| 184 | + |
| 185 | +You should now be able to interact with your cluster with `talosctl`. |
| 186 | + |
| 187 | +### Retrieve the `kubeconfig` |
| 188 | + |
| 189 | +At this point we can retrieve the admin `kubeconfig` by running: |
| 190 | + |
| 191 | +```bash |
| 192 | +talosctl kubeconfig . --talosconfig talosconfig |
| 193 | +``` |
| 194 | + |
| 195 | +### Add worker nodes to the cluster |
| 196 | + |
| 197 | +```bash |
| 198 | +# Create worker node with the user data file |
| 199 | +openstack server create talos-worker-1 --flavor $COMPUTE_FLAVOR_NAME --nic net-id=$PRIVATE_NETWORK_ID --image $IMAGE_NAME --user-data /path/to/worker.yaml |
| 200 | +``` |
0 commit comments