It’s the first cluster!

Missing the most important line to allow access externally!

Michael Lee
3 min readJul 29, 2017
ピカチュウ (*´꒳`*)

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.

Yo. I finally created my first cluster from the console and created some services and deployments with kubectl. But I don’t know why I couldn’t access it from browsers.

-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,

metadata:
name: my-service
spec:
selector:
app: MyApp
ports:
— protocol: TCP
port: 80
targetPort: 9376
nodePort: 30061
type: LoadBalancer

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!

Meow~

-alias k to kubectl?

Yes 😆
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,

You can set multiple alerts for a budget, for example 20%, 50%, …, to follow more closely how you spend the money.

Like me…

Luckily not that much _(┐「ε:)_

If you would like to read more articles about devops, you could go here or follow Eric Ho on Medium. You will see new posts there from time to time 😄

--

--