IT DOES NOT JUST MEAN SAVING INFRASTRUCTURE EXPENSES ӡ༻ޮԽ(ࣗಈԽ)ʹΑΔ ਓతίετݮ ΠϯϑϥͷίετΛ҆͘Ͱ ͖ͨͱͯ͠ɺͦΕΛҡ࣋ ͢ΔͨΊʹଟ͘ͷखಈΦϖ Ϩʔγϣϯ͕ඞཁʹͳΔͱ ϏδωεʹूதͰ͖ͳ͍ɻ Մ༻ੑ্ʹΑΔ ػձଛࣦͷݮ (≒ ച্૿Ճ) Πϯϑϥͷ͚҆ͩ͞Λٻ ͯ͠ɺαʔϏε͕ఀࢭͨ͠ Γɺ࣭͕ྼԽͯ͠͠·͏ ͱɺϏδωεͷػձଛࣦ͕ ੜ·Εͯ͠·͏ɻ
IT DOES NOT JUST MEAN SAVING INFRASTRUCTURE EXPENSES ӡ༻ޮԽ(ࣗಈԽ)ʹΑΔ ਓతίετݮ ΠϯϑϥͷίετΛ҆͘Ͱ ͖ͨͱͯ͠ɺͦΕΛҡ࣋ ͢ΔͨΊʹଟ͘ͷखಈΦϖ Ϩʔγϣϯ͕ඞཁʹͳΔͱ ϏδωεʹूதͰ͖ͳ͍ɻ Մ༻ੑ্ʹΑΔ ػձଛࣦͷݮ (≒ ച্૿Ճ) Πϯϑϥͷ͚҆ͩ͞Λٻ ͯ͠ɺαʔϏε͕ఀࢭͨ͠ Γɺ࣭͕ྼԽͯ͠͠·͏ ͱɺϏδωεͷػձଛࣦ͕ ੜ·Εͯ͠·͏ɻ ࠷దͳόϥϯεΛऔΔ
CAS? Kubernetes Cluster Autoscaler (CAS) Karpenter CAS Pod Node Pod Pod Node Node Group AWS ASG Large Node Group AWS ASG Small 1. Unschedulable 2. Create a new node from NG (small)
CAS? Kubernetes Cluster Autoscaler (CAS) Karpenter CAS Pod Node Pod Pod Node Karpenter Pod Node Pod Node AWS Fleet Node Pool Node Group AWS ASG Pod 1. Unschedulable 2. Create a new Node
CAS? Kubernetes Cluster Autoscaler (CAS) Karpenter CAS Pod Node Pod Pod Node Karpenter Pod Node Pod Pod Node 1. Unschedulable 2. Create a new (medium) Node AWS Fleet Node Pool Node Group AWS ASG
KARPENTER OPTIMIZES COSTS! Provisioning Karpenter Node AWS Fleet Node Pool Pod Pod Pod Pod Pod Pod Pod Pod 1. Grouping pending Pods and Finding f itting candidates. 3. Create an optimal instance based on strategy • Pending PodΛ·ͱΊͯϑΟοτ͢ΔNode ͷछྨΛ୳͢(BinPacking, FFD Algorithm) • ϑΟοτ͢ΔͷΑΓେ͖͍max 60ީิͷ ͏ͪɺઓུʹԠͨ͡࠷దͳΠϯελϯε͕ ىಈͰ͖Δ on-demand: lowest-price (࠷͍҆ͷ) spot: price-capacity-optimized (҆͘தஅՄೳੑͷ͍ͷ) 2. Send max 60 Candidates Save Costs!
KARPENTER OPTIMIZES COSTS! Disruption Controllers Node A Pod Node B Pod Node A’ Pod Pod $0.05 $0.02 Recreate a new node Reallocate a Pod • Expiration: ಛఆ͕࣌ؒܦաͨ͠Βআ • Consolidation: Node্ͷશͯͷPod͕ଞͷNode ʹҠಈՄೳͳΒআɺ·ͨɺݱࡏͷΠϯελϯ εΑΓ͍҆Πϯελϯε͕ར༻ՄೳͳΒஔ • Drift: NodePoolͷઃఆ͕มߋ͞ΕɺطଘͷΠϯε λϯε͕·͍͠ঢ়ଶͱͷ͕ࠩͰͨΒআ͢Δ • Interruption: SpotΠϯελϯεͷఀࢭ UnhealthyʹͳͬͨΒஔ͢Δ Pod
KARPENTER OPTIMIZES COSTS! Disruption Controllers • Expiration: ಛఆ͕࣌ؒܦաͨ͠Βআ • Consolidation: Node্ͷશͯͷPod͕ଞͷNode ʹҠಈՄೳͳΒআɺ·ͨɺݱࡏͷΠϯελϯ εΑΓ͍҆Πϯελϯε͕ར༻ՄೳͳΒஔ • Drift: NodePoolͷઃఆ͕มߋ͞ΕɺطଘͷΠϯε λϯε͕·͍͠ঢ়ଶͱͷ͕ࠩͰͨΒআ͢Δ • Interruption: SpotΠϯελϯεͷఀࢭ UnhealthyʹͳͬͨΒஔ͢Δ Node A Pod Node A’ Pod Recreate Im age v1 Im age v2 Desired state of machine image was changed from v1 to v2. Node Pool v2
NOT SUPPORTED KarpenterͱߪೖΦϓγϣϯ • αϙʔτ͍ͯ͠ΔߪೖΦϓγϣϯ ެ։ϨʔτͷOn-DemandͱSpotͷ ΈͰɺׂҾϓϥϯʹ͍ͭͯߟྀ͞ Εͳ͍ • Reserved InstanceSavings Plan ɺSpotͷΑ͏ʹΠϯελϯε͕ಥ વআ͞ΕΔ͜ͱͳ͘ɺίετ ݮʹΑ͘ΘΕ͍ͯΔΦϓγϣϯ Flexera 2023 State of the Cloud Report
COST IS NOT OPTIMIZED ҎԼͷSavings PlansΛܖͨ͠߹… 3 years EC2 Savings Plan Compute Instance Max Savings 66% 72% t3.large Sample (ఆՁ: $0.1088) $0.062 (43%) $0.047 (57%) Locked Single Instance Family & Region No Yes t3.large, Tokyo Region, 3 years, No Upfront, Linux ※ 2023/11/15 21:00 ࣌ Savings Plans for K8S Nodes $0.047 t3.large t3.large 1 hour t3.large t3.large • Instance Saving PlanͷTokyo Region, t3.largeΛ3ؒ • 1࣌ؒ͋ͨΓ$0.047Λܖ 57% off
COST IS NOT OPTIMIZED c5.largeͷOn-Demand͕࡞͞Εͨ߹ Instance Type Purchase Type Price (Discount) c5.large On-demand $0.096 t3.large On-demand $0.1088 SavingsPlan $0.047 (57%) t3.large, Tokyo Region, 3 years, No Upfront, Linux ※ 2023/11/15 21:00 ࣌ EC2 Instance Pricing List • c5.largeͷOn-demandt3.largeΑΓ͍҆ • c5.large͕࡞͞ΕΔͱՃͰ$0.096ͷՃίετ c5.large t3.large +$0.096 $0.047 Karpenter 1 hour < Compare with c5.large and t3.large on-demand rate.
ঢ়گΛखಈͰཧ͢Δͷେม • GetSavingsPlansUtilization API1୯Ґͳ ͷͰཻ͕͋Β͗͢Δ • ίετͱ༻ঢ়گϨϙʔτ(AWS CUR) ͔Β1 ࣌ؒ୯Ґͷར༻ΛऔಘͰ͖Δ͕ɺجຊత ʹલͷσʔλʹͳΔ HOW CAN WE CALCULATE SAVINGS PLAN UTILIZATION? CHALLENGING PARTS Savings Planͷར༻ΛϦΞϧλΠϜʹऔ ಘ͢ΔAPI͕ଘࡏ͠ͳ͍ K8sΫϥελͷΠϯελϯεใ͚ͩͰ ར༻͕ܭࢉͰ͖ͳ͍
Agent Karpenter Node Pool Cost Usage Report Kubernetes Cluster 1. Process CUR & Predicate SavingsPlan Utilization Server Node Pool Node Pool 2. Send Instance Information & Get Predicate Result 3. Update NodePool according to predication Cost Usage Report Upload Create Optimal Node!