
If you are not familiar with the kubectl command, check out my article Getting Started with kubectl.
There are different types of services, such as ClusterIP, NodePort and LoadBalancer. A service is used to forward requests onto one or more pods.
- The ClusterIP service is only accessible within the Kubernetes cluster
- The NodePort service is accessible within your network
- The LoadBalancer makes the service accessible externally, over the internet.
The kubectl get services command can be used to list the services in the currently selected project / namespace.
TIP
The -A or --all-namespaces flag can be used to list the services in every project / namespace.
The -n or --namespace flag can be used to list the services in a certain project / namespace.
~]# kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
myService001 ClusterIP 172.30.164.121 <none> 27017/TCP 114d
myService002 LoadBalancer 172.30.166.121 <pending> 8443:30444/TCP 114d
The kubectl get service command followed by the name of a service can be used to display an individual service.
~]# kubectl get service myService001
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
myService001 ClusterIP 172.30.164.121 <none> 27017/TCP 114d
The kubectl describe service command can be used to show the details of the service.
~]$ kubectl describe service myService001
Name: myService001
Namespace: default
Labels: app=my-app
Annotations: <none>
Selector: deployment=my-app
Type: LoadBalancer
IP: 172.30.166.121
Port: 8080-tcp 8080/TCP
TargetPort: 8080/TCP
Endpoints: 10.131.5.3:8080
Session Affinity: None
Events: <none>
Did you find this article helpful?
If so, consider buying me a coffee over at