<h2>Current set-up</h2>
<p>Cluster specs: Managed Kubernetes on Digital Ocean</p>
<h2>Goal</h2>
<p>My pods are accessing some websites but I want to use a proxy first.</p>
<h2>Problem</h2>
<p>The proxy I need to use is only taking 1 IP address in an &quot;allow-list&quot;.</p>
<p>My cluster is using different nodes, with node-autoscaler so I have multiple and changing IP addresses.</p>
<h2>Solutions I am thinking about</h2>
<ul>
<li>Setting-up a proxy (squid? nginx?) outside of the cluster (Currently not working when I access an HTTPS website)</li>
<li>Istio could let me set-up a gateway? (No knowledge of Istio)</li>
<li>Use GCP managed K8s, and follow the answers on <a href="https://stackoverflow.com/q/52484435/9967831">Kubernetes cluster outgoing traffic IP</a>. But all our stack is on Digital Ocean and the pricing is better there.</li>
</ul>
<hr />
<p><em>I am curious to know what is the best practice, easiest solution or if anyone experienced such use-case before :)</em></p>
<p>Best</p>

François
<p>You could set up all your traffic to go through <a href="https://istio.io/latest/docs/tasks/traffic-management/egress/egress-gateway/" rel="nofollow noreferrer"><code>istio-egressgateway</code></a>.</p>
<p>Then you could manipulate the <code>istio-egressgateway</code> to always be deployed on the same node of the cluster, and whitelist that IP address.</p>
<p><strong>Pros:</strong> super easy. BUT. If you are not using Istio already, to set up Istio just for this is may be killing a mosquito with a bazooka.</p>
<p><strong>Cons:</strong> Need to make sure the node doesn't change the IP address. Otherwise the <code>istio-egressgateway</code> itself might not get deployed (if you do not have the labels added to the new node), and you will need to reconfigure everything for the new node (new IP address). Another con might be the fact that if the traffic goes up, there is an HPA, which will deploy more replicas of the gateway, and all of them will be deployed on the same node. So, if you are going to have lots of traffic, may be it would be a good idea to isolate one node, just for this purpose.</p>
<p>Another option would be as you are suggesting; a proxy. I would recommend an Envoy proxy directly. I mean, Istio is going to be using Envoy anyways right? So, just get the proxy directly, put it in a pod, do the same thing as I mentioned before; node affinity, so it will always run on the same node, so it will go out with the same IP.</p>
<p><strong>Pros:</strong> You are not installing entire service mesh control plane for one tiny thing.</p>
<p><strong>Cons:</strong> Same as before, as you still have the issue of the node IP change if something goes wrong, plus you will need to manage your own <code>Deployment</code> object, HPA, configure the Envoy proxy, etc. instead of using Istio objects (like <code>Gateway</code> and a <code>VirtualService</code>).</p>
<p>Finally, I see a third option; to set up a NAT gateway outside the cluster, and configure your traffic to go through it.</p>
<p><strong>Pros:</strong> You won't have to configure any kubernetes object, therefor there will be no need to set up any node affinity, therefor there will be no node overwhelming or IP change. Plus you can remove the external IP addresses from your cluster, so it will be more secure (unless you have other workloads that need to reach internet directly). Also , probably having a single node configured as NAT will be more resilient then a kubernetes pod, running in a node.</p>
<p><strong>Cons:</strong> May be a little bit more complicate to set up?</p>
<p>And there is this general Con, that you can whitelist only 1 IP address, so you will always have a single point of failure. Even NAT gateway; it still can fail.</p>
<p>The GCP static IP won't help you. What is suggesting the other post is to reserve an IP address, so you can re-use it always. But it's not that you will have that IP address automatically added to a random node that goes down. Human intervention is needed. I don't think you can have one specific node to have a static IP address, and if it goes down, the new created node will pick the same IP. That service, to my knowledge, doesn't exist.</p>
<p>Now, GCP does offer a very resilient NAT gateway. It is managed by Google, so shouldn't fail. Not cheap though.</p>
