Examples of load balancer property settings
    • PDF

    Examples of load balancer property settings

    • PDF

    Article Summary

    The latest service changes have not yet been reflected in this content. We will update the content as soon as possible. Please refer to the Korean version for information on the latest updates.

    Available in VPC

    This is an example showing how to set the properties of the a load balancer instance using various annotations introduced in Load Balancer instance connection.

    Caution

    If you configure the load balancer of NAVER Cloud Platform created in Kubernetes through the console and API rather than the Kubernetes' Service resource, problems may occur in status synchronization. Change of settings for the created load balancers must be done by editing service resource created in Kubernetes.

    Example of setting Network Proxy Load Balancer (NPLB) property

    Example of selecting a dedicated subnet where instances will be created

    When creating an instance, lbSubnetNo in configmap of which name is ncloud-config in the kube-system namespace is used by default. If you need to create an instance in another load balancer-only subnet, then the service.beta.kubernetes.io/ncloud-load-balancer-subnet-id annotation can be used.

    The following is the example of selecting a dedicated subnet where NPLB instances will be created.

    kind: Service
    apiVersion: v1
    metadata:
      name: my-nginx
      annotations:
        service.beta.kubernetes.io/ncloud-load-balancer-layer-type: "nplb"
        service.beta.kubernetes.io/ncloud-load-balancer-subnet-id: "452772"
    spec:
      ports:
      - port: 80
        targetPort: 80
      selector:
        run: my-nginx
      type: LoadBalancer
    

    Examples of load balancer's load processing performance settings

    You can set load processing performance of a created load balancer using the service.beta.kubernetes.io/ncloud-load-balancer-size annotation.

    The following is the example of setting load processing performance using the annotation.

    kind: Service
    apiVersion: v1
    metadata:
      name: my-nginx
      annotations:
        service.beta.kubernetes.io/ncloud-load-balancer-layer-type: "nplb"
        service.beta.kubernetes.io/ncloud-load-balancer-size: "MEDIUM"
    spec:
      ports:
      - port: 80
        targetPort: 80
      selector:
        run: my-nginx
      type: LoadBalancer
    

    Example of assigning public IP to load balancer

    You can define the public IP to be assigned to a load balancer in the spec.loadBalancerIP field when the service type is LoadBalancer.
    In this field, only the public IP that has not been assigned and checked from the 네이버 클라우드 플랫폼 콘솔 > VPC > Public IP menu can be described.
    By default, deleting a load balancer returns the public IP assigned to it as well. The service.beta.kubernetes.io/ncloud-load-balancer-retain-public-ip-on-termination: "true" annotation can be used to prevent the public IP from being returned.

    apiVersion: v1
    kind: Service
    metadata:
      name: static-service
      annotations: 
        service.beta.kubernetes.io/ncloud-load-balancer-layer-type: "nplb"  
        service.beta.kubernetes.io/ncloud-load-balancer-retain-public-ip-on-termination: "true"
    spec:
      loadBalancerIP: 110.234.194.181
      type: LoadBalancer
      ports:
        - port: 80
          targetPort: 8080
          protocol: TCP
          name: http
      selector:
        app: nginx
    

    Example of setting Network Load Balancer (NLB) property

    Example of selecting a dedicated subnet where instances will be created

    When creating an instance, lbSubnetNo in configmap of which name is ncloud-config in the kube-system namespace is used by default. If you need to create an instance in another load balancer-only subnet, then the service.beta.kubernetes.io/ncloud-load-balancer-subnet-id annotation can be used.

    The following is the example of selecting a dedicated subnet where NLB instances will be created.

    kind: Service
    apiVersion: v1
    metadata:
      name: my-nginx
      annotations:
        service.beta.kubernetes.io/ncloud-load-balancer-layer-type: "nlb"
        service.beta.kubernetes.io/ncloud-load-balancer-subnet-id: "452772"
    spec:
      ports:
      - port: 80
        targetPort: 80
      selector:
        run: my-nginx
      type: LoadBalancer
    

    Example of assigning public IP to load balancer

    You can define the public IP to be assigned to a load balancer in the spec.loadBalancerIP field when the service type is LoadBalancer.
    In this field, only the public IP that has not been assigned and checked from the 네이버 클라우드 플랫폼 콘솔 > VPC > Public IP menu can be described.
    By default, deleting a load balancer returns the public IP assigned to it as well. The service.beta.kubernetes.io/ncloud-load-balancer-retain-public-ip-on-termination: "true" annotation can be used to prevent the public IP from being returned.

    apiVersion: v1
    kind: Service
    metadata:
      name: static-service
      annotations: 
        service.beta.kubernetes.io/ncloud-load-balancer-layer-type: "nlb"  
        service.beta.kubernetes.io/ncloud-load-balancer-retain-public-ip-on-termination: "true"
    spec:
      loadBalancerIP: 110.234.194.181
      type: LoadBalancer
      ports:
        - port: 80
          targetPort: 8080
          protocol: TCP
          name: http
      selector:
        app: nginx
    

    Example of setting ACG rule's inbound source upon creation of a load balancer

    If the service type is LoadBalancer, then an ACG rule with 0.0.0.0./0 as inbound source is set up by default for external communication. If a different IP block is required to be set to be the inbound source, then you can use the annotation of service.beta.kubernetes.io/ncloud-load-balancer-inbound-source. If you'd like to specify multiple inbound sources, then you can use commas (,) as separators.

    The following is the example of setting the ACG rule's Inbound Source when creating an NLB instance.

    kind: Service
    apiVersion: v1
    metadata:
      name: my-nginx
      annotations:
        service.beta.kubernetes.io/ncloud-load-balancer-layer-type: "nlb"
        service.beta.kubernetes.io/ncloud-load-balancer-inbound-source: "10.120.0.0/16,143.248.12.77/32"
    spec:
      ports:
      - port: 80
        targetPort: 80
      selector:
        run: my-nginx
      type: LoadBalancer
    

    Set UDP load balancing

    Network Load Balancer (NLB) supports UDP load balancing. Below is an example of specifying UDP in the protocol field.

    apiVersion: v1
    kind: Service
    metadata:
      name: sample-udp-app
    spec:
      type: LoadBalancer
      ports:
        - port: 9092
          targetPort: 9092
          protocol: UDP
      selector:
        app: sample-udp-app
    

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.