<p>Is possible to change the IP of the Ingress ?</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  spec:
  defaultBackend:
service:
  name: test-reg
  port:
    number: 5000
</code></pre>
<p>now is assigned in automatic the 23 but I would like to change it and keep static</p>
<pre><code>[ciuffoly@master-node ~]$ kubectl get ingresses
NAME           CLASS    HOSTS   ADDRESS        PORTS   AGE
test-ingress   &lt;none&gt;   *       192.168.1.23   80      5m9s
</code></pre>

andrea ciuffoli
<p>The possibility of &quot;changing the IP address&quot; will heavily depend on the Kubernetes solution used and how <code>Ingress</code> is handled within the cluster.</p>
<p>Having in mind the lack of the information about the setup it could be hard to point to the right direction. I've decided to post a community wiki answer to give more of a baseline idea and point where to look for possible answer.</p>
<p>Feel free to expand it.</p>
<hr />
<p>If the Kubernetes cluster is managed (<code>GKE</code>, <code>EKS</code>, <code>AKS</code>) and you are using <code>Ingress</code> that is managed by your cloud provider, the best option would be to refer to its documentation on IP allocation. Some providers through <code>Ingress</code> annotations allow you to assign a specific IP address that was previously allocated (in <code>Web UI</code> for example).</p>
<p>If the Kubernetes cluster is provisioned on premise (<code>kubespray</code> or <code>kubeadm</code> or the <code>hard-way</code>) or it's something like <code>minikube</code>, <code>microk8s</code> or a <code>Docker Desktop</code> with Kubernetes it will still be the best course of action to check how it handles <code>Ingress</code> resource. There will be differences for example between the <code>kubespray</code> cluster with <code>metallb</code> and the <code>microk8s</code>.</p>
<p>What I mean by that is for the most part the <code>Ingress</code> resource is handled by an <code>Ingress controller</code> (a <code>Pod</code> or set of <code>Pods</code> inside the cluster). Depending on the solution used, it in most cases work like following:</p>
<ul>
<li>Resources are created for <code>Ingress</code> controller (<code>ClusterRoles</code>, <code>ValidatingWebhookConfiguration</code>, <code>RoleBindings</code>, etc.)</li>
<li><code>Service</code> of specific type (depending on the solution) is created to point to the <code>Deployment</code>/<code>Daemonset</code> that is an <code>Ingress controller</code> (like <code>nginx-ingress</code>, <code>kong</code>, etc).</li>
<li><code>Deployment</code>/<code>Daemonset</code> of an <code>Ingress controller</code> is created to receive the traffic and send it to <code>Services</code> that are specified in the <code>Ingress</code> resource.</li>
</ul>
<p><strong>For IP address changing you would need to take a look specifically on the part of how this <code>Ingress controller</code> is exposed to the external sources and if/how you can alter its configuration.</strong></p>
<p>There will also be inherent differences between on-premise clusters created with <code>kubeadm</code>, <code>kubespray</code> and local development solutions like <code>minikube</code> and <code>Docker Desktop</code> with Kubernetes.</p>
<p>From my experience I've encountered <code>Ingress controllers</code> that were exposed either via:</p>
<ul>
<li><code>Service</code> of type <code>LoadBalancer</code> - assuming that your setup allows for such <code>Service</code> you could use <a href="https://metallb.universe.tf/" rel="nofollow noreferrer">metallb</a></li>
<li><code>HostNetwork</code> (binding to the port on a <code>Node</code>, hence using it's IP address)</li>
</ul>
<hr />
<p>Additional reference:</p>
<ul>
<li><em><a href="https://www.ibm.com/cloud/blog/kubernetes-ingress" rel="nofollow noreferrer">Ibm.com: Cloud: Blog: Kubernetes Ingress</a></em></li>
<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>
</ul>
