Smooth Transition to Kubernetes

I hesitated to write another post on Kubernetes since there are already tons of great Kubernetes posts on the internet. But I plan to publish a series of posts, specifically for the developer, about Kubernetes, microservices, and cloud-native applications. Hence, This is where it all starts. Kubernetes components will be the first part of this long journey.

My post series will walk you through the application, which is one of the real-world apps that I’ve prepared for this article and ongoing articles. …


Smooth Transition to Kubernetes

Before reading this post, please visit the sample project which is used in this post, plus, highly recommend you to have a look at the Ephemeral Pods in Kubernetes. That'll give you an insight. In this post, we’re going to walk through with a Service Resource in Kubernetes. Let’s get it started.

What is a Service in Kubernetes?

After creating pods, the next questions ending up, “How can app access another app running in the cluster, or can customer access to our apps? “

For now, I’m going to focus just on inter-app communication, not the customer perspective. So, let’s redefine our question, how does a pod know another pod IP each time when redeploying happened? It is critical. Because in every new deployment, the kubelet assigns automatically a new IP to the pod, which is ephemeral, and also can place them on different nodes. Also, don’t forget the scaling up and down feature of Kubernetes. How do you get new IPs to use in your other pod every time? I think the requirements here are pretty clear. We need to make a single, constant point of entry to a group of pods. …


Smooth Transition to Kubernetes

Please before starting, have a quick look at the sample project which is used in this post.

As we know from the previous post, a ReplicationControllers is used for replicating pods and rescheduling them when they fail. A similar resource called ReplicaSet which is almost identical to ReplicationController was introduced in the Kubernetes. But, one minute, why do we need a ReplicaSet. I did some googling … It seems: A ReplicaSet behaves exactly like a ReplicationController, but it has more expressive pod selectors and is comparatively more useful. …


Smooth Transition to Kubernetes

You can visit Ephemeral Pods in Kubernetes If you are not familiar with a Pod and please check the sample project which is used in this post. In this post, we’re going to focus on a Replication Controller in Kubernetes.

After creating a Pod, It should always be accessible and should remain healthy without any manual intervention. There are tons of traditional ways (expensive ones) to achieve that. But our scope is the Kubernetes and we should somehow utilize the Kubernetes feature. So, some resources in the Kubernetes should manage the Pods on behalf of us. …


Smooth Transition to Kubernetes

Please check the news-tracker-application on Github and Ephemeral Pods. Those will help to make this post understandable.

The Labels are being used to organize Kubernetes objects. Let’s take a closer look at our application pods with labels figure.

Image for post
Image for post

As you see in the figure above, we have multiple pods and can do any operation with label filtering, like :

$ kubectl delete pod -l env=develop  # delete all backend pods which have "env=develop" label.

Is that easy? Of course yes … But let’s imagine that developers in our team want to manage the pods which they create. For that, firstly, the developer’s name should be put into the Pod definition as a label. Then, they can do Kubernetes operation on their resource by using that label. …


Smooth Transition to Kubernetes

You can visit Ephemeral Pods in Kubernetes If you are not familiar with a Pod and please check the sample project which is used in this post. Let’s jump into our topic.

What is a Label:

A label is arbitrary key-value pair and you can attach it to a Kubernetes resource. We need labels to organize the Pods and all other Kubernetes objects through labels. What to do with labels:

  • Filtering Resources: Resources are filtered based on whether they include the label specified in the selector like:
Image for post
Image for post

→ Check the labels on Github. There are some samples in the “ Useful Label commands “ section, you can use labels as stated there. One more thing, a resource can have more than one label, as long as the keys of those labels are unique within that resource.


Smooth Transition to Kubernetes

Before continuing the post, I recommend you to check the news-tracker-application on Github and the first part of the series, Kubernetes Architecture. As of now, I’m frequently going to use the Kubernetes resources in that project. Let’s get started with another component of the Kubernetes.

What is a Pod?

If you want to run your app(s) on Kubernetes, then, need a POD which consists of the container(s). A pod is the smallest deployable unit of Kubernetes and consists of one or more containers, which are relatively tightly coupled. The Pods run together like a logic unit and are managed by the kube-proxy and kubelet running in the worker node. All Pods don’t need to run on the same machine as containers. They can span more than one machine, which means multiple pods can run on multiple nodes. All the containers in a pod have the same IP address, port space, network interface shared resources such as CPU, RAM, and Volume. They can communicate using localhost or standard inter-process communication. …

About

Erhan Cetin

An explorer trying to find his way

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store