For AI agents: the complete documentation index is available at https://docs.ovhcloud.com/pl/llms.txt, the full documentation bundle is available at https://docs.ovhcloud.com/pl/llms-full.txt, and this page is available as Markdown at https://docs.ovhcloud.com/pl/guides/public-cloud/containers-orchestration/managed-kubernetes/vrack-custom-gateway.md.
Przejdź do treści

Using a custom gateway on an OVHcloud Managed Kubernetes cluster

Pokaż jako Markdown

Find out how to use a custom gateway on OVHcloud Managed Kubernetes, with your own router or firewall (Standard plan) or a vRack gateway (Free plan)

Objective

A custom gateway lets you control how the nodes of your OVHcloud Managed Kubernetes cluster reach the Internet: for example to get a single output IP address you can allowlist, or to send all the traffic of your nodes through your own firewall to inspect, filter and log it (hub-and-spoke design).

The method depends on the plan of your cluster:

Standard planFree plan
Default Internet egress of the nodesThrough an OVHcloud managed gateway (one shared output IP), or through Floating IPs set at the node pool levelThrough the public IP address of each node
Custom gatewayYour own router or firewall, set as the gateway of the nodes subnet (useUserGateway)A gateway in your vRack, used as default route (privateNetworkRoutingAsDefault and defaultVrackGateway)
OVHcloud managed gateway requiredNo, when you use your own routerNot applicable
Public exposure of nodes and workloadsDisabled when you use your own router: no Floating IPs and no public Load BalancersUnchanged
When to configure itAt cluster creation only, cannot be changed afterwardsAt cluster creation or reset
Info

On every new Standard cluster, the traffic between the nodes and the Kubernetes control plane uses a private path operated by OVHcloud. Cluster operations do not depend on your gateway: a change or an outage of your router does not affect the communication between the nodes and the control plane.


OVHcloud Console Access

  • Direct link:
  • Navigation path: Public Cloud > Select your project > Containers > Managed Kubernetes Service

Use your own router or firewall (Standard plan)

How it works

On the Standard plan, nodes have no public IP by default: they reach the Internet through an OVHcloud managed gateway, or through Floating IPs set at the node pool level.

Standard clusters created since 13 October 2026, whatever their Kubernetes version, can instead use your own router or firewall as the default gateway of the nodes. This is the usual hub-and-spoke design: your security appliance is the hub, and the cluster is one of the spokes. Your appliance is the gateway announced on the nodes subnet of your private network: the outbound traffic of the nodes goes through it (except the traffic to the control plane and the system images of the service), and no OVHcloud managed gateway is required.

What this means for the cluster:

  • Your appliance carries the outbound traffic of the workloads: Internet access, other networks, on-premises resources. Pods leave with the private address of their node, so your firewall rules see node addresses, not pod addresses.
  • It is not on the path of the cluster itself: the nodes reach the Kubernetes control plane through a private path operated by OVHcloud, and the system images of the service do not go through your appliance. If your appliance is unavailable, the cluster keeps running, but your workloads that rely on it, for example to access the Internet or other external resources, are affected.
  • The public exposure of the nodes and workloads is disabled: Floating IPs cannot be attached to the nodes or to load balancers, and no public Load Balancer can be created. Inbound access to your applications goes through your own equipment.
Note

On the Standard plan, defaultVrackGateway and privateNetworkRoutingAsDefault are not used: the gateway of the nodes is the one configured on the nodes subnet.

Requirements

On the Kubernetes side:

  • A Public Cloud project in your OVHcloud account.
  • A Standard plan cluster created since 13 October 2026, with the options described below.

On the network side, whatever your appliance is (a virtual appliance on Public Cloud instances, a dedicated server or an on-premises device connected to your vRack):

  • A private network (vRack) with a subnet for the nodes, in the region of the cluster.
  • The subnet announces a default gateway (DHCP option 3), and this gateway address is held by your appliance. With the OVHcloud Console or the OVHcloud API, the subnet announces its first address: check Announce the first address of a given CIDR as the default gateway (DHCP option 3), or set noGateway to false. With the OpenStack API, you can choose another address.
  • DHCP is enabled on the subnet (recommended), and its allocation pool does not include the gateway address.
  • No OVHcloud managed gateway on this subnet.
  • Your appliance routes the outbound traffic of the nodes and allows at least DNS (port 53, TCP and UDP), plus the Internet access your workloads need, for example to pull images from public container registries.

Recommendations:

  • Make the gateway highly available, for example with two appliances sharing the gateway address as a virtual IP (VRRP or CARP): a single appliance is a single point of failure for the external access of your workloads.
  • If your appliance runs on Public Cloud instances, the gateway address must be reserved by a port of your appliance, and port security must be disabled on its interfaces so that it can forward traffic that is not its own. These settings are available through the OpenStack API.
Tip

The design of the hub (choice of appliance, high availability, filtering and routing rules) depends on your environment. To set up the network side, follow the guide Hub and spoke landing zone on OVHcloud Public Cloud. Your appliance can also sit in a separate hub network: the gateway announced on the nodes subnet is then an OpenStack router that forwards the traffic to this hub. If you need support to design or deploy it, contact your account manager or our Professional Services team.

Cluster network options

On the Managed Kubernetes side, two attributes of the cluster control this configuration. Both are optional and set to false by default; to use your own router, set both to true.

AttributeDescription
disablePublicNetworkingDisables the public exposure of the nodes and workloads: Floating IPs cannot be attached to the nodes or to load balancers, so no public Load Balancer can be created. The Kubernetes API server is not affected. Used alone, it still requires an OVHcloud managed gateway in the nodes subnet for outbound Internet access: it then works as a guardrail against any public exposure, see Understanding OVHcloud Managed Kubernetes architecture.
privateNetworkConfiguration.useUserGatewayThe nodes use your router, the gateway of the nodes subnet, as default gateway. Requires disablePublicNetworking set to true.
Warning

These attributes can only be set when the cluster is created and cannot be changed afterwards.

When disablePublicNetworking is true:

  • Floating IPs cannot be attached to the nodes or to load balancers;
  • Services of type LoadBalancer cannot be exposed through a public Load Balancer.

If you need to expose applications on the Internet from this cluster, keep the default configuration.

This option does not apply to the Kubernetes API server, which remains publicly reachable, subject to your IP restrictions.

If the configuration is not valid, the cluster creation is rejected:

SituationError message
useUserGateway set to true without disablePublicNetworking set to trueuseUserGateway require publicConnectivityDisabled
disablePublicNetworking set to true alone, without a managed gateway in the nodes subnetmissing a gateway in nodesSubnetId
Free plan clusternot supported

Create the cluster

OVHcloud Console
OVHcloud API
OVHcloud CLI
Terraform
Info

Support for these options in the OVHcloud Console is in progress. Until then, use the OVHcloud API or Terraform.

Add a node pool

Floating IPs cannot be attached to the nodes of this cluster: do not enable them on the node pool. In a region with several availability zones, such as EU-WEST-PAR, choose the zone of the node pool.

OVHcloud Console
OVHcloud API
OVHcloud CLI
Terraform

Add a node pool from the Node pools tab of your cluster by following the guide How to manage nodes and node pools on an OVHcloud Managed Kubernetes cluster.

Verify the configuration

Check the configuration of the cluster with the following API call:

The response contains "disablePublicNetworking": true and "privateNetworkConfiguration": { "useUserGateway": true }.

Once the node pool is READY, retrieve the kubeconfig file of your cluster (see the Connect to the cluster section of the guide "Creating a cluster"; with Terraform, use the kubeconfig output) and run a test Pod that displays its output IP:

kubectl run egress-test --rm -it --restart=Never --image=curlimages/curl -- curl -s https://ifconfig.me

The command must return the public IP address your router or firewall uses for outbound traffic.

Note

For an existing cluster that cannot be recreated, our teams can assess a manual migration to this configuration on a case-by-case basis. Contact your account manager.

Route egress through a gateway in your vRack (Free plan)

This tutorial applies to Free plan clusters.

In this tutorial we are going to use a custom gateway deployed in vRack with a Managed Kubernetes cluster.

Why?

By default, in a Kubernetes cluster, the Pods you deploy take the Node's output IP. So we have as many output IPs as Nodes. This can be a problem when you are in a situation where you need to manage an allowlist and you have a cluster with AutoScaling (creating and deleting Nodes on the fly).

One solution is to use a custom gateway which will allow you to have a single output IP (your gateway).

You will:

  • create a private network
  • create subnets
  • create an OpenStack router (in every region) and link them to the external provider network and the subnets
  • create an OVHcloud Managed Kubernetes cluster with the private gateway
  • test the Pod's output IP

At the end of this tutorial you should have the following flow:

Schema vrack gateway

Info

In this tutorial we guide you on how to create the private network in two regions but you can use only one region if you want, GRA9 for example.

Requirements

Initialization

In this tutorial, you use the OVHcloud CLI to create the private network, the subnets and the Kubernetes cluster, and the OpenStack CLI to create the routers and the routes of the subnets.

Configure the OVHcloud CLI with your OVHcloud API credentials by following the OVHcloud CLI documentation.

To manage OpenStack, create a utils folder in your environment/local machine, then create the utils/openrc file inside it, or download it from your OpenStack provider. It must be like:

export OS_AUTH_URL=https://auth.cloud.ovh.net/v3
export OS_IDENTITY_API_VERSION=3
export OS_USER_DOMAIN_NAME=${OS_USER_DOMAIN_NAME:-"Default"}
export OS_PROJECT_DOMAIN_NAME=${OS_PROJECT_DOMAIN_NAME:-"Default"}
export OS_TENANT_ID=xxxxxxxxxxxxxxxxxxxxx
export OS_TENANT_NAME="xxxxxxxxxxxxxxxxxx"
export OS_USERNAME="user-xxxxxxxxxxxxx"
export OS_PASSWORD="xxxxxxxxxxxxxxxxxx"
export OS_REGION_NAME="xxxx"
if [ -z "$OS_REGION_NAME" ]; then unset OS_REGION_NAME; fi

Load the variables:

. utils/openrc

The OS_TENANT_ID variable contains the ID of your Public Cloud project: the OVHcloud CLI commands of this tutorial use it with the --cloud-project flag.

Create Private Network

Important: Assuming that your PCI project is added to your vRack.

For this tutorial, we are using the two regions GRA9 and GRA11.

Create the private network named demo-pvnw, with the VLAN ID 20, in the GRA9 and GRA11 regions:

OVHcloud CLI
API

With the OVHcloud CLI, a private network is created in a single region: create one network per region, with the same VLAN ID, and get their IDs (pvnwGRA9Id & pvnwGRA11Id).

export pvnwGRA9Id="$(ovhcloud cloud network private vrack create GRA9 --cloud-project $OS_TENANT_ID --name demo-pvnw --vlan-id 20 --wait -o details.id)" && echo $pvnwGRA9Id

export pvnwGRA11Id="$(ovhcloud cloud network private vrack create GRA11 --cloud-project $OS_TENANT_ID --name demo-pvnw --vlan-id 20 --wait -o details.id)" && echo $pvnwGRA11Id

Create subnets

For this tutorial, we are splitting a /24 subnet, to obtain two /25 subnets.

Ref: https://www.davidc.net/sites/default/subnets/subnets.html

NameRegionCIDR AddressGatewayDHCP RangeBroadcast
Subnet 1GRA9192.168.0.0/25192.168.0.1192.168.0.2-192.168.0.126192.168.0.127
Subnet 2GRA11192.168.0.128/25192.168.0.129192.168.0.130-192.168.0.254192.168.0.255

Create the subnets, and get their IDs (subnGRA9 & subnGRA11):

OVHcloud CLI
API
export subnGRA9="$(ovhcloud cloud network private vrack subnet create $pvnwGRA9Id --cloud-project $OS_TENANT_ID \
  --name demo-subnet-gra9 --cidr 192.168.0.0/25 --gateway-ip 192.168.0.1 \
  --allocation-pools 192.168.0.2:192.168.0.126 --wait -o details.id)" && echo $subnGRA9

export subnGRA11="$(ovhcloud cloud network private vrack subnet create $pvnwGRA11Id --cloud-project $OS_TENANT_ID \
  --name demo-subnet-gra11 --cidr 192.168.0.128/25 --gateway-ip 192.168.0.129 \
  --allocation-pools 192.168.0.130:192.168.0.254 --wait -o details.id)" && echo $subnGRA11

It's not possible to add routes to the subnets with the OVHcloud CLI, so we must use the OpenStack CLI instead.

OpenStack CLI
openstack --os-region-name=GRA9 subnet set ${subnGRA9} --host-route destination=192.168.0.0/25,gateway=192.168.0.1

openstack --os-region-name=GRA11 subnet set ${subnGRA11} --host-route destination=192.168.0.128/25,gateway=192.168.0.129

OpenStack router

Create the routers

We have the ability to create OpenStack virtual routers. To do this, we need to use the OpenStack CLI. Create routers and get their IDs (rtrGRA9Id & rtrGRA11Id):

OpenStack CLI
export rtrGRA9Id="$(openstack --os-region-name=GRA9 router create rtr-GRA9 -f json | jq -r .id)" && echo $rtrGRA9Id
export rtrGRA11Id="$(openstack --os-region-name=GRA11 router create rtr-GRA11 -f json | jq -r .id)" && echo $rtrGRA11Id

You should have a result like this:

$ export rtrGRA9Id="$(openstack --os-region-name=GRA9 router create rtr-GRA9 -f json | jq -r .id)" && echo $rtrGRA9Id
26bf99c8-d6fa-4c5a-9d42-1358776ee0a2

$ export rtrGRA11Id="$(openstack --os-region-name=GRA11 router create rtr-GRA11 -f json | jq -r .id)" && echo $rtrGRA11Id
5c1e3f0a-8b2d-4e6f-9a7c-3d4b5e6f7a8b

First, get the regional external network ID (extNwGRA9Id & extNwGRA11Id), then link the router to it:

OpenStack CLI
# GRA9
export extNwGRA9Id="$(openstack --os-region-name=GRA9 network list -f json | jq -r '.[] | select(.Name=="Ext-Net") | .ID')" && echo $extNwGRA9Id
openstack --os-region-name=GRA9 router set $rtrGRA9Id --external-gateway $extNwGRA9Id
# GRA11
export extNwGRA11Id="$(openstack --os-region-name=GRA11 network list -f json | jq -r '.[] | select(.Name=="Ext-Net") | .ID')" && echo $extNwGRA11Id
openstack --os-region-name=GRA11 router set $rtrGRA11Id --external-gateway $extNwGRA11Id

You should have a result like this:

$ export extNwGRA9Id="$(openstack --os-region-name=GRA9 network list -f json | jq -r '.[] | select(.Name=="Ext-Net") | .ID')" && echo $extNwGRA9Id
b2c02fdc-ffdf-40f6-9722-533bd7058c06
$ openstack --os-region-name=GRA9 router set $rtrGRA9Id --external-gateway $extNwGRA9Id

$ export extNwGRA11Id="$(openstack --os-region-name=GRA11 network list -f json | jq -r '.[] | select(.Name=="Ext-Net") | .ID')" && echo $extNwGRA11Id
bcf59eb2-9d83-41cc-b4f5-0435ed594833
$ openstack --os-region-name=GRA11 router set $rtrGRA11Id --external-gateway $extNwGRA11Id

Now, you can display the information of your new virtual router on GRA9 in order to display its IP:

$ openstack --os-region-name=GRA9 router show $rtrGRA9Id -c id -c name -c status -c created_at -c external_gateway_info
+-----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field                 | Value                                                                                                                                                                                                                                                                                     |
+-----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at            | 2022-07-25T07:32:06Z                                                                                                                                                                                                                                                                      |
| external_gateway_info | {"network_id": "b2c02fdc-ffdf-40f6-9722-533bd7058c06", "external_fixed_ips": [{"subnet_id": "0f11270c-1113-4d4f-98de-eba83445d962", "ip_address": "141.94.209.244"}, {"subnet_id": "4aa6cac1-d5cd-4e25-b14b-7573aeabcab1", "ip_address": "2001:41d0:304:400::917"}], "enable_snat": true} |
| id                    | 26bf99c8-d6fa-4c5a-9d42-1358776ee0a2                                                                                                                                                                                                                                                      |
| name                  | rtr-GRA9                                                                                                                                                                                                                                                                                  |
| status                | ACTIVE                                                                                                                                                                                                                                                                                    |
+-----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

As you can see, in this example, the IP of the gateway will be 141.94.209.244.

Do the same with the regional subnets:

OpenStack CLI
# GRA9
openstack --os-region-name=GRA9 router add subnet $rtrGRA9Id $subnGRA9
# GRA11
openstack --os-region-name=GRA11 router add subnet $rtrGRA11Id $subnGRA11

Create a Kubernetes cluster with private gateway

Now the network is ready. Create an OVHcloud Managed Kubernetes cluster, specifying the use of the gateway defined on each subnet.

Note: until the end of this tutorial, we are only using the GRA9 region, but you can repeat the exact same steps to create a cluster on the GRA11 region.

Info

In this guide we defined 1.34 version for the Kubernetes cluster but you can use another supported version.

Create the OVHcloud Managed Kubernetes cluster in GRA9, on the GRA9 private network (pvnwGRA9Id), and get the cluster ID (kubeId):

OVHcloud CLI
API
OVHcloud Console
Terraform

Create a data-kube.json file with the parameters of the cluster and of its node pool:

{
  "region": "GRA9",
  "name": "demo",
  "version": "1.34",
  "nodepool": {
    "flavorName": "b3-8",
    "antiAffinity": false,
    "monthlyBilled": false,
    "autoscale": false,
    "desiredNodes": 3
  },
  "privateNetworkConfiguration": {
    "privateNetworkRoutingAsDefault": true,
    "defaultVrackGateway": "192.168.0.1"
  }
}

Then create the cluster with the ID of the GRA9 private network:

export kubeId="$(ovhcloud cloud managed-kubernetes create --cloud-project $OS_TENANT_ID --from-file data-kube.json --private-network-id $pvnwGRA9Id -o details.id)" && echo $kubeId

Now wait until your OVHcloud Managed Kubernetes cluster is READY.

For that, you can check its status in the OVHcloud Console:

Click on Managed Kubernetes Service under Containers in the left-hand menu of your Public Cloud project.

Click your demo cluster: its Network tab shows that it is attached to the demo-pvnw network.

Its status is displayed in the Overview tab.

When your cluster's status is OK, you can go to the next section.

Get Kubeconfig file

To proceed with the freshly created Kubernetes cluster, you must get the Kubeconfig file.

OVHcloud CLI
API
Terraform
ovhcloud cloud managed-kubernetes kubeconfig generate $kubeId --cloud-project $OS_TENANT_ID > kubeconfig-demo.yml

To use this kubeconfig file and access to your cluster, you can follow our configuring kubectl tutorial, or simply add the --kubeconfig flag in your kubectl commands.

Test

List the running nodes in your cluster:

kubectl --kubeconfig=kubeconfig-demo.yml get no -o wide

You should obtain a result like this:

$ kubectl --kubeconfig=kubeconfig-demo.yml get no -o wide
NAME                                         STATUS   ROLES    AGE   VERSION   INTERNAL-IP    EXTERNAL-IP      OS-IMAGE             KERNEL-VERSION       CONTAINER-RUNTIME
nodepool-8f0b4d98-874a-4cfd-b8-node-c74f26   Ready    <none>   56m   v1.34.0   192.168.0.71   141.94.215.23    Ubuntu 18.04.6 LTS   4.15.0-189-generic   containerd://1.4.6
nodepool-8f0b4d98-874a-4cfd-b8-node-c9bf60   Ready    <none>   57m   v1.34.0   192.168.0.96   141.94.208.78    Ubuntu 18.04.6 LTS   4.15.0-189-generic   containerd://1.4.6
nodepool-8f0b4d98-874a-4cfd-b8-node-e666f5   Ready    <none>   56m   v1.34.0   192.168.0.31   141.94.212.214   Ubuntu 18.04.6 LTS   4.15.0-189-generic   containerd://1.4.6

Now test the cluster by running a simple container that requests its published IP address.

kubectl --kubeconfig=kubeconfig-demo.yml run --image=debian debian -it -- bash
apt update
apt install -y curl
curl ifconfig.me

You should obtain a result like this:

$ kubectl --kubeconfig=kubeconfig-demo.yml run --image=debian debian  -it -- bash
If you don't see a command prompt, try pressing enter.
root@debian:/# apt update
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Get:4 http://deb.debian.org/debian bullseye/main amd64 Packages [8182 kB]
Get:5 http://deb.debian.org/debian-security bullseye-security/main amd64 Packages [167 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [2592 B]
...

root@debian:/# apt install -y curl
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  ca-certificates libbrotli1 libcurl4 libldap-2.4-2 libldap-common libnghttp2-14 libpsl5 librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libssh2-1 openssl publicsuffix
Suggested packages:
...

root@debian:/# curl ifconfig.me
141.94.209.244

The IP address of our Pod is indeed that of our gateway!

Cleanup

To delete created resources, please follow these instructions:

Kubernetes cluster

OVHcloud CLI
API
Terraform
ovhcloud cloud managed-kubernetes delete $kubeId --cloud-project $OS_TENANT_ID

Routers

To delete an Openstack router, you must first remove the linked ports.

OpenStack CLI
# Get the routers subnets attached ports Ids
export portIdGRA9="$(openstack --os-region-name=GRA9 port list | grep -w "192.168.0.1" | awk '{print $2}')" && echo $portIdGRA9
export portIdGRA11="$(openstack --os-region-name=GRA11 port list | grep -w "192.168.0.129" | awk '{print $2}')" && echo $portIdGRA11
# Get the routers Ids
export rtrIdGRA9="$(openstack --os-region-name=GRA9 router list -f json | jq -r '.[] | select(.Name=="rtr-GRA9") | .ID')" && echo $rtrIdGRA9
export rtrIdGRA11="$(openstack --os-region-name=GRA11 router list -f json | jq -r '.[] | select(.Name=="rtr-GRA11") | .ID')" && echo $rtrIdGRA11
# Remove ports from routers
openstack --os-region-name=GRA9 router remove port $rtrIdGRA9 $portIdGRA9
openstack --os-region-name=GRA11 router remove port $rtrIdGRA11 $portIdGRA11
# Delete routers
openstack --os-region-name=GRA9 router delete $rtrIdGRA9
openstack --os-region-name=GRA11 router delete $rtrIdGRA11

Subnets

OVHcloud CLI
API
ovhcloud cloud network private vrack subnet delete $pvnwGRA9Id $subnGRA9 --cloud-project $OS_TENANT_ID
ovhcloud cloud network private vrack subnet delete $pvnwGRA11Id $subnGRA11 --cloud-project $OS_TENANT_ID

Private Network

OVHcloud CLI
API
ovhcloud cloud network private vrack delete $pvnwGRA9Id --cloud-project $OS_TENANT_ID
ovhcloud cloud network private vrack delete $pvnwGRA11Id --cloud-project $OS_TENANT_ID

Go further

Join our community of users.

Czy ta strona była pomocna?