Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
      • Pod
    • Helm Chart
    • OAuth2 Proxy
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Argo Events
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • DevSecOps
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
      • Azure Cloud
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log, Monitor & Tracing
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[EKS/IPs] Increase most many IPs as possible on each Node of your EKS.

Posted on June 23, 2023August 20, 2023 By nim No Comments on [EKS/IPs] Increase most many IPs as possible on each Node of your EKS.

Contents

Toggle
  • 1) Look into the case.
  • 2) Solution
    • 2.1) decrease the type of EC2 instance
    • 2.2) Using Prefix Assigment to have more many IPs than previous
      • 2.2.1) How to understand about Prefix Assigment
      • 2.2.2) How to do it.
        • 2.2.2.1) Adjust kubelet
        • 2.2.2.2) Update environments cho aws-node.
      • 2.2.3) The issues when using Prefix Assignment.
  • 3) What type is adequate for your Eks?

1) Look into the case.

Hiện tại mình đang gặp vấn đề như sau:

Bạn có thể thấy hình ảnh là các pod của mình không comsume nhiều ram và cpu.
Nhưng nó có rất nhiều pod trên 1 node.

Nhưng 1 bài viết mình có giải thích thì số pod trên 1 node của eks là có giới hạn.
https://nimtechnology.com/2022/12/25/eks-the-exciting-things-about-eks/#an_example_of_network_interface_IP_address_exhaustion

2) Solution

2.1) decrease the type of EC2 instance

Cách này mình nghĩ là sẽ hiệu quả, dễ làm nhất.

Hiện tại mình đang sử dụng con m5.2xlarge 8CPU/32Gi Ram

Nó có 4 interface and 15 IPs per interface.

giờ mình giảm xuống m5.2xlarge 4 CPU và 16 Gb RAm

Các thông số network thì không đổi

==> Bạn sẽ tạo ra nhiều node hơn và nhiều ip hơn mà giả thì chỉ có rẻ hơn và bằng thôi

2.2) Using Prefix Assigment to have more many IPs than previous

2.2.1) How to understand about Prefix Assigment

Bài này dạo gần đây mới nổi
https://itnext.io/ip-and-pod-allocations-in-eks-5be6612b8325

dưới đây là tóm tắt sự khác biệt

Bạn sẽ hiện đơn giản là thây vị chỉ cập 1 IP trên network ảo thì aws sẽ assign range IP – /28 network ảo.

2.2.2) How to do it.

https://docs.aws.amazon.com/eks/latest/userguide/cni-increase-ip-addresses.html

Sau khi đọc bài viết trên chúng ta cần làm 2 việc là:
+ Sửa kubelet
+ update env cho aws-node.

2.2.2.1) Adjust kubelet

Đâu tiên chúng ta cần Calculate the number of maximum pods per node

Chúng ta sẽ cần download script:

curl -o max-pods-calculator.sh https://raw.githubusercontent.com/awslabs/amazon-eks-ami/master/files/max-pods-calculator.sh
chmod +x max-pods-calculator.sh

Để run script, bạn cần cung cấp instance type và CNI version để tính toán max pod trên 1 node.

./max-pods-calculator.sh \
--instance-type <m5.large> \
--cni-version <1.9.x-eksbuild.y> \
--cni-prefix-delegation-enabled

Về Instance thì bạn chọn các instance trong list EC2 Nitro Amazon Linux 2 Instance Type
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html#ec2-nitro-instances

cni-version: thì bạn sẽ lấy ở kube-proxy

Ở đây thỉ result của mình là 110 IP trên 1 node.

mình sử dụng terraform thì mình sẽ add trong terraform eks module

Với linux trong self_managed_node_groups

https://github.com/mrnim94/terraform-aws-eks-windows/blob/master/eks.tf#L110-L112

self_managed_node_groups = {
    linux = {
      platform = "linux"
      name = "linux"
      public_ip    = false
      instance_type = var.lin_instance_type
      key_name = var.node_host_key_name
      desired_size = var.lin_desired_size
      max_size = var.lin_max_size
      min_size = var.lin_min_size
      ami_id = data.aws_ami.lin_ami.id
      #####################
      #### BOOTSTRAPING ###
      #####################
      bootstrap_extra_args = chomp(
      <<-EOT
      --kubelet-extra-args '--max-pods=${var.max_ips_per_node} --node-labels=apps=true'
      EOT
      )
    }

Với windows trong self_managed_node_groups

windows = {
      platform = "windows"
      name = "windows"
      public_ip    = false
      instance_type = var.win_instance_type
      key_name = var.node_host_key_name
      desired_size = var.win_desired_size
      max_size = var.win_max_size
      min_size = var.win_min_size
      ami_id = data.aws_ami.win_ami.id
      #####################
      #### BOOTSTRAPING ###
      #####################
      bootstrap_extra_args = chomp(
      <<-EOT
      -KubeletExtraArgs '--max-pods=${var.max_ips_per_node} --node-labels=apps=true'
      EOT
      )
    }
  }
2.2.2.2) Update environments cho aws-node.

Tiếp theo bạn vào aws-node và edit env

https://github.com/mrnim94/terraform-aws-eks-windows/blob/master/eks.tf#L137-L144

  cluster_addons = {
    vpc-cni = {
      configuration_values = jsonencode({
        env = {
          # Reference docs https://docs.aws.amazon.com/eks/latest/userguide/cni-increase-ip-addresses.html
          ENABLE_PREFIX_DELEGATION = "true"
          WARM_PREFIX_TARGET       = "1"
        }
      })
    }
  }
}

2.2.3) The issues when using Prefix Assignment.

Thoạt đầu bạn có thể nghĩ rằng “Prefix Assigment” là solution hiệu quả thì mình sẽ trình các vần đề gặp phải

Nếu bạn có 1 subnet là 10.0.0.0/24 và như phần trên giới thiệu thì “Prefix Assignment” sẽ chia network của bạn thành các 16 subnet nhỏ với “/26”

Những subnet nay được asign cho các Ec2:

Đây là hỉnh ảnh trên aws web:

Vậy nếu 1 EC2 giữ 1 subnet/28 thì chúng ta maybe chỉa được 16 node trong 1 subnet
==> 1 Ec2 có thể giữ tốt đa 16 pods trong 1 node
==> nếu bạn các pod của bạn chiếm nhiều ram cpu => khiến 1 node chĩ hold được 5 pods.

===> Kiến chúng ta cần 17 nodes trên 1 subnet thì chúng ta ko con IPs to assign for Node

Sẽ thấy trong Network Interface như anh bên dưới

Bạn có thể truy nghĩ thêm nếu apply “Prefix Assignment”

3) What type is adequate for your Eks?

Bạn có thể dùng trang web này để tính toán pod của bạn sài bao nhiều ram/cpu và bạn sẽ sử dụng type node nào:

https://learnk8s.io/kubernetes-instance-calculator

AWS - Amazon Web Service

Post navigation

Previous Post: [DevSecOps] Remove the secrets on Git.
Next Post: [Kubernetes] Taints and Tolerations

More Related Articles

[EKS windows] Using EKS terraform module to install K8S windows with manage node Group mode. AWS - Amazon Web Service
[AWS] View Windows AMIs that have faster launching enabled AWS - Amazon Web Service
[Terraform] – Terraform Beginner – Lesson 6: Terraform Import, Tainting Resources, and Debugging AWS - Amazon Web Service
[AWS] Login and get secret/token/credential of ECR AWS - Amazon Web Service
[Terraform] Error: InvalidPermission.Duplicate: the specified rule AWS - Amazon Web Service
[AWS] Creating AWS Certificate Manager (ACM) AWS - Amazon Web Service

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [Laravel] Laravel Helpful June 26, 2025
  • [VScode] Hướng dẫn điều chỉnh font cho terminal June 20, 2025
  • [WordPress] Hướng dấn gửi mail trên WordPress thông qua gmail. June 15, 2025
  • [Bitbucket] Git Clone/Pull/Push with Bitbucket through API Token. June 12, 2025
  • [Teamcity] How to transfer the value from pipeline A to pipeline B June 9, 2025

Archives

  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
    • NextCloud
  • CI/CD
    • Argo Events
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • DevSecOps
    • Golang
    • Jquery & JavaScript
    • Laravel
    • NextJS 14 & ReactJS & Type Script
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • Azure Cloud
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Ingress
      • Pod
    • Longhorn – Storage
    • MetalLB
    • OAuth2 Proxy
    • Vault
    • VictoriaMetrics
  • Log, Monitor & Tracing
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Fluent
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2025 NimTechnology.