Monday, January 14, 2019

Services

How to access our app?-- by services
--from outside --webbrowser
--inside--from other pods.

service: REST objects in the k8s API.
it provides an abstracion to the pods also.




we can have same port numbers like belo...so serrvice will pick the node.


Another option,we will also create an endpoint object along with service.To maintain pod details.

kubectl get ep --> to see endpoints






We can tag pods using labels.





































the label sticks te service to the pods.



Service discovery:
-dns based (best one, by dns cluster addon--dns service in the cluster--pod based)
kubelet=node(the k8s agent on the node)
-environment variables(done when pod is created..)

-----------
we are explosing the replicaton controller as a service below.

kubectl expose rc hello-rc --name=hello-svc --target-port=8080 --type=NodePort
kubectl describe svc hello-svc



The same can be done usin declarative approach with yml file instead of the iterative way above.

To see existing service.
kubectl get svc

To clear existing services.
kubectl delete svc hello-svc

svc.yml
-------

added node port below.





































kubectl describe pods | grep app

kubectl create -f svc.yml
kubectl get svc
kubectl describe svc hello-svc


kubectl get ep
kuectl describe ep hello-svc --> same name as svc.

No comments:

Post a Comment