<p>I installed Minikube v1.3.1 on my RedHat EC2 instance for some tests. </p>

<p><strong><em>Since the ports that the nginx-ingress-controller uses by default are already in use, I am trying to change them in the deployment but without result. Could please somebody advise how to do it?</em></strong></p>

<p><strong>How do I know that the port are already in Use?</strong></p>

<p>When I listed the system pods using the command <code>kubectl -n kube-system get deployment | grep nginx</code>, I get:</p>

<blockquote>
  <p>nginx-ingress-controller   0/1     1            0           9d</p>
</blockquote>

<p>meaning that my container is not up. When I describe it using the command <code>kubectl -n kube-system describe pod nginx-ingress-controller-xxxxx</code> I get:</p>

<blockquote>
  <p>Type     Reason                  Age                        From<br>
  Message   ----     ------                  ----<br>
  ----               -------   Warning  FailedCreatePodSandBox  42m (x163507 over 2d1h)    kubelet, minikube  (combined from similar
  events): Failed create pod sandbox: rpc error: code = Unknown desc =
  failed to start sandbox container for pod
  "nginx-ingress-controller-xxxx": Error response from daemon: driver
  failed programming external connectivity on endpoint
  k8s_POD_nginx-ingress-controller-xxxx_kube-system_...: Error starting
  userland proxy: listen tcp 0.0.0.0:443: bind: address already in use</p>
</blockquote>

<p>Then I check the processes using those ports and I kill them. That free them up and the ingress-controller pod gets deployed correctly. </p>

<p>What did I try to change the nginx-ingress-controller port?</p>

<pre><code>kubectl -n kube-system get deployment | grep nginx

&gt; NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
&gt; nginx-ingress-controller   0/1     1            0           9d

kubectl -n kube-system edit deployment nginx-ingress-controller
</code></pre>

<p>The relevant part of my deployment looks like this:</p>

<pre><code>name: nginx-ingress-controller
        ports:
        - containerPort: 80
          hostPort: 80
          protocol: TCP
        - containerPort: 443
          hostPort: 443
          protocol: TCP
        - containerPort: 81
          hostPort: 81
          protocol: TCP
        - containerPort: 444
          hostPort: 444
          protocol: TCP
        - containerPort: 18080
          hostPort: 18080
          protocol: TCP
</code></pre>

<p>Then I remove the subsections with port 443 and 80, but when I rollout the changes, <strong>they get added again</strong>.</p>

<p>Now my services are not reachable anymore through ingress.</p>

<p>Please note that <strong>minikube</strong> ships with <a href="https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/addon-manager" rel="nofollow noreferrer"><strong>addon-manager</strong></a>, which role is to keep an eye on specific addon template files (default location: <code>/etc/kubernetes/addons/</code>) and do one of two specific actions based on the label's value of managed resource:</p>
<blockquote>
<p>addonmanager.kubernetes.io/mode</p>
</blockquote>
<ol>
<li><code>addonmanager.kubernetes.io/mode=Reconcile</code></li>
</ol>
<blockquote>
<p>Will be periodically reconciled. Direct manipulation to these addons
through apiserver is discouraged because addon-manager will bring
them back to the original state. In particular</p>
</blockquote>
<ol start="2">
<li><code>addonmanager.kubernetes.io/mode=KeepOnly</code></li>
</ol>
<blockquote>
<p>Will be checked for existence only. Users can edit these addons as
they want.</p>
</blockquote>
<p>So to keep your customized version of default Ingress service listening ports, please change first the <a href="https://github.com/kubernetes/minikube/blob/ff0e25ada888cf1bd7b262857ce96531c1231e69/deploy/addons/ingress/ingress-dp.yaml.tmpl#L281" rel="nofollow noreferrer">Ingress deployment template configuration</a> to <code>KeepOnly</code> on minikube VM.</p>
