Kubernetes Services Explained with Examples

Kubernetes service explained, Kubernetes service basics, Kubernetes service concepts, understanding Kubernetes service, kubernetes service examples

This post will explain you about kubernetes services with examples of each types and how it can be implemented with live demo on youtube.

If you are new to kubernetes and want to learn about kubernetes from basics, Refer the below links and also you can checkout all tutorial videos for free on YouTube and do subscribe for more free videos.

What is Kubernetes - Learn Kubernetes from Basics
How to Install Kubernetes on Linux (RedHat / CentOS)
How to Install Kubernetes On Ubuntu 16.04 LTS
How to Create Kubernetes Deployment, Services & Pods Using Kubectl
How to Create Kubernetes YAML for Deployment, Service & Pods
Kubernetes Volumes Explained with Examples
Kubernetes Persistent Volumes and Claims Explained

Also You can Watch this Entire Tutorial video with more examples on our YouTube Channel. Make use of it.
[youtube src="d9xx4cfcWUM" height="315" width="560" /]

Lets get started.

Why Kubernetes Service is needed?
You can access your deployed pods only from the worker node where it is running. And it cannot be accessed even from your kubernetes master nodes or from any other nodes until it is exposed through service. Because each pods get its IP address through CNI plugin only from the local host. This is a basic behaviour of pod networking. In Order to access the application over the network, we must use kubernetes service to expose our pods to external traffic and load balancing the traffic across multiple pods.
kubernetes service examples
How we can define the Kubernetes Service?
A Service can be defined in a YAML or JSON file, like all other Kubernetes objects.

Types of Kubernetes Services
These services can be used in different ways based on the types.
[ads-post]
  1. ClusterIP (default) - Exposes the Service on an internal IP in the cluster. This type makes the Service only reachable from within the cluster.
  2. NodePort - Exposes the Service on the same port of each selected Node in the cluster using NAT. Makes a Service accessible from outside the cluster using <NodeIP>:<NodePort>. Superset of ClusterIP.
  3. LoadBalancer - Creates an external load balancer in the current cloud (if supported) and assigns a fixed, external IP to the Service. Superset of NodePort.
  4. ExternalName - Exposes the Service using an arbitrary name (specified by externalName in the spec) by returning a CNAME record with the name. 

ClusterIP:
kubernetes clusterip examples
Cluster IP is the default one used only for internal communication within the cluster through service, not to the external traffic. it is very useful when you plan to have architecture like frontend end and backend services. You can use this cluster ip service for your backend pods. its like a private pods, not exposed to public.

NodePort:
kubernetes nodeport examples
Nodeport type exposes your pod to external network with the same target port, so user can access it using worker node ip and port it is exposed. traffic will be send to respective pods through service.

LoadBalancer:
kubernetes loadbalancer examples
But this loadbalancer types works only with cloud provider as of now. If your kubernetes cluster environment is on any cloud provider like google cloud or aws, then if you use the type loadbalancer, you will get an external ip from these provider on behalf of you. so you can access your application using the external ip provided by the provider that will forward the request to the pods. But is is chargeable.

External Name:
kubernetes externalname examples
As the name says, this service used to define the external dns name. lets say you have frontend pod in your cluster that need to access any other application that is outside the cluster and then you can use this service. If your database service is hosted externally and you want to access it within the cluster.

Hope you have got an idea about kubernetes services and why it is needed.

Also refer below related articles and checkout all tutorial videos for free on youtube.

What is Kubernetes - Learn Kubernetes from Basics
How to Install Kubernetes on Linux (RedHat / CentOS)
How to Install Kubernetes On Ubuntu 16.04 LTS
How to Create Kubernetes Deployment, Services & Pods Using Kubectl
How to Create Kubernetes YAML for Deployment, Service & Pods
Kubernetes Volumes Explained with Examples
Kubernetes Persistent Volumes and Claims Explained

Keep practicing and have fun. Leave your comments if any.
Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.
YouTube | Facebook | Twitter | Pinterest | Rss
Incoming searches: Kubernetes service Explained, Kubernetes service, Kubernetes service basics, Kubernetes service concepts, understanding Kubernetes service, basics of Kubernetes service, Kubernetes service types, types of kubernetes service, Kubernetes service tutorial, Kubernetes service commands, k8s, kubernetes, kubernetes tutorial, Kubernetes service example, Kubernetes service examples, Kubernetes service explained, Kubernetes service explained with examples, kubernetes full tutorial, kubernetes volume explained, kubernetes volumes explained, kubernetes volume local, kubernetes hostpath, real time kubernetes scenario, kubernetes tutorial for beginners, kubernetes beginner tutorial, kubernetes free online tutorial, kubernetes online free tutorial, kubernetes best tutorial, kubernetes videos, kubernetes clusterip service examples, kubernetes nodeport service examples, kubernetes loadbalancer service examples, kubernetes externalname service examples
May 08, 2020

Post a comment

[disqus][facebook][blogger]

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget