Service
resource fields and annotations
The Service
resource defines a Kubernetes service. In Network Load Balancer for Managed Service for Kubernetes, services are load balancers for incoming traffic.
Service
is a standard Kubernetes resource. This reference describes the resource fields and annotations supported by Network Load Balancer for Managed Service for Kubernetes. For a complete Service
reference, see this Kubernetes article
Service
apiVersion: v1
kind: Service
metadata: <ObjectMeta>
spec: <ServiceSpec>
Field |
Value / Type |
Description |
|
|
This is a required field |
|
|
Resource type |
|
|
This is a required field |
|
|
This is a required field |
Example
apiVersion: v1
kind: Service
metadata:
name: nlb-demo-1
spec:
selector:
app: app-demo-1
type: LoadBalancer
ports:
- port: 80
name: plaintext
targetPort: 8080
ObjectMeta
name: <string>
annotations:
yandex.cloud/load-balancer-type: <string>
yandex.cloud/subnet-id: <string>
yandex.cloud/load-balancer-healthcheck-healthy-threshold: <string>
yandex.cloud/load-balancer-healthcheck-interval: <string>
yandex.cloud/load-balancer-healthcheck-timeout: <string>
yandex.cloud/load-balancer-healthcheck-unhealthy-threshold: <string>
Field |
Value / Type |
Description |
|
|
This is a required field It does not match the load balancer name in Network Load Balancer. |
|
|
Metadata.annotations
Annotations are collections of key:value
pairs for assigning metadata to objects. Annotation values are always of the string
data type. For more information on annotations, see this Kubernetes article
You can add the following annotations to ObjectMeta
:
-
yandex.cloud/load-balancer-type
Load balancer type (by default, with an external IP address).
For a load balancer with an internal IP address, the value is
internal
. -
yandex.cloud/subnet-id
ID of the subnet the internal load balancer will get its IP address.
-
yandex.cloud/load-balancer-healthcheck-healthy-threshold
Number of consecutive successful checks to consider a node healthy.
It can range from
2
to10
. -
yandex.cloud/load-balancer-healthcheck-interval
Health check interval in seconds.
It can range from
2s
to300s
. -
yandex.cloud/load-balancer-healthcheck-timeout
Health check timeout in seconds. If a node fails to respond within this time, it is considered unavailable.
It can range from
1s
to60s
. -
yandex.cloud/load-balancer-healthcheck-unhealthy-threshold
Number of consecutive failed checks to consider a node unhealthy.
It can range from
2
to10
.
ServiceSpec
type: LoadBalancer
ports:
- <ServicePort>
- ...
loadBalancerIP: <string>
externalTrafficPolicy: <string>
Field |
Value / Type |
Description |
|
|
This is a required field Warning The Kubernetes services used as network load balancers must be of the |
|
|
This is a required field |
|
|
When using an external load balancer, you may specify a static public IP address in this field. You need to reserve such an address in advance. When reserving a public IP address, you can enable DDoS protection. If you do not specify a static public IP address, the network load balancer will get a dynamic public IP address. When using an internal load balancer, you may specify an internal IP address. Make sure the specified internal IP address is not assigned to some other resource in the same cloud network. Warning Once removed from the specification, the internal IP address may be automatically assigned to a different resource in the same cloud network. We recommend selecting an IP address closer to the upper end of the selected subnet range. |
|
|
|
ServicePort
name: <string>
port: <int32>
targetPort: <int32>
nodePort: <int32>
Field |
Value / Type |
Description |
|
|
Service port name |
|
|
This is a required field This port will also be assigned to the load balancer listener as the incoming traffic port. |
|
|
Container port on which the application will be available. If skip this field, the |
|
|
Port to handle incoming user requests to the service from outside the cluster. This port will also be assigned to the load balancer listener as the target incoming traffic port for targets in the target group. Typically, this field is skipped and its value is automatically selected from the specified range. However, you can specify a port explicitly. This port must not be used by other Kubernetes objects. Range of values: |