Assigning an egress IP address

As a cluster administrator, you can assign an egress IP address for traffic leaving the cluster from a namespace or from specific pods in a namespace.

Assigning an egress IP address to a namespace

You can assign one or more egress IP addresses to a namespace or to specific pods in a namespace.

Prerequisites

  • Install the OpenShift CLI (oc).

  • Log in to the cluster as a cluster administrator.

  • Configure at least one node to host an egress IP address.

Procedure

  1. Create an EgressIP object:

    1. Create a <egressips_name>.yaml file where <egressips_name> is the name of the object.

    2. In the file that you created, define an EgressIPs object, as in the following example:

      1. apiVersion: k8s.ovn.org/v1
      2. kind: EgressIP
      3. metadata:
      4. name: egress-project1
      5. spec:
      6. egressIPs:
      7. - 192.168.127.10
      8. - 192.168.127.11
      9. namespaceSelector:
      10. matchLabels:
      11. env: qa
  2. To create the object, enter the following command.

    1. $ oc apply -f <egressips_name>.yaml (1)
    1Replace <egressips_name> with the name of the object.

    Example output

    1. egressips.k8s.ovn.org/<egressips_name> created
  3. Optional: Save the <egressips_name>.yaml file so that you can make changes later.

Additional resources