[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"/en/kb/manual/network-and-load-balancer-kubernetesKbData":3},{"page":4,"pages":92,"recommendedPages":93,"category":41,"categoryTree":41,"total":99,"currentOrder":122,"activeManualCategoryId":41,"tag":-1},{"route":5,"uuid":8,"title":9,"excerpt":10,"content":11,"view_count":12,"published_at":13,"modified_at":13,"like":14,"category":17,"hero_image":34,"seo_metadata":35,"schema_org_metadata":39,"open_graph_metadata":42,"sections":43,"tags":87,"breadcrumbs":88,"images":91},{"language":6,"path":7},"en","/kb/manual/network-and-load-balancer-kubernetes","a6b7e2c4-4efe-66e9-fa8a-f6706b10a442","Kubernetes Networking and Load Balancer","This article describes the network model and how Kubernetes networking works. It also covers how to set up Kubernetes load balancers for application access.","\u003Cp>This article describes the network model and how Kubernetes networking works. It also covers how to set up Kubernetes load balancers for application access.\u003C/p>\n\u003Cp>If you are unfamiliar with the concepts of services and pods, start with the article “\u003Ca href=\"https://beget.com/en/kb/manual/what-is-kubernetes\">Kubernetes Basics\u003C/a>”.\u003C/p>\n\u003Ch2 id=\"cluster-networking-model\">Cluster Networking Model\u003C/h2>\n\u003Cp>In a Kubernetes cluster, each pod receives its own IP address from the Pod CIDR range specified when the \u003Ca href=\"https://beget.com/en/kb/manual/creating-and-configuring-cluster-kubernetes\">cluster was created\u003C/a>. Pods can communicate with each other directly via IP addresses, regardless of which node (group of servers) they are running on.\u003C/p>\n\u003Cp>Services are used to provide stable access to a group of pods, they provide a static address and distribute traffic among the pods.\u003C/p>\n\u003Ch3 id=\"service-types\">Service Types\u003C/h3>\n\u003Cul>\n\u003Cli>\u003Cstrong>ClusterIP \u003C/strong>– accessible only within the cluster. The service receives a virtual IP address from the service address range. Used for communication between application components.\u003C/li>\n\u003Cli>\u003Cstrong>NodePort \u003C/strong>– opens a fixed port on each cluster node. Traffic arriving at this port is redirected to the service’s pods.\u003C/li>\n\u003Cli>\u003Cstrong>LoadBalancer \u003C/strong>– creates a load balancer on the platform side. Suitable for providing external access to the application.\u003C/li>\n\u003C/ul>\n\u003Ch3 id=\"creating-a-clusterip-service\">Creating a ClusterIP Service\u003C/h3>\n\u003Cp>ClusterIP – the default service type. It provides a stable internal address for a group of pods, accessible only from within the cluster. Use it for communication between application components – for example, so that the frontend (external interface) can address the backend (server-side) by a fixed name.\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>apiVersion: v1\nkind: Service\nmetadata:\n  name: backend\n  namespace: default\nspec:\n  selector:\n    app: backend\n  ports:\n  - port: 8080\n    targetPort: 8080\n  type: ClusterIP\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Cp>After applying the manifest, the service will be accessible within the cluster by the name \u003Ccode>backend\u003C/code> (or the fully qualified DNS name \u003Ccode>backend.default.svc.cluster.local\u003C/code>) and by the assigned ClusterIP:\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>kubectl apply -f backend-service.yaml\nkubectl get svc backend\n\nNAME      TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE\nbackend   ClusterIP   10.96.45.12    &lt;none&gt;        8080/TCP   5s\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Cp>Other pods in the cluster can access this service by name:\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>http://backend:8080\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Ch3 id=\"creating-a-nodeport-service\">Creating a NodePort Service\u003C/h3>\n\u003Cp>A NodePort opens a fixed port (from the 30000–32767 range) on each node in the cluster. Traffic arriving at this port on any node is redirected to the service’s pods.\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>apiVersion: v1\nkind: Service\nmetadata:\n  name: frontend\n  namespace: default\nspec:\n  selector:\n    app: frontend\n  ports:\n  - port: 80\n    targetPort: 80\n    nodePort: 30080\n  type: NodePort\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Cp>Once deployed, the service will be available on port \u003Ccode>30080\u003C/code> on each node in the cluster:\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>kubectl apply -f frontend-nodeport.yaml\nkubectl get svc frontend\n\nNAME       TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE\nfrontend   NodePort   10.96.78.90    &lt;none&gt;        80:30080/TCP   5s\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Cdiv class=\"wp-block-beget-alert alert-block alert-block-info\">\n\u003Cdiv class=\"alert-block-title\">\u003Cstrong>Please note!\u003C/strong>\u003C/div>\n\u003Cdiv class=\"alert-block-content\">For production workloads, it is recommended to use a LoadBalancer instead of a NodePort, it provides a single entry point and traffic distribution.\u003C/div>\n\u003C/div>\n\u003Ch2 id=\"load-balancer\">Load balancer\u003C/h2>\n\u003Cdiv class=\"wp-block-beget-alert alert-block alert-block-info\">\n\u003Cdiv class=\"alert-block-title\">\u003Cstrong>Please note!\u003C/strong>\u003C/div>\n\u003Cdiv class=\"alert-block-content\">Load balancers are free of charge during the public beta.\u003C/div>\n\u003C/div>\n\u003Cp>When you create a LoadBalancer service, the platform automatically assigns a load balancer that distributes incoming traffic across the application’s pods.\u003C/p>\n\u003Ch3 id=\"external-and-internal-load-balancers\">External and internal load balancers\u003C/h3>\n\u003Cp>The load balancer type is specified using the \u003Ccode>lb.beget.com/type\u003C/code> annotation:\u003C/p>\n\u003Cp>\u003Cstrong>external \u003C/strong>– the load balancer is assigned a public IP address accessible from the internet. Suitable for:\u003C/p>\n\u003Cul>\n\u003Cli>Websites and web applications\u003C/li>\n\u003Cli>Public APIs\u003C/li>\n\u003Cli>Any services accessed by external users\u003C/li>\n\u003C/ul>\n\u003Cp>\u003Cstrong>internal \u003C/strong>– the load balancer is accessible only within a private network. Suitable for:\u003C/p>\n\u003Cul>\n\u003Cli>Internal APIs and inter-service communication\u003C/li>\n\u003Cli>Databases and other services that should not be accessible from the outside\u003C/li>\n\u003Cli>Components that interact only with other services in the cloud\u003C/li>\n\u003C/ul>\n\u003Ch3 id=\"creating-an-external-load-balancer\">Creating an external load balancer\u003C/h3>\n\u003Cp>Save the manifest to the file \u003Ccode>loadbalancer-external.yaml\u003C/code>:\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>apiVersion: v1\nkind: Service\nmetadata:\n  annotations:\n    lb.beget.com/algorithm: round_robin\n    lb.beget.com/healthcheck-interval-seconds: \"60\"\n    lb.beget.com/healthcheck-timeout-seconds: \"5\"\n    lb.beget.com/type: external\n  name: nginx\n  namespace: default\nspec:\n  allocateLoadBalancerNodePorts: true\n  ports:\n  - port: 80\n    targetPort: nginx\n  selector:\n    app: nginx\n  type: LoadBalancer\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Cp>Apply the manifesto:\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>kubectl apply -f loadbalancer-external.yaml\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Ch3 id=\"creating-an-internal-balancer\">Creating an internal balancer\u003C/h3>\n\u003Cp>Save the manifest to the file \u003Ccode>loadbalancer-internal.yaml\u003C/code>:\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>apiVersion: v1\nkind: Service\nmetadata:\n  annotations:\n    lb.beget.com/algorithm: round_robin\n    lb.beget.com/healthcheck-interval-seconds: \"60\"\n    lb.beget.com/healthcheck-timeout-seconds: \"5\"\n    lb.beget.com/type: internal\n  name: internal-api\n  namespace: default\nspec:\n  allocateLoadBalancerNodePorts: true\n  ports:\n  - port: 8080\n    targetPort: api\n  selector:\n    app: internal-api\n  type: LoadBalancer\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Cp>Apply the manifesto:\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>kubectl apply -f loadbalancer-internal.yaml\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Ch2 id=\"balancer-annotations\">Balancer annotations\u003C/h2>\n\u003Cp>Balancer settings are configured via annotations in the \u003Ccode>metadata.annotations\u003C/code> space of the manifest.\u003C/p>\n\u003Ch3 id=\"load-balancer-type\">Load Balancer Type\u003C/h3>\n\u003Cul>\n\u003Cli>\u003Cstrong>\u003Ccode>lb.beget.com/type\u003C/code>\u003C/strong> – values: \u003Ccode>external\u003C/code>, \u003Ccode>internal\u003C/code>. Load balancer type: public or private\u003C/li>\n\u003C/ul>\n\u003Ch3 id=\"load-balancing-algorithm\">Load Balancing Algorithm\u003C/h3>\n\u003Cul>\n\u003Cli>\u003Cstrong>\u003Ccode>lb.beget.com/algorithm\u003C/code> \u003C/strong>– values: \u003Ccode>round_robin\u003C/code>, \u003Ccode>least_connections\u003C/code>. Algorithm for distributing traffic among backends\u003C/li>\n\u003C/ul>\n\u003Ch3 id=\"health-checks\">Health Checks\u003C/h3>\n\u003Cp>Healthcheck annotations determine how the load balancer checks the availability of backend services. If a service does not respond within the timeout period, the load balancer stops directing traffic to it until it is restored.\u003C/p>\n\u003Cul>\n\u003Cli>\u003Ccode>lb.beget.com/healthcheck-interval-seconds\u003C/code> – a positive integer. The interval between checks (in seconds). Default: 5.\u003C/li>\n\u003Cli>\u003Ccode>lb.beget.com/healthcheck-timeout-seconds\u003C/code> – a positive integer. The timeout for waiting for a response (in seconds). Default: 30.\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"checking-the-load-balancer-status\">Checking the Load Balancer Status\u003C/h2>\n\u003Cp>After applying the manifest, verify that the load balancer has been created and assigned an address:\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>kubectl get svc &lt;service-name&gt;\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Cp>Replace \u003Ccode>&lt;service-name&gt;\u003C/code> with the name from the \u003Ccode>metadata.name\u003C/code> space in your manifest. In our example, this is \u003Ccode>nginx\u003C/code>:\u003C/p>\n\u003Cp>Expected output for an external load balancer:\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>NAME    TYPE           CLUSTER-IP      EXTERNAL-IP       PORT(S)        AGE\nnginx   LoadBalancer   10.96.162.132   155.212.142.254   80:31160/TCP   10s\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Cul>\n\u003Cli>\u003Cstrong>CLUSTER-IP\u003C/strong> – the service’s internal address within the cluster\u003C/li>\n\u003Cli>\u003Cstrong>EXTERNAL-IP\u003C/strong> – the address at which the load balancer is accessible from the outside (for external) or within a private network (for internal)\u003C/li>\n\u003Cli>\u003Cstrong>PORT(S)\u003C/strong> – the service port and the assigned NodePort\u003C/li>\n\u003C/ul>\n\u003Cp>If \u003Ccode>&lt;pending&gt;\u003C/code> is displayed in the \u003Ccode>EXTERNAL-IP\u003C/code> column, the load balancer is still being created. Repeat the command after a while or use the \u003Ccode>--watch\u003C/code> flag to monitor:\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>kubectl get svc nginx --watch\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Cp>IP address allocation usually takes no more than a minute. If the \u003Ccode>&lt;pending&gt;\u003C/code> status persists for more than a few minutes, check the service events using the \u003Ccode>kubectl describe svc nginx\u003C/code> command.\u003C/p>\n\u003Ch2 id=\"deleting-the-load-balancer\">Deleting the load balancer\u003C/h2>\n\u003Cp>To delete the load balancer, delete the corresponding service:\u003C/p>\n\u003Cdiv class=\"wp-block-beget-code code-block\">\n\u003Cpre data-options=\"{&quot;mode&quot;:&quot;&quot;}\">\u003Ccode>kubectl delete svc nginx\u003C/code>\u003C/pre>\n\u003C/div>\n\u003Cp>After deleting the service, the platform-side load balancer will also be deleted, and the assigned IP address will be released.\u003C/p>\n\u003Cp>All articles in this section\u003C/p>\n\u003Col>\n\u003Cli>\u003Ca href=\"https://beget.com/en/kb/manual/managed-kubernetes\">Kubernetes (K8s)\u003C/a> – An Overview of the Managed Kubernetes Service\u003C/li>\n\u003Cli>\u003Ca href=\"https://beget.com/en/kb/manual/what-is-kubernetes\">Kubernetes Basics\u003C/a> – Key Concepts: Cluster, Nodes, Pods, Services\u003C/li>\n\u003Cli>\u003Ca href=\"https://beget.com/en/kb/manual/creating-and-configuring-cluster-kubernetes\">Creating and Configuring a Cluster\u003C/a> – Master Node Configuration, Networking, and Worker Groups\u003C/li>\n\u003Cli>\u003Ca href=\"https://beget.com/en/kb/manual/kubectl\">Connecting to the Cluster and Working with kubectl\u003C/a> – kubeconfig, Connectivity, and Core Kubernetes Tools\u003C/li>\n\u003Cli>\u003Ca href=\"https://beget.com/en/kb/manual/cluster-management-kubernetes\">Cluster management\u003C/a> – adding nodes, changing configuration, updating, and deleting\u003C/li>\n\u003Cli>\u003Cstrong>Networking and load balancers\u003C/strong> – You are here\u003C/li>\n\u003Cli>\u003Ca href=\"https://beget.com/en/kb/manual/limits-quotas-restrictions-kubernetes\">Limits, quotas, and constraints\u003C/a> – platform constraints, what can and cannot be changed\u003C/li>\n\u003C/ol>\n\u003Cp>If you have any questions, please submit a ticket via the account dashboard (under “\u003Ca href=\"https://cp.beget.com/support?utm_source=kb&amp;utm_medium=article&amp;utm_campaign=kubernetes_balansirovshchik&amp;utm_content=cp_support\">Help and Support\u003C/a>”). And if you’d like to discuss this article or our products, we’d love to see you in our Telegram \u003Ca href=\"https://t.me/beget_chat\">community\u003C/a>.\u003C/p>\n",55,"2026-11-11T14:50:32.000Z",{"count":15,"liked":16},1,false,{"route":18,"title":20,"tags":21,"breadcrumbs":27,"uuid":28,"parent_uuid":29,"default_page_path":26,"seo_metadata":30},{"language":6,"path":19},"/kb/manual","Control Panel User's Manual",[22],{"id":23,"title":24,"seo_metadata":25},"vps","VPS",{"title":26,"description":26,"header":26,"keywords":26},"",[],"5afe272b-ca8e-731e-0871-c5b169760081","80213437-0399-4b4f-2333-426bb5050534",{"title":31,"description":32,"header":31,"keywords":33},"Beget Hosting Panel Guide","Руководство по панели управления Beget. Инструкции по работе с аккаунтом, файловыми менеджерами, почтой, CMS и др.","hosting panel instructions, hosting beget",{"src":26,"text":26},{"title":36,"description":37,"keywords":38},"Configuring the Kubernetes load balancer","Guide to Configuring the Managed Kubernetes Network and Load Balancer in Beget Cloud ✔ User Guide","Beget User Guide for the Managed Kubernetes Service: A Guide and Documentation for Setting Up a Load Balancer in Kubernetes",{"faq":40,"how_to":41,"product":41},[],null,{},[44,47,51,54,57,60,63,66,69,72,75,78,81,84],{"level":15,"name":45,"anchor":46},"Cluster Networking Model","cluster-networking-model",{"level":48,"name":49,"anchor":50},2,"Service Types","service-types",{"level":48,"name":52,"anchor":53},"Creating a ClusterIP Service","creating-a-clusterip-service",{"level":48,"name":55,"anchor":56},"Creating a NodePort Service","creating-a-nodeport-service",{"level":15,"name":58,"anchor":59},"Load balancer","load-balancer",{"level":48,"name":61,"anchor":62},"External and internal load balancers","external-and-internal-load-balancers",{"level":48,"name":64,"anchor":65},"Creating an external load balancer","creating-an-external-load-balancer",{"level":48,"name":67,"anchor":68},"Creating an internal balancer","creating-an-internal-balancer",{"level":15,"name":70,"anchor":71},"Balancer annotations","balancer-annotations",{"level":48,"name":73,"anchor":74},"Load Balancer Type","load-balancer-type",{"level":48,"name":76,"anchor":77},"Load Balancing Algorithm","load-balancing-algorithm",{"level":48,"name":79,"anchor":80},"Health Checks","health-checks",{"level":15,"name":82,"anchor":83},"Checking the Load Balancer Status","checking-the-load-balancer-status",{"level":15,"name":85,"anchor":86},"Deleting the load balancer","deleting-the-load-balancer",[],[89],{"route":90,"title":20},{"language":6,"path":19},[],[],[94,104,113],{"route":95,"uuid":97,"title":98,"excerpt":26,"content":26,"view_count":99,"published_at":26,"modified_at":26,"like":41,"category":41,"hero_image":41,"seo_metadata":41,"schema_org_metadata":41,"open_graph_metadata":41,"sections":100,"tags":101,"breadcrumbs":102,"images":103},{"language":6,"path":96},"/kb/manual/domains","b231d5f2-9688-cb24-0b37-9ece8b8940c9","Domains",0,[],[],[],[],{"route":105,"uuid":107,"title":108,"excerpt":26,"content":26,"view_count":99,"published_at":26,"modified_at":26,"like":41,"category":41,"hero_image":41,"seo_metadata":41,"schema_org_metadata":41,"open_graph_metadata":41,"sections":109,"tags":110,"breadcrumbs":111,"images":112},{"language":6,"path":106},"/kb/manual/ftp","b97c3b6e-0c0d-4d0b-dff2-1de38d0b2a61","FTP",[],[],[],[],{"route":114,"uuid":116,"title":117,"excerpt":26,"content":26,"view_count":99,"published_at":26,"modified_at":26,"like":41,"category":41,"hero_image":41,"seo_metadata":41,"schema_org_metadata":41,"open_graph_metadata":41,"sections":118,"tags":119,"breadcrumbs":120,"images":121},{"language":6,"path":115},"/kb/manual/mysql","66c3a229-6671-2530-9421-cc67fba4df04","MySQL",[],[],[],[],"popularity-desc"]