Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
Yandex Managed Service for Kubernetes
  • Comparison with other Yandex Cloud services
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Connecting to a node over SSH
    • Updating Kubernetes
    • Configuring autoscaling
    • Connecting to a cluster
      • Connection method overview
      • Configuring security groups
      • Creating a static configuration file
    • Installing applications from Cloud Marketplace
      • Basics of working with Cloud Marketplace
      • Installing Argo CD
      • Installing Container Storage Interface for S3
      • Installing Crossplane
      • Installing External Secrets Operator
      • Installing Filebeat
      • Installing Fluent Bit
      • Installing Gateway API
      • Installing GitLab Agent
      • Installing GitLab Runner
      • Installing HashiCorp Vault
      • Installing the Application Load Balancer Ingress controller
      • Installing Jaeger
      • Installing Kyverno & Kyverno Policies
      • Installing Metrics Provider
      • Installing NodeLocal DNS
      • Installing Policy Reporter
      • Installing Thumbor
    • Network scenarios
      • Granting access to an app running in a Kubernetes cluster
      • Configuring the Calico network policy controller
      • Configuring the Cilium network policy controller
      • Configuring NodeLocal DNS for the Cilium network policy controller
    • Working with persistent volumes
      • Dynamic volume provisioning
      • Static volume provisioning
      • Managing storage classes
      • Expanding a pod volume
      • Expanding a StatefulSet controller volume
      • Mounting a volume in Block mode
      • Integration with Object Storage
    • Managing a Kubernetes cluster
      • Getting information about a Kubernetes cluster
      • Creating a Kubernetes cluster
      • Editing a Kubernetes cluster
      • Creating a namespace in a Kubernetes cluster
      • Deleting a Kubernetes cluster
    • Managing a node group
      • Information about existing node groups
      • Creating a node group
      • Connecting to a node over SSH
      • Configuring autoscaling
      • Changing a node group
      • Managing Kubernetes cluster node labels
      • Deleting a node group
    • Connecting external nodes to the cluster
  • Practical guidelines
    • All tutorials
    • Creating a new Kubernetes project in Yandex Cloud
    • Integration with Container Registry
    • Running workloads with GPUs
    • Installing an NGINX Ingress controller with Let's Encrypt®
    • Installing an NGINX Ingress controller with a certificate from Certificate Manager
    • Backups to Object Storage
    • Horizontal application scaling in a cluster
    • Vertical application scaling in a cluster
    • Deploying and load testing a gRPC service with scaling
    • Working with snapshots
    • Integrating into a corporate DNS zone
    • Automatic DNS scaling by cluster size
    • Setting up local DNS caching
    • Checking DNS Challenge for Let's Encrypt® certificates
    • Monitoring a cluster using Prometheus and Grafana
    • Continuous deployment of containerized applications using GitLab
    • Using Cloud Marketplace products
      • Integrating with Argo CD
      • Integration with Crossplane
      • Syncing with Yandex Lockbox secrets
      • Configuring Fluent Bit for Cloud Logging
      • Setting up Gateway API
      • Configuring the Application Load Balancer Ingress controller
      • Using Jaeger to trace requests in Managed Service for YDB
      • Using Metrics Provider to stream metrics
  • Concepts
    • Relationships between service resources
    • Release channels and updates
    • Encrypting secrets
    • Using Kubernetes API objects
      • Volumes
      • Service
    • Node groups
      • Cluster autoscaler
      • Evicting pods from nodes
      • Dynamic resource allocation for a node
      • Node groups with GPUs
    • Network in Managed Service for Kubernetes
    • External cluster nodes
    • Network settings and cluster policies
    • Automatic scaling
    • Quotas and limits
    • Recommendations for using Managed Service for Kubernetes
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • ClusterService
      • NodeGroupService
      • VersionService
      • OperationService
    • REST
      • Overview
      • Cluster
        • Overview
        • create
        • delete
        • get
        • list
        • listNodeGroups
        • listNodes
        • listOperations
        • start
        • stop
        • update
      • NodeGroup
        • Overview
        • create
        • delete
        • get
        • list
        • listNodes
        • listOperations
        • update
      • Version
        • Overview
        • list
  • Questions and answers
    • General questions
    • Data storage
    • Configuring and updating
    • Automatic scaling
    • Resources
    • Logs
    • All questions on one page
  1. Practical guidelines
  2. Deploying and load testing a gRPC service with scaling

Deploying and load testing a gRPC service with scaling

Written by
Yandex Cloud
  • Prepare your cloud
    • Required paid resources
  • Prepare a test target
  • Prepare a domain
  • Install Ingress
  • Configure horizontal pod autoscaling
  • Perform load testing of the gRPC service
  • How to delete created resources

Use this tutorial to deploy an autoscalable gRPC service in a Managed Service for Kubernetes cluster using an Application Load Balancer Ingress controller to perform load testing of the service.

To deploy the service and perform load testing:

  1. Prepare your cloud.
  2. Prepare a test target.
  3. Prepare a domain.
  4. Install Ingress.
  5. Configure horizontal pod autoscaling.
  6. Perform load testing of a gRPC service.

When testing is complete, delete the created resources if you no longer need them.

Prepare your cloud

  1. Register a domain name for your website.

  2. If security groups are enabled for your cloud, create a group according to the rules described in Configuring security groups for Application Load Balancer tools for Managed Service for Kubernetes.

    If security groups are not available in your cloud, all incoming and outgoing traffic will be enabled for the resources and no additional setup is required.

  3. Set up the Managed Service for Kubernetes cluster.

  4. Install Metrics Provider.

  5. Install the Ingress controller:

    1. Create a service account for the Ingress controller.

    2. Install the Application Load Balancer Ingress controller for Managed Service for Kubernetes.

Required paid resources

The cost of this infrastructure includes:

  • A fee for using the master and outgoing Managed Service for Kubernetes traffic (see Pricing for Managed Service for Kubernetes).
  • A fee for using computing resources of the L7 load balancer (see Application Load Balancer pricing).
  • A fee for public DNS queries and DNS zones if you use Yandex Cloud DNS (see Cloud DNS pricing).

Prepare a test target

This instruction will use a gRPC service as a test target.

  1. Save the following specification to create an application in the grpc-server.yaml file:

    ### Deployment
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: grpc-app
      labels:
        app: grpc-app
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: grpc-app
      template:
        metadata:
          name: grpc-app
          labels:
            app: grpc-app
        spec:
          affinity:
            podAntiAffinity:
              requiredDuringSchedulingIgnoredDuringExecution:
                - labelSelector:
                    matchExpressions:
                      - key: app
                        operator: In
                        values:
                          - grpc-app
                  topologyKey: "kubernetes.io/hostname"
    
          containers:
            - name: grpc-app
              image: cr.yandex/crp6a9o7k9q5rrtt2hoq/grpc-test-server
              resources:
                requests:
                  memory: "256Mi"
                  cpu: "500m"
                limits:
                  memory: "500Mi"
                  cpu: "1"
    
    ### Service
    apiVersion: v1
    kind: Service
    metadata:
      name: grpc-service
    spec:
      selector:
        app: grpc-app
      type: NodePort
      ports:
        - name: grpc
          port: 80
          targetPort: 8080
          protocol: TCP
          nodePort: 30085    
    
  2. Create an application:

    kubectl apply -f grpc-server.yaml
    

Prepare a domain

  1. Create a public DNS zone and delegate the domain.

    Note

    For the domain example.com, the zone must be named example.com. (with a dot at the end)

  2. Create a Let's Encrypt® certificate.

  3. Check the rights for the domain.

Install Ingress

  1. Create an Ingress resource manifest in the ingress.yaml file:

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: grpc-demo
      annotations:
        ingress.alb.yc.io/subnets: <subnet_IDs>
        ingress.alb.yc.io/external-ipv4-address: auto
        ingress.alb.yc.io/protocol: grpc
        ingress.alb.yc.io/security-groups: <security_group_ID>
    spec:
      tls:
        - hosts:
            - <website_name>
          secretName: yc-certmgr-cert-id-<certificate_ID>
      rules:
        - host: <website_name>
          http:
            paths:
              - pathType: Prefix
                path: "/api.Adder/Add"
                backend:
                  service:
                    name: grpc-service
                    port:
                      number: 80
              - pathType: Prefix
                path: "/grpc.reflection.v1alpha.ServerReflection"
                backend:
                  service:
                    name: grpc-service
                    port:
                      number: 80
    

    Where:

    • ingress.alb.yc.io/subnets: A list of comma-separated subnet IDs.
    • ingress.alb.yc.io/security-groups: ID of the security group created when preparing your cloud. If security groups are not enabled in your cloud, delete this annotation.
    • secretName: A reference to a TLS certificate from Yandex Certificate Manager as yc-certmgr-cert-id-<certificate ID>.
    • hosts, host: The domain name the TLS certificate corresponds to.

    For more information, see Ingress fields and annotations.

  2. Create an Ingress resource:

    kubectl apply -f ingress.yaml
    
  3. Check that the resource was created and given a public IP address:

    kubectl get ingress grpc-demo
    

    Expected result:

    NAME        CLASS    HOSTS            ADDRESS         PORTS     AGE
    grpc-demo   <none>   <website_name>   <IP_address>    80, 443   2m
    

    Where:

    • <website_name> is the domain name the TLS certificate corresponds to.
    • <IP address> is the IP address of the website.

    The ADDRESS column must contain an IP address. Otherwise, the load balancer was not created or was created with an error. Check the logs for the yc-alb-ingress-controller-* pod.

  4. In Cloud DNS, create an A record referring to the load balancer's public address.

Configure horizontal pod autoscaling

  1. Create the hpa.yaml file with the Horizontal Pod Autoscaler specification:

    ### HPA
    apiVersion: autoscaling/v2beta2
    kind: HorizontalPodAutoscaler
    metadata:
      name: grpc-app
    spec:
      scaleTargetRef:
       apiVersion: apps/v1
       kind: Deployment
       name: grpc-app
      minReplicas: 1
      maxReplicas: 10
      metrics:
       - type: External
         external:
          metric:
            name: "load_balancer.requests_count_per_second"
            selector:
             matchLabels:
               service: "application-load-balancer"
               load_balancer: <load_balancer_ID>
               code: "total"
               backend_group: <backend_group_IDs>
          target:
            type: AverageValue
            averageValue: 2
    

    Where:

    • load_balancer is the L7 load balancer ID.
    • backend_group is the backend group ID.

    You can find them in the Application Load Balancer console or by running the commands:

    yc alb load-balancer list
    yc alb backend-group list
    
  2. Create the Horizontal Pod Autoscaler:

    kubectl apply -f hpa.yaml
    

Perform load testing of the gRPC service

  1. Create a service account:

    1. Create a sa-loadtest service account in the folder to host the agent that will generate the load.
    2. Assign a role to a service account.
      • loadtesting.generatorClient: Enables you to run agents and tests on agents and upload test results to the storage.
      • compute.admin: Enables you to manage a VM in Compute Cloud.
      • vpc.user: Enables you to connect to Virtual Private Cloud network resources and use them.
  2. Enable NAT to the internet on the subnet where the test target is and the agent will be located. This ensures the agent has access to Load Testing.

  3. Create a test agent.

  4. Prepare the ammo.json file with test data:

    {"tag": "/Add", "call": "api.Adder.Add", "payload": {"x": 21, "y": 12}}
    
  5. Prepare the load.yaml configuration file:

    phantom:
      enabled: false
      package: yandextank.plugins.Phantom
    pandora:
      enabled: true
      package: yandextank.plugins.Pandora
      config_content:
       pools:
         - id: Gun
          gun:
            type: grpc
            target: <your-site-name>:<port>
            tls: true
          ammo:
            type: grpc/json
            file: ammo.json
          result:
            type: phout
            destination: ./phout.log
          rps:
            - duration: 60s
             type: line
             from: 1
             to: 10
          startup:
            - type: once
             times: 1000
       log:
         level: debug
       monitoring:
         expvar:
          enabled: true
          port: 1234
    uploader:
      enabled: true
      package: yandextank.plugins.DataUploader
      job_name: '[pandora][grpc][tls]'
      job_dsc: ''
      ver: ''
      api_address: loadtesting.api.cloud.yandex.net:443
    

    Where:

    • target is the name of your website and port (for HTTPS: 443).
  6. Run a test:

    • Upload the ammo.json file to the File with test data field.
    • Upload the load.yaml file to the Configuration file field.
  7. Monitor the test:

    1. In the management console, select Managed Service for Kubernetes.
    2. Select your test cluster.
    3. Go to the Workload tab.
    4. Monitor the change in the number of application pods as the load increases and decreases.
    5. After testing is complete, in the management console, select Application Load Balancer.
    6. Select the created L7 load balancer.
    7. Go to the Monitoring tab.
    8. View the test load chart.

How to delete created resources

To shut down the infrastructure and stop paying for the created resources:

  1. If you set up CNAME records in Cloud DNS, delete the DNS zone.
  2. Delete the L7 load balancer.
  3. Delete the Managed Service for Kubernetes cluster.

Was the article helpful?

Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
In this article:
  • Prepare your cloud
  • Required paid resources
  • Prepare a test target
  • Prepare a domain
  • Install Ingress
  • Configure horizontal pod autoscaling
  • Perform load testing of the gRPC service
  • How to delete created resources