<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kieran Yio on Medium]]></title>
        <description><![CDATA[Stories by Kieran Yio on Medium]]></description>
        <link>https://medium.com/@kieranyio?source=rss-81c27b903ea6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4qTs4mAIqBFC5ZwwbmrVhQ.jpeg</url>
            <title>Stories by Kieran Yio on Medium</title>
            <link>https://medium.com/@kieranyio?source=rss-81c27b903ea6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 19:06:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kieranyio/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AWS IP Address Manager Issues and Tips]]></title>
            <link>https://kieranyio.medium.com/aws-ip-address-manager-issues-and-tips-fa564d11cffc?source=rss-81c27b903ea6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa564d11cffc</guid>
            <category><![CDATA[aws-networking]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Kieran Yio]]></dc:creator>
            <pubDate>Thu, 01 Jan 2026 09:03:28 GMT</pubDate>
            <atom:updated>2026-01-01T09:03:28.318Z</atom:updated>
            <content:encoded><![CDATA[<p>AWS IP Address Manager (IPAM) is a VPC feature that was released in 2021 for organisations to manage IP addresses efficiently for their AWS workloads. There are already many useful blogs and guides written about AWS IPAM so we are not going to reinvent the wheel here.</p><p>In this blog post, we will discuss some of the issues with AWS IPAM and the workarounds.</p><h3>Cross Account Resource Discovery Issue Caused By IPAM Administrator Delegation</h3><p>There are a few ways to delegate a service administrator to an account. The most common way is to navigate to the <em>AWS Organisations settings</em> page in the master account and delegate the administrator to a member account. In Terraform, the resource name is aws_organizations_delegated_administrator.</p><p>However, this approach has an issue for AWS IPAM where the required IAM role used by the service is not created automatically across all the member accounts. This causes the resource discovery to be unable to assume the role and discover all the network resources like VPC, Subnets and ENIs.</p><p>To avoid this issue, we should navigate to <em>AWS IPAM Organisation settings</em> page and delegate the administrator there. In Terraform, the resource name is aws_vpc_ipam_organization_admin_account.</p><h3>Resource Discovery Delay</h3><p>When you create a new network resource (i.e. VPC, Subnet or ENI), resource discovery will take some time to discover. This also happens to network resources that use AWS IPAM for CIDR allocation.</p><p>For example, even though you created a new VPC via AWS IPAM for CIDR allocation, you will not be able to create a VPC/Subnet pool for that new VPC because the VPC has not yet been discovered. This causes an issue where we have to wait for the resource to be discovered before we can continue the rest of the work. As a result, reduces efficiency and productivity.</p><h3>Inventory for Public IP Address</h3><p>There may be a time when you need to manage a list of public IP addresses that do not belong to AWS (BYOIP). Using a public scope for those IP addresses will require you to perform domain verification using either X.509 certificate or DNS TXT record. This can be quite tedious or undoable if the public IP addresses do not belong to your organisation.</p><p>One way to overcome this issue is to create a separate private scope and use that to manage the public IP addresses. Do note that you cannot use the IP addresses for your EC2 instances or any other services.</p><p><strong>Example</strong></p><p><strong>Create Public IP Private Scope</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rMHX-JzIiU8xbyX8w5nkZg.png" /></figure><p><strong>Create Public IP Pool in the new private scope with </strong><strong>0.0.0.0/0 CIDR</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M1uWTKjCODEKrgT-utmVUw.png" /></figure><p>Wait for a few seconds for the CIDR to be provisioned.</p><p>Now you can create custom allocations and use it to manage your public IP addresses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_YoaMe81d9haFHC-veDabg.png" /></figure><h3>Unsupported Config in Terraform AWS Provider</h3><p>If you are using Terraform as your IaC tool, take note that as of writing this blog post, Terraform AWS provider still does not support various AWS IPAM configurations for some resources like VPC/Subnet pool and Subnet.</p><blockquote>See Terraform provider open issue on Github: <a href="https://github.com/hashicorp/terraform-provider-aws/issues/34615">https://github.com/hashicorp/terraform-provider-aws/issues/34615</a></blockquote><p>To work around this, we have written a blog post for this issue. This solution can be applied to other resources as well.</p><blockquote>See <a href="https://kieranyio.medium.com/workaround-for-unsupported-config-in-terraform-aws-provider-31337208705f">Workaround for Unsupported Config in Terraform AWS Provider</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa564d11cffc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring and Analysing AWS PrivateLink cross-region connectivity to AWS services]]></title>
            <link>https://kieranyio.medium.com/exploring-and-analysing-aws-privatelink-cross-region-connectivity-to-aws-services-3a36edde8c2d?source=rss-81c27b903ea6------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a36edde8c2d</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-networking]]></category>
            <dc:creator><![CDATA[Kieran Yio]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 01:32:02 GMT</pubDate>
            <atom:updated>2025-12-22T01:32:02.395Z</atom:updated>
            <content:encoded><![CDATA[<p>In one of my previous blog posts, I explored an alternative solution in accessing VPC endpoints in another region using Route53 resolvers. With that, we can access AWS API using default FQDN from our applications without changing anything related to the connection string.</p><blockquote>See <a href="https://kieranyio.medium.com/cross-region-vpc-endpoints-access-using-route53-resolvers-97bc72c9c38e">https://kieranyio.medium.com/cross-region-vpc-endpoints-access-using-route53-resolvers-97bc72c9c38e</a></blockquote><p>In November 2025, AWS released cross-region connectivity for VPC endpoints. This greatly simplifies the cross-region API access, removing the need for an overhead setup to enable such connectivity.</p><blockquote>See <a href="https://aws.amazon.com/about-aws/whats-new/2025/11/aws-privatelink-cross-region-connectivity-aws-services/">https://aws.amazon.com/about-aws/whats-new/2025/11/aws-privatelink-cross-region-connectivity-aws-services/</a></blockquote><p>In this blog post, we will explore and analyse the usage of this new feature.</p><h3>Testing and Exploring</h3><p>We have created an EC2 instance in ap-southeast-1 region and we can see that currently it’s accessing us-east-1 KMS over the internet.</p><pre>nslookup kms.us-east-1.amazonaws.com<br>Server:         10.0.0.2<br>Address:        10.0.0.2#53<br><br>Non-authoritative answer:<br>Name:   kms.us-east-1.amazonaws.com<br>Address: 67.220.247.34</pre><p>To create a cross-region VPC endpoint, go to the <em>Create Endpoint</em> page. Under <em>Service Region</em>, tick <strong>Enable Cross Region endpoint</strong> and select us-east-1. Then, under <em>Services</em>, select com.amazonaws.us-east-1.kms. The rest of the settings are the same as creating a regional VPC endpoint. You have to select the VPC, Subnets, Security groups and Policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BeZFvL7hkRYNZhAV-Yk0SQ.png" /></figure><p>It will take a few minutes to create. Once that is done, we can see that the EC2 instance is now accessing us-east-1 KMS over the VPC endpoint.</p><pre>nslookup kms.us-east-1.amazonaws.com<br>Server:         10.0.0.2<br>Address:        10.0.0.2#53<br><br>Non-authoritative answer:<br>Name:   kms.us-east-1.amazonaws.com<br>Address: 10.0.136.0<br>Name:   kms.us-east-1.amazonaws.com<br>Address: 10.0.173.168<br>Name:   kms.us-east-1.amazonaws.com<br>Address: 10.0.154.44</pre><h3>Analysis</h3><p><strong>Limited AWS Services Supported</strong></p><p>As of today, AWS PrivateLink cross-region connectivity to AWS services is still in its early stage. There are only a few core services that support this feature like S3, IAM, ECR, KMS etc. We will have to wait for quite some time before the support for other services are released. Moreover, there are even some services that do not support VPC endpoint.</p><p>For those services that already support this, we can slowly start to migrate them over to the cross-region connectivity. In the meantime, two approaches are used concurrently to enable cross-region API access until AWS releases the support for the other services that you need.</p><blockquote>See <a href="https://docs.aws.amazon.com/vpc/latest/privatelink/aws-services-cross-region-privatelink-support.html">https://docs.aws.amazon.com/vpc/latest/privatelink/aws-services-cross-region-privatelink-support.html</a> for the full list of supported services</blockquote><p><strong>Cross-Region VPC Endpoint Policy</strong></p><p>Similar to regional VPC endpoint, a best practice is to apply policy on the cross-region VPC endpoint instead of full access to restrict resource access to prevent data exfiltration through a backdoor.</p><blockquote>See <a href="https://medium.com/aws-tip/securing-vpc-endpoints-with-policies-to-protect-against-data-exfiltration-aa6ee729ef26">Securing VPC endpoints with policies to protect against data exfiltration on how to secure your VPC endpoints</a></blockquote><p><strong>Pricing</strong></p><p>Hourly pricing remains the same, there is no additional hourly charges for cross-region connectivity. However, there is a charge for inter-region data transfer.</p><blockquote>See <a href="https://aws.amazon.com/privatelink/pricing/">https://aws.amazon.com/privatelink/pricing/</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a36edde8c2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Workaround for Unsupported Config in Terraform AWS Provider]]></title>
            <link>https://kieranyio.medium.com/workaround-for-unsupported-config-in-terraform-aws-provider-31337208705f?source=rss-81c27b903ea6------2</link>
            <guid isPermaLink="false">https://medium.com/p/31337208705f</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws-ipam]]></category>
            <dc:creator><![CDATA[Kieran Yio]]></dc:creator>
            <pubDate>Sun, 07 Dec 2025 08:35:55 GMT</pubDate>
            <atom:updated>2025-12-07T08:35:55.347Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog is co-authored with <a href="https://medium.com/u/b7e99f7e4fe5">Faith Tay</a>.</p><p>There are times where AWS releases a new service or feature and the API (SDK/CLI) supports the management of the resource but Terraform AWS Provider does not support it yet due to various reasons. If you need to use the service/feature, you can either create it manually, which is not recommended, or use workarounds to continue to manage it via Terraform.</p><p>One example is AWS VPC IPAM (IP Address Manager) — a VPC feature provided by AWS to manage IP addresses efficiently for workloads across the organisation. AWS VPC IPAM was released a few years ago but Terraform AWS Provider still does not support the creation of VPC/Subnet Pool nor the usage of IPAM Pool in subnet creation.</p><blockquote>See Terraform provider open issue on Github: <a href="https://github.com/hashicorp/terraform-provider-aws/issues/34615">https://github.com/hashicorp/terraform-provider-aws/issues/34615</a></blockquote><p>In this blog post, we will explore two workarounds for managing the resource via Terraform while waiting for Terraform AWS Provider to be updated. This can be used for all services or features, not only AWS VPC IPAM.</p><h3><strong>null_resource with local-exec</strong></h3><p>null_resource is used to follow the standard Terraform resource lifecycle and local-exec is used to customise the provisioning and deprovisioning of the actual AWS resource.</p><p>First, we construct the awscli command and test the creation of the resource. Once successful and result is as expected, we will copy the command into local-exec. In the example below, we are creating a VPC/Subnet pool (please do not hardcode the values in your actual environment and use variables instead).</p><pre>provisioner &quot;local-exec&quot; {<br> command = &quot;aws ec2 create-ipam-pool --ipam-scope-id ipam-scope-xxx --description faith-vpc --address-family ipv4 --locale ap-southeast-1 --source-ipam-pool ipam-pool-xxx --source-resource ResourceId=vpc-xxx,ResourceType=vpc,ResourceRegion=ap-southeast-1,ResourceOwner=xxx --tag-specifications &#39;ResourceType=ipam-pool,Tags=[{Key=Name,Value=\&quot;faith-vpc\&quot;}]&#39; --region ap-southeast-1&quot;<br>}</pre><p>Next, construct the awscli command to destroy the resource. This will be triggered when the resource is getting destroyed.</p><pre>provisioner &quot;local-exec&quot; {<br>  when    = destroy<br>  command = &quot;aws ec2 delete-ipam-pool --ipam-pool-id $(aws ec2 describe-ipam-pools --filters Name=description,Values=faith-vpc --region ap-southeast-1 --query &#39;IpamPools[0].IpamPoolId&#39; --output text) &quot;<br>}</pre><p>Here, we are executing multiple commands in a single line. Retrieve the resource ID first then delete the resource using the retrieved ID.</p><p>Final result will look like this.</p><pre>resource &quot;null_resource&quot; &quot;faith_vpc_pool&quot; {<br>  provisioner &quot;local-exec&quot; {<br>    command = &quot;aws ec2 create-ipam-pool --ipam-scope-id ipam-scope-xxx --description faith-vpc --address-family ipv4 --locale ap-southeast-1 --source-ipam-pool ipam-pool-xxx --source-resource ResourceId=vpc-xxx,ResourceType=vpc,ResourceRegion=ap-southeast-1,ResourceOwner=xxx --tag-specifications &#39;ResourceType=ipam-pool,Tags=[{Key=Name,Value=\&quot;faith-vpc\&quot;}]&#39; --region ap-southeast-1&quot;<br>  }<br><br>  provisioner &quot;local-exec&quot; {<br>    when    = destroy<br>    command = &quot;aws ec2 delete-ipam-pool --ipam-pool-id $(aws ec2 describe-ipam-pools --filters Name=description,Values=faith-vpc --region ap-southeast-1 --query &#39;IpamPools[0].IpamPoolId&#39; --output text) &quot;<br>  }<br>}</pre><h3>CloudFormation resource</h3><p>This approach utilises AWS IaC (Infrastructure as Code) to manage the resource, as long as CloudFormation supports the service or feature.</p><p>In a nutshell, <em>Terraform -&gt; CloudFormation -&gt; AWS resource</em></p><p>First, construct the resource template with the desired values.</p><pre>Resources = {<br>  vpcIpamPool = {<br>    Type = &quot;AWS::EC2::IPAMPool&quot;<br>    Properties = {<br>      AddressFamily    = &quot;ipv4&quot;<br>      AutoImport       = true<br>      Description      = &quot;faith-vpc&quot;<br>      IpamScopeId      = &quot;ipam-scope-xxx&quot;<br>      Locale           = &quot;ap-southeast-1&quot;<br>      SourceIpamPoolId = &quot;ipam-pool-xxx&quot;<br>      SourceResource = {<br>        ResourceId     = &quot;vpc-xxx&quot;<br>        ResourceType   = &quot;vpc&quot;<br>        ResourceRegion = &quot;ap-southeast-1&quot;<br>        ResourceOwner  = &quot;xxx&quot;<br>      }<br>      Tags = [{<br>        Key   = &quot;Name&quot;<br>        Value = &quot;faith-vpc&quot;<br>      }]<br>    }<br>  }<br>}</pre><p>After that, construct the outputs that you need for other Terraform resources to consume.</p><pre>Outputs = {<br>  Id = {<br>    Value = {<br>      &quot;Ref&quot; = &quot;vpcIpamPool&quot;<br>    }<br>  }<br>  Arn = {<br>    Value = {<br>      &quot;Fn::GetAtt&quot; = [&quot;vpcIpamPool&quot;, &quot;Arn&quot;]<br>    }<br>  }<br>}</pre><p>Final result will look like this.</p><pre>resource &quot;aws_cloudformation_stack&quot; &quot;ipam_vpc_pool&quot; {<br>  name = &quot;faith-vpc&quot;<br><br>  template_body = jsonencode({<br>    Resources = {<br>      vpcIpamPool = {<br>        Type = &quot;AWS::EC2::IPAMPool&quot;<br>        Properties = {<br>          AddressFamily    = &quot;ipv4&quot;<br>          AutoImport       = true<br>          Description      = &quot;faith-vpc&quot;<br>          IpamScopeId      = &quot;ipam-scope-xxx&quot;<br>          Locale           = &quot;ap-southeast-1&quot;<br>          SourceIpamPoolId = &quot;ipam-pool-xxx&quot;<br>          SourceResource = {<br>            ResourceId     = &quot;vpc-xxx&quot;<br>            ResourceType   = &quot;vpc&quot;<br>            ResourceRegion = &quot;ap-southeast-1&quot;<br>            ResourceOwner  = &quot;xxx&quot;<br>          }<br>          Tags = [{<br>            Key   = &quot;Name&quot;<br>            Value = &quot;faith-vpc&quot;<br>          }]<br>        }<br>      }<br>    }<br>    Outputs = {<br>      Id = {<br>        Value = {<br>          &quot;Ref&quot; = &quot;vpcIpamPool&quot;<br>        }<br>      }<br>      Arn = {<br>        Value = {<br>          &quot;Fn::GetAtt&quot; = [&quot;vpcIpamPool&quot;, &quot;Arn&quot;]<br>        }<br>      }<br>    }<br>  })<br>}</pre><h3>Migrating over to Terraform</h3><p>Once Terraform AWS Provider is updated to support the config, we can migrate it over to be fully managed by the provider.</p><p><strong>null_resource with local-exec</strong></p><ol><li>Remove the local-exec codeblock with when = destroy</li><li>Destroy the null_resource</li><li>Define a new resource with the same properties</li><li>Import the resource using Terraform CLI or codeblock</li></ol><p><strong>CloudFormation resource</strong></p><ol><li>Add deletion policy and set to Retain</li><li>Destroy the aws_cloudformation_stack resource</li><li>Define a new resource with the same properties</li><li>Import the resource using Terraform CLI or codeblock</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31337208705f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cross-region VPC endpoints access using Route53 resolvers]]></title>
            <link>https://kieranyio.medium.com/cross-region-vpc-endpoints-access-using-route53-resolvers-97bc72c9c38e?source=rss-81c27b903ea6------2</link>
            <guid isPermaLink="false">https://medium.com/p/97bc72c9c38e</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[route-53]]></category>
            <category><![CDATA[aws-route53]]></category>
            <dc:creator><![CDATA[Kieran Yio]]></dc:creator>
            <pubDate>Sat, 29 Mar 2025 07:33:05 GMT</pubDate>
            <atom:updated>2025-03-29T07:33:05.733Z</atom:updated>
            <content:encoded><![CDATA[<p>VPC endpoints are regional resources, and accessing VPC endpoints in other regions can be achieved through several solutions. One such solution is using <a href="https://repost.aws/knowledge-center/vpc-endpoints-cross-region-aws-services">Route53 Private Hosted Zones</a>. However, this approach requires you to manage a list of private hosted zones and records.</p><p>In this blog post, we will be exploring an alternative solution which can address the operational overhead encountered by some of the existing solutions.</p><blockquote>See <a href="https://medium.com/aws-tip/securing-vpc-endpoints-with-policies-to-protect-against-data-exfiltration-aa6ee729ef26">https://medium.com/aws-tip/securing-vpc-endpoints-with-policies-to-protect-against-data-exfiltration-aa6ee729ef26</a> on how to secure VPC endpoints</blockquote><h3>Architecture Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xtkAG7aNKuR1WzQot_R6CQ.png" /></figure><h3>Implementation</h3><ol><li>Create DNS VPC in both regions</li><li>Connect all VPCs using Transit Gateway</li><li>Create Route53 inbound and outbound endpoints in ap-southeast-1</li><li>Create Route53 inbound endpoints in us-east-1</li><li>Create DHCP option set and set ap-southeast-1 Route53 inbound endpoints as the DNS servers</li><li>Associate the new DHCP option set to Workload VPC</li><li>Create a Route53 resolver rule that forwards *.us-east.amazonaws.com to us-east-1 Route53 inbound endpoints</li><li>Create VPC endpoints with DNS name enabled in us-east-1 (e.g. ec2.us-east-1.amazonaws.com )</li></ol><h3>How It Works</h3><p>Whenever the workload attempts to access any us-east-1 endpoints (e.g., ec2.us-east-1.amazonaws.com), it sends a DNS query to the Route53 inbound endpoints due to the DHCP option set configuration. The Route53 resolver receives the query and checks for any applicable resolver rules. In this case, there’s a rule to forward all *.us-east-1.amazonaws.com queries to the us-east-1 Route53 inbound endpoints.</p><p>The us-east-1 Route53 resolver receives the query and attempts to resolve it. Since the ec2 VPC endpoint is created in the same VPC with DNS name enabled, the Route53 resolver can resolve the query and return a set of private IP addresses associated with the VPC endpoint. The workload receives these IP addresses and connects to one of them through the transit gateway.</p><p>For any new VPC endpoints created in the us-east-1 DNS VPC, Route53 can resolve them without needing any additional configuration.</p><p>This solution not only supports two regions but can also be extended to multiple regions using the same pattern. However, its suitability may vary based on the existing network design.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97bc72c9c38e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing VPC endpoints with policies to protect against data exfiltration]]></title>
            <link>https://awstip.com/securing-vpc-endpoints-with-policies-to-protect-against-data-exfiltration-aa6ee729ef26?source=rss-81c27b903ea6------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa6ee729ef26</guid>
            <category><![CDATA[aws-networking]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[aws-security]]></category>
            <dc:creator><![CDATA[Kieran Yio]]></dc:creator>
            <pubDate>Sat, 25 May 2024 09:02:23 GMT</pubDate>
            <atom:updated>2025-03-29T05:51:20.503Z</atom:updated>
            <content:encoded><![CDATA[<p>VPC endpoints are virtual devices that enable you to access AWS services privately without going through the internet. Many organizations use VPC endpoints to allow their internal applications to access AWS services as they are more secure since the traffic does not leave the Amazon network. However, this can be a double-edged sword if the VPC endpoints are not properly secured using policies or security group.</p><blockquote><a href="https://docs.aws.amazon.com/whitepapers/latest/aws-privatelink/what-are-vpc-endpoints.html">https://docs.aws.amazon.com/whitepapers/latest/aws-privatelink/what-are-vpc-endpoints.html</a></blockquote><p>In this blog post, we will be exploring how we can apply policies to secure the VPC endpoints as a layer of defense to prevent data exfiltration.</p><h3>How can it be exploited?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*4XEiUhlfaWcht-2YkugTCQ.png" /></figure><p>Suppose we have the following conditions:</p><ul><li>VPC endpoints have <em>Full Access</em> policy</li><li>EC2 is hosting an application or IaC tool that has privileged access</li><li>Attackers allow the EC2 in <em>Organization Account</em> to access resources in <em>Attacker Account </em>(e.g. S3 bucket)</li></ul><p>If the EC2 instance is compromised, attackers can freely exfiltrate data to their own buckets through the VPC endpoint either using the EC2 role or their IAM user. Since VPC endpoints have no logging capability, this means that there is no traceability on what bucket the EC2 is trying to access. Even if VPC flow log is enabled, we are only able to see the network layer 4 information such as IP address of the source and destination, which cannot be used to determine the name of the bucket. Moreover, there might be legitimate requests in the VPC flow logs as well. Therefore, blocking it via IP address is not a proper solution. Instead, we should be looking at how to secure the VPC endpoints.</p><h3>How to secure the VPC endpoints?</h3><h4>Using PrincipalOrgId or PrincipalAccount</h4><p>This condition is to allow the use of VPC endpoints for expected accounts or organizations (trusted identities) only. Meaning, requesters of the AWS API must belong to the specific organizations or accounts. This is to prevent attackers from using their own IAM user or role in the compromised resources (e.g. EC2) and send data to their resources through the VPC endpoints.</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: &quot;*&quot;,<br>      &quot;Action&quot;: &quot;*&quot;,<br>      &quot;Resource&quot;: &quot;*&quot;,<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;aws:PrincipalOrgId&quot;: &quot;o-xxxxxxxxxxx&quot;<br>        }<br>      }<br>    }<br>  ]<br>}</pre><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: &quot;*&quot;,<br>      &quot;Action&quot;: &quot;*&quot;,<br>      &quot;Resource&quot;: &quot;*&quot;,<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;aws:PrincipalAccount&quot;: [ &quot;111122223333&quot;, &quot;222233334444&quot; ]<br>        }<br>      }<br>    }<br>  ]<br>}</pre><p>It is recommended to have this condition in every policy unless there is a legit use case where you need to use an IAM user or role that belongs to a third party, in which case this condition can be excluded. Otherwise, you will only be blocking yourself.</p><h4>Allowing Specific Resources</h4><p>The simplest way to restrict access on the resources side is to specify the exact resources in the policy. Combining with PrincipalOrgId, it controls the access on both sides, the requesters and resources. However, this is not a scalable solution. If new resources are created in the same account, you will need to update the policy again, which results in high operational cost. As such, this is mainly used for allowing access to third party resources.</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: &quot;*&quot;,<br>      &quot;Action&quot;: &quot;*&quot;,<br>      &quot;Resource&quot;: [<br>        &quot;arn:aws:s3:::xxxxx-my-bucket&quot;,<br>        &quot;arn:aws:s3:::xxxxx-my-bucket/*&quot;<br>      ],<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;aws:PrincipalOrgId&quot;: &quot;o-xxxxxxxxxxx&quot;<br>        }<br>      }<br>    }<br>  ]<br>}</pre><h4>Using ResourceAccount</h4><p>This condition is to allow access to all resources within a specific AWS account.</p><pre><br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: &quot;*&quot;,<br>      &quot;Action&quot;: &quot;*&quot;,<br>      &quot;Resource&quot;: &quot;*&quot;,<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;aws:PrincipalOrgId&quot;: &quot;o-xxxxxxxxxxx&quot;,<br>          &quot;aws:ResourceAccount&quot;: [ &quot;111122223333&quot;, &quot;222233334444&quot; ]<br>        }<br>      }<br>    }<br>  ]<br>}</pre><p>This is useful only if you fully trust an AWS account. As this requires the account Id, it is not feasible if you are using AWS Organizations with multiple accounts as you will need to add all the account Ids in the policy. Similar to <em>allowing specific resources</em>, if you create a new account, you will need to update the policy, which again results in high operational cost. There are other conditions available that we can use to address this issue.</p><h4>Using ResourceOrgID</h4><p>Instead of adding all AWS accounts in the policy, we can use this condition to automatically allow access to all resources within the organization.</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: &quot;*&quot;,<br>      &quot;Action&quot;: &quot;*&quot;,<br>      &quot;Resource&quot;: &quot;*&quot;,<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;aws:PrincipalOrgId&quot;: &quot;o-xxxxxxxxxxx&quot;,<br>          &quot;aws:ResourceOrgID&quot;: &quot;o-xxxxxxxxxxx&quot;<br>        }<br>      }<br>    }<br>  ]<br>}</pre><p>However, if you have a <em>test</em> account in your organization that is used for proof of concept (POC) or experimentation, it will also be automatically allowed. This poses a different security risk if the <em>test</em> account does not have the proper guardrails where attackers can send data to test resources and exfiltrate data from the “open” <em>test</em> account. To mitigate this, we can use the condition below.</p><h4>Using ResourceOrgPaths</h4><p>This condition only works if you have already grouped your accounts into organizational units (OUs) such as <em>test</em>, development, staging and production.</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: &quot;*&quot;,<br>      &quot;Action&quot;: &quot;*&quot;,<br>      &quot;Resource&quot;: &quot;*&quot;,<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;aws:PrincipalOrgId&quot;: &quot;o-xxxxxxxxxxx&quot;<br>        },<br>        &quot;ForAnyValue:StringEquals&quot;: {<br>          &quot;aws:ResourceOrgPaths&quot;: [<br>            &quot;o-org/r-root/ou-prod/&quot;<br>          ]<br>        }<br>      }<br>    }<br>  ]<br>}</pre><p>With this, we are restricting the resources access based on organizational units. Sending data to the <em>test</em> account is no longer allowed unless explicitly specified in the policy.</p><p>These are the 5 basic approaches that you can take to get started with securing your VPC endpoints. There are many other conditions out there that are available where you can explore and use it in your policy.</p><p>As a side note, not all VPC endpoints support policy. Some examples are email-smtp , ebs and eks. You can follow the AWS documentation below to generate the list and check for policy support.</p><blockquote><a href="https://docs.aws.amazon.com/vpc/latest/privatelink/aws-services-privatelink-support.html#vpce-endpoint-policy-support">https://docs.aws.amazon.com/vpc/latest/privatelink/aws-services-privatelink-support.html#vpce-endpoint-policy-support</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa6ee729ef26" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/securing-vpc-endpoints-with-policies-to-protect-against-data-exfiltration-aa6ee729ef26">Securing VPC endpoints with policies to protect against data exfiltration</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upgrading EKS nodes provisioned by Karpenter]]></title>
            <link>https://kieranyio.medium.com/upgrading-eks-nodes-provisioned-by-karpenter-798b32b9c7e1?source=rss-81c27b903ea6------2</link>
            <guid isPermaLink="false">https://medium.com/p/798b32b9c7e1</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[amazon-eks]]></category>
            <category><![CDATA[karpenter]]></category>
            <dc:creator><![CDATA[Kieran Yio]]></dc:creator>
            <pubDate>Sat, 19 Aug 2023 10:27:11 GMT</pubDate>
            <atom:updated>2025-12-07T06:35:03.401Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a continuation of the previous <a href="https://medium.com/@kieranyio/exploring-eks-with-karpenter-on-fargate-part-1-7fe3a5cd0281">blog post</a> where we explored how to get started with Karpenter and how to create a “nodelesss” EKS cluster by using Fargate to host Karpenter.</p><p>EKS node upgrade is part of the operational activities and it is considered a best practice to use the latest version as it includes new Kubernetes patches and security updates. Depending on the organisation, you may be required to upgrade the nodes on a set frequency to comply with the security policy.</p><p>This blog post will explore how we can upgrade the EKS nodes provisioned by Karpenter using two methods — manual and automated.</p><h3>Getting Started</h3><p>We will be using the following setup:</p><ul><li>EKS Cluster v1.26</li><li>2 EKS AMIs: amazon-eks-node-1.26-v20230711 and amazon-eks-node-1.26-v20230728</li><li>Karpenter v0.29.2 with Fargate</li><li>Nginx service and deployment with 5 replicas</li><li>Karpenter Provisioner</li></ul><pre>apiVersion: karpenter.sh/v1alpha5<br>kind: Provisioner<br>metadata:<br>  name: nginx<br>spec:<br>  requirements:<br>    - key: karpenter.k8s.aws/instance-family<br>      operator: In<br>      values: [t3]<br>    - key: karpenter.k8s.aws/instance-size<br>      operator: In<br>      values: [micro]<br>  providerRef:<br>    name: ami-1-26-v20230711<br>  ttlSecondsAfterEmpty: 30</pre><ul><li>Karpenter node templates</li></ul><pre>apiVersion: karpenter.k8s.aws/v1alpha1<br>kind: AWSNodeTemplate<br>metadata:<br>  name: ami-1-26-v20230711<br>spec:<br>  subnetSelector:<br>    karpenter.sh/discovery: &quot;kieran-cluster&quot;<br>  securityGroupSelector:<br>    karpenter.sh/discovery: &quot;kieran-cluster&quot;<br>  amiFamily: Custom<br>  amiSelector:<br>    aws::name: amazon-eks-node-1.26-v20230711<br>  userData: |<br>    #!/bin/bash<br>    set -o xtrace<br>    /etc/eks/bootstrap.sh kieran-cluster<br>---<br>apiVersion: karpenter.k8s.aws/v1alpha1<br>kind: AWSNodeTemplate<br>metadata:<br>  name: ami-1-26-v20230728<br>spec:<br>  subnetSelector:<br>    karpenter.sh/discovery: &quot;kieran-cluster&quot;<br>  securityGroupSelector:<br>    karpenter.sh/discovery: &quot;kieran-cluster&quot;<br>  amiFamily: Custom<br>  amiSelector:<br>    aws::name: amazon-eks-node-1.26-v20230728<br>  userData: |<br>    #!/bin/bash<br>    set -o xtrace<br>    /etc/eks/bootstrap.sh kieran-cluster</pre><h3>Manual Upgrade</h3><p>Ensure drift feature flag (featureGates.driftEnabled) is <strong>disabled</strong> in the karpenter-global-settings configmap.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get configmap karpenter-global-settings -n karpenter -o yaml<br>apiVersion: v1<br>data:<br>  aws.clusterEndpoint: &quot;&quot;<br>  aws.clusterName: kieran-cluster<br>  aws.defaultInstanceProfile: kieran-cluster-karpenter-node-role<br>  aws.enableENILimitedPodDensity: &quot;true&quot;<br>  aws.enablePodENI: &quot;false&quot;<br>  aws.interruptionQueueName: kieran-cluster<br>  aws.isolatedVPC: &quot;false&quot;<br>  aws.vmMemoryOverheadPercent: &quot;0.075&quot;<br>  batchIdleDuration: 1s<br>  batchMaxDuration: 10s<br>  featureGates.driftEnabled: &quot;false&quot;<br>kind: ConfigMap<br>metadata:<br>  ...</pre><p>If the drift feature flag is <strong>enabled</strong>, edit the configmap to set it false.</p><pre>kubectl edit configmap karpenter-global-settings -n karpenter</pre><p>Then restart the pods using rollout restart.</p><pre>kubectl rollout restart deployment karpenter -n karpenter</pre><p>All the nodes are currently using amazon-eks-node-1.26-v20230711 AMI and the nginx pods are spread across multiple nodes.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get pods -o wide<br>NAME                     READY   STATUS    RESTARTS   AGE   IP            NODE                                              NOMINATED NODE   READINESS GATES<br>nginx-748c667d99-4c99p   1/1     Running   0          15m   10.x.x.90     ip-10-x-x-76.ap-southeast-1.compute.internal      &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-l2grc   1/1     Running   0          16m   10.x.x.92     ip-10-x-x-251.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-l5v8p   1/1     Running   0          14m   10.x.x.89     ip-10-x-x-186.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-lkf76   1/1     Running   0          16m   10.x.x.12     ip-10-x-x-236.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-mb4v4   1/1     Running   0          14m   10.x.x.119    ip-10-x-x-186.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;</pre><p>Update the Karpenter Provisioner to use the node template (ami-1–26-v20230728) that has the latest AMI specified. Karpenter will not attempt to replace the nodes as the drift feature flag is disabled.</p><pre>apiVersion: karpenter.sh/v1alpha5<br>kind: Provisioner<br>metadata:<br>  name: nginx<br>spec:<br>  requirements:<br>    - key: karpenter.k8s.aws/instance-family<br>      operator: In<br>      values: [t3]<br>    - key: karpenter.k8s.aws/instance-size<br>      operator: In<br>      values: [micro]<br>  providerRef:<br>    name: ami-1-26-v20230728<br>  ttlSecondsAfterEmpty: 30</pre><p>We can start to drain the old node.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl drain ip-10-x-x-186.ap-southeast-1.compute.internal --ignore-daemonsets<br>node/ip-10-x-x-186.ap-southeast-1.compute.internal cordoned<br>WARNING: ignoring DaemonSet-managed Pods: kube-system/aws-node-v7rxw, kube-system/kube-proxy-xct9k<br>evicting pod default/nginx-748c667d99-l5v8p<br>evicting pod default/nginx-748c667d99-mb4v4<br>pod/nginx-748c667d99-l5v8p evicted<br>pod/nginx-748c667d99-mb4v4 evicted<br>node/ip-10-x-x-186.ap-southeast-1.compute.internal evicted</pre><p>Once the pods are evicted, the node will be deleted and a new one will be provisioned automatically. This new node should be using the new amazon-eks-node-1.26-v20230728 AMI.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get pods -o wide<br>NAME                     READY   STATUS    RESTARTS   AGE    IP             NODE                                              NOMINATED NODE   READINESS GATES<br>nginx-748c667d99-4c99p   1/1     Running   0          29m    10.x.x.90      ip-10-x-x-76.ap-southeast-1.compute.internal      &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-9bbbk   1/1     Running   0          3m7s   10.x.x.221     ip-10-x-x-136.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-l2grc   1/1     Running   0          30m    10.x.x.92      ip-10-x-x-251.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-lkf76   1/1     Running   0          30m    10.x.x.12      ip-10-x-x-236.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-x8cf2   1/1     Running   0          3m7s   10.x.x.73      ip-10-x-x-236.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;</pre><p>That’s it. You have completed the upgrade for one node. Repeat the draining process for other nodes to upgrade it.</p><h3>Automated Upgrade</h3><p>Ensure drift feature flag (featureGates.driftEnabled) is <strong>enabled</strong> in the karpenter-global-settings configmap.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get configmap karpenter-global-settings -n karpenter -o yaml<br>apiVersion: v1<br>data:<br>  aws.clusterEndpoint: &quot;&quot;<br>  aws.clusterName: kieran-cluster<br>  aws.defaultInstanceProfile: kieran-cluster-karpenter-node-role<br>  aws.enableENILimitedPodDensity: &quot;true&quot;<br>  aws.enablePodENI: &quot;false&quot;<br>  aws.interruptionQueueName: kieran-cluster<br>  aws.isolatedVPC: &quot;false&quot;<br>  aws.vmMemoryOverheadPercent: &quot;0.075&quot;<br>  batchIdleDuration: 1s<br>  batchMaxDuration: 10s<br>  featureGates.driftEnabled: &quot;true&quot;<br>kind: ConfigMap<br>metadata:<br>  ...</pre><p>If the drift feature flag is <strong>disabled</strong>, edit the configmap to set it true.</p><pre>kubectl edit configmap karpenter-global-settings -n karpenter</pre><p>Then restart the pods using rollout restart.</p><pre>kubectl rollout restart deployment karpenter -n karpenter</pre><p>All the nodes are currently using amazon-eks-node-1.26-v20230711 AMI and the nginx pods are spread across multiple nodes.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get pods -o wide<br>NAME                     READY   STATUS    RESTARTS   AGE     IP             NODE                                              NOMINATED NODE   READINESS GATES<br>nginx-748c667d99-dd7gb   1/1     Running   0          6m46s   10.x.x.134     ip-10-x-x-235.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-fb5jl   1/1     Running   0          4m24s   10.x.x.217     ip-10-x-x-9.ap-southeast-1.compute.internal       &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-nv2fg   1/1     Running   0          6m44s   10.x.x.113     ip-10-x-x-235.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-vr9lc   1/1     Running   0          4m33s   10.x.x.185     ip-10-x-x-111.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-x28cf   1/1     Running   0          4m24s   10.x.x.100     ip-10-x-x-9.ap-southeast-1.compute.internal       &lt;none&gt;           &lt;none&gt;</pre><p>Update the Karpenter Provisioner to use the node template (ami-1–26-v20230728) that has the latest AMI specified.</p><pre>apiVersion: karpenter.sh/v1alpha5<br>kind: Provisioner<br>metadata:<br>  name: nginx<br>spec:<br>  requirements:<br>    - key: karpenter.k8s.aws/instance-family<br>      operator: In<br>      values: [t3]<br>    - key: karpenter.k8s.aws/instance-size<br>      operator: In<br>      values: [micro]<br>  providerRef:<br>    name: ami-1-26-v20230728<br>  ttlSecondsAfterEmpty: 30</pre><p>Once the Karpenter Provisioner has been updated, Karpenter will detect a drift in the AMI and start to upgrade the nodes one by one.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get nodes<br>NAME                                                       STATUS                     ROLES    AGE     VERSION<br>fargate-ip-10-x-x-219.ap-southeast-1.compute.internal      Ready                      &lt;none&gt;   73s     v1.26.3-eks-f4dc2c0<br>fargate-ip-10-x-x-191.ap-southeast-1.compute.internal      Ready                      &lt;none&gt;   71s     v1.26.3-eks-f4dc2c0<br>ip-10-x-x-235.ap-southeast-1.compute.internal              Ready                      &lt;none&gt;   10m     v1.26.6-eks-a5565ad<br>ip-10-x-x-9.ap-southeast-1.compute.internal                Ready                      &lt;none&gt;   7m54s   v1.26.6-eks-a5565ad<br>ip-10-x-x-111.ap-southeast-1.compute.internal              Ready                      &lt;none&gt;   7m49s   v1.26.6-eks-a5565ad<br>ip-10-x-x-94.ap-southeast-1.compute.internal               Ready,SchedulingDisabled   &lt;none&gt;   10m     v1.26.6-eks-a5565ad</pre><p>After awhile (depending on the number of pods and nodes), all the nodes will be upgraded to use the new amazon-eks-node-1.26-v20230728 AMI.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get pods -o wide                       <br>NAME                     READY   STATUS    RESTARTS   AGE     IP             NODE                                              NOMINATED NODE   READINESS GATES<br>nginx-748c667d99-4tk25   1/1     Running   0          3m7s    10.x.x.42      ip-10-x-x-133.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-ck8nb   1/1     Running   0          3m53s   10.x.x.42      ip-10-x-x-218.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-kslfz   1/1     Running   0          3m7s    10.x.x.16      ip-10-x-x-182.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-lt5vq   1/1     Running   0          4m40s   10.x.x.227     ip-10-x-x-178.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;<br>nginx-748c667d99-r27gz   1/1     Running   0          3m53s   10.x.x.213     ip-10-x-x-218.ap-southeast-1.compute.internal     &lt;none&gt;           &lt;none&gt;</pre><p>The node upgrade is now completed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=798b32b9c7e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accessing internal applications hosted on EKS with AWS Verified Access]]></title>
            <link>https://kieranyio.medium.com/accessing-internal-applications-hosted-on-eks-with-aws-verified-access-b6b4f3c3635b?source=rss-81c27b903ea6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6b4f3c3635b</guid>
            <category><![CDATA[amazon-eks]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Kieran Yio]]></dc:creator>
            <pubDate>Thu, 06 Jul 2023 06:17:10 GMT</pubDate>
            <atom:updated>2025-12-07T06:38:03.081Z</atom:updated>
            <content:encoded><![CDATA[<p>AWS Verified Access is a managed service that is used for providing secure access to internal applications. It is like a reverse proxy with an authentication feature. It was released as <a href="https://aws.amazon.com/about-aws/whats-new/2023/04/aws-verified-access-generally-available/">General Availability in late April 2023</a>. Organisations who are looking at VPN-less solution or to replace their costly VPN can consider using AWS Verified Access. For authentication, AWS Verified Access can be integrated with AWS IAM Identity, AWS Cognito or even third party identity providers such as Okta.</p><p>This blog post will show you how to set up AWS Verified Access to provide secure access to an internal application hosted on EKS.</p><p><em>Note: At the point of writing this blog post, AWS Verified Access only supports the following regions — US East (Ohio), US East (N. Virginia), US West (N. California), US West (Oregon), Asia Pacific (Sydney), Canada (Central), Europe (Frankfurt), Europe (Ireland), Europe (London), and South America (São Paulo).</em></p><h3>Prerequisites setup</h3><p>First, we will set the environment variables needed for the setup…</p><pre>export CLUSTER_NAME=&lt;your cluster name&gt;<br>export SUBNET_IDS=(&quot;&lt;subnet 1&gt;&quot; &quot;&lt;subnet 2&gt;&quot; &quot;&lt;subnet 3&gt;&quot;)<br>export AWS_DEFAULT_REGION=&lt;your region&gt;<br>export AWS_ACCOUNT_ID=&quot;$(aws sts get-caller-identity --query Account --output text)&quot;<br>export HOSTED_ZONE_ID=&lt;your public route53 hosted zone id&gt;<br>export VPC_ID=&lt;your VPC ID&gt;</pre><p>…as well as tag the subnets with the following tag.</p><pre>aws ec2 create-tags \<br>--resources &quot;${SUBNET_IDS[0]}&quot; &quot;${SUBNET_IDS[1]}&quot; &quot;${SUBNET_IDS[2]}&quot; \<br>--tags Key=kubernetes.io/role/internal-elb,Value=1</pre><h3>Create EKS cluster and node group role</h3><pre>cat &lt;&lt;EOF &gt; cluster-trust-policy.json<br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;Service&quot;: &quot;eks.amazonaws.com&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}<br>EOF<br>aws iam create-role --role-name ${CLUSTER_NAME}-role --assume-role-policy-document file://&quot;cluster-trust-policy.json&quot;<br>aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AmazonEKSClusterPolicy --role-name ${CLUSTER_NAME}-role<br><br>cat &lt;&lt;EOF &gt; nodegroup-trust-policy.json<br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;Service&quot;: &quot;ec2.amazonaws.com&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}<br>EOF<br>aws iam create-role --role-name ${CLUSTER_NAME}-ng-role --assume-role-policy-document file://&quot;nodegroup-trust-policy.json&quot;<br>aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly --role-name ${CLUSTER_NAME}-ng-role<br>aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy --role-name ${CLUSTER_NAME}-ng-role<br>aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy --role-name ${CLUSTER_NAME}-ng-role<br>rm -f nodegroup-trust-policy.json</pre><h3>Create private EKS cluster</h3><p>To create a private EKS cluster, we will set the endpointPublicAccess = false and endpointPrivateAccess = true.</p><pre>aws eks create-cluster \<br>--name $CLUSTER_NAME \<br>--role-arn arn:aws:iam::${AWS_ACCOUNT_ID}:role/${CLUSTER_NAME}-role \<br>--resources-vpc-config subnetIds=${SUBNET_IDS[0]},${SUBNET_IDS[1]},${SUBNET_IDS[2]},endpointPublicAccess=false,endpointPrivateAccess=true \<br>--kubernetes-version 1.26 \<br>--region $AWS_DEFAULT_REGION</pre><h3>Create node group</h3><pre>aws eks create-nodegroup \<br>--cluster-name $CLUSTER_NAME \<br>--nodegroup-name $CLUSTER_NAME \<br>--node-role arn:aws:iam::${AWS_ACCOUNT_ID}:role/${CLUSTER_NAME}-ng-role \<br>--scaling-config minSize=1,maxSize=2,desiredSize=1 \<br>--subnets &quot;${SUBNET_IDS[0]}&quot; &quot;${SUBNET_IDS[1]}&quot; &quot;${SUBNET_IDS[2]}&quot;</pre><h3>Deploy Nginx with a load balancer</h3><p>By default, when you deploy a load balancer service without any annotation, EKS will attempt to deploy a <strong>Classic Load Balancer </strong>(CLB). However, AWS Verified Access does not support CLB as an endpoint type. It only supports <strong>Application Load Balancer (ALB) </strong>and <strong>Network Load Balancer (NLB)</strong>. If your existing application is using CLB, you will need to migrate it to either ALB or CLB for AWS Verified Access for it to work. Therefore, we will be deploying an Nginx deployment with a network load balancer service.</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: nginx<br>  labels:<br>    app: nginx<br>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: nginx<br>  template:<br>    metadata:<br>      labels:<br>        app: nginx<br>    spec:<br>      containers:<br>      - name: nginx<br>        image: nginx<br>        ports:<br>        - containerPort: 80<br>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: nginx<br>  annotations:<br>    service.beta.kubernetes.io/aws-load-balancer-internal: &quot;true&quot;<br>    service.beta.kubernetes.io/aws-load-balancer-scheme: internal<br>    service.beta.kubernetes.io/aws-load-balancer-type: &quot;nlb&quot;<br>spec:<br>  selector:<br>    app: nginx<br>  ports:<br>    - port: 80<br>      targetPort: 80<br>  type: LoadBalancer</pre><h3>Request for a certificate from AWS Certificate Manager</h3><p>I will be using my own domain for the certificate request. For simplicity, I will request for a wildcard certificate and set validation method as DNS. This certificate will be used for the Verified Access endpoint.</p><pre>aws acm request-certificate \<br>--domain-name *.island.x.x.x \<br>--validation-method DNS</pre><p>After requesting for a certificate, we will need to validate it. Replace the following in the script below with your own values:</p><ul><li>&lt;cert cname name&gt;</li><li>&lt;cert cname value&gt;</li></ul><pre>cat &lt;&lt;EOF &gt; cert-validation.json<br>{<br>  &quot;Comment&quot;: &quot;Certificate validation&quot;,<br>  &quot;Changes&quot;: [<br>    {<br>      &quot;Action&quot;: &quot;UPSERT&quot;,<br>      &quot;ResourceRecordSet&quot;: {<br>        &quot;Name&quot;: &quot;&lt;cert cname name&gt;&quot;,<br>        &quot;Type&quot;: &quot;CNAME&quot;,<br>        &quot;TTL&quot;: 300,<br>        &quot;ResourceRecords&quot;: [<br>           {<br>             &quot;Value&quot;: &quot;&lt;cert cname value&gt;&quot;<br>           }<br>         ]<br>       }<br>     }<br>  ]<br>}<br>EOF<br>aws route53 change-resource-record-sets \<br>--hosted-zone-id $HOSTED_ZONE_ID \<br>--change-batch file://cert-validation.json<br>rm -f cert-validation.json</pre><p>Alternatively, if you do not have your own domain, you can <a href="https://itnext.io/using-letsencrypt-ssl-certificates-in-aws-certificate-manager-c2bc3c6ae10">generate a Let’s Encrypt certificate and import it into AWS Certificate Manager</a>.</p><h3>Create Verified Access instance</h3><pre>aws ec2 create-verified-access-instance \<br>--tag-specification &#39;ResourceType=verified-access-instance,Tags=[{Key=Name,Value=eks-verified-access}]&#39; \<br>--region $AWS_DEFAULT_REGION</pre><h3>Create and attach Verified Access trust provider</h3><p>We are using <strong>AWS IAM Identity Center</strong> as our trust provider. Feel free to change it to your own trust provider.</p><pre>aws ec2 create-verified-access-trust-provider \<br>--trust-provider-type user \<br>--user-trust-provider-type iam-identity-center \<br>--policy-reference-name iam \<br>--tag-specification &#39;ResourceType=verified-access-trust-provider,Tags=[{Key=Name,Value=eks-verified-access-trust-provider}]&#39;<br><br>aws ec2 attach-verified-access-trust-provider \<br>--verified-access-instance-id $(aws ec2 describe-verified-access-instances --filters Name=tag:Name,Values=eks-verified-access --query VerifiedAccessInstances[0].VerifiedAccessInstanceId --output text) \<br>--verified-access-trust-provider-id $(aws ec2 describe-verified-access-trust-providers --filters Name=tag:Name,Values=eks-verified-access-trust-provider --query VerifiedAccessTrustProviders[0].VerifiedAccessTrustProviderId --output text)</pre><h3>Create Verified Access group</h3><pre>aws ec2 create-verified-access-group \<br>--verified-access-instance-id $(aws ec2 describe-verified-access-instances --filters Name=tag:Name,Values=eks-verified-access --query VerifiedAccessInstances[0].VerifiedAccessInstanceId --output text) \<br>--tag-specification &#39;ResourceType=verified-access-group,Tags=[{Key=Name,Value=eks-verified-access-group}]&#39;</pre><h3>Create security group and allow ingress</h3><p>Again for simplicity, we will allow 0.0.0.0/0 since AWS Verified Access will authenticate the users.</p><pre>aws ec2 create-security-group \<br>--description eks-verified-access-endpoint \<br>--group-name eks-verified-access-endpoint-sg \<br>--tag-specification &#39;ResourceType=security-group,Tags=[{Key=Name,Value=eks-verified-access-endpoint}]&#39; \<br>--vpc-id $VPC_ID<br><br>aws ec2 authorize-security-group-ingress \<br>--group-id $(aws ec2 describe-security-groups --filters Name=tag:Name,Values=eks-verified-access-endpoint --query SecurityGroups[0].GroupId --output text) \<br>--protocol tcp \<br>--port 443 \<br>--cidr &#39;0.0.0.0/0&#39;</pre><h3>Create Verified Access endpoint</h3><p>Replace the following in the script below with your own values:</p><ul><li>&lt;nginx nlb arn&gt; : The arn of the Nginx NLB that was deployed via Kubernetes</li><li>&lt;ACM certificate arn&gt; : The arn of the wildcard certificate that was generated previously</li></ul><p>The application-domain is the URL of the application for users to access the internal application.</p><pre>cat &lt;&lt;EOF &gt; verified-acces-policy.json<br>permit(principal,action,resource)<br>when {<br>    context.iam.user.user_name == &quot;x@x.com&quot;<br>};<br>EOF<br><br>aws ec2 create-verified-access-endpoint \<br>--verified-access-group-id $(aws ec2 describe-verified-access-groups --filters Name=tag:Name,Values=eks-verified-access-group --query VerifiedAccessGroups[0].VerifiedAccessGroupId --output text) \<br>--endpoint-type load-balancer \<br>--load-balancer-options Protocol=http,Port=80,LoadBalancerArn=&lt;nginx nlb arn&gt;,SubnetIds=${SUBNET_IDS[0]},${SUBNET_IDS[1]},${SUBNET_IDS[2]} \<br>--attachment-type vpc \<br>--domain-certificate-arn &lt;ACM certificate arn&gt; \<br>--application-domain nginx.island.x.x.x \<br>--endpoint-domain-prefix nginx \<br>--security-group-ids $(aws ec2 describe-security-groups --filters Name=tag:Name,Values=eks-verified-access-endpoint --query SecurityGroups[0].GroupId --output text) \<br>--policy-document file://&quot;verified-acces-policy.json&quot; \<br>--tag-specification &#39;ResourceType=verified-access-endpoint,Tags=[{Key=Name,Value=eks-verified-access-endpoint}]&#39;<br>rm -f nodegroup-trust-policy.json</pre><h3>Configure DNS settings</h3><p>After creating the Verified Access endpoint, we will need to map the application domain to the Verified Access endpoint domain by creating a Route53 CNAME record. Otherwise, users will not be able to access the application using the application-domain.</p><pre>cat &lt;&lt;EOF &gt; dns-mapping.json<br>{<br>  &quot;Comment&quot;: &quot;Verified Access DNS Mapping&quot;,<br>  &quot;Changes&quot;: [<br>    {<br>      &quot;Action&quot;: &quot;UPSERT&quot;,<br>      &quot;ResourceRecordSet&quot;: {<br>        &quot;Name&quot;: &quot;$(aws ec2 describe-verified-access-endpoints --filters Name=tag:Name,Values=eks-verified-access-endpoint --query VerifiedAccessEndpoints[0].ApplicationDomain --output text)&quot;,<br>        &quot;Type&quot;: &quot;CNAME&quot;,<br>        &quot;TTL&quot;: 300,<br>        &quot;ResourceRecords&quot;: [<br>           {<br>             &quot;Value&quot;: &quot;$(aws ec2 describe-verified-access-endpoints --filters Name=tag:Name,Values=eks-verified-access-endpoint --query VerifiedAccessEndpoints[0].EndpointDomain --output text)&quot;<br>           }<br>         ]<br>       }<br>     }<br>  ]<br>}<br>EOF<br>aws route53 change-resource-record-sets \<br>--hosted-zone-id $HOSTED_ZONE_ID \<br>--change-batch file://dns-mapping.json<br>rm -f dns-mapping.json</pre><h3>Testing application access</h3><p>Navigate to the application domain on browser. AWS will attempt to authenticate before the application can be accessed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cbSS67vGKFESA44p3OiE1Q.png" /></figure><p>If you are still facing issues accessing the application, see below.</p><h3>Troubleshooting access issues</h3><p>We need to enable logging for the Verified Access instance.</p><p>Create a CloudWatch log group and modify the Verified Access instance logging configuration. The IncludeTrustContext property will need to be set to true so that we are able to view the context data and use it to craft the policy.</p><pre>aws logs create-log-group --log-group-name eks-verified-access<br>aws ec2 modify-verified-access-instance-logging-configuration \<br>--verified-access-instance-id $(aws ec2 describe-verified-access-instances --filters Name=tag:Name,Values=eks-verified-access --query VerifiedAccessInstances[0].VerifiedAccessInstanceId --output text) \<br>--access-logs &#39;IncludeTrustContext=true,CloudWatchLogs={Enabled=true,LogGroup=eks-verified-access}&#39;</pre><p>After updating the logging configuration, try to access the application a few times for the logs to appear.</p><p>In the logs, it will show something like this (it depends on the identity provider you are using):</p><pre>{<br>    ...,<br>    &quot;data&quot;: {<br>        &quot;context&quot;: {<br>            &quot;iam&quot;: {<br>                &quot;user&quot;: {<br>                    &quot;user_id&quot;: &quot;xxx&quot;,<br>                    &quot;user_name&quot;: &quot;x@x.com&quot;,<br>                    &quot;email&quot;: {<br>                        &quot;address&quot;: &quot;x@x.com&quot;,<br>                        &quot;verified&quot;: false<br>                    }<br>                },<br>                &quot;groups&quot;: {<br>                    &quot;xxx&quot;: {<br>                        &quot;group_name&quot;: &quot;xxx&quot;<br>                    },<br>                    &quot;yyy&quot;: {<br>                        &quot;group_name&quot;: &quot;xxx&quot;<br>                    },<br>                    &quot;zzz&quot;: {<br>                        &quot;group_name&quot;: &quot;xxx&quot;<br>                    }<br>                }<br>            },<br>            &quot;http_request&quot;: {<br>                &quot;hostname&quot;: &quot;nginx.island.x.x.x&quot;,<br>                &quot;http_method&quot;: &quot;GET&quot;,<br>                &quot;x_forwarded_for&quot;: &quot;xxx&quot;,<br>                &quot;port&quot;: 80,<br>                &quot;user_agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36&quot;,<br>                &quot;client_ip&quot;: &quot;xxx&quot;<br>            }<br>        }<br>    },<br>    ...<br>}</pre><p>What we are interested in is the data.context.</p><p>For example, if you want to allow access for a specific user, look at data.context.iam and your Verified Access endpoint policy should look like this.</p><pre>permit(principal,action,resource)<br>when {<br>    context.iam.user.user_name == &quot;x@x.com&quot;<br>};</pre><p>The iam is the policy-reference-name that was specified during the creation of the Verified Access trust provider.</p><p>To understand more on how access policy works, visit the <a href="https://docs.aws.amazon.com/verified-access/latest/ug/auth-policies.html">Verified Access Policies Documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6b4f3c3635b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring EKS with Karpenter on Fargate — Part 1]]></title>
            <link>https://kieranyio.medium.com/exploring-eks-with-karpenter-on-fargate-part-1-7fe3a5cd0281?source=rss-81c27b903ea6------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fe3a5cd0281</guid>
            <category><![CDATA[autoscaling]]></category>
            <category><![CDATA[karpenter]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[amazon-eks]]></category>
            <dc:creator><![CDATA[Kieran Yio]]></dc:creator>
            <pubDate>Sat, 17 Jun 2023 05:40:42 GMT</pubDate>
            <atom:updated>2025-12-07T06:35:48.230Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploring EKS with Karpenter on Fargate — Part 1</h3><p>Karpenter is a Kubernetes component built with AWS that helps to autoscale your compute resources based on the workload. It is similar to a Cluster Autoscaler but works differently. Between the two, Karpenter provides better flexibility in terms of configuring and launching the right-sized resources.</p><blockquote><a href="https://karpenter.sh/">https://karpenter.sh/</a></blockquote><p>Similar to other Kubernetes components, Karpenter is required to run on a compute resource. Instead of creating a node group and running Karpenter on it, we will run it on Fargate, making it a “nodelesss” EKS cluster.</p><p>This topic is split into two blog posts. In the first post, we will explore how to set up a “nodeless” EKS test cluster and how Karpenter works (Part 1). In the second post, we will dive deeper into the operational aspects of Karpenter (Part 2).</p><p>The following CLI tools will be used:</p><ul><li>awscli</li><li>kubectl</li><li>helm</li><li>openssl</li></ul><h3>Set environment variables</h3><p>First, we will set the environment variables which are needed for the setup.</p><pre>export CLUSTER_NAME=&lt;your cluster name&gt;<br>export SUBNET_IDS=(&quot;&lt;subnet 1&gt;&quot; &quot;&lt;subnet 2&gt;&quot; &quot;&lt;subnet 3&gt;&quot;)<br>export PRIVATE_SUBNET_IDS=(&quot;&lt;subnet 1&gt;&quot; &quot;&lt;subnet 2&gt;&quot; &quot;&lt;subnet 3&gt;&quot;)<br>export AWS_DEFAULT_REGION=&lt;your region&gt;<br>export AWS_ACCOUNT_ID=&quot;$(aws sts get-caller-identity --query Account --output text)&quot;<br>export KARPENTER_VERSION=v0.27.5</pre><p>The SUBNET_IDS is used to create the EKS cluster while the PRIVATE_SUBNET_IDS is used to create the Fargate profile. At the time of posting, Fargate profile only allows private subnets to be selected (no direct route to an Internet Gateway) as the running pods are not assigned public IP addresses. If you have set the public subnets in the SUBNET_IDS environment variable above, you will either need to create new private subnets or reuse existing ones.</p><h3>Create EKS cluster role</h3><pre>cat &lt;&lt;EOF &gt; cluster-trust-policy.json<br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;Service&quot;: &quot;eks.amazonaws.com&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}<br>EOF<br>aws iam create-role --role-name ${CLUSTER_NAME}-role --assume-role-policy-document file://&quot;cluster-trust-policy.json&quot;<br>aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AmazonEKSClusterPolicy --role-name ${CLUSTER_NAME}-role<br>rm cluster-trust-policy.json</pre><h3>Create EKS cluster</h3><p>Since this is just a test cluster, we will use the default setting of endpointPublicAccess = true and endpointPrivateAccess = false.</p><pre>aws eks create-cluster --name $CLUSTER_NAME --role-arn arn:aws:iam::${AWS_ACCOUNT_ID}:role/${CLUSTER_NAME}-role --resources-vpc-config subnetIds=${SUBNET_IDS[1]},${SUBNET_IDS[2]},${SUBNET_IDS[3]} --kubernetes-version 1.26 --region $AWS_DEFAULT_REGION </pre><h3>Create identity provider</h3><p>This enables the pods to authenticate and assume the IAM role defined in its service account to access AWS services.</p><pre>TEMP=$(mktemp -d -t oidc-eks-XXXX)<br>OIDC_PROVIDER=$(aws eks describe-cluster --name ${CLUSTER_NAME} --query &quot;cluster.identity.oidc.issuer&quot; --output text)<br>JWKS_URI=&quot;oidc.eks.${AWS_DEFAULT_REGION}.amazonaws.com&quot;<br>openssl s_client -servername $JWKS_URI -showcerts -connect $JWKS_URI:443 &lt; /dev/null 2&gt;/dev/null | awk -v dir=&quot;$TEMP&quot; &#39;/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/{ if(/BEGIN/){a++}; out=dir&quot;/cert00&quot;a&quot;.crt&quot;; print &gt;out }&#39;<br>LAST_CERT=$(ls -1 $TEMP/* | tail -1)<br>THUMBPRINT=$(openssl x509 -fingerprint -noout -in $LAST_CERT | sed &#39;s/^.*=//&#39; | sed &#39;s/://g&#39;)<br>aws iam create-open-id-connect-provider --url &quot;${OIDC_PROVIDER}&quot; --thumbprint-list ${THUMBPRINT} --client-id-list sts.amazonaws.com<br>rm -rf $TEMP</pre><p>Alternatively, you can also create it on the console by following this AWS documentation: <a href="https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html">https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html</a>.</p><h3><strong>Create EKS add-ons (Optional)</strong></h3><p>When creating a cluster via management console, the core add-ons (kube-proxy, vpc-cni and coredns) are installed as <strong>managed</strong> add-ons by default and cannot be unselected. However, this is different from creating a cluster via awscli where EKS will still automatically install the core add-ons but as <strong>self-managed</strong> add-ons. Thus, this step is considered optional as the cluster already has the add-ons installed.</p><h3>Create Karpenter roles</h3><p>There are three roles that we need to create for Karpenter usage.</p><p><strong>Karpenter Controller role </strong>—<strong> </strong>used by the controller pods to call the AWS services.</p><pre>cat &lt;&lt;EOF &gt; karpenter-controller-trust-policy.json<br>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;Federated&quot;: &quot;arn:aws:iam::${AWS_ACCOUNT_ID}:oidc-provider/$(aws eks describe-cluster --name $CLUSTER_NAME --query &#39;cluster.identity.oidc.issuer&#39; --output text | sed &#39;s/https\:\/\///g&#39;)&quot;<br>            },<br>            &quot;Action&quot;: &quot;sts:AssumeRoleWithWebIdentity&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;StringEquals&quot;: {<br>                    &quot;$(aws eks describe-cluster --name $CLUSTER_NAME --query &#39;cluster.identity.oidc.issuer&#39; --output text | sed &#39;s/https\:\/\///g&#39;):aud&quot;: &quot;sts.amazonaws.com&quot;,<br>                    &quot;$(aws eks describe-cluster --name $CLUSTER_NAME --query &#39;cluster.identity.oidc.issuer&#39; --output text | sed &#39;s/https\:\/\///g&#39;):sub&quot;: &quot;system:serviceaccount:karpenter:karpenter&quot;<br>                }<br>            }<br>        }<br>    ]<br>}<br>EOF<br>aws iam create-role --role-name ${CLUSTER_NAME}-karpenter-controller-role --assume-role-policy-document file://&quot;karpenter-controller-trust-policy.json&quot;<br>cat &lt;&lt;EOF &gt; karpenter-controller-policy.json<br>{<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Action&quot;: [<br>                &quot;ssm:GetParameter&quot;,<br>                &quot;iam:PassRole&quot;,<br>                &quot;ec2:DescribeImages&quot;,<br>                &quot;ec2:RunInstances&quot;,<br>                &quot;ec2:DescribeSubnets&quot;,<br>                &quot;ec2:DescribeSecurityGroups&quot;,<br>                &quot;ec2:DescribeLaunchTemplates&quot;,<br>                &quot;ec2:DescribeInstances&quot;,<br>                &quot;ec2:DescribeInstanceTypes&quot;,<br>                &quot;ec2:DescribeInstanceTypeOfferings&quot;,<br>                &quot;ec2:DescribeAvailabilityZones&quot;,<br>                &quot;ec2:DeleteLaunchTemplate&quot;,<br>                &quot;ec2:CreateTags&quot;,<br>                &quot;ec2:CreateLaunchTemplate&quot;,<br>                &quot;ec2:CreateFleet&quot;,<br>                &quot;ec2:DescribeSpotPriceHistory&quot;,<br>                &quot;pricing:GetProducts&quot;,<br>                &quot;eks:DescribeCluster&quot;<br>            ],<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Sid&quot;: &quot;Karpenter&quot;<br>        },<br>        {<br>            &quot;Action&quot;: &quot;ec2:TerminateInstances&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;StringLike&quot;: {<br>                    &quot;ec2:ResourceTag/Name&quot;: &quot;*karpenter*&quot;<br>                }<br>            },<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Sid&quot;: &quot;ConditionalEC2Termination&quot;<br>        }<br>    ],<br>    &quot;Version&quot;: &quot;2012-10-17&quot;<br>}<br>EOF<br>aws iam create-policy --policy-name ${CLUSTER_NAME}-karpenter-controller-policy --policy-document file://&quot;karpenter-controller-policy.json&quot;<br>aws iam attach-role-policy --policy-arn arn:aws:iam::${AWS_ACCOUNT_ID}:policy/${CLUSTER_NAME}-karpenter-controller-policy --role-name ${CLUSTER_NAME}-karpenter-controller-role<br>rm karpenter-controller-trust-policy.json karpenter-controller-policy.json</pre><p><strong>Karpenter node role and instance profile </strong>— used by the compute resources (EC2) that Karpenter provisioned.</p><p>When using awscli to create the IAM role, we will need to create the instance profile separately and attach a role to it, which is unlike using management console where instance profile will be created automatically when creating the IAM role.</p><pre>cat &lt;&lt;EOF &gt;&gt; karpenter-node-trust-policy.json<br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;Service&quot;: &quot;ec2.amazonaws.com&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}<br>EOF<br>aws iam create-role --role-name ${CLUSTER_NAME}-karpenter-node-role --assume-role-policy-document file://&quot;karpenter-node-trust-policy.json&quot;<br>aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy --role-name ${CLUSTER_NAME}-karpenter-node-role<br>aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly --role-name ${CLUSTER_NAME}-karpenter-node-role<br>aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy --role-name ${CLUSTER_NAME}-karpenter-node-role<br>aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore --role-name ${CLUSTER_NAME}-karpenter-node-role<br>aws iam create-instance-profile --instance-profile-name ${CLUSTER_NAME}-karpenter-node-role<br>aws iam add-role-to-instance-profile --instance-profile-name ${CLUSTER_NAME}-karpenter-node-role --role-name ${CLUSTER_NAME}-karpenter-node-role<br>rm karpenter-node-trust-policy.json</pre><p><strong>Karpenter Fargate profile role</strong> — used by the Fargate to connect to the cluster and pull container images.</p><pre>cat &lt;&lt;EOF &gt;&gt; karpenter-fargate-trust-policy.json<br>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;Statement1&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;Service&quot;: &quot;eks-fargate-pods.amazonaws.com&quot;<br>            },<br>            &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>        }<br>    ]<br>}<br>EOF<br>aws iam create-role --role-name ${CLUSTER_NAME}-karpenter-fargate-role --assume-role-policy-document file://&quot;karpenter-fargate-trust-policy.json&quot;<br>aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AmazonEKSFargatePodExecutionRolePolicy --role-name ${CLUSTER_NAME}-karpenter-fargate-role<br>aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy --role-name ${CLUSTER_NAME}-karpenter-fargate-role<br>rm karpenter-fargate-trust-policy.json</pre><h3><strong>Create Fargate profile</strong></h3><p>Here, we specify the karpenter namespace for the selector as that is where we will deploy the pods.</p><pre>aws eks create-fargate-profile --fargate-profile-name karpenter --cluster-name $CLUSTER_NAME --pod-execution-role-arn arn:aws:iam::${AWS_ACCOUNT_ID}:role/${CLUSTER_NAME}-karpenter-fargate-role --subnets $PRIVATE_SUBNET_IDS --selectors namespace=karpenter</pre><h3>Patch aws-auth configmap</h3><p>We need to add the <strong>Karpenter node role</strong> in the<strong> </strong>aws-auth configmap. To do this, we will update kubeconfig to use the newly created cluster and run kubectl command to patch it.</p><pre>aws eks update-kubeconfig --name $CLUSTER_NAME<br>ROLE=&quot;    - rolearn: arn:aws:iam::${AWS_ACCOUNT_ID}:role/${CLUSTER_NAME}-karpenter-node-role\n      username: system:node:{{EC2PrivateDNSName}}\n      groups:\n      - system:bootstrappers\n      - system:nodes&quot;<br>kubectl get -n kube-system configmap/aws-auth -o yaml | awk &quot;/mapRoles: \|/{print;print \&quot;$ROLE\&quot;;next}1&quot; &gt; aws-auth-patch.yml<br>kubectl patch configmap/aws-auth -n kube-system --patch &quot;$(cat aws-auth-patch.yml)&quot;</pre><h3>Deploy Karpenter</h3><pre>helm upgrade --install karpenter oci://public.ecr.aws/karpenter/karpenter --version $KARPENTER_VERSION --namespace karpenter --create-namespace \<br>  --set serviceAccount.annotations.&quot;eks\.amazonaws\.com/role-arn&quot;=arn:aws:iam::${AWS_ACCOUNT_ID}:role/${CLUSTER_NAME}-karpenter-controller-role \<br>  --set settings.aws.clusterName=$CLUSTER_NAME \<br>  --set settings.aws.defaultInstanceProfile=${CLUSTER_NAME}-karpenter-node-role \<br>  --set settings.aws.interruptionQueueName=$CLUSTER_NAME</pre><p>After installing, we can see the Karpenter pods are running on Fargate node.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get pods -A -o wide<br>NAMESPACE     NAME                        READY   STATUS    RESTARTS   AGE     IP              NODE                                                       NOMINATED NODE   READINESS GATES<br>karpenter     karpenter-9b99dc5cf-65554   1/1     Running   0          2m9s    10.x.x.40       fargate-ip-10-x-x-40.ap-southeast-1.compute.internal       &lt;none&gt;           &lt;none&gt;<br>karpenter     karpenter-9b99dc5cf-ptn9t   1/1     Running   0          2m9s    10.x.x.131      fargate-ip-10-x-x-131.ap-southeast-1.compute.internal      &lt;none&gt;           &lt;none&gt;<br>kube-system   coredns-7bc775787b-lsz7j    0/1     Pending   0          3h53m   &lt;none&gt;          &lt;none&gt;                                                     &lt;none&gt;           &lt;none&gt;<br>kube-system   coredns-7bc775787b-lx9qj    0/1     Pending   0          3h53m   &lt;none&gt;          &lt;none&gt;                                                     &lt;none&gt;           &lt;none&gt;<br>kieranyio@Kierans-MacBook-Pro-2 ~ % </pre><h3>Create Provisioner and AWSNodeTemplate</h3><p>To start using karpenter, we will tag the subnets and security group to specify where the nodes will be provisioned and which security group to use.</p><pre>aws ec2 create-tags --resources $SUBNET_IDS $(aws eks describe-cluster --name ${CLUSTER_NAME} --query &#39;cluster.resourcesVpcConfig.clusterSecurityGroupId&#39; --output text) --tags Key=&quot;karpenter.sh/discovery&quot;,Value=&quot;${CLUSTER_NAME}&quot;</pre><p>Then create the Provisioner and AWSNodeTemplate.</p><pre>cat &lt;&lt;EOF | kubectl apply -f -<br>apiVersion: karpenter.sh/v1alpha5<br>kind: Provisioner<br>metadata:<br>  name: default<br>spec:<br>  requirements:<br>    - key: karpenter.k8s.aws/instance-family<br>      operator: In<br>      values: [t3]<br>    - key: karpenter.k8s.aws/instance-size<br>      operator: In<br>      values: [micro, medium]<br>  providerRef:<br>    name: default<br>  ttlSecondsAfterEmpty: 30<br>---<br>apiVersion: karpenter.k8s.aws/v1alpha1<br>kind: AWSNodeTemplate<br>metadata:<br>  name: default<br>spec:<br>  subnetSelector:<br>    karpenter.sh/discovery: &quot;${CLUSTER_NAME}&quot;<br>  securityGroupSelector:<br>    karpenter.sh/discovery: &quot;${CLUSTER_NAME}&quot;<br>EOF</pre><p>After a few minutes, you will see that a new node is being provisioned. This is used by the coredns add-on.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get nodes -o wide<br>NAME                                                       STATUS   ROLES    AGE   VERSION               INTERNAL-IP     EXTERNAL-IP     OS-IMAGE         KERNEL-VERSION                  CONTAINER-RUNTIME<br>fargate-ip-10-x-x-131.ap-southeast-1.compute.internal      Ready    &lt;none&gt;   79m   v1.26.3-eks-f4dc2c0   10.x.x.131      &lt;none&gt;          Amazon Linux 2   5.10.179-168.710.amzn2.x86_64   containerd://1.6.6<br>fargate-ip-10-x-x-40.ap-southeast-1.compute.internal       Ready    &lt;none&gt;   79m   v1.26.3-eks-f4dc2c0   10.x.x.40       &lt;none&gt;          Amazon Linux 2   5.10.179-168.710.amzn2.x86_64   containerd://1.6.6<br>ip-10-x-x-189.ap-southeast-1.compute.internal              Ready    &lt;none&gt;   38m   v1.26.4-eks-0a21954   10.x.x.189      13.x.x.38       Amazon Linux 2   5.10.179-168.710.amzn2.x86_64   containerd://1.6.19</pre><h3>Test the autoscaling</h3><p>Let’s test the autoscaling by deploying an nginx deployment with two replicas.</p><pre>cat &lt;&lt;EOF | kubectl apply -f -<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: nginx<br>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: nginx<br>  template:<br>    metadata:<br>      labels:<br>        app: nginx<br>    spec:<br>      containers:<br>        - name: nginx<br>          image: nginx<br>EOF</pre><p>We can see that a new node has been provisioned and the pods started running in less than a minute.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get pods <br>NAME                     READY   STATUS    RESTARTS   AGE<br>nginx-748c667d99-2292z   1/1     Running   0          54s<br>nginx-748c667d99-594fl   1/1     Running   0          54s<br>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get nodes<br>NAME                                                       STATUS   ROLES    AGE    VERSION<br>fargate-ip-10-x-x-131.ap-southeast-1.compute.internal      Ready    &lt;none&gt;   118m   v1.26.3-eks-f4dc2c0<br>fargate-ip-10-x-x-40.ap-southeast-1.compute.internal       Ready    &lt;none&gt;   118m   v1.26.3-eks-f4dc2c0<br>ip-10-x-x-189.ap-southeast-1.compute.internal              Ready    &lt;none&gt;   77m    v1.26.4-eks-0a21954<br>ip-10-x-x-95.ap-southeast-1.compute.internal               Ready    &lt;none&gt;   53s    v1.26.4-eks-0a21954</pre><p>What happens if we scale up the replica by 5? Another new node is provisioned and all actions are completed within a minute.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl scale deployment nginx --replicas 5<br>deployment.apps/nginx scaled<br>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get pods <br>NAME                     READY   STATUS    RESTARTS   AGE<br>nginx-748c667d99-2292z   1/1     Running   0          3m49s<br>nginx-748c667d99-594fl   1/1     Running   0          3m49s<br>nginx-748c667d99-6kvll   1/1     Running   0          56s<br>nginx-748c667d99-77bq5   1/1     Running   0          55s<br>nginx-748c667d99-7g67b   1/1     Running   0          55s<br>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get nodes<br>NAME                                                       STATUS   ROLES    AGE     VERSION<br>fargate-ip-10-x-x-131.ap-southeast-1.compute.internal      Ready    &lt;none&gt;   121m    v1.26.3-eks-f4dc2c0<br>fargate-ip-10-x-x-40.ap-southeast-1.compute.internal       Ready    &lt;none&gt;   121m    v1.26.3-eks-f4dc2c0<br>ip-10-x-x-243.ap-southeast-1.compute.internal              Ready    &lt;none&gt;   55s     v1.26.4-eks-0a21954<br>ip-10-x-x-189.ap-southeast-1.compute.internal              Ready    &lt;none&gt;   80m     v1.26.4-eks-0a21954<br>ip-10-x-x-95.ap-southeast-1.compute.internal               Ready    &lt;none&gt;   3m49s   v1.26.4-eks-0a21954</pre><p>Finally, we will test the scaling down by deleting the nginx deployment.</p><pre>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl delete deployment nginx  <br>deployment.apps &quot;nginx&quot; deleted<br>kieranyio@Kierans-MacBook-Pro-2 ~ % kubectl get nodes<br>NAME                                                       STATUS   ROLES    AGE    VERSION<br>fargate-ip-10-x-x-131.ap-southeast-1.compute.internal      Ready    &lt;none&gt;   110m   v1.26.3-eks-f4dc2c0<br>fargate-ip-10-x-x-40.ap-southeast-1.compute.internal       Ready    &lt;none&gt;   110m   v1.26.3-eks-f4dc2c0<br>ip-10-x-x-189.ap-southeast-1.compute.internal              Ready    &lt;none&gt;   83m    v1.26.4-eks-0a21954</pre><p>All the nodes used by nginx deployment are terminated.</p><p>That’s it for <strong>Part 1</strong>. In the next part, we will explore some of the operational aspects of using Karpenter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fe3a5cd0281" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Capturing container packets from EKS worker nodes using tcpdump]]></title>
            <link>https://kieranyio.medium.com/capturing-container-packets-from-eks-worker-nodes-using-tcpdump-fce901dff36d?source=rss-81c27b903ea6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fce901dff36d</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[amazon-eks]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Kieran Yio]]></dc:creator>
            <pubDate>Sat, 13 May 2023 02:54:48 GMT</pubDate>
            <atom:updated>2025-12-07T06:36:03.290Z</atom:updated>
            <content:encoded><![CDATA[<p>There are times where you will need to troubleshoot a network issue and have to go into the packet detail level to analyse it. To capture the packets, you will usually run tcpdump either at the source or destination, or even both. However, this gets tricky if you are using containers to run your application or microservice, which are deployed to a Kubernetes cluster such as Amazon EKS (Elastic Kubernetes Service), and if the containers might not have tcpdump installed.</p><p>This blog post will show you how you can capture the container packets from the EKS worker nodes.</p><p>Here, we assume your worker nodes to have tcpdump installed. To verify, SSH into your worker node and run the tcpdump --version command.</p><pre>root@ip-10-x-x-93 ~]# tcpdump --version<br>tcpdump version 4.9.2<br>libpcap version 1.5.3<br>OpenSSL 1.0.2k-fips  26 Jan 2017</pre><h3>Identify the worker node of your pod</h3><p>The first step is to find out which worker node your pod is running on so that we will know where to run tcpdump later on. In the example below, I only have one worker node and the pod I’m interested in is nginx-deployment-7f99dd46c4-s9777.</p><pre>kieranyio@Kierans-MBP-2 ~ % kubectl get pods -o wide<br>NAME                                     READY   STATUS    RESTARTS   AGE     IP             NODE                                             NOMINATED NODE   READINESS GATES<br>nginx-deployment-7f99dd46c4-s9777        2/2     Running   0          3m45s   10.x.x.132   ip-10-x-x-93.ap-southeast-1.compute.internal   &lt;none&gt;           &lt;none&gt;<br>nginx-deployment-test-5dd7b48477-rlv77   1/1     Running   0          2m17s   10.x.x.31    ip-10-x-x-93.ap-southeast-1.compute.internal   &lt;none&gt;           &lt;none&gt;</pre><blockquote>Note: In Kubernetes, a pod is a group of one or more containers. You will need to know the name of the pod where your container is.</blockquote><h3>Identify the container name</h3><p>If you have multiple containers running in a pod, you will need to find the name of the container that you want to capture the packets from. You can do so by running the command kubectl describe pod <strong>&lt;pod name&gt;</strong> and viewing the C<em>ontainers</em> property. This also works for pods with a single container.</p><pre>kieranyio@Kierans-MBP-2 ~ % kubectl describe pod nginx-deployment-7f99dd46c4-s9777 <br>Name:         nginx-deployment-7f99dd46c4-s9777<br>Namespace:    default<br>Priority:     0<br>Node:         ip-10-x-x-93.ap-southeast-1.compute.internal/10.x.x.93<br>Start Time:   Wed, 10 May 2023 21:05:43 +0800<br>Labels:       app=nginx<br>              pod-template-hash=7f99dd46c4<br>Annotations:  &lt;none&gt;<br>Status:       Running<br>IP:           10.x.x.132<br>IPs:<br>  IP:           10.x.x.132<br>Controlled By:  ReplicaSet/nginx-deployment-7f99dd46c4<br>Containers:<br>  nginx:<br>    Container ID:   containerd://c3786d2d0a0a1f7fce9005e4006e4453466efa7aa0f116c7ead01ba47dc6a130<br>    Image:          nginx:1.14.2<br>    Image ID:       docker.io/library/nginx@sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d<br>    Port:           80/TCP<br>    Host Port:      0/TCP<br>    State:          Running<br>      Started:      Wed, 10 May 2023 21:05:44 +0800<br>    Ready:          True<br>    Restart Count:  0<br>    Environment:    &lt;none&gt;<br>    Mounts:<br>      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-jn7d5 (ro)<br>  busybox:<br>    Container ID:  containerd://43fc84423c1beff9b118498c7f302561999bdb4c22724bba81de877f601a74f2<br>    Image:         busybox<br>    Image ID:      docker.io/library/busybox@sha256:b5d6fe0712636ceb7430189de28819e195e8966372edfc2d9409d79402a0dc16<br>    Port:          &lt;none&gt;<br>    Host Port:     &lt;none&gt;<br>    Command:<br>      /bin/sh<br>      -c<br>      sleep 9999999<br>...</pre><h3>Identify the container network interface on the worker node</h3><p>Once we have the container name, we will get a shell to the container by running the command kubectl exec -i -t <strong>&lt;pod name&gt;</strong> -c <strong>&lt;container name&gt;</strong> -- /bin/bash. While inside the container, run the command cat /sys/class/net/eth0/iflink<strong> </strong>to retrieve the network interface index.</p><pre>kieranyio@Kierans-MBP-2 ~ % kubectl exec -i -t nginx-deployment-7f99dd46c4-s9777 -c nginx -- /bin/bash<br>root@nginx-deployment-7f99dd46c4-s9777:/# cat /sys/class/net/eth0/iflink<br>8<br>root@nginx-deployment-7f99dd46c4-s9777:/#</pre><p>With the network interface index, we can locate the network interface on the worker node by SSH-ing into it and running ip link | grep <strong>&lt;network interface index&gt;</strong>.</p><pre>[root@ip-10-x-x-93 ~]# ip link | grep 8<br>...<br>8: enid16b4c965eb@if3: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 9001 qdisc noqueue state UP mode DEFAULT group default<br>    link/ether ea:dc:dc:d8:xx:xx brd ff:ff:ff:ff:ff:ff link-netns cni-c0b05ee1-6ef2-68ea-d1c3-c2d1c5355612<br>...<br>[root@ip-10-x-x-93 ~]#</pre><h3>Capture packets from the network interface</h3><p>Now that we have all the necessary information, we can start running the command tcpdump -i <strong>&lt;network interface&gt;</strong> on the worker node to capture the packets. If you want to save it to a file, add the argument -w <strong>&lt;file name&gt;</strong>.pcap. To stop the run, press <em>Ctrl + c.</em></p><pre>[root@ip-10-x-x-93 ~]# tcpdump -i enid16b4c965eb -w network.pcap<br>tcpdump: listening on enid16b4c965eb, link-type EN10MB (Ethernet), capture size 262144 bytes<br>^C128 packets captured<br>128 packets received by filter<br>0 packets dropped by kernel<br>[root@ip-10-x-x-93 ~]# </pre><h3>Analyse and view packets on Wireshark</h3><p>There are multiple ways to extract the <em>pcap</em> file out of the worker node. One way is to upload it to an S3 bucket and download the file from console or via CLI. After extracting, you can use a Wireshark to view and analyse the packets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wjMq2N16Z1-6pwXlfMQCuw.png" /></figure><blockquote>Note: For demo purpose, our nginx is using HTTP protocol and that is why we are able to see the content in the packet. In normal circumstances, HTTPS is used and we won’t be able to view the content as it is encrypted.</blockquote><p>That’s it. You now know how to capture the container packets from EKS worker nodes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fce901dff36d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Moving EKS add-ons from self-managed to managed]]></title>
            <link>https://kieranyio.medium.com/moving-eks-add-ons-from-self-managed-to-managed-1a1ac1eb559e?source=rss-81c27b903ea6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a1ac1eb559e</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[amazon-eks]]></category>
            <dc:creator><![CDATA[Kieran Yio]]></dc:creator>
            <pubDate>Sun, 05 Mar 2023 10:30:52 GMT</pubDate>
            <atom:updated>2025-12-07T06:36:20.693Z</atom:updated>
            <content:encoded><![CDATA[<p>EKS add-ons are like plugins for your Kubernetes cluster. They provide operational capabilities support to Kubernetes applications. There are quite a number of add-ons provided by AWS and these can be either self-managed or managed. Examples of these are kube-proxy, coredns and vpc-cni.</p><blockquote><a href="https://docs.aws.amazon.com/eks/latest/userguide/eks-add-ons.html">https://docs.aws.amazon.com/eks/latest/userguide/eks-add-ons.html</a></blockquote><p>For self-managed add-ons, you will be handling their maintenance and upgrade. You will have to update the manifest and deploy it to your cluster, whereas for managed add-ons, you just need to specify the version that you need and AWS will handle the rest for you behind the scene.</p><p>If you are using managed add-ons and want to transit to self-managed, you can also easily do so by deleting the add-on with the Preserve on the cluster flag (or --preserve if you are using CLI). AWS will then stop managing the add-on and the add-on will be retained in your cluster. However, if you want to transit from self-managed to managed add-ons, you will probably wonder how to do it as there is no documentation on this (at the point of writing).</p><p>This blog post will show you examples of how it can be done easily.</p><h3>Example 1: kube-proxy</h3><p>By default, kube-proxy is already installed in your EKS cluster in the kube-system namespace. In our test cluster, we are using the v1.24.7-eksbuild.1 version and we do not have any managed add-ons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*qUG4WIPbV91uPnBFLISoNQ.png" /></figure><p>We can simply do the transition by adding the add-on to the cluster. Since this is the first time we are adding it, we <strong>MUST</strong> set the Conflict resolution method option to Overwrite. Otherwise, the transition will fail. Subsequently, for the upgrade, you can set to Preserve if you are using custom values. After awhile, you can see that the kube-proxy has been updated and the add-on is also being added to the cluster. Be sure to do some testings like scaling the nodes up and down, observing the behaviour and checking for any issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*CJVzQYzKayIuoA1VHsCKSQ.png" /></figure><h3>Example 2: aws-ebs-csi-driver</h3><p>In the above example, the self-managed add-on is created in the same namespace as the managed add-on. What if the self-managed add-on is created in a <strong>different</strong> namespace? Using aws-ebs-csi-driver add-on as an example, we will show you how to do it.</p><p>In the same test cluster, we have installed the add-on in the ebs-csi-driver namespace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*9J2LkAyA8J4X9Grh61_G1Q.png" /></figure><p>To transit it to a managed add-on, firstly we need to remove the existing one to avoid having two drivers running simultaneously, which may potentially cause conflicts when managing the EBS lifecycle. Then, add the add-on to the cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*0qAJ0jpQBJityx1fJuk_lQ.png" /></figure><p>It can take as fast as a minute to complete. After that, you can see the new aws-ebs-csi-driver resources and that the add-on has also been added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*R-rk7VegRq0JYYUuGz-tQA.png" /></figure><p>To ensure everything is working as expected, it is recommended to do some testings like creating and deleting a persistent volume claim (PVC) <strong>before</strong> and <strong>after</strong> the transition. You can follow the example provided by AWS below.</p><blockquote><a href="https://docs.aws.amazon.com/eks/latest/userguide/ebs-sample-app.html">https://docs.aws.amazon.com/eks/latest/userguide/ebs-sample-app.html</a></blockquote><h3>Common Questions</h3><ol><li><strong>How do I pass in my custom values to the managed add-ons? E.g. setting values for certain environment variables, replica count and resources (CPU and memory).<br></strong>You can make use of the <em>configuration values</em> option when adding the add-ons and must adhere to the JSON schema for that particular version as it will be validated.</li><li><strong>What should I do if the JSON schema does not support the property I need?<br></strong>Check if the higher version of the add-on supports the property that you need and upgrade to it. If it still does not support, you will have to patch the resources yourself either manually or via a deployment pipeline (recommended).</li><li><strong>When do I need to set the </strong><strong>--preserve flag for conflict resolution?<br></strong>This flag should be used when you are upgrading the add-on and want to preserve the patched (custom) values on your Kubernetes resources.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a1ac1eb559e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>