I was working on a small project and struggling to expose port 80 and 443 in google container engine without load balance.
Although, this service is powered by the Container Engine. So I chose GCE to avoid configuration issues, costs are affordable and to learn new things.
My modules are working fine and I created a service with a type
LoadBalancer to provide service on ports 80 and 443. This works fine.
However, I found that
LoadBalancer in a new Google Compute Engine, created for each service. This load balancer is quite expensive and is really complete for my project in one copy.
But, to cut costs, I’m looking for a way to expose ports without load balancing.
So what I’ve tried so far:
- Deploy the
NodePortservice. Unfortunately, it is forbidden to set the port below 30,000.
- Expand Ingress, but this will create a load balancer as well.
- Tried to disable
HttpLoadBalancing( https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters#HttpLoadBalancing ) but it still creates the load balancer.
Even it did not fit for my requirement, so I tried my next steps, which could be helpful for you to meet your requirement too.
Which solution worked ?
After configuring the service for ports 80 and 443, I had to create a firewall rule to allow traffic to my instance host:
gcloud compute firewall-rules create your-name-for-this-fw-rule --allow tcp:80,tcp:443 --source-ranges=0.0.0.0/0
Doing this setup, finally, I was able to access my service via http (s): // yourexternalIp. You may also check out this article.