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
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 - Kubernetes Services Explained with Examples
Lets get started.
Kubernetes Services Explained with Examples
Why Kubernetes Services 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.
How we can define the Kubernetes Services?
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.- ClusterIP (default) - Exposes the Service on an internal IP in the cluster. This type makes the Service only reachable from within the cluster.
- 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.
- LoadBalancer - Creates an external load balancer in the current cloud (if supported) and assigns a fixed, external IP to the Service. Superset of NodePort.
- ExternalName - Exposes the Service using an arbitrary name (specified by externalName in the spec) by returning a CNAME record with the name.
ClusterIP:
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:
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:
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:
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.
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.
Stay connected with us on social networking sites, Thank you.
0 Comments