It’s the first cluster!
Missing the most important line to allow access externally!
Few weeks after the chat of all the Kubernetes and stuff, I finally got myself together and started my first cluster on Google Cloud. But I tried and tried, searched the internet, followed different tutorials to get my interesting API up and running, somehow I just couldn’t access my endpoint from outside the cluster. The next thing I did was asking for help again.
-Did you see anything on
kubectl get po --all-namespaces ?
I did, and I see my Service with
None as external IP and
80/TCP as port. But if I ssh to the node,
docker ps, I didn’t see any ports binding with any of the containers…
-Have you added
type: LoadBalancer in the service spec ?
Oh no! I didn’t 😱
-Yeahhhhh. By default a service has a ClusterIP, which is only accessible inside the cluster. You have to set
type: LoadBalancer on your service YAML file, then it will create a load balancer on GCP for external access.
So instead of
kind: Service, I replace it with
type: LoadBalancer ?
-Nope, not replacing. You should add the type into the spec section. Your spec should be like this,
— protocol: TCP
I see. And which IP should I use for accessing ?
-You will use the IP of the load balancer.
Okay ! Let me give it a try !
Some time after.
Oh great! It works!
-alias k to kubectl?
But now, I’m trying to clean up the YAML files because originally I generated them from my docker compose files by kompose. My
mq service has a line in the spec,
ClusterIP: None .
This one seems so useful I can’t delete it, or else my other service can’t connect to it.
-I guess you could head up to the doc and check for the definition.
Okay thanks !
Remember to set up budget alerts
If you are a new Google Cloud user, you will have $300 credits and some extra free quotas for 1 year. But if you are like me who registered the account for a long time (and then never used it since), you might want to set up some budget alerts under the Billing tab, so that you won’t be charged accidentally,