<p>I have a pod within a Kubernetes cluster that needs to send alarms via SNMP to an external network management system. However, the external system will only be able to identify the pod if it keeps a stable IP address. Considering the ephermal nature of pods, would it be possible to send/redirect requests to a system outside of the cluster with a static IP?</p>
<p>The information I could gather by now only proposed solutions on how to reach the pod from outside the cluster with e.g. Services. I found the following <a href="https://stackoverflow.com/a/59488628/11783513">answer</a> that suggests using an egress gateway, but not much information is provided on how to approach the issue.</p>

M M
<p>One viable solution is to utilize an Egress Router resource defined <a href="https://docs.openshift.com/container-platform/4.12/networking/openshift_sdn/using-an-egress-router.html" rel="nofollow noreferrer">here</a>, which redirects traffic to a specified IP using a dedicated source IP address:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: egress-1
  labels:
    name: egress-1
  annotations:
    pod.network.openshift.io/assign-macvlan: &quot;true&quot; 
spec:
  initContainers:
  - name: egress-router
    image: registry.redhat.io/openshift4/ose-egress-router
    securityContext:
      privileged: true
    env:
    - name: EGRESS_SOURCE 
      value: &lt;egress_router&gt;
    - name: EGRESS_GATEWAY 
      value: &lt;egress_gateway&gt;
    - name: EGRESS_DESTINATION 
      value: &lt;egress_destination&gt;
    - name: EGRESS_ROUTER_MODE
      value: init
  containers:
  - name: egress-router-wait
    image: registry.redhat.io/openshift4/ose-pod
</code></pre>
<p>An example configuration looks like follows:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: egress-multi
  labels:
    name: egress-multi
  annotations:
    pod.network.openshift.io/assign-macvlan: &quot;true&quot;
spec:
  initContainers:
  - name: egress-router
    image: registry.redhat.io/openshift4/ose-egress-router
    securityContext:
      privileged: true
    env:
    - name: EGRESS_SOURCE
      value: 192.168.12.99/24
    - name: EGRESS_GATEWAY
      value: 192.168.12.1
    - name: EGRESS_DESTINATION
      value: |
        203.0.113.25
    - name: EGRESS_ROUTER_MODE
      value: init
  containers:
  - name: egress-router-wait
    image: registry.redhat.io/openshift4/ose-pod
</code></pre>
<p>The Egress Router pod is exposed by a Service and linked to the application that needs to send outbound SNMP traps:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: egress-1
spec:
  ports:
  - name: snmp
    port: 162
  type: ClusterIP
  selector:
    name: egress-1
</code></pre>
<p>The application sends the SNMP trap to the ClusterIP/Service-Name of the Service exposing the Egress Router pod, and the pod redirects the request to the specified remote server. Once redirected, the source IP is changed to the Source IP specified in the Egress Router resource. For more information on implementing the egress router in redirection mode, see <a href="https://docs.openshift.com/container-platform/4.12/networking/openshift_sdn/deploying-egress-router-layer3-redirection.html#deploying-egress-router-layer3-redirection" rel="nofollow noreferrer">here</a>.</p>
<p><strong>Note that depending on your network configuration, you might need to configure the <em>assign-macvlan</em> field to a different NIC interface and set it to the name of that interface, e.g. <em>eth1</em></strong>.</p>
