0

Every where its mentioned "cluster type of service makes pod accessible within a Kubernetes cluster"

Does it mean, after adding cluster service to a POD, then that POD can be connected only using cluster service IP of POD, we will not be able to connect POD using the IP of POD generated before adding cluster ?

Please help me understanding, am learning Kubernetes so.

sudhir tataraju
  • 1,159
  • 1
  • 14
  • 30

1 Answers1

4

When a service is created using the ClusterIP then that service is accessible only inside the cluster as service IP's are virtual IP.

Although if you want to access the pod from outside using the service IP then you can use the nodeport or loadbalancer type service which will allow you to access the pod using the Node's IP or the loadbalancer's IP.

Main reason behind using services to access pod is that it give a fixed location (ClusterIP or service name) to access. Pod's can come an go but service IP will remain same.

Frank Yucheng Gu
  • 1,807
  • 7
  • 21
Aman Juneja
  • 151
  • 8
  • Thank you @Aman Juneja The Main reason you mentioned is what I wanted to know. I want to add 1 more point same I can achieve using NodePort service also i.e Fixed IP but using nodeport i.e we will get static IP but problem is we will get one port also which will be exposed so outside world can connect to that port using machine IP which is security breach we can say if our application inside pod is database or any backend application as nodePort preferred for front end applications. – sudhir tataraju Mar 31 '19 at 08:19
  • 1
    @sudhirtataraju yes you are right.. node ip can be used but I think main reason to not use the node's ip directly could be that in a cluster nodes can come and go.. so it would be better if we add them behind loadbalancers and let client's always use that. – Aman Juneja Mar 31 '19 at 08:46