Kubernetes, understand services types in the deployment type.

I am sure that when you create deployments file for kubernestes, it is coming to a question of what is different type in services and when we use these service types?

In this article, we will try to deploy service types k8s on aws eks, I assume that you are familiar with k8s, deployment concept and having clusters on AWS. if you want to understand about services type, please check the official document.


A ClusterIP service is the default K8s service, we only access this service within the cluster and cannot access from the external. imagining that it is only available on private networks.

up the first config file, below YAML file is an example for services type is ClusterIP

apiVersion: v1
kind: Service
name: test-clusterIP
app: hello
type: ClusterIP
- name: http
port: 80
targetPort: 80
protocol: TCP

In this case, we will try to deploy an application with services type is ClusterIP

kubectl apply -f https://raw.githubusercontent.com/thanhtungka91/kubernetes-config/master/svcClusterIP.yaml

Off course, we cannot access this service from the internet but in some cases, we want to debug or check whether service is working or not? fortunately, k8s provide to our proxy server. now let's try to use proxy to pass it. This command to anable proxy on k8s

$ kubectl proxy --port=8080

then you can check services by


and we can debug:

When we use ?

  • Debug services
  • Demo dashboard


Because for ClusterIP you can't access services from external so Nodeport is primitive to access directly your services by port number

We will deploy an app hello2


it will get the error:

Invalid value: 3036: provided port is not in the valid range. The range of valid ports is 30000-32767

It is a downside of NodePort that why I don’t recommend you use NodePort on productions.

As a result, we get Hello world(2) for application 2, NodePort is not different from ClusterIP, just add a specific port to nodes. if we don't add port, K8s auto selects random port for us.


As the name load balancer which we always to talk about web scalable, it is the way we can access services from external with the easiest way.

We will deploy a new app hello10 use services type is LoadBalancer :

kubectl apply -f https://raw.githubusercontent.com/thanhtungka91/kubernetes-config/master/app.yaml

In this case, AWS EKS will create a link for the services, it is very simple :) now we simply check the result

However, LoadBalancer is very expensive and some services are private which we don't want to public to the internet. The way we config services some are ClusterIP other are Loadbalancer, it takes time and complex. To resolve this issue, we will use Ingress, what is Ingress and how to use we will walk next article.


It is the most important and complex in k8s service and may you will use almost for your production. Please check in next article :D


In this article, I have referred some other articles from Medium: