<p>I was wondering if it was possible to bind my minikube network to my <code>host</code> network.</p>
<p>I tried:</p>
<pre><code>minikube start --memory=10000 --cpus=4 --vm-driver=docker --kubernetes-version=v1.19.6 --mount --mount-string=&quot;/usr/local/citizennet/db:/usr/local/citizennet/db&quot; --network=&quot;host&quot;
</code></pre>
<p>But I'm getting the following error:</p>
<pre><code>❗  Unable to create dedicated network, this might result in cluster IP change after restart: un-retryable: create network host 192.168.49.0/24: docker network create --driver=bridge --subnet=192.168.49.0/24 --gateway=192.168.49.1 -o --ip-masq -o --icc -o com.docker.network.driver.mtu=1500 --label=created_by.minikube.sigs.k8s.io=true host: exit status 1
stdout:

stderr:
Error response from daemon: operation is not permitted on predefined host network
</code></pre>
<p>I was able to do that by using <code>haproxy</code> but I would like to know if there is a cleaner way of doing that.
My minikube is hosted on an EC2 instance and I would like to forward everything to my minikube directly. Or at least the HTTP/HTTPS requests.</p>
<p>Thanks!</p>

Jérémy Octeau
<p>I haven't found a way to expose the <code>minikube</code> instance with <code>--driver=docker</code> to the host network (apart from <code>$ kubectl port-forward svc/svc-name --address=0.0.0.0 local_port:pod_port</code> ran on the host).</p>
<p>It produces the same error as original poster is experiencing:</p>
<pre><code>Error response from daemon: operation is not permitted on predefined host network
</code></pre>
<p>Acknowledging following comment:</p>
<blockquote>
<p>the problem is that I want to use the <code>ingress</code> addon and this addon is not compatible anymore with <code>--driver=none</code>.</p>
</blockquote>
<p>Instead of using <code>--driver=docker</code> which will place all of the resources in the Docker container, you can opt for a <code>--driver=none</code> which will provision all of your resources directly on the <code>VM</code>. You will be able to directly query the resources from other network devices.</p>
<p>For now <code>minikube</code> version <code>v1.17.1</code> does not allow to use the <code>ingress</code> addon with <code>--driver=none</code> but I found a way it could be provisioned. I've included this example on the end of this answer. Please treat this as a workaround.</p>
<p><strong>This issue (inability to use <code>ingress</code> addon on <code>--driver=none</code>) is already addressed on github</strong>:</p>
<ul>
<li><em><a href="https://github.com/kubernetes/minikube/issues/9322" rel="nofollow noreferrer">Github.com: Kubernetes: Minikube: Issues: Ingress addon stopped to work with 'none' VM driver starting from v1.12.x</a></em></li>
</ul>
<hr />
<p>Talking from the perspective of exposing <code>minikube</code>:</p>
<p><strong>As it's intended for accessing from external sources, I do recommend trying out other solutions that will subjectively speaking have easier time exposing your workloads to the external sources.</strong> There are many available tools that spawn Kubernetes clusters and you can look which suits your needs the most. <strong>Some</strong> of them are:</p>
<ul>
<li><em><a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/" rel="nofollow noreferrer">Kubeadm</a></em></li>
<li><em><a href="https://github.com/kubernetes-sigs/kubespray" rel="nofollow noreferrer">Kubespray</a></em></li>
<li><em><a href="https://microk8s.io/" rel="nofollow noreferrer">MicroK8S</a></em></li>
</ul>
<hr />
<h2>Deploying <code>nginx-ingress</code> with <code>minikube --driver=none</code></h2>
<p>As stated previously, please treat it as a workaround.</p>
<blockquote>
<p>A side note!</p>
<p>Take a look on how your <code>NGINX Ingress</code> controller is configured with <code>minikube addons enable ingress</code> as it will be pretty much mimicked in this example.</p>
</blockquote>
<p>Steps:</p>
<ul>
<li><code>Download</code> the <code>nginx-ingress</code> <code>YAML</code> manifest:
<ul>
<li>Modify the <code>Deployment</code> in the manifest</li>
<li>Delete the <code>Service</code> from manifest</li>
</ul>
</li>
<li>Apply and check</li>
</ul>
<h3><code>Download</code> the <code>nginx-ingress</code> <code>YAML</code> manifest</h3>
<p>You can use following manifest:</p>
<ul>
<li><em><a href="https://kubernetes.github.io/ingress-nginx/deploy/" rel="nofollow noreferrer">Kubernetes.github.io: Ingress Nginx: Deploy</a></em> (for example <code>GKE</code> manifest could be downloaded)</li>
</ul>
<h3>Modify the <code>Deployment</code> in the manifest</h3>
<p>As I said previously, what is happening when you run <code>minikube addons enable ingress</code> could prove useful. The resources deployed have some clues on how you need to modify it.</p>
<ul>
<li>Add the <code>hostPort</code> for <code>HTTP</code> and <code>HTTPS</code> communication:</li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>          ports:
            - name: http
              hostPort: 80 # &lt;-- IMPORTANT, ADD THIS
              containerPort: 80
              protocol: TCP
            - name: https
              hostPort: 443 # &lt;-- IMPORTANT, ADD THIS
              containerPort: 443
              protocol: TCP
            - name: webhook
              containerPort: 8443
              protocol: TCP
</code></pre>
<ul>
<li>Delete the <code>--publish-service=$(POD_NAMESPACE)/ingress-nginx-controller</code>:</li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>          args:
            - /nginx-ingress-controller
            - --publish-service=$(POD_NAMESPACE)/ingress-nginx-controller # &lt;-- DELETE THIS
            - --election-id=ingress-controller-leader
            - --ingress-class=nginx
            - --configmap=$(POD_NAMESPACE)/ingress-nginx-controller
            - --validating-webhook=:8443
            - --validating-webhook-certificate=/usr/local/certificates/cert
            - --validating-webhook-key=/usr/local/certificates/key
</code></pre>
<h3>Delete the <code>Service</code> from manifest</h3>
<p>You will need to entirely delete the <code>Service</code> of type <code>LoadBalancer</code> named:  <code>ingress-nginx</code> from the manifest as you will already be using <code>hostPort</code>.</p>
<p>After this steps you should be able to use <code>Ingress</code> resources and communicate with them on <code>VM_IP</code>:<code>80</code>/<code>443</code>.</p>
<hr />
<p>Additional resources:</p>
<ul>
<li><em><a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">Kubernetes.io: Docs: Concepts: Services networking: Ingress</a></em></li>
<li><em><a href="https://minikube.sigs.k8s.io/docs/drivers/none/" rel="nofollow noreferrer">Minikube.sigs.k8s.io: Docs: Drivers: None</a></em></li>
</ul>
