Fields and annotations of the Service resource
The Service
resource defines the Kubernetes service. Services in Network Load Balancer for Managed Service for Kubernetes are load balancers for incoming traffic.
Service
is a standard Kubernetes resource. This reference describes the resource's fields and annotations supported by Network Load Balancer for Managed Service for Kubernetes. For a complete reference for the resource, please see the Kubernetes documentation
Service
apiVersion: v1
kind: Service
metadata: <ObjectMeta>
spec: <ServiceSpec>
Field |
Value or type |
Description |
|
|
Required |
|
|
Resource type |
|
|
Required |
|
|
Required |
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 or type |
Description |
|
|
Required Does not match the balancer name in Network Load Balancer. |
|
|
Annotations (metadata.annotations)
Annotations are collections of key:value
pairs used for assigning metadata to objects. Annotation values are always of the string
data type. See more on annotations in the Kubernetes documentation
You can provide the following annotations for a ObjectMeta
object:
-
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 in which you need to allocate an IP address for the internal network load balancer.
-
yandex.cloud/load-balancer-healthcheck-healthy-threshold
Number of consecutive successful checks to consider a node available.
The minimum value is
2
, and the maximum value is10
. -
yandex.cloud/load-balancer-healthcheck-interval
Health check interval in seconds.
The minimum value is
2s
, and the maximum value is300s
. -
yandex.cloud/load-balancer-healthcheck-timeout
Timeout for health checks in seconds. A node is considered unavailable if it has not responded within the specified time.
The minimum value is
1s
, and the maximum value is60s
. -
yandex.cloud/load-balancer-healthcheck-unhealthy-threshold
Number of consecutive failed checks to consider a node unavailable.
The minimum value is
2
, and the maximum value is10
.
ServiceSpec
type: LoadBalancer
ports:
- <ServicePort>
- ...
loadBalancerIP: <string>
externalTrafficPolicy: <string>
Field |
Value or type |
Description |
|
|
Required Warning The Kubernetes services used as network load balancers must be of the |
|
|
|
|
|
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 IP address, the network load balancer will get a dynamic IP address. |
|
|
|
ServicePort
name: <string>
port: <int32>
targetPort: <int32>
nodePort: <int32>
Field |
Value or type |
Description |
|
|
Port name within the service. |
|
|
Required The same port will be assigned to the load balancer's listener as the incoming traffic port. |
|
|
Container port the application will be available on. If you put nothing in this field, the |
|
|
Port to handle incoming user requests to the service from outside the cluster. The same port will be assigned to the load balancer's listener as the target incoming traffic port for the target group resources. Normally nothing is specified for this field, so However, you can specify a port explicitly. The selected port must not be used by other Kubernetes objects. Range of values: |