DEV Community

Sampriti Mitra
Sampriti Mitra

Posted on

Docker and Kubernetes Made Relatable - IV

How Do External Teams Talk to Each Other?

Pods are ephemeral resources. Deployments can dynamically generate and destroy pods. Because pods are unstable, transient, and volatile, we can’t trust that the application will always be reachable via a pod’s IP.
We’ll need a permanent address that will route requests to whatever pod is active at the time.

Kubernetes services: The team SPOC that routes relevant external communication to devs

In Kubernetes, a service is an abstraction which defines a logical set of pods and a policy by which to access them. The set of pods targeted by a service is usually determined by a selector. Kubernetes services provide addresses through which associated pods can be accessed.

Take a look at the service.yaml file below:


This specifies a service that targets the port 10000 of pods with the label app:myapp.

Creating a Kubernetes Service

kubectl apply -f service.yaml
Enter fullscreen mode Exit fullscreen mode

The minikube tunnel command can be used to expose LoadBalancer services. To keep the LoadBalancer active, it must be run in a separate terminal window.

minikube tunnel 
Enter fullscreen mode Exit fullscreen mode

minikube tunnel runs as a process on the host and creates a network route to the cluster’s service CIDR using the cluster’s IP address as a gateway. The tunnel command gives any application on the host operating system immediate access to the external IP address.

kubectl get service myapp
Enter fullscreen mode Exit fullscreen mode

You should be able to see the external ip; earlier it would have been pending.
Now you can use this ip to open the service in the browser:

minikube service --url myapp
Enter fullscreen mode Exit fullscreen mode

You should be able to view this in your browser.
Welcome to myapp!

The section about services is incomplete without an analogy from the dev life.
Imagine an external team is unsure or confused about how to use a feature developed by the dev team. One way to resolve the problem is to contact a known developer directly. Of course, that would work, but what in case the developer has moved to a different team and lost context? In this case, the team SPOC comes to the rescue to help route the query within the team.

It’s Been a Long Article… and I Hope To Tell You More About It Next Time!

With that, we come to the end of the series on K8s made relatable and the adventures of the fresher on the first day. However there is more to be learned, and more adventures to follow, so stay tuned!

References
Kubernetes Service
Kubernetes Deployment
Read more about Kubernetes components
Docker Containers

Top comments (0)