<p>I'm quite new in docker and VPNs so I don't know what should be the best way to achieve this.</p>
<p>Contex:
I use airflow in Google Cloud to schedule some task. These tasks are dockerized so each task is the execution of a docker container with a script (Using KubernetesPodOperator)</p>
<p>For this use case I need that the connection was done through VPN and then run the script.
To connect the VPN (locally) I use user, password and CA certificate.</p>
<p>I've seen some ways to do it, but all of them use another docker image as VPN or with a bridge using host vpn.</p>
<p>What's the best way to develop a solution for this?</p>

Miguel Angel Alvarez Rodriguez
<p>I think what you saw is good advice.</p>
<p>There are a number of projects that show how it could be done - one example here: <a href="https://gitlab.com/dealako/k8s-sidecar-vpn" rel="nofollow noreferrer">https://gitlab.com/dealako/k8s-sidecar-vpn</a></p>
<p>Using sidecar for VPN connection is usually a good idea. It has a number of advantages:</p>
<ul>
<li>allows you to use existing VPN images so that you do not have to add the VPN software to your images</li>
<li>Allows to use exactly the same VPN image and configuration for multiple pods/services</li>
<li>allows you to keep your secrets (user/password) only available to VPN and the VPN will only expose a plain TCP/http connection available only to your service - your service/task will never a cess the secrets which makes it a very secure way of storing the secrets and authentication</li>
</ul>
