Reputation: 161
Is possible to change the IP of the Ingress ?
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test-ingress
spec:
defaultBackend:
service:
name: test-reg
port:
number: 5000
now is assigned in automatic the 23 but I would like to change it and keep static
[ciuffoly@master-node ~]$ kubectl get ingresses
NAME CLASS HOSTS ADDRESS PORTS AGE
test-ingress <none> * 192.168.1.23 80 5m9s
Upvotes: 0
Views: 3461
Reputation: 9877
The possibility of "changing the IP address" will heavily depend on the Kubernetes solution used and how Ingress
is handled within the cluster.
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.
Feel free to expand it.
If the Kubernetes cluster is managed (GKE
, EKS
, AKS
) and you are using Ingress
that is managed by your cloud provider, the best option would be to refer to its documentation on IP allocation. Some providers through Ingress
annotations allow you to assign a specific IP address that was previously allocated (in Web UI
for example).
If the Kubernetes cluster is provisioned on premise (kubespray
or kubeadm
or the hard-way
) or it's something like minikube
, microk8s
or a Docker Desktop
with Kubernetes it will still be the best course of action to check how it handles Ingress
resource. There will be differences for example between the kubespray
cluster with metallb
and the microk8s
.
What I mean by that is for the most part the Ingress
resource is handled by an Ingress controller
(a Pod
or set of Pods
inside the cluster). Depending on the solution used, it in most cases work like following:
Ingress
controller (ClusterRoles
, ValidatingWebhookConfiguration
, RoleBindings
, etc.)Service
of specific type (depending on the solution) is created to point to the Deployment
/Daemonset
that is an Ingress controller
(like nginx-ingress
, kong
, etc).Deployment
/Daemonset
of an Ingress controller
is created to receive the traffic and send it to Services
that are specified in the Ingress
resource.For IP address changing you would need to take a look specifically on the part of how this Ingress controller
is exposed to the external sources and if/how you can alter its configuration.
There will also be inherent differences between on-premise clusters created with kubeadm
, kubespray
and local development solutions like minikube
and Docker Desktop
with Kubernetes.
From my experience I've encountered Ingress controllers
that were exposed either via:
Service
of type LoadBalancer
- assuming that your setup allows for such Service
you could use metallbHostNetwork
(binding to the port on a Node
, hence using it's IP address)Additional reference:
Upvotes: 2