Service Introduction
This chapter mainly provides you with a brief introduction to an important concept in Kubernetes called Service, as well as knowledge related to ULB.
1. Service Introduction
Service is a resource object in the Kubernetes cluster, used to define how to access a group of Pods with the same features. Usually, Service determines the target Pods through the Label Selector, except for ExternalName Services, for the detailed introduction of Service, please refer to the Services section in the official documentation.
Kubernetes provides four types of Service, each used for different business scenarios, and the default type is ClusterIp.
ClusterIp
ClusterIp is the default service type (ServiceType) in Kubernetes. With this type selected, the corresponding Service will be assigned an IP address within the cluster that can only be accessed from within the cluster.
NodePort
The service is exposed at a fixed port on each Node. When choosing the NodePort service type, the cluster will automatically create a ClusterIp service type to handle external traffic received by the Node. External Client of the cluster can access the service through the <NodeIp>:<NodePort>
method.
LoadBalancer
The service is exposed through an external load balancing device, which is generally provided by the cloud manufacturer or set up by the user themselves. In UK8S, we have integrated ULB through the Surfercloud CloudProvider plug-in, which will be introduced in detail later. Please note that when creating a LoadBalancer Service, the cluster will automatically create a NodePort and ClusterIp type Service to receive traffic from ULB.
ExternalName
The service is mapped to a DNS domain name (such as example.test.surfercloud.com), the DNS domain name can be configured through the spec.externalName parameter.
2. Brief Introduction to ULB
ULB provides two types of load balancing: Layer 4 (based on IP + port) and Layer 7 (based on URL and other application layer information). The difference between Layer 4 and Layer 7 ULB is shown in the table below:
Load Balancer Type | Network Mode | Supported Protocol |
---|---|---|
Packet forwarding | Internal network, External network | TCP、UDP |
Request proxying | Internal network, External network | HTTP、HTTPS、TCP |
If you want to have a deep understanding of ULB, please visit the ULB product documentation.
In UK8S, we support both packet forwarding and request proxying ULB types. You can configure the ULB parameters yourself through the Annotations in the Service yaml.
Next, we will separately introduce how to access Service in internal and external networks through ULB.