Reputation: 16755
I already have a Loadbalancer
service for my a Deployment
. I now want to add an Ingress
on top of the service. Would I need to change the type of service to NodePort
?
Current service
apiVersion: v1
kind: Service
metadata:
name: name-service
spec:
selector:
app: name
ports:
- protocol: TCP
port: 9000 #this service is reachable at this port
targetPort: 9000 #this service will forward the request to correspoding nodes of the service at this port
type: LoadBalancer
I want to add this Ingress
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: name-https-loadbalancer-ingress
annotations:
# If the class annotation is not specified it defaults to "gce".
#There are two Ingress classes available for GKE Ingress. The gce class deploys an external load balancer and the gce-internal class deploys an internal load balancer. Ingress resources without a class specified default to gce.
kubernetes.io/ingress.class: "gce"
kubernetes.io/ingress.global-static-ip-name: SomeReservedIP
networking.gke.io/managed-certificates: SomeSSLCertificate
spec:
rules:
- http:
paths:
- path: /*
backend:
serviceName: name-service
servicePort: 9000
The examples on GCP
website use Nodeport
.
As I already have a Loadbalancer
service and Ingress
also creates a Loadbalancer
, I am wondering if this causes issues
Upvotes: 0
Views: 95
Reputation: 161
Since on k8s, kind: Service and kind: Ingress are different things, here is a little summary about each one:
As per Service, is a An abstract way to expose an application running on a set of Pods as a network service. Meanwhile Ingress, exposes HTTP and HTTPS routes from outside the cluster to services within the cluster. Traffic routing is controlled by rules defined on the Ingress resource.
Also, there are a defined ports that you are able to use for an HTTP(s), and node port, for example, for an HTTP(s) you can only use ports 80, 443 and 8080.
So, the answer is yes, if you have an ingress and a service with the same port, this is causing an issue. My recommendation is to review this guidance about to configure an ingress on a HTTP(s) LB.
I hope this information will be helpful to you.
Upvotes: 1