Egress service custom resource
You can define the configuration for an egress service in an EgressService custom resource.
The following YAML describes the fields for the configuration of an egress service:
apiVersion: k8s.ovn.org/v1
kind: EgressService
metadata:
name: <egress_service_name>
namespace: <namespace>
spec:
sourceIPBy: <egress_traffic_ip>
nodeSelector:
matchLabels:
node-role.kubernetes.io/<role>: ""
network: <egress_traffic_network>
where:
metadata.name-
Specifies the name for the egress service. The name of the
EgressServiceresource must match the name of the load-balancer service that you want to modify. metadata.namespace-
Specifies the namespace for the egress service. The namespace for the
EgressServicemust match the namespace of the load-balancer service that you want to modify. The egress service is namespace-scoped. spec.sourceIPBy-
Specifies the source IP address of egress traffic for pods behind a service. Valid values are
LoadBalancerIPorNetwork. Use theLoadBalancerIPvalue to assign theLoadBalancerservice ingress IP address as the source IP address for egress traffic. SpecifyNetworkto assign the network interface IP address as the source IP address for egress traffic. spec.nodeSelector-
Optional parameter. If you use the
LoadBalancerIPvalue for thesourceIPByspecification, a single node handles theLoadBalancerservice traffic. Use thenodeSelectorfield to limit which node can be assigned this task. When a node is selected to handle the service traffic, OVN-Kubernetes labels the node in the following format:egress-service.k8s.ovn.org/<svc-namespace>-<svc-name>: "". When thenodeSelectorfield is not specified, any node can manage theLoadBalancerservice traffic. spec.network-
Optional parameter. Specifies the routing table ID for egress traffic. Ensure that the value matches the
route-table-idID defined in theNodeNetworkConfigurationPolicyresource. If you do not include thenetworkspecification, the egress service uses the default host network.
apiVersion: k8s.ovn.org/v1
kind: EgressService
metadata:
name: test-egress-service
namespace: test-namespace
spec:
sourceIPBy: "LoadBalancerIP"
nodeSelector:
matchLabels:
vrf: "true"
network: "2"