Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for Kubernetes
  • Comparison with other Yandex Cloud services
  • Getting started
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
    • Overview
    • Service
    • NetworkPolicy
  • Release notes

In this article:

  • Service
  • ObjectMeta
  • Metadata.annotations
  • ServiceSpec
  • ServicePort
  1. Network Load Balancer tools
  2. Service

Service resource fields and annotations

Written by
Yandex Cloud
Updated at May 5, 2025
  • Service
  • ObjectMeta
    • Metadata.annotations
  • ServiceSpec
    • ServicePort

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.

ServiceService

apiVersion: v1
kind: Service
metadata: <ObjectMeta>
spec: <ServiceSpec>

Field

Value / Type

Description

apiVersion

v1

This is a required field
Kubernetes API version.

kind

Service

Resource type

metadata

ObjectMeta

This is a required field
Resource metadata.

spec

ServiceSpec

This is a required field
Resource specification.

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

ObjectMetaObjectMeta

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

name

string

This is a required field
Resource name.

It does not match the load balancer name in Network Load Balancer.

annotations

map[string]string

Resource annotations.

Metadata.annotationsMetadata.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 to 10.

  • yandex.cloud/load-balancer-healthcheck-interval

    Health check interval in seconds.

    It can range from 2s to 300s.

  • 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 to 60s.

  • yandex.cloud/load-balancer-healthcheck-unhealthy-threshold

    Number of consecutive failed checks to consider a node unhealthy.

    It can range from 2 to 10.

ServiceSpecServiceSpec

type: LoadBalancer
ports:
  - <ServicePort>
  - ...
loadBalancerIP: <string>
externalTrafficPolicy: <string>

Field

Value / Type

Description

type

LoadBalancer

This is a required field
Service type.

Warning

The Kubernetes services used as network load balancers must be of the LoadBalancer type. For more information about this type, see this Kubernetes article.

ports

[]ServicePort

This is a required field
List of service ports.

loadBalancerIP

string

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.

externalTrafficPolicy

string

Traffic management policy:

  • Cluster: Traffic can reach any of the Kubernetes cluster nodes. If the target pods are not on that node, kube-proxy redirects traffic to another node. This is used by default.

  • Local: Traffic goes directly to the nodes where the application containers are running. In this case, the following applies:

    • User request IP address remains unchanged.
    • Inter-VM traffic is reduced.

ServicePortServicePort

name: <string>
port: <int32>
targetPort: <int32>
nodePort: <int32>

Field

Value / Type

Description

name

string

Service port name

port

int32

This is a required field
Port to handle incoming user requests to the service.

This port will also be assigned to the load balancer listener as the incoming traffic port.

targetPort

int32

Container port on which the application will be available.

If skip this field, the targetPort value will be the same as the port value.

nodePort

int32

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: 30000-32767.

Was the article helpful?

Previous
Overview
Next
NetworkPolicy
© 2025 Direct Cursus Technology L.L.C.