SlideShare ist ein Scribd-Unternehmen logo
1 von 13
EKSのCoreDNSにおいて、
名前解決が失敗する事例とその解決法について
@renjikari
自己紹介
@renjikari
SRE@freee
K8sがすき。最近全然追えてないけどDockerもだいすき
最近は大体APEXをやる日々(ドヘタ)
ホントは対面してボードゲームをするのがすき
注意
今回の話は全編に渡りチームで原因調査、検証、実装を行ってます
Thanks for @nekottyo/@hatajoe
今回の話のもう少し詳細に書いた版をブログにアップしてます
検証とか原因に対する解決策の今回選ばなかった方法とかも載せて
ます
LTは五分しかないので触りだけの気持ちでonss
名前解決が一部失敗する話
(数ヶ月前)EKS上で動かしているとあるサービスの名前解決が一部失
敗
hpaなどによってpodが増減し、CoreDNSの乗っているNodeが
shutdownされるときに名前解決が失敗していることに気づく
CoreDNSはEKSを利用するときのデフォルトで起動しているDNS
Cacheサーバ(という言い方であっているか…?)であり、今回の話で
もこのCoreDNSを利用しているときに起きたもの
CoreDNSの終了時の挙動
Podの終了時の挙動
https://qiita.com/superbrothers/items/3ac78daba3560ea406b2
CoreDNSはservice + deploymentによって宣言されているリソースで、podの終了時
には以下の1及び2が順序制御されずに行われる。
1. podにshutdown命令がだされる
2. serviceのendpointの削除命令がだされる
つまり、"serviceのendpointの削除が行われる前"にpodにたどりついたdns要求には
(podがshutdown中なので)corednsから応答がないということになる。
原因その①
CoreDNSの終了時の挙動によってDNSが失敗してしまう。gracefulに
落ちてくれてない
諸々検証したところ、cluster全体でのdnsリクエスト数が1k req/secと
かを超えるとたくさんこの事象が発生するみたい
原因その① 解決編
CoreDNS health pluginにlameduck オプションを導入
CoreDNS Podが終了を受け取ってからsleepしてくれるだけ
Corefile
.:53 {
health {
lameduck 10s
}
(関係ないので略)
}
}
原因その②
今回の根本解決のためには解決策その①だけでは不十分でした。
ここでは解決策その①をしてなお失敗する事例を紹介します。
原因その②
ClusterAutoscaler(以下CA)とAWS AutoScalingGroup(以下ASG)の相性
が良くないようで、CAがnodeをへらすときにASGがdesiredをフラッピ
ングさせてしまうことがあるようです。
事象はこの辺のissueで上がっています。おそらくASGのAZ間の
rebalanceによってこれが行われているという予想です(が、rebalance
を切ることはできないので大変です)
https://github.com/kubernetes/autoscaler/issues/2787
https://github.com/kubernetes/autoscaler/issues/3342
原因その②
CAが正常に(CoreDNS Podの乗っている)Nodeをdrainしていれば解決
策その①によって、CoreDNS Podは終了時にsleepし安全に落ちます
。
ASGのdesiredのフラッピングによって、ASGがInstanceを落とす際に
はdrainなどをせず突然落とします。
そうするとlameduckを設定していても同様に名前解決が失敗する事象
が発生します。
原因その② 解決編
ASGがInstanceを落とすときにlifecicle hookによって安全に落として
あげれば良さそうです
今回はlifecicle hookの追加とそれをhookしてnodeをdrainするnode-
drainerというものを作りました
原因その② 解決編
中身はkube-awsがやっていたnode-drainerのやり方を真似させて頂いてます
。
① ASGがInstanceをterminateしようとする
② Lifecicle hookで、terminate時にstatusをtermination:waitになるように
③ K8s上にいるDaemonset Node-drainerが定期的に自分のstatusをmetadata
経由で監視していて、termination:waitになったら、自分自身に対してdrainを
かける
④ とても安全
まとめ
はじめにK8s上で名前解決失敗しだしたときは何事かと思った
いろんな原因とそれに対する複数の解決策を考えて検証してってやっ
ててなんか楽しかった

Weitere ähnliche Inhalte

Empfohlen

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Empfohlen (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

EKSのCoreDNSにおいて、名前解決が失敗する事例とその解決法について