Im new to kubernetes. In the yaml file to create services, i define externalIPs value in order to access services from outside the cluster:
kind: Service
apiVersion: v1
metadata:
name: mytestservice
spec:
type: ClusterIP
clusterIP: 10.96.1.113
externalIPs:
- 172.16.80.117
ports:
- name: tcp-8088
protocol: TCP
port: 8088
targetPort: 8088:
selector:
service-app: mytestservice
and it works just fine, i can call to my service by using externalIp:port (this case 172.16.80.117:8088). But i heard people talking about ingress controller (and some API gateways) that provide access from outside. I do read about them a bit but still cant tell what're the differences!? and does my cluster need them or not?
(According to the accepted answer i found here https://stackoverflow.com/questions/44110876/kubernetes-service-external-ip-pending
With the Ingress Controller you can setup a domain name which maps to your pod; you don't need to give your Service the LoadBalancer type if you use an Ingress Controller.
My cluster is a custom K8s Cluster too, using kubeadm. If i have no need of using domain name, just address my services directly by externalip and port then i can totally ignore ingress controller. Am i right?
Thanks!
According to Kubernetes documentation this is the recommendation.
ClusterIP: Exposes the Service on a cluster-internal IP. Choosing this value makes the Service only reachable from within the cluster. This is the default ServiceType.
NodePort: Exposes the Service on each Node's IP at a static port (the NodePort). A ClusterIP Service, to which the NodePort Service routes, is automatically created. You'll be able to contact the NodePort Service, from outside the cluster, by requesting <NodeIP>:<NodePort>.
LoadBalancer: Exposes the Service externally using a cloud provider's load balancer. NodePort and ClusterIP Services, to which the external load balancer routes, are automatically created
Finally the Ingress controller helps you to configure different domains or services through the Ingress rather than utilizing the LoadBalancer which is a bit expensive especially when you are hosting with cloud services More details about Ingress controller is described in the Kubernetes documentation
Welcome to the community.
Short answer:
At this point the answer to your question is yes, for simple cases you may completely ignore ingress. It will be a good option when it's time to go to production.
A bit more details:
Main point why you may need to look at ingress
is because it manages incoming traffic: works with HTTP/HTTPS requests, provides routing based on paths, can work with TLS/SSL and can perform TLS termination and many more.
There are different ingresses available, most common is nginx ingress
. It has almost all features regular nginx
has. You can find nginx ingress annotations to see what it can do.
For example, if you have microservices application, for each service separate load balancer will be required while everything can be directed to single ingress and routed further to services (see examples in useful links).
If you only play with kubernetes and single service, no need to even have a loadbalancer, you can use a nodePort
or externalIP
.
Also with ingress
deployed, there's no need to specify a port. Usually ingress
listens to 80
and 443
respectively.
I'd say it's worth trying to see how it works and make routing and managing service cleaner.
Useful links: