$ oc patch netnamespace <project_name> --type=merge -p \ (1)
'{
"egressIPs": [
"<ip_address>" (2)
]
}'
As a cluster administrator, you can configure the OpenShift SDN default Container Network Interface (CNI) network provider to assign one or more egress IP addresses to a project.
By configuring an egress IP address for a project, all outgoing external connections from the specified project will share the same, fixed source IP address. External resources can recognize traffic from a particular project based on the egress IP address. An egress IP address assigned to a project is different from the egress router, which is used to send traffic to specific destinations.
egress IP addresses are implemented as additional IP addresses on the primary network interface of the node and must be in the same subnet as the node’s primary IP address.
egress IP addresses must not be configured in any Linux network configuration files, such as egress IPs on Amazon Web Services (AWS), Google Cloud Platform (GCP), and Azure are supported only on OKD version 4.10 and later. Allowing additional IP addresses on the primary network interface might require extra configuration when using some virtual machines solutions. |
You can assign egress IP addresses to namespaces by setting the egressIPs
parameter of the NetNamespace
object. After an egress IP is associated with a project, OpenShift SDN allows you to assign egress IPs to hosts in two ways:
In the automatically assigned approach, an egress IP address range is assigned to a node.
In the manually assigned approach, a list of one or more egress IP address is assigned to a node.
Namespaces that request an egress IP address are matched with nodes that can host those egress IP addresses, and then the egress IP addresses are assigned to those nodes.
If the egressIPs
parameter is set on a NetNamespace
object, but no node hosts that egress IP address, then egress traffic from the namespace will be dropped.
High availability of nodes is automatic. If a node that hosts an egress IP address is unreachable and there are nodes that are able to host that egress IP address, then the egress IP address will move to a new node. When the unreachable node comes back online, the egress IP address automatically moves to balance egress IP addresses across nodes.
The following limitations apply when using egress IP addresses with the OpenShift SDN cluster network provider:
|
If you use OpenShift SDN in multitenant mode, you cannot use egress IP addresses with any namespace that is joined to another namespace by the projects that are associated with them.
For example, if |
When using the automatic assignment approach for egress IP addresses the following considerations apply:
You set the egressCIDRs
parameter of each node’s HostSubnet
resource to indicate the range of egress IP addresses that can be hosted by a node.
OKD sets the egressIPs
parameter of the HostSubnet
resource based on the IP address range you specify.
Only a single egress IP address per namespace is supported when using the automatic assignment mode.
If the node hosting the namespace’s egress IP address is unreachable, OKD will reassign the egress IP address to another node with a compatible egress IP address range. The automatic assignment approach works best for clusters installed in environments with flexibility in associating additional IP addresses with nodes.
This approach is used for clusters where there can be limitations on associating additional IP addresses with nodes such as in public cloud environments.
When using the manual assignment approach for egress IP addresses the following considerations apply:
You set the egressIPs
parameter of each node’s HostSubnet
resource to indicate the IP addresses that can be hosted by a node.
Multiple egress IP addresses per namespace are supported.
When a namespace has multiple egress IP addresses, if the node hosting the first egress IP address is unreachable, OKD will automatically switch to using the next available egress IP address until the first egress IP address is reachable again.
In OKD you can enable automatic assignment of an egress IP address for a specific namespace across one or more nodes.
You have access to the cluster as a user with the cluster-admin
role.
You have installed the OpenShift CLI (oc
).
Update the NetNamespace
object with the egress IP address using the
following JSON:
$ oc patch netnamespace <project_name> --type=merge -p \ (1)
'{
"egressIPs": [
"<ip_address>" (2)
]
}'
1 | Specify the name of the project. |
2 | Specify a single egress IP address. Using multiple IP addresses is not supported. |
For example, to assign project1
to an IP address of 192.168.1.100 and
project2
to an IP address of 192.168.1.101:
$ oc patch netnamespace project1 --type=merge -p \
'{"egressIPs": ["192.168.1.100"]}'
$ oc patch netnamespace project2 --type=merge -p \
'{"egressIPs": ["192.168.1.101"]}'
Because OpenShift SDN manages the |
Indicate which nodes can host egress IP addresses by setting the egressCIDRs
parameter for each host using the following JSON:
$ oc patch hostsubnet <node_name> --type=merge -p \ (1)
'{
"egressCIDRs": [
"<ip_address_range_1>", "<ip_address_range_2>" (2)
]
}'
1 | Specify a node name. |
2 | Specify one or more IP address ranges in CIDR format. |
For example, to set node1
and node2
to host egress IP addresses
in the range 192.168.1.0 to 192.168.1.255:
$ oc patch hostsubnet node1 --type=merge -p \
'{"egressCIDRs": ["192.168.1.0/24"]}'
$ oc patch hostsubnet node2 --type=merge -p \
'{"egressCIDRs": ["192.168.1.0/24"]}'
OKD automatically assigns specific egress IP addresses to
available nodes in a balanced way. In this case, it assigns the egress IP
address 192.168.1.100 to node1
and the egress IP address 192.168.1.101 to
node2
or vice versa.
In OKD you can associate one or more egress IP addresses with a namespace.
You have access to the cluster as a user with the cluster-admin
role.
You have installed the OpenShift CLI (oc
).
Update the NetNamespace
object by specifying the following JSON
object with the desired IP addresses:
$ oc patch netnamespace <project> --type=merge -p \ (1)
'{
"egressIPs": [ (2)
"<ip_address>"
]
}'
1 | Specify the name of the project. |
2 | Specify one or more egress IP addresses. The egressIPs parameter is an
array. |
For example, to assign the project1
project to an IP address of
192.168.1.100
:
$ oc patch netnamespace project1 --type=merge \
-p '{"egressIPs": ["192.168.1.100"]}'
You can set egressIPs
to two or more IP addresses on different nodes to
provide high availability. If multiple egress IP addresses are set, pods use the
first IP in the list for egress, but if the node hosting that IP address fails,
pods switch to using the next IP in the list after a short delay.
Because OpenShift SDN manages the |
Manually assign the egress IP to the node hosts. Set the egressIPs
parameter
on the HostSubnet
object on the node host. Using the following JSON, include
as many IPs as you want to assign to that node host:
$ oc patch hostsubnet <node_name> --type=merge -p \ (1)
'{
"egressIPs": [ (2)
"<ip_address_1>",
"<ip_address_N>"
]
}'
1 | Specify the name of the node. |
2 | Specify one or more egress IP addresses. The egressIPs field is an array. |
For example, to specify that node1
should have the egress IPs 192.168.1.100
,
192.168.1.101
, and 192.168.1.102
:
$ oc patch hostsubnet node1 --type=merge -p \
'{"egressIPs": ["192.168.1.100", "192.168.1.101", "192.168.1.102"]}'
In the previous example, all egress traffic for project1
will be routed to the
node hosting the specified egress IP, and then connected (using NAT) to that IP
address.