<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Eks on Geoff Baskwill</title>
    <link>https://geoffbaskwill.ca/tags/eks/</link>
    <description>Geoff Baskwill (Eks)</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-ca</language>
    <lastBuildDate>Thu, 22 Apr 2021 00:00:00 +0000</lastBuildDate>
    
    <atom:link href="https://geoffbaskwill.ca/tags/eks/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>CloudFormation, Route 53, and ... EKS?</title>
      <link>https://geoffbaskwill.ca/posts/cloudformation-route53-and-eks/</link>
      <pubDate>Thu, 22 Apr 2021 00:00:00 +0000</pubDate>
      
      <guid>https://geoffbaskwill.ca/posts/cloudformation-route53-and-eks/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;images/down-the-rabbit-hole.jpg&#34; alt=&#34;Falling down the rabbit hole into Wonderland&#34; title=&#34;Falling down the rabbit hole into Wonderland&#34;&gt;&lt;/p&gt;
&lt;p&gt;The other day I got halfway through writing a &lt;em&gt;very irate&lt;/em&gt; support ticket to
AWS, stopped to do some fact checking, and learned something deeply annoying.&lt;/p&gt;
&lt;p&gt;One of the teams I work manages a bunch of services. One of these “services” is
some common &lt;a href=&#34;https://aws.amazon.com/route53/&#34;&gt;Amazon Route 53&lt;/a&gt; infrastructure
that is set up using
&lt;a href=&#34;https://aws.amazon.com/cloudformation/&#34;&gt;AWS CloudFormation&lt;/a&gt;, and over the
history of the project the deployment in the development account the team uses
has been a little flaky. Each time we hit a deployment problem, the problem
always turned out to be rate limiting. It never happened in production, so the
flakiness didn&amp;rsquo;t quite get the attention that it could have.&lt;/p&gt;
&lt;h2&gt;Rate limiting in Route 53&lt;/h2&gt;&lt;p&gt;Some background: Route 53 has a hard limit of 5 control plane requests per second per AWS
account. For most folks, this is fine. However, it wasn&amp;rsquo;t working well for this
team.&lt;/p&gt;
&lt;p&gt;The team had raised support tickets and gotten advice like “CloudFormation will
attempt to create your resources in parallel. One option to avoid rate limiting
is to add &lt;code&gt;DependsOn&lt;/code&gt; links to serialize the resource creation.” We weren&amp;rsquo;t
super-happy with that answer, and there&amp;rsquo;s a
&lt;a href=&#34;https://github.com/aws-cloudformation/aws-cloudformation-coverage-roadmap/issues/573&#34;&gt;CloudFormation roadmap item&lt;/a&gt;
to fix it, but we needed something in the interim, and it worked &amp;hellip; mostly.&lt;/p&gt;
&lt;p&gt;On this day a deployment had failed again, and after going after the usual
suspects and making sure that the resources were properly serialized, I got
&lt;em&gt;very irate&lt;/em&gt;. I was halfway through writing a support ticket:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;We are still encountering Route 53 rate limits and our CloudFormation stack
deployment / updates are intermittently failing, sometimes after only two
resources are created. There are no Route 53 API calls being made by our
applications, only through CloudFormation.&lt;/p&gt;
&lt;p&gt;We are &lt;em&gt;quite frustrated&lt;/em&gt; at this point and would like to request a session
with a solution architect to help us understand how we should be doing this
and&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;and I paused.&lt;/p&gt;
&lt;h2&gt;Check yourself before you wreck yourself&lt;/h2&gt;&lt;blockquote&gt;
&lt;p&gt;“There is no point in using the word &amp;lsquo;impossible&amp;rsquo; to describe something that
has clearly happened.” — Douglas Adams, &lt;em&gt;Dirk Gently&amp;rsquo;s Holistic Detective
Agency&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;“Is it true that there are no other Route 53 API calls being made?” I asked
myself. A quick jaunt into &lt;a href=&#34;https://aws.amazon.com/cloudtrail/&#34;&gt;AWS CloudTrail&lt;/a&gt;
told me the answer, and also opened a gaping pit beneath my feet.&lt;/p&gt;
&lt;p&gt;There were &lt;strong&gt;436&lt;/strong&gt; Route 53 API calls made in the 2-minute period surrounding our
CloudFormation failure. If you do the math, that&amp;rsquo;s 3.6 requests per second on
average, so it&amp;rsquo;s not at all surprising that we maybe tipped over the limit of 5
at some point in there.&lt;/p&gt;
&lt;p&gt;“But where are these coming from?” was my immediate question, and it was
immediately answered.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/cloudtrail-route53.png&#34; alt=&#34;CloudTrail console showing Route 53 calls from an EC2 instance&#34; title=&#34;CloudTrail console showing Route 53 calls from an EC2 instance&#34;&gt;&lt;/p&gt;
&lt;p&gt;Virtually all of these requests were being made by an EC2 instance that was part
of an &lt;a href=&#34;https://aws.amazon.com/eks/&#34;&gt;Amazon Elastic Kubernetes Service (EKS)&lt;/a&gt;
cluster.&lt;/p&gt;
&lt;p&gt;Talking through this with some other folks, I learned that they&amp;rsquo;d configured
&lt;a href=&#34;https://github.com/kubernetes-sigs/external-dns&#34;&gt;external-dns&lt;/a&gt; on the cluster,
and that this behaviour is
&lt;a href=&#34;https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/aws.md#throttling&#34;&gt;actually documented&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The production account doesn&amp;rsquo;t have the EKS cluster, so it&amp;rsquo;s not overwhelmed
with Route 53 API calls, which explains why deployment never failed there.&lt;/p&gt;
&lt;h2&gt;Buh-bye&lt;/h2&gt;&lt;p&gt;I wanted to decommission the cluster immediately, but unfortunately some teams
still need it, so I wasn&amp;rsquo;t able to.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;external-dns&lt;/code&gt; documentation says that one workaround for the issue of the
controller eating your entire Route 53 request budget is to extend the interval
that the controller reconciliation loop runs at. In this particular cluster, the
reconciliation loop was running &lt;em&gt;every minute&lt;/em&gt; (the default!) to reconcile a set
of records that change approximately never. I followed the instructions, set the
&lt;code&gt;interval&lt;/code&gt; to a week, and settled in to see what happened.&lt;/p&gt;
&lt;p&gt;The first thing I noticed was that immediately the calls to Route 53 stopped. Not
surprising, but great to see the confirmation. Several hours after the change,
there were still no calls from the previously-misbehaving cluster.&lt;/p&gt;
&lt;p&gt;All is well now, and I get to put away my detective hat for another day.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“The light works,” he said, indicating the window, “the gravity works,” he
said, dropping a pencil on the floor. “Anything else we have to take our
chances with.” — Douglas Adams, &lt;em&gt;Dirk Gently&amp;rsquo;s Holistic Detective Agency&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;What I learned&lt;/h2&gt;&lt;p&gt;First, CloudTrail was instrumental here. I&amp;rsquo;m still a novice, but I&amp;rsquo;m learning
how powerful a tool it is. Once I knew what to look for, it was &lt;em&gt;immediately&lt;/em&gt;
obvious what the source of the rate limiting was. The events in CloudTrail
identified the EC2 instance and even made it clear that the source of the
requests was in an EKS cluster.&lt;/p&gt;
&lt;p&gt;Second, I was reminded that Kubernetes is not a get-out-of-ops-free card. There
is a lot of expertise involved in running Kubernetes well, even when you&amp;rsquo;re
using a managed service like EKS. I knew this before, but this was an example of
a cluster I didn&amp;rsquo;t even know existed (don&amp;rsquo;t worry: someone more responsible did
know!) having side effects way outside its scope.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
