<?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 Raino Raphel on Medium]]></title>
        <description><![CDATA[Stories by Raino Raphel on Medium]]></description>
        <link>https://medium.com/@rainoraphel?source=rss-3c7629da0cee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fojXwH9HKFGSrqz_ADMgBg.jpeg</url>
            <title>Stories by Raino Raphel on Medium</title>
            <link>https://medium.com/@rainoraphel?source=rss-3c7629da0cee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 04:27:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rainoraphel/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[How to Deploy Wazuh on Amazon EC2 and Configure Wazuh Agents]]></title>
            <link>https://rainoraphel.medium.com/how-to-deploy-wazuh-on-amazon-ec2-and-configure-wazuh-agents-c1fd46fd4bde?source=rss-3c7629da0cee------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1fd46fd4bde</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[wazuh]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Raino Raphel]]></dc:creator>
            <pubDate>Thu, 29 Oct 2026 13:46:23 GMT</pubDate>
            <atom:updated>2026-10-29T13:46:23.823Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide demonstrates how to deploy Wazuh on Amazon EC2 instances and configure Wazuh agents on endpoint machines.</p><h4>What Is Wazuh?</h4><p>Wazuh is an open-source security platform (XDR and SIEM) that helps you monitor your systems, servers, and endpoints. It collects security-related data from your machines, detects suspicious activity, identifies vulnerabilities, and helps you respond to potential security threats.</p><p>It’s also important to have tools like Wazuh to monitor your servers and containers, keep them patched and up to date, and protect them from the latest security threats. Regular monitoring helps you spot suspicious activity early and act before it becomes a bigger problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8P9UL5xHHwTVh-2J7Jw58g.png" /><figcaption>Image taken from Wazuh docs</figcaption></figure><h4>Wazuh Components</h4><p>Wazuh consists of several components that work together to collect, analyse, and visualise security data.</p><ul><li><strong>Wazuh Agent</strong><br>The Wazuh Agent is installed on the systems you want to monitor. It collects security events, logs, vulnerability information, and other data, then sends it to the Wazuh Server.</li><li><strong>Wazuh Server</strong><br>The Wazuh Server receives and analyses data collected by the agents. It processes security events, detects potential threats, and generates alerts based on configured rules.</li><li><strong>Wazuh Indexer</strong><br>The Wazuh Indexer stores and organises the security data and alerts received from the Wazuh Server. It makes the data available for searching and analysis.</li><li><strong>Wazuh Dashboard</strong><br>The Wazuh Dashboard provides a web-based interface for viewing and analysing security data. You can use it to monitor alerts, investigate events, and manage your Wazuh environment.</li></ul><p>Let’s Get Started</p><h4>Prerequisites</h4><ul><li>AWS IAM access with EC2 privileges</li><li>AWS CLI</li></ul><h4>Step 1: Creating an EC2 Instance</h4><p><strong>1.1</strong> We will create an EC2 instance with the Ubuntu 24 AMI, and the instance type will be t3a.large(2vCPU &amp; 8GB memory).</p><ul><li>If you have more agents, refer to the <a href="https://documentation.wazuh.com/current/quickstart.html#hardware">Hardware Requirements</a>.</li></ul><p><strong>1.2</strong> Retrieve the Ubuntu AMI ID using the AWS CLI</p><pre># Change the AWS Profile <br><br>aws ssm get-parameters \<br>  --names /aws/service/canonical/ubuntu/server/24.04/stable/current/amd64/hvm/ebs-gp3/ami-id \<br>  --region ap-south-1 --query Parameters[*].Value  --profile &lt;aws_profile&gt;<br><br>[<br>    &quot;ami-006f82a1d5a27da54&quot;<br>]</pre><p><strong>1.3</strong> Now we need to generate the SSH key for accessing the server. For that, we will create an EC2 key pair</p><pre># EC2 key creation<br><br>aws ec2 create-key-pair \<br>  --key-name wazuh-key \<br>  --query &#39;KeyMaterial&#39; \<br>  --output text &gt; wazuh-key.pem<br><br># Set the file permissions to read-only<br><br>chmod 400 wazuh-key.pem<br><br>#verification<br>aws ec2 describe-key-pairs \<br>  --key-names wazuh-key</pre><p><strong>1.4</strong> Create a security group for the Wazuh server. Here, we need to provide the VPC, and in the next section, we will open the required ports</p><pre>#Create Security group<br><br>aws ec2 create-security-group \<br>  --group-name wazuh-sg \<br>  --description &quot;Wazuh Security Group&quot; \<br>  --vpc-id &lt;vpc-id&gt;</pre><p><strong>1.5</strong> Open the required ports</p><ul><li>Allow HTTPS dashboard access (TCP 443)</li></ul><pre>aws ec2 authorize-security-group-ingress \<br>  --group-id &lt;security-group-id&gt; \<br>  --protocol tcp \<br>  --port 443 \<br>  --cidr &lt;your-public-ip&gt; / &lt;0.0.0.0&gt; /32 \<br>  --region ap-south-1 \<br>  --profile &lt;aws_profile&gt;</pre><ul><li>Allow Wazuh agent communication (TCP 1514)</li></ul><pre>aws ec2 authorize-security-group-ingress \<br>  --group-id &lt;security-group-id&gt; \<br>  --protocol tcp \<br>  --port 1514 \<br>  --cidr &lt;agent-source-cidr&gt; \<br>  --region ap-south-1 \<br>  --profile &lt;aws_profile&gt;</pre><ul><li>Allow Wazuh agent enrollment (TCP 1515)</li></ul><pre>aws ec2 authorize-security-group-ingress \<br>  --group-id &lt;security-group-id&gt; \<br>  --protocol tcp \<br>  --port 1515 \<br>  --cidr &lt;agent-source-cidr&gt; \<br>  --region ap-south-1 \<br>  --profile &lt;aws_profile&gt;</pre><ul><li>Replace &lt;agent-source-cidr&gt; with the IP range of the machine or network where your agents run. If the agents have changing public IPs, consider a VPN or private network instead of opening these ports broadly.</li></ul><p><strong>1.6</strong> Based on the above details, we will create an EC2 instance</p><pre>#create EC2 instance<br><br>aws ec2 run-instances \<br>  --image-id ami-xxxxxxxxxxxxxxxxx \<br>  --instance-type t3a.large \<br>  --key-name my-keypair \<br>  --security-group-ids sg-xxxxxxxxxxxxxxxxx \<br>  --subnet-id &lt;Public subnet id&gt;\<br>  --block-device-mappings &#39;[{&quot;DeviceName&quot;:&quot;/dev/sda1&quot;,&quot;Ebs&quot;:{&quot;VolumeSize&quot;:30,&quot;VolumeType&quot;:&quot;gp3&quot;}}]&#39; \<br>  --tag-specifications &#39;ResourceType=instance,Tags=[{Key=Name,Value=Wazuh-Server}]&#39; \<br>  --region ap-south-1 --profile &lt;aws_profile&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ju9rVS06-bvb3Lkol1t7cA.png" /><figcaption>EC2 instance</figcaption></figure><h4>Step 2: Configuring the Wazuh Server</h4><p><strong>2.1</strong> Using the private key we created earlier, SSH into the server</p><pre>#SSH to server<br><br>ssh -i wazuh-key.pem username@&lt;ip&gt;<br><br>#Update the server<br><br>sudo apt-get update -y<br>sudo apt-get upgrade -y</pre><p><strong>2.2 </strong>The server is now ready. Let’s install the Wazuh server using the script provided in the Wazuh documentation</p><pre>#installe using curl<br><br>curl -sO https://packages.wazuh.com/4.14/wazuh-install.sh &amp;&amp; sudo bash ./wazuh-install.sh -a</pre><p><strong>2.3 </strong>Once the installation assistant completes the installation, the output shows the access credentials and a message that confirms that the installation was successful.</p><pre>INFO: --- Summary ---<br>INFO: You can access the web interface https://&lt;WAZUH_DASHBOARD_IP_ADDRESS&gt;<br>    User: admin<br>    Password: &lt;ADMIN_PASSWORD&gt;<br>INFO: Installation finished.<br><br><br>You have now installed and configured Wazuh.</pre><p><strong>2.4</strong> Access the Wazuh web interface with https://&lt;WAZUH_DASHBOARD_IP_ADDRESS&gt; and your credentials:</p><ul><li>Username: admin</li><li>Password: &lt;ADMIN_PASSWORD&gt;</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DBp8Wg5CTRJvGX7Isxycww.png" /><figcaption>Wazuh Dashboard</figcaption></figure><h4>Step 3: Configuring the Wazuh Agent</h4><p><strong>3.1</strong> You can deploy a new agent by following the instructions in the Wazuh dashboard. Go to <strong>Agents management</strong> &gt; <strong>Summary</strong>, and click on <strong>Deploy new agent</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bwd-hSmIGVRlR1T9l6t9iQ.png" /></figure><p><strong>3.2</strong> Select the Linux Operating System. Under the <strong>Deploy new agent</strong> section in the Wazuh dashboard, select <strong>Linux</strong> as the target operating system.</p><p>Choose the appropriate package format and architecture based on your Linux distribution:</p><ul><li><strong>RPM amd64:</strong> For compatible 64-bit RPM-based distributions.</li><li><strong>RPM aarch64:</strong> For compatible ARM 64-bit RPM-based distributions.</li><li><strong>DEB amd64:</strong> For compatible 64-bit Debian-based distributions.</li><li><strong>DEB aarch64:</strong> For compatible ARM 64-bit Debian-based distributions.</li></ul><p>For example, select <strong>DEB amd64</strong> if you are using a compatible 64-bit Debian or Ubuntu system.</p><p><strong>3.3</strong> Configure the Wazuh Server Address. In the <strong>Server address</strong> field, enter the IP address or fully qualified domain name (FQDN) of your Wazuh server.</p><p>For example:</p><pre>10.0.0.198</pre><p>Replace this example with the actual IP address of your Wazuh server. The agent uses this address to communicate with the server.</p><p><strong>3.4</strong> Configure Optional Agent Settings. You can customise the agent name and assign it to an existing group.</p><ul><li><strong>Agent name:</strong> Enter a unique name to identify the Linux endpoint. If no name is specified, the hostname is used by default.</li><li><strong>Agent group:</strong> Select an existing group, such asdefault, to organise the agent and apply the appropriate group configuration.</li></ul><p>Choose the agent name carefully because it cannot be changed once the agent has been enrolled.</p><p><strong>3.5</strong> Install the Wazuh Agent on Linux. After selecting the package and configuring the server address, the Wazuh dashboard generates the installation commands for your selected Linux distribution.</p><ul><li>Open a terminal on the Linux endpoint and execute the commands displayed in the dashboard. These commands download and install the Wazuh agent and configure it to communicate with your Wazuh server.</li><li>For a Debian or Ubuntu system, the installation process typically involves downloading the DEB package, installing it, and configuring the manager address, agent name, and group.</li><li>Make sure to replace example values with the settings appropriate for your environment and execute installation commands with the required administrative privileges.</li></ul><p><strong>3.6</strong> Enable and Start the Wazuh Agent Service. After installing and configuring the agent, enable and start its service using the following commands:</p><pre>sudo systemctl daemon-reload<br>sudo systemctl enable wazuh-agent<br>sudo systemctl start wazuh-agent</pre><ul><li>These commands reload the systemd service configuration, enable the Wazuh agent to start automatically at boot, and start the service immediately.</li></ul><p><strong>3.7</strong> Verify the Agent Status. To check whether the Wazuh agent service is running, execute:</p><pre>sudo systemctl status wazuh-agent</pre><ul><li>Confirm that the service is active and running.</li><li>Next, return to the Wazuh dashboard and navigate to <strong>Agents management</strong>&gt; <strong>Summary</strong>. Locate the newly registered Linux agent and verify that its status is <strong>Active</strong>.</li><li>If the agent is not active, check the server address, network connectivity, firewall configuration, and agent logs to identify the issue.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mytn0i0PMHAKjY7drIUwGg.png" /><figcaption>Wazuh Dashboard</figcaption></figure><h3>Conclusion</h3><p>In this guide, we deployed Wazuh on an Amazon EC2 instance and configured a Linux endpoint to communicate with the Wazuh server.</p><p>We covered EC2 instance creation, security group configuration, Wazuh installation, agent enrollment, and service verification.</p><p>With the agent connected, Wazuh can collect security-related data from the endpoint and make it available for monitoring and analysis through the dashboard.</p><p>This setup provides a starting point for exploring security monitoring, vulnerability detection, log analysis, and threat detection in your AWS environment.</p><p>If you are new to Wazuh, the next step is to explore the dashboard, review generated alerts, and learn how to configure monitoring for your own infrastructure.</p><p>For more details, refer to the <a href="https://documentation.wazuh.com/current/index.html">official Wazuh documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1fd46fd4bde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Serverless REST API using AWS Lambda & API Gateway]]></title>
            <link>https://rainoraphel.medium.com/building-a-serverless-rest-api-using-aws-lambda-api-gateway-fc2ba67ee66c?source=rss-3c7629da0cee------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc2ba67ee66c</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-api-gateway]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Raino Raphel]]></dc:creator>
            <pubDate>Mon, 05 Jan 2026 18:29:31 GMT</pubDate>
            <atom:updated>2026-01-05T18:29:31.597Z</atom:updated>
            <content:encoded><![CDATA[<p>Serverless architecture helps teams build scalable APIs without managing servers. In this blog, we’ll build a simple REST API using AWS Lambda and Amazon API Gateway, and understand how requests flow from the client to the backend.</p><h3>AWS Lambda</h3><p>AWS Lambda is a serverless compute service that allows you to run code without provisioning or managing servers. You focus only on writing your application logic, while AWS handles scaling, availability, and infrastructure behind the scenes. Lambda runs your code only when it is triggered and scales automatically based on incoming traffic, which makes it a cost-effective option for APIs, automation tasks, and event-driven workloads.</p><p><strong>Why Lambda?</strong></p><ul><li>No server management</li><li>Automatic scaling</li><li>Pay only for execution time</li><li>Event-driven by design</li><li>Well-suited for APIs and microservices</li></ul><h3>Amazon API Gateway</h3><p>Amazon API Gateway is a fully managed service for creating and managing APIs. It acts as the front door for your application by receiving HTTP requests from clients and routing them to backend services such as AWS Lambda. In addition to routing, API Gateway takes care of authentication, throttling, monitoring, and versioning, making it easier to expose secure and scalable APIs with minimal operational effort.</p><p><strong>Why API Gateway?</strong></p><ul><li>Central entry point for APIs</li><li>Native integration with Lambda</li><li>Built-in security and throttling</li><li>Supports REST, HTTP, and WebSocket APIs</li><li>Simplifies API lifecycle management</li></ul><h3>Architecture Overview</h3><p>Before diving into the implementation, let’s look at the high-level architecture of the serverless API we are going to build.</p><p>The API consists of a client sending an HTTP request to Amazon API Gateway, which acts as the entry point. API Gateway then invokes an AWS Lambda function, where the business logic is executed. Once the Lambda function completes its execution, the response is sent back through API Gateway to the client.</p><p>This architecture is fully serverless, meaning there are no servers to provision, manage, or scale manually. AWS handles scalability, availability, and fault tolerance by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*usXxalphBGvvK6bFoMMxTw.png" /><figcaption>Lambda &amp; Api Gateway Architecture</figcaption></figure><h3>Defining the API</h3><p>Before implementing the serverless setup, let’s define the API we are going to build. Keeping the API small and focused helps in understanding how API Gateway and Lambda work together.</p><p>For this example, we will create a simple HTTP endpoint:</p><pre>GET /hello</pre><p><strong>Expected response:</strong></p><pre>{<br>  &quot;message&quot;: &quot;Hello from AWS Lambda!&quot;<br>}</pre><p>This endpoint will be exposed using Amazon API Gateway and backed by a single AWS Lambda function that returns a static response.</p><h3>Creating the Lambda Function</h3><p>Now that the API is defined, let’s create the AWS Lambda function that will handle the request. This Lambda function contains the backend logic and returns a response to API Gateway.</p><p>For simplicity, we’ll use <strong>AWS Lambda</strong> with a Python runtime and return a static message.</p><p><strong>Steps:</strong></p><ol><li>Open <strong>AWS Lambda</strong> in the AWS Console</li><li>Click the <strong>Create function</strong></li><li>Choose <strong>Author from scratch</strong></li><li>Set:</li></ol><ul><li><strong>Function name:</strong> hello-api</li><li><strong>Runtime:</strong> Python 3.10</li><li><strong>Execution role:</strong> Create a new role with basic permissions</li></ul><p>Once the function is created, add the following code to the handler and deploy it.</p><pre>def lambda_handler(event, context):<br>    return {<br>        &quot;statusCode&quot;: 200,<br>        &quot;body&quot;: &quot;Hello from AWS Lambda!&quot;<br>    }</pre><p>In production, we usually create Lambda functions using IaC (Terraform or CDK), but for simplicity, this example uses the AWS Console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vP7VqMfvVCq5YGkfegMUyg.png" /><figcaption>AWS Lambda Creation</figcaption></figure><h3>Creating the API Gateway</h3><p>Now that the Lambda function is ready, the next step is to expose it using <strong>Amazon API Gateway</strong>. API Gateway will act as the entry point for incoming HTTP requests and forward them to the Lambda function.</p><p>For this example, we’ll use an <strong>HTTP API</strong>, as it is simpler and more cost-effective than a REST API for basic use cases.</p><ol><li>Open <strong>API Gateway</strong> in the AWS Console</li><li>Click <strong>Create API</strong></li><li>Choose <strong>HTTP API</strong></li><li>Select <strong>Add integration</strong> → <strong>Lambda</strong></li><li>Choose the previously created Lambda function</li><li>Add a route:</li></ol><pre>GET /hello</pre><p>Deploy the API</p><p>Once deployed, API Gateway provides a public endpoint URL, which is available in the stages section under deploy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8SPNygxOvSGceZ2qYUhRpA.png" /><figcaption>AWS API Gateway</figcaption></figure><h3>Testing the API</h3><p>Now that the API Gateway is connected to the Lambda function, let’s verify that everything works as expected by sending a request to the endpoint.</p><p>Once the API is deployed, <strong>Amazon API Gateway</strong> provides a public invoke URL. Any request sent to this URL will trigger the <strong>AWS Lambda</strong> function.</p><h3>Test using curl</h3><pre>curl https://&lt;api-id&gt;.execute-api.&lt;region&gt;.amazonaws.com/hello</pre><h3>Expected response</h3><pre>{<br>  &quot;message&quot;: &quot;Hello from AWS Lambda!&quot;<br>}</pre><p>If you receive this response, it confirms that:</p><ul><li>API Gateway is routing the request correctly</li><li>Lambda is executing successfully</li><li>The response is returned to the client</li></ul><h3>Test using a browser</h3><p>You can also paste the API endpoint directly into a browser. Since this is a simple GET request, the response should be displayed immediately.</p><h3>Security &amp; Best Practices</h3><p>Even though this is a simple example, it’s important to follow basic security and operational best practices when using <strong>AWS Lambda</strong> with <strong>Amazon API Gateway</strong>. These practices help keep your API secure, reliable, and production-ready.</p><h3>1. Use Least-Privilege IAM Roles</h3><ul><li>Assign the Lambda execution role only the permissions it actually needs</li><li>Avoid using overly permissive policies like AdministratorAccess</li><li>Grant the API Gateway permission to invoke only the required Lambda function</li></ul><h3>2. Enable Logging and Monitoring</h3><ul><li>Enable <strong>CloudWatch Logs</strong> for Lambda to track executions and errors</li><li>Monitor API Gateway metrics such as request count, latency, and error rates</li><li>Logs are essential for debugging and incident analysis</li></ul><h3>3. Protect the API</h3><ul><li>Enable throttling to prevent abuse</li><li>Add authentication (JWT, IAM, or Cognito) for protected endpoints</li><li>Avoid exposing sensitive APIs publicly unless required</li></ul><h3>4. Handle Errors Properly</h3><ul><li>Return meaningful HTTP status codes</li><li>Avoid exposing internal error details to clients</li><li>Log detailed errors only in CloudWatch</li></ul><h3>5. Optimise for Performance</h3><ul><li>Keep Lambda functions lightweight to reduce cold start time</li><li>Avoid unnecessary dependencies</li><li>Set appropriate memory and timeout values</li></ul><h3>Cost Considerations</h3><p>One of the biggest advantages of using <strong>AWS Lambda</strong> with <strong>Amazon API Gateway</strong> is the pay-per-use pricing model. You only pay when your API is actually used.</p><h3>AWS Lambda Costs</h3><ul><li>Charged based on the number of invocations</li><li>Execution time is billed in milliseconds</li><li>No cost when the function is idle</li></ul><p>This makes Lambda highly cost-effective for low to medium-traffic workloads.</p><h3>API Gateway Costs</h3><ul><li>Charged per API request</li><li>HTTP APIs are cheaper than REST APIs</li><li>No minimum or fixed monthly cost</li></ul><h3>Why this matters</h3><p>For simple APIs, internal tools, or startup workloads, this architecture can significantly reduce costs compared to running always-on servers.</p><p>However, for <strong>very high traffic or long-running workloads</strong>, costs can grow, and services like ECS or EKS may become more economical.</p><h3>Final Thoughts</h3><p>Using <strong>AWS Lambda</strong> with <strong>Amazon API Gateway</strong> is one of the simplest ways to build scalable and cost-effective REST APIs on AWS. This serverless approach removes the need to manage infrastructure while still providing built-in scalability, high availability, and security.</p><p>This pattern works especially well for lightweight APIs, backend services for web or mobile applications, webhooks, and internal tools. While it may not be suitable for long-running or highly performance-sensitive workloads, it is an excellent starting point for most modern API use cases.</p><p>If you are getting started with serverless or looking to reduce operational overhead, Lambda and API Gateway provide a strong, production-ready foundation.</p><p>This example intentionally keeps things simple, but the same architecture can be extended with authentication, logging, monitoring, and infrastructure as code for real-world production use.</p><h3>Reference</h3><ul><li><a href="https://docs.aws.amazon.com/lambda/">AWS Lambda</a></li><li><a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html">AWS API Gateway</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc2ba67ee66c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Traefik and cert-manager on EKS: Simplifying Kubernetes Ingress]]></title>
            <link>https://aws.plainenglish.io/traefik-and-cert-manager-on-eks-simplifying-kubernetes-ingress-1a74f37018b6?source=rss-3c7629da0cee------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a74f37018b6</guid>
            <category><![CDATA[cert-manager]]></category>
            <category><![CDATA[aws-eks]]></category>
            <category><![CDATA[traefik]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Raino Raphel]]></dc:creator>
            <pubDate>Tue, 02 Sep 2025 00:50:41 GMT</pubDate>
            <atom:updated>2025-09-02T00:50:41.988Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide demonstrates how to deploy Traefik as an Ingress Controller on a preconfigured Amazon EKS cluster and configure Ingress routes for routing external traffic.</p><h4>What is Traefik</h4><p>Traefik is a modern reverse proxy and load balancer designed for both cloud-native and bare-metal environments<strong>.</strong> It’s commonly used as an Ingress controller in Kubernetes, where it helps route external traffic to the right services within a cluster. Overall, it’s a simple yet powerful tool that makes traffic management easy in dynamic, containerised setups.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cv3pTba_HSS-fflv.png" /><figcaption>Image taken from Traefik docs</figcaption></figure><h4>Traefik Features</h4><p>Traefik’s core concepts provide a clear understanding of how incoming requests are handled and routed to your services.</p><ul><li><strong>EntryPoints </strong>are the way traffic first enters Traefik. They define which ports Traefik should listen on, such as port 80 for HTTP or 443 for HTTPS, and whether it should handle TCP or UDP connections.</li><li><strong>Routers </strong>determine where each incoming request should be directed. They match requests based on factors such as the URL or hostname and then direct them to the appropriate service. Before doing that, they can also apply middleware, such as adding headers or checking authentication, to modify or handle the request as it progresses.</li><li><strong>Services </strong>instruct Traefik on where to direct the request. They define the actual backend (such as a pod or container) that will handle the request once it’s been routed.</li><li><strong>Providers</strong> are infrastructure components, whether orchestrators, container engines, cloud providers, or key-value stores. The idea is that Traefik queries the provider APIs to retrieve relevant routing information, and when Traefik detects a change, it dynamically updates the routes accordingly.</li></ul><p>Let’s Deploy…</p><h4>Prerequisites</h4><ul><li>AWS IAM access with admin privileges</li><li>AWS EKS cluster (1.31). If not created, you can refer to my previous story on <a href="https://medium.com/aws-in-plain-english/how-to-create-an-eks-cluster-using-eksctl-1a905b704d3f">EKS Cluster Creation</a>.</li><li>AWS CLI</li><li>Helm</li><li>kubectl</li></ul><h4>Step 1: Traefik Deployment</h4><p>1.1 Before getting into Helm deployment, the Traefik CRD needs to be installed. Traefik CRDs allow you to manage routing, TLS, middlewares, and other Traefik-specific configurations using native Kubernetes-style YAML resources. They extend Kubernetes’ functionality beyond standard Ingress objects</p><pre>#Apply the Traefik CRD&#39;S<br>kubectl apply -n traefik -k https://github.com/traefik/traefik-helm-chart/traefik-crds<br><br>#The CRD will be installed based on the kustomization.yaml in the GitHub Folder<br><br>#Output<br><br>customresourcedefinition.apiextensions.k8s.io/accesscontrolpolicies.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/aiservices.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/apiauths.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/apibundles.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/apicatalogitems.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/apiplans.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/apiportalauths.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/apiportals.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/apiratelimits.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/apis.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/apiversions.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/gatewayclasses.gateway.networking.k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/gateways.gateway.networking.k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/grpcroutes.gateway.networking.k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/httproutes.gateway.networking.k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/ingressroutes.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/ingressroutetcps.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/ingressrouteudps.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/managedapplications.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/managedsubscriptions.hub.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/middlewares.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/middlewaretcps.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/referencegrants.gateway.networking.k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/serverstransports.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/serverstransporttcps.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/tlsoptions.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/tlsstores.traefik.io created<br>customresourcedefinition.apiextensions.k8s.io/traefikservices.traefik.io created</pre><p>1.2 Helm is used for the Traefik deployment. First, we will add the Traefik Helm repo</p><pre>#Add traefik repo<br>helm repo add traefik https://traefik.github.io/charts<br><br>&quot;traefik&quot; has been added to your repositories<br><br>#Repo Update<br>helm repo update<br><br>Hang tight while we grab the latest from your chart repositories...<br>...Successfully got an update from the &quot;traefik&quot; chart repository<br>...Successfully got an update from the &quot;eks&quot; chart repository<br>Update Complete. ⎈Happy Helming!⎈</pre><p>1.3 Export the Helm traefik values to a value file for further customisation and apply the file during Helm deployment</p><pre>#Show Helm values<br>helm show values traefik/traefik<br><br>#Export the Helm values to values file<br>helm show values traefik/traefik &gt; values.yml</pre><p>1.4 The Traefik works in both Layer 7 (HTTP/HTTPS) &amp; Layer 4 (TCP/UDP), so to provision an NLB, some service annotations need to be provided in the values.yml</p><pre>#Add this under the service: annotaions: block<br>service:<br><br>  annotations:<br>       service.beta.kubernetes.io/aws-load-balancer-type: &quot;nlb&quot;</pre><p>1.5 Helm Apply</p><pre>#Create Traefik namespace<br>kubectl create ns traefik<br><br>#Helm Apply<br>#Namespace can also be provided in the values file<br>helm install traefik traefik/traefik -f values.yml --namespace traefik<br><br>traefik with docker.io/traefik:v3.5.0 has been deployed successfully on traefik namespace !<br><br>#Check pods are running<br>kubectl get pods -n traefik<br><br>NAME                       READY   STATUS    RESTARTS   AGE<br>traefik-84fd8d7898-wfrcw   1/1     Running   0          13s<br><br>#Loadbalancer status<br><br>kubectl get svc -n traefik<br><br>NAME      TYPE           CLUSTER-IP       EXTERNAL-IP                                                                     PORT(S)                      AGE<br>traefik   LoadBalancer   172.20.205.234   ae12511b039dd40729451709f6a7b46c-f1ac98144669d8e5.elb.us-east-1.amazonaws.com   80:32672/TCP,443:30295/TCP   84s</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*LojzqK757677KmXKixyY8Q.png" /><figcaption>Screenshot captured from AWS</figcaption></figure><p>We have successfully deployed traefik. Now let’s move on to the configuration part.</p><h4>Step 2: Traefik Configuration</h4><p>2.1 Traefik has a built-in Dashboard endpoint. We will be exposing the endpoint with Basic authentication.</p><ul><li>It’s always recommended to provide authentication for the dashboard, as it contains all Traefik data related to Middleware, Routers, Services, etc.</li><li>In Traefik, the web , websecure Ports are used for handling HTTP and HTTPS traffic. The web port typically listens on port 80 for plain HTTP requests, while the websecure port listens on port 443 for secure HTTPS traffic. You can configure routing rules separately for each port, and Traefik can also handle automatic HTTP-to-HTTPS redirection if needed.</li></ul><p>2.2 Apply the code below to expose the Dashboard</p><pre>#This block creates the secret for the Dashboard, For Basic Auth Setup<br>---<br>apiVersion: v1<br>kind: Secret<br>metadata:<br>  name: basic-auth<br>  namespace: traefik<br>type: kubernetes.io/basic-auth<br>stringData:<br>  username: test<br>  password: password<br>#This block creates the Traefik Middleware to enable the basic auth<br>---<br>apiVersion: traefik.io/v1alpha1<br>kind: Middleware<br>metadata:<br>  name: basic-auth<br>  namespace: traefik<br>spec:<br>  basicAuth:<br>    secret: basic-auth<br>#This block creates the ingressroute using the traefik cutom CRD, Note that this is path based routing<br>---<br>apiVersion: traefik.io/v1alpha1<br>kind: IngressRoute<br>metadata:<br>  name: traefik-dashboard<br>  namespace: traefik<br>spec:<br>  entryPoints:<br>    - web<br>  routes:<br>  - match: PathPrefix(`/dashboard`) || PathPrefix(`/api`)<br>    kind: Rule<br>    services:<br>    - name: api@internal<br>      kind: TraefikService<br>    middlewares:<br>      - name: basic-auth </pre><pre>#Apply the above code<br>kubectl apply -f dashboard-ingress.yml<br><br>secret/basic-auth created<br>middleware.traefik.io/basic-auth created<br>ingressroute.traefik.io/traefik-dashboard created<br><br>kubectl get ingressroute -n traefik<br><br>NAME                AGE<br>traefik-dashboard   108s</pre><p>2.3 Verify if the dashboard is accessible using the Loadbalancer DNS endpoint</p><ul><li>Hmm, Traefik dashboard returned 404, after the basic auth</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tiulb5qnP7cvtvKX8xBPgA.png" /><figcaption>Screenshot for Traefik Dashboard 404 error</figcaption></figure><ul><li>From the <a href="https://github.com/traefik/traefik-helm-chart/issues/85#issuecomment-589436204">GitHub Thread</a>, there is a slash / after the dashboard path, and the Dashboard loaded successfully</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YQMieXyEN1cwJx5C2Tsoug.png" /><figcaption>Traefik Dashboard</figcaption></figure><h4>Step 3: Application deployment &amp; Routing</h4><p>3.1 For the Demo, A sample HTTP echo image will be deployed and routed via traefik</p><ul><li>Deploy the sample application</li></ul><pre>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: http-echo<br>  namespace: traefik<br>  labels:<br>    app: http-echo<br>spec:<br>  replicas: 3<br>  selector:<br>    matchLabels:<br>      app: http-echo<br>  template:<br>    metadata:<br>      labels:<br>        app: http-echo<br>    spec:<br>      containers:<br>      - name: http-echo<br>        image: hashicorp/http-echo:0.2.3<br>        args:<br>          - &quot;-text=Hello from http-echo on EKS!&quot;<br>        ports:<br>        - containerPort: 5678<br>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: http-echo<br>  namespace: traefik<br>spec:<br>  selector:<br>    app: http-echo<br>  ports:<br>  - port: 80<br>    targetPort: 5678<br>    protocol: TCP</pre><pre>#Check if http-echo pods are running fine<br><br>kubectl get pods -n traefik<br><br>NAME                         READY   STATUS    RESTARTS   AGE<br>http-echo-75b8dddf58-k9hbn   1/1     Running   0          8m48s<br>http-echo-75b8dddf58-kfq67   1/1     Running   0          5s<br>http-echo-75b8dddf58-xrn8h   1/1     Running   0          5s<br>traefik-7ddf7488c8-tz8ml     1/1     Running   0          15d</pre><p>3.2 Create an ingress rule for the http-echo deployment.</p><ul><li>Here, we have added host-based routing, and the load balancer&#39;s DNS name is added as a CNAME record at the domain level.</li></ul><pre>---<br>apiVersion: traefik.io/v1alpha1<br>kind: IngressRoute<br>metadata:<br>  name: echo-ingress<br>  namespace: traefik<br>spec:<br>  entryPoints:<br>    - web<br>  routes:<br>  - match: Host(`domain.example.com`)<br>    kind: Rule<br>    services:<br>    - name: http-echo<br>      port: 80<br>      kind: Service</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*Iy0mfYREpSiuRrSwNDf0gg.png" /><figcaption>Http Ingressroute</figcaption></figure><ul><li>We successfully routed the subdomain to http-echo pods using the Traefik ingress CRD.</li><li>This is currently exposed via the traefik web port, which is HTTP. In the next step, we will enable SSL using the traefik websecure port.</li></ul><h4>Step 4: Enable SSL using Cert Manager (Let’s Encrypt)</h4><p>4.1 Initialise SSL in traefik</p><ul><li>Cert-Manager is a Kubernetes add-on that automates the management and renewal of TLS/SSL certificates. It integrates with certificate authorities like Let’s Encrypt, making it easier to secure applications running inside your cluster without manual certificate handling.</li><li>The cert manager will be installed using the Helm chart</li></ul><pre>#Helm Add Repo<br>helm repo add jetstack https://charts.jetstack.io --force-update<br><br>&quot;jetstack&quot; has been added to your repositories<br><br>#Helm install<br>helm install \<br>  cert-manager jetstack/cert-manager \<br>  --namespace cert-manager \<br>  --create-namespace \<br>  --version v1.18.2 \<br>  --set crds.enabled=true<br><br>#Verify the pods are running<br><br>kubectl get pods -n cert-manager<br>NAME                                       READY   STATUS    RESTARTS   AGE<br>cert-manager-5969544f77-5ghdt              1/1     Running   0          3m9s<br>cert-manager-cainjector-65967ff5cc-ctn7r   1/1     Running   0          3m9s<br>cert-manager-webhook-7c665868cb-lwdpp      1/1     Running   0          3m9s</pre><ul><li>To create a certificate, we need to configureIssuers or ClusterIssuers</li><li>Issuers, and ClusterIssuersKubernetes resources that represent certificate authorities (CAs) that can generate signed certificates by honouring certificate signing requests. The<strong> </strong>issuer works only within a single namespace. ClusterIssue<strong>r</strong> works across the whole cluster.</li><li>Here, I will be creating an issuer in the traefik namespace</li></ul><pre>apiVersion: cert-manager.io/v1<br>kind: Issuer<br>metadata:<br>  name: acme<br>  namespace: traefik<br>spec:<br>  acme:<br>    # Staging endpoint : https://acme-staging-v02.api.letsencrypt.org/directory<br>    # Production server is on https://acme-v02.api.letsencrypt.org/directory<br>    # Use Production, For Demo purpose use staging endpoint<br>    server: https://acme-v02.api.letsencrypt.org/directory<br>    privateKeySecretRef:<br>      name: acme<br>    solvers:<br>      - http01:<br>          ingress:<br>            ingressClassName: traefik</pre><pre>#Apply Issuer<br><br>kubectl apply -f issuer.yml<br><br>issuer.cert-manager.io/acme created</pre><ul><li>A Certificate in cert-manager is a Kubernetes resource that requests and stores an SSL/TLS certificate for your domain. You define the domain names you want (like example.com), and cert-manager talks to the Issuer/ClusterIssuer to fetch a valid certificate and save it as a Kubernetes Secret.</li></ul><pre>apiVersion: cert-manager.io/v1<br>kind: Certificate<br>metadata:<br>  name: http-echo<br>  namespace: traefik<br>spec:<br>  secretName: tls-http-echo       # &lt;===  Name of secret where the generated certificate will be stored.<br>  dnsNames:<br>    - &quot;domain.example.com&quot;<br>  issuerRef:<br>    name: acme<br>    kind: Issuer</pre><pre>#Apply Cert<br><br>kubectl apply -f cert.yml<br><br>certificate.cert-manager.io/http-echo created<br><br>#Check the status<br><br>kubectl get certificate -n traefik<br><br>NAME        READY   SECRET          AGE<br>http-echo   False   tls-http-echo   20s<br><br>kubectl get certificate -n traefik<br><br>NAME        READY   SECRET          AGE<br>http-echo   True    tls-http-echo   46s<br><br>#Status changed to true and secret is created<br><br>kubectl describe certificate/http-echo -n traefik<br><br>Events:<br>  Type    Reason     Age   From                                       Message<br>  ----    ------     ----  ----                                       -------<br>  Normal  Issuing    40s   cert-manager-certificates-trigger          Issuing certificate as Secret does not exist<br>  Normal  Generated  39s   cert-manager-certificates-key-manager      Stored new private key in temporary Secret resource &quot;http-echo-rvffl&quot;<br>  Normal  Requested  39s   cert-manager-certificates-request-manager  Created new CertificateRequest resource &quot;http-echo-1&quot;<br>  Normal  Issuing    8s    cert-manager-certificates-issuing          The certificate has been successfully issued<br><br>#check secret status<br>kubectl get secret -n traefik<br><br>NAME                            TYPE                       DATA   AGE<br>tls-http-echo                   kubernetes.io/tls          2      33s</pre><ul><li>We have already created an ingress route (HTTP) via the traefik web entrypoint. Now, to implement, we will be creating another ingress route with the entrypoint as websecure</li><li>Also, the TLS secret will be attached to this ingress route</li></ul><pre>---<br>apiVersion: traefik.io/v1alpha1<br>kind: IngressRoute<br>metadata:<br>  name: echo-ingress-https<br>  namespace: traefik<br>spec:<br>  entryPoints:<br>    - websecure<br>  routes:<br>  - match: Host(`domain.example.com`)<br>    kind: Rule<br>    services:<br>    - name: http-echo<br>      port: 80<br>      kind: Service<br>  tls:<br>    secretName: tls-http-echo  #The secret which was created for TLS</pre><pre>#Apply HTTPS ingressroutes<br><br>kubectl apply -f http-echo-https.yml<br><br>ingressroute.traefik.io/echo-ingress-https created</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*YtjlLAJIWzwXn3wtLOEFtw.png" /><figcaption>HTTPS Ingressroute</figcaption></figure><ul><li>We have successfully configured the HTTPS ingress route. You can also set up the traefik middleware to enable redirection from HTTP to HTTPS</li></ul><h4>Conclusion</h4><ul><li>By deploying <strong>Traefik</strong> on Amazon EKS and integrating it with <strong>cert-manager</strong> and <strong>Let’s Encrypt</strong>, you can seamlessly manage ingress traffic with built-in HTTPS support. This setup not only simplifies routing and TLS certificate automation but also provides flexibility, scalability, and security for your Kubernetes workloads.</li><li>With Traefik handling traffic at the edge, cert-manager taking care of certificates, and EKS providing a managed Kubernetes backbone, you get a production-ready ingress solution that requires minimal manual intervention.</li></ul><h4>Reference</h4><ul><li><a href="https://doc.traefik.io/traefik/getting-started/kubernetes/">Traefik Getting Started</a></li><li><a href="https://cert-manager.io/docs/installation/helm/#installing-from-the-legacy-helm-repository">Cert-Manager Deployment</a></li></ul><h3>A message from our Founder</h3><p><strong>Hey, </strong><a href="https://linkedin.com/in/sunilsandhu"><strong>Sunil</strong></a><strong> here.</strong> I wanted to take a moment to thank you for reading until the end and for being a part of this community.</p><p>Did you know that our team run these publications as a volunteer effort to over 3.5m monthly readers? <strong>We don’t receive any funding, we do this to support the community. ❤️</strong></p><p>If you want to show some love, please take a moment to <strong>follow me on </strong><a href="https://linkedin.com/in/sunilsandhu"><strong>LinkedIn</strong></a><strong>, </strong><a href="https://tiktok.com/@messyfounder"><strong>TikTok</strong></a>, <a href="https://instagram.com/sunilsandhu"><strong>Instagram</strong></a>. You can also subscribe to our <a href="https://newsletter.plainenglish.io/"><strong>weekly newsletter</strong></a>.</p><p>And before you go, don’t forget to <strong>clap</strong> and <strong>follow</strong> the writer️!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a74f37018b6" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/traefik-and-cert-manager-on-eks-simplifying-kubernetes-ingress-1a74f37018b6">Traefik and cert-manager on EKS: Simplifying Kubernetes Ingress</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy an Application in the ECS cluster]]></title>
            <link>https://aws.plainenglish.io/deploy-an-application-in-the-ecs-cluster-3d97e7d07892?source=rss-3c7629da0cee------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d97e7d07892</guid>
            <category><![CDATA[elastic-container-service]]></category>
            <category><![CDATA[fargate]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[Raino Raphel]]></dc:creator>
            <pubDate>Sun, 05 Jan 2025 12:35:24 GMT</pubDate>
            <atom:updated>2025-01-05T12:35:24.119Z</atom:updated>
            <content:encoded><![CDATA[<p>In this demo, we will deploy a web server in the ECS Cluster</p><h4>What is an ECS cluster</h4><p>Amazon Elastic Container Service, or ECS for short, is a service that simplifies the running of applications inside containers—small, portable software units—on a cluster of computers referred to as EC2 instances in the cloud. This will help manage, scale, and deploy the application without worrying about the infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*kE13VJIyBk1JA2xP.png" /><figcaption>Image from AWS Docs</figcaption></figure><p>One of the key features of ECS is AWS Fargate which lets you run containers without paying attention to the servers and virtual machines they are running on. This way, developers need to focus on creating and running their apps, while Amazon Web Services handles technical details that include managing and scaling infrastructures.</p><p>Let’s Deploy…</p><h3>Prerequisites</h3><ul><li>AWS IAM access with admin privileges</li><li>AWS VPC with the private subnet</li><li>AWS CLI</li></ul><h4>Step 1: Setup ECS cluster</h4><ul><li>A cluster is a collection of EC2 instances (virtual servers) or Fargate (serverless) where your containers will run.</li><li>To create an ECS service, First we need to create an ECS cluster</li><li>Login to the AWS console and choose ECS from the Services</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ma_I4noZuIqohkTuIUoVdQ.png" /><figcaption>ECS Cluster Dashboard</figcaption></figure><ul><li>Click on the Create Cluster button at the top</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zf8ZByRvq7gJwQmPm90GxQ.png" /><figcaption>ECS Cluster creation</figcaption></figure><ul><li>So I have provided the cluster name as Demo, which will be used for the namespace name.</li><li>As I mentioned, you can run your containers on AWS Fargate (serverless) and AWS EC2. For this demo, I will be using the AWS Fargate serverless approach.</li><li>Choose AWS Fargate in the infrastructure menu and Click on Create</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gq_7STjum_jdydVARS12zA.png" /><figcaption>Demo cluster created</figcaption></figure><h4>Step 2: Task Definition Creation</h4><ul><li>A task definition is a template for running containers. It defines the Docker image, CPU and memory requirements, networking settings, environment variables, and other configurations for the container.</li><li>To create a task definition, you can use a JSON file with all parameters that can be applied using AWS CLI or the AWS console.</li><li>We also need to add a task execution role that grants the Amazon ECS container and Fargate agents permission to make AWS API calls on your behalf.</li><li>Create a file named ecs-tasks-trust-policy.json that contains the trust policy document for the IAM role. The policy should specify the permissions for ECS tasks to assume the role</li></ul><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Sid&quot;: &quot;&quot;,<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;Service&quot;: &quot;ecs-tasks.amazonaws.com&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}</pre><ul><li>Create an IAM role named ecsTaskExecutionRole<strong><em> </em></strong>with the above trust policy</li></ul><pre>aws iam create-role \<br>      --role-name ecsTaskExecutionRole \<br>      --assume-role-policy-document file://ecs-tasks-trust-policy.json</pre><ul><li>Now we will attach an AWS-managed AmazonECSTaskExecutionRolePolicy policy to the ecsTaskExecutionRole role. Which will default have Cloudwatch Logs&amp; ECR permission. Based on your preference you can create a policy and attach it to this role</li></ul><pre>aws iam attach-role-policy \<br>      --role-name ecsTaskExecutionRole \<br>      --policy-arn arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy</pre><ul><li>Below is a sample task definition with FARGATE as the backend</li></ul><pre>{<br>   &quot;containerDefinitions&quot;: [ <br>      { <br>         &quot;command&quot;: [<br>            &quot;/bin/sh -c \&quot;echo &#39;&lt;html&gt; &lt;head&gt; &lt;title&gt;Amazon ECS Sample App&lt;/title&gt; &lt;style&gt;body {margin-top: 40px; background-color: #333;} &lt;/style&gt; &lt;/head&gt;&lt;body&gt; &lt;div style=color:white;text-align:center&gt; &lt;h1&gt;Amazon ECS Sample App&lt;/h1&gt; &lt;h2&gt;Congratulations!&lt;/h2&gt; &lt;p&gt;Your application is now running on a container in Amazon ECS.&lt;/p&gt; &lt;/div&gt;&lt;/body&gt;&lt;/html&gt;&#39; &gt;  /usr/local/apache2/htdocs/index.html &amp;&amp; httpd-foreground\&quot;&quot;<br>         ],<br>         &quot;entryPoint&quot;: [<br>            &quot;sh&quot;,<br>            &quot;-c&quot;<br>         ],<br>         &quot;essential&quot;: true,<br>         &quot;image&quot;: &quot;httpd:2.4&quot;,<br>         &quot;logConfiguration&quot;: { <br>            &quot;logDriver&quot;: &quot;awslogs&quot;,<br>            &quot;options&quot;: { <br>               &quot;awslogs-group&quot; : &quot;/ecs/fargate-task-definition&quot;,<br>               &quot;awslogs-region&quot;: &quot;us-east-1&quot;,<br>               &quot;awslogs-stream-prefix&quot;: &quot;ecs&quot;<br>            }<br>         },<br>         &quot;name&quot;: &quot;sample-fargate-app&quot;,<br>         &quot;portMappings&quot;: [ <br>            { <br>               &quot;containerPort&quot;: 80,<br>               &quot;hostPort&quot;: 80,<br>               &quot;protocol&quot;: &quot;tcp&quot;<br>            }<br>         ]<br>      }<br>   ],<br>   &quot;cpu&quot;: &quot;256&quot;,<br>   &quot;executionRoleArn&quot;: &quot;arn:aws:iam::012345678910:role/ecsTaskExecutionRole&quot;,<br>   &quot;family&quot;: &quot;fargate-task-definition&quot;,<br>   &quot;memory&quot;: &quot;512&quot;,<br>   &quot;networkMode&quot;: &quot;awsvpc&quot;,<br>   &quot;runtimePlatform&quot;: {<br>        &quot;operatingSystemFamily&quot;: &quot;LINUX&quot;<br>    },<br>   &quot;requiresCompatibilities&quot;: [ <br>       &quot;FARGATE&quot; <br>    ]<br>}</pre><blockquote><strong>containerDefinitions</strong>: Defines the container(s) that make up the task.</blockquote><blockquote><strong>command</strong>: Specifies the shell command to run inside the container, creating a simple HTML page and starting the Apache server.</blockquote><blockquote><strong>entryPoint</strong>: Defines the command to start the container</blockquote><blockquote><strong>essential</strong>: Marks the container as necessary, meaning the task will fail if this container stops.</blockquote><blockquote><strong>image</strong>: Specifies the Docker image to use for the container, in this case, the Apache HTTP server (httpd:2.4).</blockquote><blockquote><strong>logConfiguration</strong>: Specifies the logging configuration for the container, using AWS CloudWatch Logs.</blockquote><blockquote><strong>logDriver</strong>: Sets the logging driver awslogs for integration with AWS CloudWatch.</blockquote><blockquote><strong>awslogs-group</strong>: Specifies the CloudWatch Logs group.</blockquote><blockquote><strong>awslogs-region</strong>: Defines the AWS region for the log group.</blockquote><blockquote><strong>awslogs-stream-prefix</strong>: Prefix for log streams in CloudWatch.</blockquote><blockquote><strong>name</strong>: The name of the container in the task definition.</blockquote><blockquote><strong>portMappings</strong>: Maps the container’s internal port (80) to the host’s port (80) for HTTP traffic.</blockquote><blockquote><strong>cpu</strong>: Allocates 256 CPU units for the container task.</blockquote><blockquote><strong>executionRoleArn</strong>: The IAM role that grants the task permissions to interact with other AWS services (e.g., logging).</blockquote><blockquote><strong>family</strong>: The family name for the task definition, is used for versioning.</blockquote><blockquote><strong>memory</strong>: Allocates 512 MB of memory for the container task.</blockquote><blockquote><strong>networkMode</strong>: Specifies that the task uses the awsvpc network mode (each gets its own ENI).</blockquote><blockquote><strong>runtimePlatform</strong>: Specifies the operating system family for the task, in this case, Linux.</blockquote><blockquote><strong>requiresCompatibilities</strong>: Specifies that the task can only run on AWS Fargate (serverless container service).</blockquote><ul><li>Replace the <strong>executionRoleArn </strong>with the role that you have created in the before step and apply the task definition file. You can also modify other parameters based on the application requirements</li></ul><pre>aws ecs register-task-definition --cli-input-json file://task-def.json</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ifz-cOI6uwmT53l5QfXPg.png" /><figcaption>ECS Task Def Console</figcaption></figure><ul><li>We have successfully created the task definition and you can view this from the ECS AWS console.</li></ul><h4>Step 3: Cloudwatch setup</h4><ul><li>CloudWatch Logs allows you to monitor, store, and access log files from various AWS services. It provides real-time insights and facilitates troubleshooting and performance monitoring.</li><li>We have already added the log group in the task definition, Now we will create the log group.</li></ul><pre>aws logs create-log-group --log-group-name /ecs/fargate-task-definition</pre><h4>Step 4: Load Balancer Setup</h4><ul><li>When deploying an ECS service, you often want to distribute incoming traffic across multiple application instances. To do this, you must set up an <strong>Elastic Load Balancer (ELB)</strong> to forward traffic to your ECS tasks. This is especially important when using ECS in <strong>Fargate mode</strong> or having a scalable EC2 infrastructure, as the load balancer ensures that traffic is balanced and routed efficiently.</li><li>Here we will be using the <strong>ALB (Application Load Balancer)</strong> type of load balancer within the <strong>Elastic Load Balancing (ELB)</strong> service provided by AWS. Primarily designed for routing HTTP and HTTPS traffic. It operates at <strong>Layer 7</strong> (the application layer) of the OSI model.</li></ul><pre>aws elbv2 create-load-balancer \<br>   --name my-alb \<br>   --subnets subnet-xxx subnet-xxxx \<br>   --security-groups sg-xxxx \<br>   --scheme internet-facing \<br>   --type application</pre><ul><li>Replace the subnet and security group id’s. You need to provide the public subnet which have IGW attached, Also 80(HTTP) and 443(HTTPS) ports should be open in the security group, This is to receive traffic from the public internet.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R6YuSbQc4Cq6W4eIlhCjBg.png" /><figcaption>Security group inbound rules</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AdToaiUNzkdcHBuyoHRuow.png" /><figcaption>Load balancer</figcaption></figure><ul><li>The load balancer was created successfully and in the next step, we will cover the ECS service creation.</li></ul><h4>Step 5: ECS Service creation</h4><ul><li>An <strong>ECS service</strong> is a tool that helps you keep your app’s containers running on AWS. It ensures that the right number of containers are always running, and if any container stops working, ECS automatically restarts it. ECS makes managing your app easier by handling things like scaling (adding or removing containers) and traffic distribution.</li><li>Here the ECS backend type is Fargate and we need to specify the subnet during the service creation.</li><li>As a best practice, The ECS service will be created in a private subnet with a NAT gateway attached and exposed using a public load balancer. I will cover the network part in detail in another post.</li><li>A target group is essential for routing traffic to your targets (such as ECS tasks or EC2 instances) from an Application Load Balancer (ALB), So we will create a target group and attach it to the ECS service.</li></ul><pre> aws elbv2 create-target-group \<br>   --name demo-target-group \<br>   --protocol HTTP \<br>   --port 80 \<br>   --vpc-id vpc-xxxxx \<br>   --target-type ip \<br>   --health-check-protocol HTTP \<br>   --health-check-port 80 \<br>   --health-check-path / \<br>   --healthy-threshold-count 3 \<br>   --unhealthy-threshold-count 3 \<br>   --health-check-timeout-seconds 5 \<br>   --health-check-interval-seconds 30</pre><ul><li>Replace the VPC ID and modify other parameters based on your application requirements.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wG-Hf2RK-lxtoAUT4DkplA.png" /><figcaption>Target Group Console</figcaption></figure><ul><li>The created target group needs to be attached to the load balancer, For that we will be creating a listener (80) in ELB to receive traffic on HTTP.</li></ul><pre>aws elbv2 create-listener \<br>  --load-balancer-arn arn-xxxx\<br>  --protocol HTTP \<br>  --port 80 \<br>  --default-actions Type=forward,TargetGroupArn=arn-xxx</pre><ul><li>Replace the load balancer arn &amp; target group arn</li><li>Based on the above details, We can create the ECS service</li></ul><pre>  aws ecs create-service \<br>  --cluster Demo \<br>  --service-name fargate-task \<br>  --task-definition fargate-task-definition:1 \<br>  --desired-count 1 \<br>  --launch-type FARGATE \<br>  --network-configuration &quot;awsvpcConfiguration={subnets=[subnet-xxx],securityGroups=[sg-xxx],assignPublicIp=DISABLED}&quot; \<br>  --load-balancers &quot;targetGroupArn=arn:arn-xxx,containerName=sample-fargate-app,containerPort=80&quot;</pre><ul><li>Replace the values with your infrastructure resources name, Also make sure to provide the private subnet and security group which should have an inbound rule (Application port number )to allow traffic from the load balancer</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2UNRg0bHwdXqO3m39io7iA.png" /><figcaption>ECS Service</figcaption></figure><ul><li>Now, The Service is running and you can view the logs in cloudwatch</li><li>Go to the load balancer section copy the DNS name of the load balancer and paste it into the browser</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u5gPpNXPd0C5f2gXBLEL8w.png" /><figcaption>Application web page</figcaption></figure><ul><li>Yay, it’s finally done! We have successfully deployed a web server in ECS</li><li>You can also use your custom domain for accessing the application by adding a hostname and paths in the load balancer rules</li><li>Feel free to experiment with its various features. My next post will cover Autoscaling, Alerting, and Monitoring in ECS</li></ul><h4>References</h4><ul><li><a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html">Amazon ECS Documentation</a></li><li><a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/example_task_definitions.html">Example Amazon ECS task definitions</a></li></ul><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://cofeed.app/"><strong>Check out CoFeed, the smart way to stay up-to-date with the latest in tech</strong></a> <strong>🧪</strong></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d97e7d07892" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/deploy-an-application-in-the-ecs-cluster-3d97e7d07892">Deploy an Application in the ECS cluster</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Set Up Argo CD in EKS Cluster]]></title>
            <link>https://aws.plainenglish.io/how-to-set-up-argo-cd-in-eks-cluster-d11858ea826a?source=rss-3c7629da0cee------2</link>
            <guid isPermaLink="false">https://medium.com/p/d11858ea826a</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws-eks]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[argo-cd]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Raino Raphel]]></dc:creator>
            <pubDate>Thu, 31 Oct 2024 13:11:56 GMT</pubDate>
            <atom:updated>2024-10-31T13:11:56.717Z</atom:updated>
            <content:encoded><![CDATA[<p>In this demo, we will set up Argo CD in a preconfigured EKS cluster</p><h4>What is Argo CD?</h4><p>Argo CD is a Kubernetes-native continuous deployment (CD) tool that automates application deployment to Kubernetes clusters using GitOps principles. It can pull updated code from Git repositories and deploy it directly to Kubernetes resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*cKB0hSs6JWbRnsjB.gif" /><figcaption>GIF taken from Argo CD source</figcaption></figure><h4>How does Argo CD Work?</h4><p>Argo CD is a continuous delivery tool designed for Kubernetes. It operates within the Kubernetes cluster and continuously monitors Git repositories for changes in Kubernetes manifest files. When a developer commits code, the CI/build tool creates a Docker image and updates the image tag in the corresponding Kubernetes manifest file stored in the Git repository. Argo CD then detects this change and automatically deploys the updated application to the Kubernetes cluster, ensuring that the deployed state matches the desired state defined in the Git repository.</p><p>Let’s Deploy…</p><h4>Prerequisites</h4><ul><li>AWS IAM access with admin privileges</li><li>AWS EKS Cluster</li><li>AWS CLI</li><li>Kubectl</li></ul><h4>Step 1: Verification</h4><ul><li>EKS Cluster version: 1.30</li><li>Instance Type: t3a.medium</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YS4Hdog78NkALenFSi6xYA.png" /><figcaption>EKS Cluster</figcaption></figure><pre>kubectl version<br><br>Client Version: v1.31.1<br>Kustomize Version: v5.4.2<br>Server Version: v1.30.4-eks-a737599<br>vagrant@ubuntu-focal:~/medium/EKS$ kubectl get pods -n kube-system<br>NAME                       READY   STATUS    RESTARTS   AGE<br>aws-node-fbfql             2/2     Running   0          3m44s<br>aws-node-q5m4k             2/2     Running   0          3m56s<br>aws-node-vg7zm             2/2     Running   0          3m45s<br>coredns-586b798467-hcwqx   1/1     Running   0          7m7s<br>coredns-586b798467-k6nmq   1/1     Running   0          7m7s<br>kube-proxy-g6lq2           1/1     Running   0          3m44s<br>kube-proxy-jj75k           1/1     Running   0          3m45s<br>kube-proxy-m7sxk           1/1     Running   0          3m56s<br><br>kubectl get nodes<br>NAME                         STATUS   ROLES    AGE     VERSION<br>ip-10-0-1-210.ec2.internal   Ready    &lt;none&gt;   3m53s   v1.30.4-eks-a737599<br>ip-10-0-1-90.ec2.internal    Ready    &lt;none&gt;   4m5s    v1.30.4-eks-a737599<br>ip-10-0-3-183.ec2.internal   Ready    &lt;none&gt;   3m54s   v1.30.4-eks-a737599<br>vagrant@ubuntu-focal:~/medium/EKS$</pre><ul><li>AWS CLI: 2.17.61</li></ul><pre>aws --version<br>aws-cli/2.17.61 Python/3.12.6 Linux/5.4.0-196-generic exe/x86_64.ubuntu.20</pre><h4>Step 2: Install Argo CD in the EKS cluster</h4><ul><li>Create a namespace named argocd, where Argo CD services and applications will be deployed.</li></ul><pre>kubectl create namespace argocd<br>namespace/argocd created</pre><ul><li>Apply the Argo CD manifest file from the stable release</li></ul><pre>kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml</pre><ul><li>Verify if pods are successfully deployed</li></ul><pre>kubectl get pods -n argocd<br>NAME                                                READY   STATUS    RESTARTS   AGE<br>argocd-application-controller-0                     1/1     Running   0          5m8s<br>argocd-applicationset-controller-744b76d7fd-gqzhd   1/1     Running   0          5m16s<br>argocd-dex-server-5bf5dbc64d-bvw2q                  1/1     Running   0          5m14s<br>argocd-notifications-controller-84f5bf6896-jzmgs    1/1     Running   0          5m13s<br>argocd-redis-74b8999f94-8hzfz                       1/1     Running   0          5m12s<br>argocd-repo-server-57f4899557-ckpsn                 1/1     Running   0          5m11s<br>argocd-server-7bc7b97977-scn9n                      1/1     Running   0          5m9s</pre><h4>Step 3: Setup Argo CD API &amp; UI</h4><ul><li>The Argo CD API server is not exposed to an external IP. To access the API server, We need to expose the argocd-server svc.</li><li>For this demo, I’m using the ingress method. You can use any method like port forwarding.</li><li>Here I have used the <a href="https://medium.com/aws-in-plain-english/how-to-setup-aws-load-balancer-controller-in-eks-cluster-682a81c4e5ca">AWS Load Balancer Controller</a> for configuring ingress, You can follow the above document for the installation and configuration.</li><li>Below is the ingress manifest file</li></ul><pre>---<br>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  namespace: argocd<br>  name: ingress<br>  annotations:<br>    kubernetes.io/ingress.class: alb<br>    alb.ingress.kubernetes.io/scheme: internet-facing<br>    alb.ingress.kubernetes.io/target-type: ip<br>    alb.ingress.kubernetes.io/subnets: public_subnet_one,public_subnet_two<br>    alb.ingress.kubernetes.io/certificate-arn: acm_ssl_arn<br>    alb.ingress.kubernetes.io/listen-ports: &#39;[{&quot;HTTP&quot;: 80}, {&quot;HTTPS&quot;:443}]&#39;<br>    alb.ingress.kubernetes.io/group.name: app<br>    alb.ingress.kubernetes.io/actions.ssl-redirect: &gt;-<br>        {<br>            &quot;Type&quot;: &quot;redirect&quot;,<br>            &quot;RedirectConfig&quot;: {<br>                &quot;Protocol&quot;: &quot;HTTPS&quot;,<br>                &quot;Port&quot;: &quot;443&quot;,<br>                &quot;Host&quot;: &quot;#{host}&quot;,<br>                &quot;Path&quot;: &quot;/#{path}&quot;,<br>                &quot;Query&quot;: &quot;#{query}&quot;,<br>                &quot;StatusCode&quot;: &quot;HTTP_301&quot;<br>            }<br>        }<br>spec:<br>  rules:<br>     - host: app.example.com  ##Replace the host value with your desired custom domain <br>       http:<br>        paths:<br>          - path: /<br>            pathType: Prefix<br>            backend:<br>             service:<br>              name: ssl-redirect<br>              port:<br>               name: use-annotation<br>          - path: /<br>            pathType: Prefix<br>            backend:<br>              service:<br>                name: argocd-server<br>                port:<br>                  number: 443 </pre><pre>kubectl apply -f ingress.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*hbZlk_Z6FGUj9GmIHMdJ0w.png" /><figcaption>Error page</figcaption></figure><ul><li>ArgoCD was failing due to ERR_TOO_MANY_REDIRECTS. The problem is that Argo-CD handles TLS termination and redirects HTTP requests to HTTPS. Combine that with an ingress controller that handles TLS termination and always communicates with the backend service with HTTP, and you get Argo-CD’s server always responding with a redirect to HTTPS. So, one solution would be to disable HTTPS on Argo-CD.</li><li>This can be solved by adding the — insecure flag to true for the configmap. yaml to populate the environment variables used by argo-server</li></ul><pre>kubectl edit configmap argocd-cmd-params-cm -n argocd -o yaml<br><br>## Add the below given aurgment in data<br>data:  <br>  server.insecure: &quot;true&quot; # &lt;-- this line need to be added</pre><ul><li>Restart the argocd-server</li></ul><pre>kubectl rollout restart deployment argocd-server -n argocd</pre><ul><li>Now the argocd API &amp; UI are available</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*F-iENXEPWwDekufXMAoCew.png" /><figcaption>Argo CD Login Page</figcaption></figure><h4>Step 4: Setup Argo CD CLI</h4><ul><li>The Argo CD CLI connects with the Argo CD API and manages it from the system terminal.</li><li>Download the latest stable version.</li></ul><pre>VERSION=$(curl -L -s https://raw.githubusercontent.com/argoproj/argo-cd/stable/VERSION)<br>curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/download/v$VERSION/argocd-linux-amd64<br>sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd<br>rm argocd-linux-amd64</pre><pre>argocd version<br>argocd: v2.12.3+6b9cd82<br>  BuildDate: 2024-08-27T12:18:06Z<br>  GitCommit: 6b9cd828c6e9807398869ad5ac44efd2c28422d6<br>  GitTreeState: clean<br>  GoVersion: go1.22.6<br>  Compiler: gc<br>  Platform: linux/amd64<br>FATA[0000] Argo CD server address unspecified</pre><ul><li>The initial password for the admin account is auto-generated and stored as clear text in the field password in a secret named argocd-initial-admin-secret. You can simply retrieve this password using the argocd CLI</li></ul><pre>argocd admin initial-password -n argocd</pre><ul><li>let’s try logging in using the argocd cli</li></ul><pre>argocd login &lt;ARGOCD_SERVER&gt;<br><br>WARN[0004] Failed to invoke grpc call. Use flag --grpc-web in grpc calls. To avoid this warning message, use flag --grpc-web.<br>Username: admin<br>Password:<br>&#39;admin:login&#39; logged in successfully<br>Context &#39;app.example.com&#39; updated</pre><ul><li>You can also try logging into UI (app.example.com) using the same credentials.</li></ul><h4>Step 4: Create an application using Argo CD Ui</h4><ul><li>I have logged into the argocd UI by visiting the IP/hostname and using the above credentials</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TRgvuCCN2PEUXi-1lqdcow.png" /><figcaption>ArgoCD Dashboard</figcaption></figure><ul><li>Now let&#39;s create an application in argocd which will deploy the manifest files from the repo</li><li>Here I will use an example repo containing a guestbook application available at <a href="https://github.com/argoproj/argocd-example-apps.git">https://github.com/argoproj/argocd-example-apps.git</a></li><li>Click on the NEW APP button</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*RVD_xzsmTjR1qtrPPH6Ibw.png" /><figcaption>ArgoCD Application Setup</figcaption></figure><ul><li>Set the app name as guestbook, use the project default, and leave the sync policy as Manual</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*63LEcwN-EAiO-izCYsyqdA.png" /><figcaption>ArgoCD Application Setup</figcaption></figure><ul><li>In the source section add the GitHub <a href="https://github.com/argoproj/argocd-example-apps.git">repo</a>, and leave the revision as HEAD, and set the path to guestbook:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bsCgzvC4uI2S_7hj-o24Xw.png" /><figcaption>ArgoCD Application Setup</figcaption></figure><ul><li>In the destination part, set the cluster URL to https://kubernetes.default.svc (or in-cluster for cluster name) and namespace to default</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q8GCH7TRBf9yqWe-3_9nxg.png" /><figcaption>ArgoCD Application Setup</figcaption></figure><ul><li>Click on the Create button at the top of the UI</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*WiANz2qRbRv6r56NSp76aQ.png" /><figcaption>ArgoCD Application Setup</figcaption></figure><ul><li>Application creation can also be done using the ArgoCD cli (Optional)</li></ul><pre>kubectl config set-context --current --namespace=argocd<br><br>argocd app create guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path guestbook --dest-server https://kubernetes.default.svc --dest-namespace default</pre><h4>Step 5: Deploy the application using Argo CD Ui / CLI</h4><ul><li>The application is configured as manual sync, So we are now going to sync the application using argocd cli</li><li>Once the application is created, We can check the status of the guestbook</li></ul><pre>argocd app get guestbook<br><br>WARN[0004] Failed to invoke grpc call. Use flag --grpc-web in grpc calls. To avoid this warning message, use flag --grpc-web.<br>Name:               argocd/guestbook<br>Project:            default<br>Server:             https://kubernetes.default.svc<br>Namespace:          default<br>URL:                https://app.example.com/applications/guestbook<br>Source:<br>- Repo:             https://github.com/argoproj/argocd-example-apps.git<br>  Target:           HEAD<br>  Path:             guestbook<br>SyncWindow:         Sync Allowed<br>Sync Policy:        Manual<br>Sync Status:        OutOfSync from HEAD (d7927a2)<br>Health Status:      Missing<br><br>GROUP  KIND        NAMESPACE  NAME          STATUS     HEALTH   HOOK  MESSAGE<br>       Service     default    guestbook-ui  OutOfSync  Missing<br>apps   Deployment  default    guestbook-ui  OutOfSync  Missing</pre><ul><li>The application starts in the OutOfSync state because it hasn’t been deployed yet, and no Kubernetes resources exist. To synchronize (or deploy) the application, execute the following command</li></ul><pre>argocd app sync guestbook<br><br>WARN[0002] Failed to invoke grpc call. Use flag --grpc-web in grpc calls. To avoid this warning message, use flag --grpc-web.<br><br>Name:               argocd/guestbook<br>Project:            default<br>Server:             https://kubernetes.default.svc<br>Namespace:          default<br>URL:                https://app.example.com/applications/guestbook<br>Source:<br>- Repo:             https://github.com/argoproj/argocd-example-apps.git<br>  Target:           HEAD<br>  Path:             guestbook<br>SyncWindow:         Sync Allowed<br>Sync Policy:        Manual<br>Sync Status:        Synced to HEAD (d7927a2)<br>Health Status:      Progressing<br><br>Operation:          Sync<br>Sync Revision:      d7927a27b4533926b7d86b5f249cd9ebe7625e90<br>Phase:              Succeeded<br>Start:              2024-10-30 07:12:04 +0000 UTC<br>Finished:           2024-10-30 07:12:05 +0000 UTC<br>Duration:           1s<br>Message:            successfully synced (all tasks run)<br><br>GROUP  KIND        NAMESPACE  NAME          STATUS  HEALTH       HOOK  MESSAGE<br>       Service     default    guestbook-ui  Synced  Healthy            service/guestbook-ui created<br>apps   Deployment  default    guestbook-ui  Synced  Progressing        deployment.apps/guestbook-ui created</pre><ul><li>This command fetches the manifests from the repository and applies them using kubectl. The guestbook app is now running allowing you to view its resource components, logs, events, and overall health status.</li><li>You can see more details by clicking on the application.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FXkal13FGADosPWXuFr0bA.png" /><figcaption>ArgoCD Application Workflow</figcaption></figure><ul><li>You can also sync from UI. On the Applications page, click on the <em>Sync</em> button of the guestbook application.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*CEzfMqjjG32bGXto_gpKow.png" /><figcaption>ArgoCD Application</figcaption></figure><ul><li>We’ve successfully set up ArgoCD and deployed applications with it. Feel free to experiment with its various features. My next post will cover ArgoCD’s integrations with build tools.</li></ul><h4>References</h4><ul><li><a href="https://argo-cd.readthedocs.io/en/stable/getting_started/">Argo CD Getting Started</a></li><li><a href="https://github.com/argoproj/argo-cd/issues/2953">Redirect Issue Thread GitHub</a></li><li><a href="https://stackoverflow.com/questions/76624577/argocd-ingress-kubernetes-too-many-redirects-even-with-insecure-nginx">Redirect Issue Thread StackOverflow</a></li></ul><h3>In Plain English 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://plainenglish.io/"><strong><em>In Plain English</em></strong></a><em> community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://differ.blog/"><strong>Create a free AI-powered blog on Differ.</strong></a></li><li>More content at <a href="https://plainenglish.io/"><strong>PlainEnglish.io</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d11858ea826a" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/how-to-set-up-argo-cd-in-eks-cluster-d11858ea826a">How to Set Up Argo CD in EKS Cluster</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create an EKS Cluster Using EKSCTL]]></title>
            <link>https://aws.plainenglish.io/how-to-create-an-eks-cluster-using-eksctl-1a905b704d3f?source=rss-3c7629da0cee------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a905b704d3f</guid>
            <category><![CDATA[eksctl]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Raino Raphel]]></dc:creator>
            <pubDate>Wed, 13 Dec 2023 10:17:19 GMT</pubDate>
            <atom:updated>2023-12-13T10:17:19.085Z</atom:updated>
            <content:encoded><![CDATA[<p>This story aims at provisioning a EKS cluster using Eksctl command line</p><h4>What is EKSCTL?</h4><p>Eksctl is a user-friendly command-line interface (CLI) tool designed for effortlessly setting up clusters on Amazon Elastic Kubernetes Service (EKS). Eksctl, developed in the Go programming language, leverages CloudFormation to streamline the cluster creation process. In essence, it provides a straightforward way to initiate and manage Kubernetes clusters on the EKS platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KcRnOD1ssSwhPsjW" /><figcaption>Image taken from Eksctl GitHub Repo</figcaption></figure><h4>Installation</h4><p>Eksctl binary file is available in official <a href="https://github.com/eksctl-io/eksctl/releases">GitHub</a> releases. Get the latest release link and replace the value of EKSCTL_BINARY_URL</p><pre>##Using Ubuntu OS<br>ARCH=amd64<br>PLATFORM=$(uname -s)_$ARCH<br>EKSCTL_BINARY_URL=https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz<br>wget $EKSCTL_BINARY_URL<br><br>##Extract tar file<br>tar -xzvf eksctl_Linux_amd64.tar.gz<br>cp eksctl /usr/local/bin/eksctl<br><br>##Add execute permission if required<br>chmod +x /usr/local/bin/eksctl<br><br>##Check eksctl version<br>eksctl version<br>0.164.0</pre><h4>Prerequisites</h4><ul><li>AWS IAM access with admin privileges</li><li>Kubectl</li><li>AWS credentials</li><li>For restricted IAM policies, Please refer this <a href="https://github.com/eksctl-io/eksctl#prerequisite">GitHub</a> page</li></ul><h4>Create EKS cluster using default config</h4><pre>eksctl create cluster --profile &lt;Provide AWS profile&gt; --region &lt;region&gt;<br><br>#A cluster will be created with default parameters</pre><h4>Create EKS cluster using custom config</h4><pre># An example of ClusterConfig object using an existing VPC:<br>--- <br>apiVersion: eksctl.io/v1alpha5<br>kind: ClusterConfig<br><br>metadata:<br>  name: deme<br>  region: us-east-1<br><br># An existing VPC wil be used for creatin the EKS cluster<br><br>vpc:<br>  id: &quot;vpc-id&quot;  # (optional, must match VPC ID used for each subnet below)<br>  subnets:<br>    # must provide &#39;private&#39; and/or &#39;public&#39; subnets by availability zone as shown<br>    private:<br>      us-east-1a:<br>        id: &quot;subnet-id&quot;<br><br>      us-east-1b:<br>        id: &quot;subnet-id&quot;<br><br># Specify the Worker node details<br><br>nodeGroups:<br>  - name: ng-1<br>    instanceType: m5.xlarge<br>    desiredCapacity: 2<br>    privateNetworking: true # if only &#39;Private&#39; subnets are given, this must be enabled<br></pre><pre>eksctl create cluster -f config.yml --profile &lt;Provide AWS profile&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4sPK-7YfqCtYwohkHN3PbQ.png" /><figcaption>Screenshot of EKS clusters with default and custom parameters</figcaption></figure><p>Once you have created a cluster, you will find that cluster credentials were added in ~/.kube/config</p><p>You can find lot of examples in their <a href="https://github.com/eksctl-io/eksctl/tree/main/examples">GitHub</a> Repo</p><h4>Conclusion</h4><p>In this guide, we’ve seen how eksctl makes creating and managing EKS clusters on AWS a breeze. Whether you’re starting fresh or using an existing VPC, Eksctl simplifies the process, letting you focus on your applications, not infrastructure.</p><h4>Reference</h4><ol><li>Eksctl <a href="https://github.com/eksctl-io/eksctl">GitHub</a> Repo</li><li>Eksctl <a href="https://eksctl.io/getting-started/">Getting Started</a></li><li>AWS <a href="https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html">Document</a></li></ol><h3><a href="https://plainenglish.io/">PlainEnglish.io</a> 🚀</h3><p><em>Thank you for being a part of the In Plain English community! Before you go:</em></p><ul><li><em>Be sure to </em><strong><em>clap</em></strong><em> and </em><strong><em>follow</em></strong><em> the writer</em><strong>️</strong></li><li><em>Learn how you can also </em><a href="https://plainenglish.io/blog/how-to-write-for-in-plain-english"><strong><em>write for In Plain English</em></strong></a><em>️</em></li><li><em>Follow us: </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>X</em></strong></a><strong><em> | </em></strong><a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><strong><em> | </em></strong><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><strong><em> | </em></strong><a href="https://discord.gg/in-plain-english-709094664682340443"><strong><em>Discord</em></strong></a><strong><em> | </em></strong><a href="https://newsletter.plainenglish.io/"><strong><em>Newsletter</em></strong></a></li><li><em>Visit our other platforms: </em><a href="https://stackademic.com/"><strong><em>Stackademic</em></strong></a><strong><em> | </em></strong><a href="https://cofeed.app/"><strong><em>CoFeed</em></strong></a><strong><em> | </em></strong><a href="https://venturemagazine.net/"><strong><em>Venture</em></strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a905b704d3f" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/how-to-create-an-eks-cluster-using-eksctl-1a905b704d3f">How to Create an EKS Cluster Using EKSCTL</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Set Up Karpenter in the EKS Cluster]]></title>
            <link>https://aws.plainenglish.io/how-to-setup-karpenter-in-the-eks-cluster-3c8e285733f6?source=rss-3c7629da0cee------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c8e285733f6</guid>
            <category><![CDATA[karpenter]]></category>
            <category><![CDATA[helm]]></category>
            <category><![CDATA[cloudformation]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Raino Raphel]]></dc:creator>
            <pubDate>Tue, 01 Aug 2023 04:06:09 GMT</pubDate>
            <atom:updated>2024-09-12T03:08:26.661Z</atom:updated>
            <content:encoded><![CDATA[<h4>In this demo, we will deploy Karpenter in the EKS cluster</h4><h4>What is Karpenter?</h4><p>Designed as an open-source Kubernetes cluster autoscaler, Karpenter seamlessly integrates with AWS (Amazon Web Services) to enhance application availability and cluster efficiency. By swiftly provisioning compute resources of the right size, it effectively responds to fluctuations in application load, ensuring optimal performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_sWZpZ4fb5vPTLA4Nhwsww.png" /><figcaption>Image taken from Karpenter source</figcaption></figure><h4>How Karpenter works?</h4><p>Once installed in your cluster, Karpenter actively monitors the combined resource requests of unscheduled pods and takes actions to minimize scheduling delays and reduce infrastructure expenses by launching or terminating nodes. This is accomplished by observing Kubernetes cluster events and issuing commands to the underlying compute service of the cloud provider, such as Amazon EC2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-2Ixpm2OwUNljmDd.png" /><figcaption>Image taken from respective AWS document</figcaption></figure><p>Let’s Deploy…</p><h4>Prerequisites</h4><ul><li>AWS IAM access with admin privileges</li><li>AWS CLI</li><li>Kubectl</li><li>Eksctl</li><li>Helm</li></ul><blockquote><em>💡</em> <strong>Learn how to efficiently store one million small objects to S3 for your stock analytics app with AWS Athena integration:</strong></blockquote><p><a href="https://differ.blog/p/how-to-write-one-million-small-objects-to-s3-c69e8c">How to write one million small objects to S3</a></p><blockquote><em>👉</em> To read more such acrticles, <a href="https://differ.blog/"><strong>sign up for free on Differ</strong></a>.</blockquote><h4>Step 1: Setup ENV variables</h4><p>1.1 Declare variables for the stack</p><pre>## Set karpenter version<br>export KARPENTER_VERSION=v0.29.0<br>## if you are not using standard partitions, you may need to configure to aws-cn / aws-us-gov<br>export AWS_PARTITION=&quot;aws&quot; <br>## Set your desired cluster name<br>export CLUSTER_NAME=&quot;karpenter-demo&quot;<br>## Set AWS region<br>export AWS_DEFAULT_REGION=&quot;us-east-1&quot;<br>## Set AWS Account ID<br>export AWS_ACCOUNT_ID=&quot;$(aws sts get-caller-identity --query Account --output text)&quot;<br></pre><p>1.2 Verify the variables</p><pre>echo $KARPENTER_VERSION $CLUSTER_NAME $AWS_DEFAULT_REGION $AWS_ACCOUNT_ID</pre><h4>Step 2: Setup Infra</h4><p>2.1 Setup infrastructure needed by the EKS cluster</p><ul><li>Here we will use the <a href="https://raw.githubusercontent.com/aws/karpenter/main/website/content/en/preview/getting-started/getting-started-with-karpenter/cloudformation.yaml">getting started</a> CloudFormation templates provided by the Karpenter to set up the infrastructure needed by the EKS cluster.</li><li>This template will set up required roles, policies, etc...</li><li>Fetch the CloudFormation yaml to your local</li></ul><pre>curl -fsSL https://raw.githubusercontent.com/aws/karpenter/&quot;${KARPENTER_VERSION}&quot;/website/content/en/preview/getting-started/getting-started-with-karpenter/cloudformation.yaml &gt; cloudformation.yaml</pre><ul><li>Now we can deploy the CloudFormation stack</li></ul><pre>aws cloudformation deploy \<br>  --stack-name &quot;${CLUSTER_NAME}&quot; \<br>  --template-file cloudformation.yaml \<br>  --capabilities CAPABILITY_NAMED_IAM \<br>  --parameter-overrides &quot;ClusterName=${CLUSTER_NAME}&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OJ4S-RpOlfJhghdC_8CGcQ.png" /><figcaption>Screenshot of the CloudFormation stack</figcaption></figure><ul><li>Successfully deployed, Now Let’s create the EKS cluster</li></ul><p>2.2 Provision of EKS cluster</p><ul><li>Here, We will create the EKS cluster using the Eksctl template</li><li>It will establish a Kubernetes service account and an AWS IAM Role, then utilize IRSA to associate them, allowing Karpenter to initiate instance launches.</li><li>VPC, Subnets, and Security Groups will be created</li><li>Mapping of Karpenter node role to the aws-auth configmap to allow nodes to connect.</li><li>Uses AWS EKS-managed node groups for the kube-system and karpenter namespaces</li></ul><pre>eksctl create cluster -f - &lt;&lt;EOF<br>---<br>apiVersion: eksctl.io/v1alpha5<br>kind: ClusterConfig<br>metadata:<br>  name: ${CLUSTER_NAME}<br>  region: ${AWS_DEFAULT_REGION}<br>  version: &quot;1.27&quot;<br>  tags:<br>    karpenter.sh/discovery: ${CLUSTER_NAME}<br><br>iam:<br>  withOIDC: true<br>  serviceAccounts:<br>  - metadata:<br>      name: karpenter<br>      namespace: karpenter<br>    roleName: ${CLUSTER_NAME}-karpenter<br>    attachPolicyARNs:<br>    - arn:${AWS_PARTITION}:iam::${AWS_ACCOUNT_ID}:policy/KarpenterControllerPolicy-${CLUSTER_NAME}<br>    roleOnly: true<br><br>iamIdentityMappings:<br>- arn: &quot;arn:${AWS_PARTITION}:iam::${AWS_ACCOUNT_ID}:role/KarpenterNodeRole-${CLUSTER_NAME}&quot;<br>  username: system:node:{{EC2PrivateDNSName}}<br>  groups:<br>  - system:bootstrappers<br>  - system:nodes<br><br>managedNodeGroups:<br>- instanceType: t3a.large<br>  amiFamily: AmazonLinux2<br>  name: ${CLUSTER_NAME}-ng<br>  desiredCapacity: 2<br>  minSize: 1<br>  maxSize: 10<br>EOF</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0dkm2WozMYi-BixV1DUwA.png" /><figcaption>CloudFormation created by Eksctl</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yUKC7Hl8fhFTHhNwlNBYnQ.png" /><figcaption>EKS Cluster</figcaption></figure><ul><li>Successfully created the EKS cluster</li><li>Set KARPENTER_IAM_ROLE_ARN variables. Which will be used during the Karpenter installation</li></ul><pre>export CLUSTER_ENDPOINT=&quot;$(aws eks describe-cluster --name ${CLUSTER_NAME} --query &quot;cluster.endpoint&quot; --output text)&quot;<br>export KARPENTER_IAM_ROLE_ARN=&quot;arn:${AWS_PARTITION}:iam::${AWS_ACCOUNT_ID}:role/${CLUSTER_NAME}-karpenter&quot;<br><br>echo $CLUSTER_ENDPOINT $KARPENTER_IAM_ROLE_ARN</pre><ul><li>Create a role to allow spot instances.</li></ul><pre>aws iam create-service-linked-role --aws-service-name spot.amazonaws.com || true<br># If the role has already been successfully created, you will see:<br># An error occurred (InvalidInput) when calling the CreateServiceLinkedRole operation: Service role name AWSServiceRoleForEC2Spot has been taken in this account, please try a different suffix.</pre><h4>Step 3: Install Karpenter</h4><p>3.1 Installation of Karpenter using HELM</p><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;=${KARPENTER_IAM_ROLE_ARN} \<br>  --set settings.aws.clusterName=${CLUSTER_NAME} \<br>  --set settings.aws.defaultInstanceProfile=KarpenterNodeInstanceProfile-${CLUSTER_NAME} \<br>  --set settings.aws.interruptionQueueName=${CLUSTER_NAME} \<br>  --set controller.resources.requests.cpu=1 \<br>  --set controller.resources.requests.memory=1Gi \<br>  --set controller.resources.limits.cpu=1 \<br>  --set controller.resources.limits.memory=1Gi \<br>  --wait</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mF0Mhy-DxMLz9Razz9H-2Q.png" /><figcaption>Helm Output</figcaption></figure><p>3.2 Configuration of Provisioner</p><ul><li>Karpenter provisioners can efficiently manage numerous pod shapes by utilizing pod attributes like labels and affinity, thus streamlining scheduling and provisioning decisions and eliminating the necessity to handle multiple node groups.</li><li>More about <a href="https://karpenter.sh/preview/concepts/provisioners/">Provisioners</a>, <a href="https://karpenter.sh/preview/concepts/node-templates/">Node Templates</a></li></ul><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.sh/capacity-type<br>      operator: In<br>      values: [&quot;spot&quot;]<br>    - key: &quot;node.kubernetes.io/instance-type&quot;<br>      operator: In<br>      values: [&quot;t3a.large&quot;]<br>  limits:<br>    resources:<br>      cpu: 1000<br>  providerRef:<br>    name: default<br>  consolidation: <br>    enabled: true<br>---<br>apiVersion: karpenter.k8s.aws/v1alpha1<br>kind: AWSNodeTemplate<br>metadata:<br>  name: default<br>spec:<br>  subnetSelector:<br>    karpenter.sh/discovery: ${CLUSTER_NAME}<br>  securityGroupSelector:<br>    karpenter.sh/discovery: ${CLUSTER_NAME}<br>EOF</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*4K4Vr-6IK1oKiQLPmr4CFg.png" /><figcaption>Provisioner output</figcaption></figure><ul><li>Karpenter has been activated and is fully prepared to initiate node provisioning.</li></ul><h4>Step 4: Deploy the Application</h4><p>4.1 Upscale deployment</p><ul><li>Now, Let’s create a deployment and watch Karpenter provision nodes in response</li></ul><pre>cat &lt;&lt;EOF | kubectl apply -f -<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: nginx<br>spec:<br>  replicas: 0<br>  selector:<br>    matchLabels:<br>      app: nginx<br>  template:<br>    metadata:<br>      labels:<br>        app: nginx<br>    spec:<br>      terminationGracePeriodSeconds: 0<br>      containers:<br>        - name: nginx<br>          image: nginx<br>          resources:<br>            requests:<br>              cpu: 1<br>EOF</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*dkM_SiAulEtl-rJH81_l3g.png" /><figcaption>Before Scaling</figcaption></figure><ul><li>Deployed nginx with zero replicas, Now Let’s scale the deployment and watch the Karpenter logs</li></ul><pre>## Scale deployment<br>kubectl scale deployment nginx --replicas 5<br>## To monitor the karpenter logs<br>kubectl logs -f -n karpenter -l app.kubernetes.io/name=karpenter -c controller</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*Cx2sRbTYiXP6A32P4giWpg.png" /><figcaption>After Scaling</figcaption></figure><ul><li>Based on your Requirements and Configuration, You can modify the provisioner and node templates</li></ul><p>4.1 Downscale deployment</p><ul><li>Next, proceed to downscale the deployment. In a brief duration, Karpenter will automatically terminate the empty nodes as part of the consolidation process.</li></ul><pre>## DownScale deployment<br>kubectl scale deployment nginx --replicas 0<br>## To monitor the karpenter logs<br>kubectl logs -f -n karpenter -l app.kubernetes.io/name=karpenter -c controller</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*nNo0_Ypcs1JMlsCb7OEQsg.png" /><figcaption>After Downscaling</figcaption></figure><ul><li>We have completed the demo of Karpenter in EKS</li></ul><h4>Conclusion</h4><ul><li>Karpenter provides enhanced scaling capabilities, enabling it to detect precise workload requirements and allocate the resources accordingly intelligently. This results in dynamic scaling that adapts to actual usage, allowing it to scale up as needed efficiently.</li></ul><h4>Reference</h4><ul><li><a href="https://karpenter.sh/docs/getting-started/getting-started-with-karpenter/">Karpenter Getting Started</a></li><li><a href="https://karpenter.sh/preview/concepts/provisioners/">Karpenter Provisioners</a></li><li><a href="https://karpenter.sh/preview/concepts/node-templates/">Karpenter Node Templates</a></li><li><a href="https://aws.amazon.com/blogs/aws/introducing-karpenter-an-open-source-high-performance-kubernetes-cluster-autoscaler/">AWS Note</a></li></ul><h3>In Plain English 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://plainenglish.io/"><strong><em>In Plain English</em></strong></a><em> community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://twitter.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a></li><li>Visit our other platforms: <a href="https://cofeed.app/"><strong>CoFeed</strong></a> | <a href="https://differ.blog/"><strong>Differ</strong></a></li><li>More content at <a href="https://plainenglish.io/"><strong>PlainEnglish.io</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c8e285733f6" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/how-to-setup-karpenter-in-the-eks-cluster-3c8e285733f6">How to Set Up Karpenter in the EKS Cluster</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to setup AWS Load Balancer controller in EKS Cluster]]></title>
            <link>https://aws.plainenglish.io/how-to-setup-aws-load-balancer-controller-in-eks-cluster-682a81c4e5ca?source=rss-3c7629da0cee------2</link>
            <guid isPermaLink="false">https://medium.com/p/682a81c4e5ca</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[elastic-load-balancer]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ingress]]></category>
            <dc:creator><![CDATA[Raino Raphel]]></dc:creator>
            <pubDate>Mon, 10 Oct 2022 05:10:42 GMT</pubDate>
            <atom:updated>2024-08-19T10:50:21.454Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Set Up AWS Load Balancer Controller in EKS Cluster</h3><h4>In this demo, we will deploy AWS Load Balancer Controller in the preconfigured EKS and configure Ingress routes.</h4><p>The AWS Load Balancer Controller manages AWS Elastic Load Balancers for a Kubernetes cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*ajsFVHvNYf2p68fC1ML3MA.png" /></figure><h4>What is the AWS Load Balancer controller?</h4><p>The AWS Load Balancer Controller manages AWS Elastic Load Balancers for a Kubernetes cluster. The controller provisions the following resources:</p><ul><li>It satisfies Kubernetes <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/">Ingress resources</a> by provisioning <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html">Application Load Balancers</a>.</li><li>It satisfies Kubernetes <a href="https://kubernetes.io/docs/concepts/services-networking/service/">Service resources</a> by provisioning <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html">Network Load Balancers</a>.</li></ul><p>Let’s Deploy…</p><h4><strong>Prerequisites</strong></h4><ul><li>AWS IAM access with admin privileges</li><li>AWS EKS cluster (1.22)</li><li>AWS CLI</li></ul><h4>Step 1: Setup permissions in IAM</h4><p>1.1 Create an IAM policy</p><ul><li>Download the below-given IAM policy for the AWS Load Balancer Controller.</li></ul><pre>curl -o iam_policy.json <a href="https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.4.3/docs/install/iam_policy.json">https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.4.3/docs/install/iam_policy.json</a></pre><ul><li>Create an IAM policy using the policy downloaded in the previous step.</li></ul><pre>aws iam create-policy \<br>    --policy-name AWSLoadBalancerControllerIAMPolicy \<br>    --policy-document file://iam_policy.json</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*36z7rWuewG5bd6BGlaK7og.png" /></figure><p>1.2 Create an IAM role</p><ul><li>We need to create an IAM role and attach the above-created IAM policy. You can use the AWS CLI to create the IAM role.</li><li>View your cluster’s OIDC provider URL.</li></ul><pre>aws eks describe-cluster --name my-cluster --query &quot;cluster.identity.oidc.issuer&quot; --output text</pre><ul><li>The example output is as follows.</li></ul><pre>oidc.eks.<em>region-code</em>.amazonaws.com/id/<em>EXAMPLED539D4633E53DE1B71EXAMPLE</em></pre><ul><li>Copy the following contents to your device. Replace <em>111122223333</em> with your account ID. Replace <em>region-code</em> with the AWS Region that your cluster is in. Replace <em>EXAMPLED539D4633E53DE1B71EXAMPLE</em> with the output returned in the previous step. After replacing the text, run the modified command to create the load-balancer-role-trust-policy.json file.</li></ul><pre>cat &gt;load-balancer-role-trust-policy.json &lt;&lt;EOF<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::111122223333:oidc-provider/oidc.eks.region-code.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE&quot;<br>            },<br>            &quot;Action&quot;: &quot;sts:AssumeRoleWithWebIdentity&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;StringEquals&quot;: {<br>                    &quot;oidc.eks.region-code.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE:aud&quot;: &quot;sts.amazonaws.com&quot;,<br>                    &quot;oidc.eks.region-code.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE:sub&quot;: &quot;system:serviceaccount:kube-system:aws-load-balancer-controller&quot;<br>                }<br>            }<br>        }<br>    ]<br>}<br>EOF</pre><ul><li>Create the IAM role.</li></ul><pre>aws iam create-role \<br>  --role-name AmazonEKSLoadBalancerControllerRole \<br>  --assume-role-policy-document file://&quot;load-balancer-role-trust-policy.json&quot;</pre><ul><li>Attach the required Amazon EKS-managed IAM policy to the IAM role. Replace <em>111122223333</em> with your account ID.</li></ul><pre>aws iam attach-role-policy \<br>  --policy-arn arn:aws:iam::111122223333:policy/AWSLoadBalancerControllerIAMPolicy \<br>  --role-name AmazonEKSLoadBalancerControllerRole</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*vNk2vrens7aiEV2_zvNQIg.png" /></figure><blockquote><em>💡</em> Serving microservices from AWS APIGW using ALB host header routing<strong>:</strong></blockquote><p><a href="https://differ.blog/inplainenglish/routing-to-multiple-backends-from-the-same-amazon-api-gateway-vpc-link-using-alb-host-based-routing-bd54d7">Serving Microservices from AWS APIGW using ALB host header routing</a></p><blockquote><em>👉</em> To read more such acrticles, <a href="https://differ.blog/"><strong>sign up for free on Differ</strong></a>.</blockquote><h4><strong>Step 2: Installing the AWS load balancer controller add-on</strong></h4><p>2.1 Add the Service Account</p><ul><li>Replace <em>111122223333</em> with your account ID. After replacing the text, run the modified command to create the aws-load-balancer-controller-service-account.yaml file.</li></ul><pre>cat &gt;aws-load-balancer-controller-service-account.yaml &lt;&lt;EOF<br>apiVersion: v1<br>kind: ServiceAccount<br>metadata:<br>  labels:<br>    app.kubernetes.io/component: controller<br>    app.kubernetes.io/name: aws-load-balancer-controller<br>  name: aws-load-balancer-controller<br>  namespace: kube-system<br>  annotations:<br>    eks.amazonaws.com/role-arn: arn:aws:iam::111122223333:role/AmazonEKSLoadBalancerControllerRole<br>EOF</pre><ul><li>Create the Kubernetes service account on your cluster. The Kubernetes service account named aws-load-balancer-controller is annotated with the IAM role that you created named <em>AmazonEKSLoadBalancerControllerRole</em>.</li><li>For the kubectl authentication you need the kubeconfig file, Run the update-kubeconfig command and confirm that it updates the config file under ~/.kube/config:</li></ul><pre>aws eks --region region-code update-kubeconfig --name cluster_name</pre><ul><li>Execute the below given kubectl command to configure the service account.</li></ul><pre>kubectl apply -f aws-load-balancer-controller-service-account.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*Su7oAM0GB642evL8cqYLcA.png" /></figure><p>2.2 Install the AWS Load Balancer Controller using <a href="https://docs.aws.amazon.com/eks/latest/userguide/helm.html">Helm V3</a></p><ul><li>Add the eks-charts repository.</li></ul><pre>helm repo add eks <a href="https://aws.github.io/eks-charts">https://aws.github.io/eks-charts</a></pre><ul><li>Run the update</li></ul><pre>helm repo update</pre><ul><li>Replace <em>my-cluster</em> with your own. The following command aws-load-balancer-controller is the Kubernetes service account you created in a previous step.</li></ul><pre>helm install aws-load-balancer-controller eks/aws-load-balancer-controller \<br>  -n kube-system \<br>  --set clusterName=my-cluster \<br>  --set serviceAccount.create=false \<br>  --set serviceAccount.name=aws-load-balancer-controller</pre><ul><li>Verify the deployment</li></ul><pre>kubectl get deployment -n kube-system aws-load-balancer-controller</pre><h4>Step 3: Configuration of ingress routes</h4><p>3.1 Deploy a sample application</p><ul><li>Deploy a sample application to configure ingress routes, Here we are deploying the Nginx image in the default namespace and exposing it as ClusterIP</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85a4b5f5364e019cfa4f8e4eb8bd01db/href">https://medium.com/media/85a4b5f5364e019cfa4f8e4eb8bd01db/href</a></iframe><ul><li>Execute the below given kubectl commands to deploy a sample application</li></ul><pre>kubectl apply -f nginx_deploy.yml</pre><pre>kubectl get deployment nginx</pre><p>3.2 Add ingress route</p><ul><li>To customize their behavior, you can add annotations to Kubernetes Ingress and Service objects.</li><li>Add two public subnets in the “alb.ingress.kubernetes.io/subnets”</li><li>We’ll use the “alb.ingress.kubernetes.io/actions.${action-name}” annotation to setup an ingress to redirect HTTP traffic into HTTPS</li><li>Here we’ll be using <a href="https://aws.amazon.com/certificate-manager/">AWS Certificate Manager (ACM )</a>for configuring HTTPS, You need to provide the ACM arn in the “alb.ingress.kubernetes.io/certificate-arn”</li><li>Replace the host value with your desired custom domain and service name example with SVC that you created during the sample application deployment.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/691e0c1d4b1d5697387e22cea100c9ba/href">https://medium.com/media/691e0c1d4b1d5697387e22cea100c9ba/href</a></iframe><pre>kubectl apply -f ingress.yml</pre><pre>Error from server (InternalError): error when creating &quot;ingress.yml&quot;: Internal error occurred: failed calling webhook &quot;vingress.elbv2.k8s.aws&quot;: Post &quot;<a href="https://aws-load-balancer-webhook-service.kube-system.svc/validate-networking-v1-ingress?timeout=10s">https://aws-load-balancer-webhook-service.kube-system.svc:443/validate-networking-v1-ingress?timeout=10s</a>&quot;: context deadline exceeded</pre><p>oops !! I think we have got a problem here</p><ul><li>The above <a href="https://github.com/kubernetes-sigs/aws-load-balancer-controller/issues/2462">error</a> indicates that the k8s control plane is not able to connect to the AWS-load-balancer-controller pods running on the worker nodes</li><li>For the AWS lb controller, We need to allow port 9443 for webhook access.</li><li>So add port 9443 in the worker nodes security group to allow access from the control plane to the webhook port of the AWS load balancer controller.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5g2rKnwlfZTGsJ9GEDr22Q.png" /></figure><ul><li>Let’s run the kubectl command again.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*kmGe1zucyFDszGuCzDESZQ.png" /></figure><ul><li>Now, let&#39;s check if the load balancer is created or not</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qm5V6NGBAlDgfnOzRQD2yg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wlwDzKjId9iN-CYi47cLMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*atYvw_oxvMO64S3Nse8iSg.png" /></figure><ul><li>The load balancer and rules are created, Now let’s try accessing the sample application using the hostname that we added in the ingress configuration.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GMIF0xdtc5WeOs5XGBNvKA.png" /></figure><ul><li>We can access the sample application(Nginx) using the hostname and thus verify that we have successfully configured the AWS load balancer controller and Ingress routes.</li></ul><h4>References</h4><ul><li><a href="https://docs.aws.amazon.com/eks/latest/userguide/aws-load-balancer-controller.html">https://docs.aws.amazon.com/eks/latest/userguide/aws-load-balancer-controller.html</a></li><li><a href="https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/">https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/</a></li><li><a href="https://github.com/kubernetes-sigs/aws-load-balancer-controller/issues/2462">https://github.com/kubernetes-sigs/aws-load-balancer-controller/issues/2462</a></li><li><a href="https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/guide/ingress/annotations.md">https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/guide/ingress/annotations.md</a></li></ul><h3>In Plain English 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://plainenglish.io/"><strong><em>In Plain English</em></strong></a><em> community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://twitter.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a></li><li>Visit our other platforms: <a href="https://cofeed.app/"><strong>CoFeed</strong></a> | <a href="https://differ.blog/"><strong>Differ</strong></a></li><li>More content at <a href="https://plainenglish.io/"><strong>PlainEnglish.io</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=682a81c4e5ca" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/how-to-setup-aws-load-balancer-controller-in-eks-cluster-682a81c4e5ca">How to setup AWS Load Balancer controller in EKS Cluster</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Integrate CloudFront Distribution with EC2 Origin | AWS]]></title>
            <link>https://aws.plainenglish.io/how-to-integrate-cloudfront-distribution-with-ec2-origin-aws-3badc2860faf?source=rss-3c7629da0cee------2</link>
            <guid isPermaLink="false">https://medium.com/p/3badc2860faf</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[cloudfront]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Raino Raphel]]></dc:creator>
            <pubDate>Fri, 01 Jul 2022 10:24:19 GMT</pubDate>
            <atom:updated>2023-12-19T01:25:37.079Z</atom:updated>
            <content:encoded><![CDATA[<h4>This post will guide you in integrating the EC2 DNS name with the CDN CloudFront.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*r7LWW37UxuxL45RkcP949w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*43NIQK3JRNPZ6mBj6NzBPA.png" /></figure><h4>What is CloudFront?</h4><p><a href="https://aws.amazon.com/cloudfront/">Amazon CloudFront</a> is a content delivery network (CDN) service built for high performance, security, and developer convenience. Amazon CloudFront speeds up the distribution of your static and dynamic web content, such as .html, .css, .js, and image files, to your users.</p><h4>How does CloudFront work?</h4><p>CloudFront delivers your content through a worldwide network of data centers called edge locations. When a user requests content that you’re serving with CloudFront, the request is routed to the edge location that provides the lowest latency (time delay), so that content is delivered with the best possible performance.</p><ul><li>If the content is already in the edge location with the lowest latency, CloudFront delivers it immediately.</li><li>Suppose the content is not in that edge location. In that case, CloudFront retrieves it from an origin that you’ve defined — such as an Amazon S3 bucket, a MediaPackage channel, or an HTTP server (for example, a web server) that you have identified as the source for the definitive version of your content.</li></ul><h3>Let’s Get Started…</h3><p>Prerequisites</p><ol><li>AWS Account with EC2 and CloudFront Access.</li><li>Preconfigured public EC2 Linux instance.</li></ol><p>In this demo, I will be using an EC2 Ubuntu instance for installing Nginx webserver and integrating the EC2 DNS name with CloudFront.</p><h4>Configuration in EC2</h4><p>Lets ssh into the server</p><pre>ssh -i &quot;key.pem&quot; ubuntu@EC2-IP</pre><p>Perform an update and install Nginx.</p><pre>sudo apt-get update -y <br>sudo apt-get upgrade -y <br>sudo apt-get install nginx net-tools -y</pre><p>Now check if Nginx is running on the instance.</p><pre>sudo service nginx status</pre><p>Run the Netstat command to check whether port 80 is up.</p><pre>netstat -tulnp</pre><p>Open port 80 in the security group and check whether the Nginx is accessible from the browser using the instance IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DMrV2CqYISvIVM7MWXu64w.png" /></figure><p>Now, Let&#39;s integrate with CloudFront.</p><h4>Creating CloudFront Distribution</h4><p>Navigate to CloudFront service from the AWS console.</p><p>Click on the create distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*qjYll1YN5_U_3JASXwLLRA.png" /></figure><p>Select protocol as HTTP since there is no SSL configured in the EC2 server and change the Origin path if needed.</p><p>CloudFront doesn’t allow IP as an origin so you need to copy the “Public IPv4 DNS” of the EC2 instance and paste it into the origin domain.</p><blockquote>“A public (external) IPv4 DNS hostname takes the form ec2-<em>public-ipv4-address</em>.compute-1.amazonaws.com for the us-east-1 Region, and ec2-<em>public-ipv4-address</em>.<em>region</em>.compute.amazonaws.com for other Regions. The Amazon DNS server resolves a public DNS hostname to the public IPv4 address of the instance outside the network of the instance, and to the private IPv4 address of the instance from within the network of the instance”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*97JnYbVmYROFgB119TxFSw.png" /></figure><p>Here I have selected Redirection from HTTP to HTTPS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*u9pH59VToJqtB6H5CQmgIA.png" /></figure><p>CloudFront provides a set of managed cache policies that you can attach to any of your distribution’s cache behaviors. With a managed cache policy, you don’t need to write or maintain your cache policy. The <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html#managed-cache-policies-list">managed policies</a> use settings that are optimized for specific use cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*7bWNOQrm3zK2FNjory7mtA.png" /></figure><p>In the settings part, You can use all edge locations for best performance or restrict it to specific regions.</p><p>If you have a domain and you need to access the CloudFront content. This can be done by adding a subdomain in the “Alternate domain name” and after the distribution creation, there will be a CloudFront Distribution URL generated, and add this as a CNAME record in your DNS. So the site would be available from your domain.</p><p>You can also integrate SSL using AWS ACM. ACM needs to be created in the us-east-1 region and choose the SSL certificate in the “Custom SSL certificate”.</p><p>Now click on the create distribution and wait for CloudFront to get deployed.</p><p>Once it is deployed, Copy the Distribution URL and then check whether you can access it from the browser with redirection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uaaN2lbd0D6ORkgFt4jhaA.png" /></figure><p>It worked…..</p><h4>Multiple Websites Nginx</h4><p>If you have configured multiple websites in a single Nginx server and they will be having different “server_name”, In that case, you need to forward the HOST header to the Nginx server.</p><p><strong>Editing the settings of an existing behavior</strong></p><ol><li>Open the <a href="https://console.aws.amazon.com/cloudfront/">CloudFront console</a>, and then choose your distribution.</li><li>Choose the <strong>Behaviors</strong> tab, and then choose the path to which you want to forward the Host header.</li><li>Choose <strong>Edit</strong>.</li><li>Under <strong>Cache key and origin requests</strong>, confirm that <strong>Legacy cache settings</strong> are selected. If it’s not set, then follow the steps in the preceding section to create a cache policy. If <strong>Legacy cache settings</strong> are selected, then complete the following:<br> For <strong>Headers</strong>, select <strong>Include the following headers</strong>.<br> From the <strong>Add header</strong> dropdown list, select <strong>Host</strong>.</li><li>Choose <strong>Save Changes</strong>.</li></ol><h4>CloudFront Invalidation</h4><p>Amazon CloudFront’s invalidation feature, which allows you to remove an object from the CloudFront cache before it expires, now supports the * wildcard character. You can add a * wildcard character at the end of an invalidation path to remove all objects that match this path.</p><p>Invalidation tab → Create Invalidation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*rK5pMSrkSMACkJ7KguKQvA.png" /></figure><p>Using the * wildcard character in the invalidation path is useful for many use cases. For example, if you’re doing a new deployment, you can now just use /* to invalidate the entire distribution.</p><h4>References:</h4><ul><li>Cloudfront: <a href="https://aws.amazon.com/cloudfront/">https://aws.amazon.com/cloudfront/</a></li><li>CloudFront Custom Origin: <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistS3AndCustomOrigins.html#concept_CustomOrigin">https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistS3AndCustomOrigins.html#concept_CustomOrigin</a></li><li>Pricing: <a href="https://aws.amazon.com/cloudfront/pricing/">https://aws.amazon.com/cloudfront/pricing/</a></li></ul><h3><a href="https://plainenglish.io/">PlainEnglish.io</a> 🚀</h3><p><em>Thank you for being a part of the In Plain English community! Before you go:</em></p><ul><li><em>Be sure to </em><strong><em>clap</em></strong><em> and </em><strong><em>follow</em></strong><em> the writer</em><strong>️</strong></li><li><em>Learn how you can also </em><a href="https://plainenglish.io/blog/how-to-write-for-in-plain-english"><strong><em>write for In Plain English</em></strong></a><em>️</em></li><li><em>Follow us: </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>X</em></strong></a><strong><em> | </em></strong><a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><strong><em> | </em></strong><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><strong><em> | </em></strong><a href="https://discord.gg/in-plain-english-709094664682340443"><strong><em>Discord</em></strong></a><strong><em> | </em></strong><a href="https://newsletter.plainenglish.io/"><strong><em>Newsletter</em></strong></a></li><li><em>Visit our other platforms: </em><a href="https://stackademic.com/"><strong><em>Stackademic</em></strong></a><strong><em> | </em></strong><a href="https://cofeed.app/"><strong><em>CoFeed</em></strong></a><strong><em> | </em></strong><a href="https://venturemagazine.net/"><strong><em>Venture</em></strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3badc2860faf" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/how-to-integrate-cloudfront-distribution-with-ec2-origin-aws-3badc2860faf">How to Integrate CloudFront Distribution with EC2 Origin | AWS</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kaniko | Jenkins | Kubernetes | How To Build Docker Image Using Kaniko]]></title>
            <link>https://rainoraphel.medium.com/kaniko-jenkins-kubernetes-how-to-build-docker-image-using-kaniko-2d6712e0458f?source=rss-3c7629da0cee------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d6712e0458f</guid>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kaniko]]></category>
            <dc:creator><![CDATA[Raino Raphel]]></dc:creator>
            <pubDate>Sun, 12 Jun 2022 06:46:32 GMT</pubDate>
            <atom:updated>2022-06-12T06:49:30.317Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>In this demo we will be using Kaniko for building container images and using Jenkins we will push to AWS ECR (Container Registry)</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*nJACeVQHoVi7QYcc6Eqk3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*9fp7mhHPrefdhcDUDeN7PQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*_0MGzFDyB5dYw3T3nRHwqw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*oGzWo-p9tUbA8FiUouMZ0Q.png" /></figure><h4><strong><em>What is Kaniko?</em></strong></h4><p><a href="https://github.com/GoogleContainerTools/kaniko">Kaniko</a><a href="https://github.com/GoogleContainerTools/kaniko"> </a>is a tool to build container images from a Dockerfile. Kaniko doesn’t depend on a Docker daemon and executes each command within a Dockerfile completely in userspace. This enables building container images in environments that can’t easily or securely run a Docker daemon, such as a standard Kubernetes cluster.</p><h4><em>Why Kaniko?</em></h4><p>Building images from a standard Dockerfile typically relies upon interactive access to a Docker daemon, which requires root access on your machine to run. This can make it difficult to build container images in environments that can’t easily or securely expose their Docker daemons, such as Kubernetes clusters</p><h4><em>How does Kaniko work?</em></h4><ol><li>The Kaniko executor image is responsible for building an image from a Dockerfile and pushing it to a registry.</li><li>The Kaniko debug image is recommended (gcr.io/kaniko-project/executor:debug) because it has a shell, and a shell is required for an image to be used with CI/CD.</li><li>Kaniko accepts three arguments. A Dockerfile, build context, and a remote Docker registry.</li><li>Kaniko extracts the filesystem of the base image (the FROM image in the Dockerfile)</li><li>Then, execute the commands in the Dockerfile, snapshotting the filesystem in userspace after each.</li><li>After each command, they append a layer of changed files to the base image (if there are any) and update image metadata.</li><li>Finally, it pushes the image to the given registry.</li></ol><h4><em>Kaniko Build Contexts</em></h4><p>You will need to store your build context in a place that Kaniko can access. Right now, Kaniko supports these storage solutions:</p><ul><li>GCS Bucket</li><li>S3 Bucket</li><li>Azure Blob Storage</li><li>Local Directory</li><li>Local Tar</li><li>Standard Input</li><li>Git Repository</li></ul><h4><strong><em>Let’s Get Started….</em></strong></h4><p>Prerequisites</p><ol><li>Kubernetes</li><li>Jenkins deployed in a Kubernetes cluster</li><li>AWS ECR Repository access</li></ol><p>Create an ECR repository. Here I have already created an ECR repo named “demo”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fa2TAj9ubFcKvpMzb3XVwg.png" /></figure><p>To access the ECR repo from Kubernetes, you need to add a valid AWS ACCESS_KEY, SECRET_KEY, or AWS role to the desired Kubernetes cluster.</p><p>For this demo, I have used <a href="https://k3s.io/">k3s.io</a> for setting up a Kubernetes cluster in EC2 and attached an IAM role with ECR permission for pushing images to ECR.</p><p>ECR Permission Policy:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;VisualEditor0&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;ecr:GetAuthorizationToken&quot;,<br>                &quot;ecr:InitiateLayerUpload&quot;,<br>                &quot;ecr:UploadLayerPart&quot;,<br>                &quot;ecr:CompleteLayerUpload&quot;,<br>                &quot;ecr:PutImage&quot;,<br>                &quot;ecr:BatchGetImage&quot;,<br>                &quot;ecr:BatchCheckLayerAvailability&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}</pre><p>Deployed Jenkins in Kubernetes cluster using <a href="https://github.com/jenkinsci/helm-charts">Jenkinsci</a> helm chart.</p><p>When using instance roles we no longer need a secret, but we still need to configure Kaniko to authenticate to AWS, by using a config.json containing just { “credsStore”: “ecr-login” }, mounted in /kaniko/.docker/.</p><p>Apply the given below configmap for Kaniko ECR configuration.</p><pre>kubectl apply -f configmap.yml</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9f1971a991c8cd06cb6a211d78c4ca0/href">https://medium.com/media/e9f1971a991c8cd06cb6a211d78c4ca0/href</a></iframe><p>Now, Let&#39;s create the Jenkins pipeline.</p><p>For creating a pipeline Jenkinsfile is required. A Jenkinsfile is a text file that contains the definition of a Jenkins Pipeline and is checked into source control.</p><p>Jenkinsfile:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bde25bfebe44fae78270c8c21a7a0ef9/href">https://medium.com/media/bde25bfebe44fae78270c8c21a7a0ef9/href</a></iframe><p>Here, “ECR_REPO” is the ECRrepo name that I have added as a variable in the Jenkins system and “BUILD_ID” is used as tagging container images.</p><p>To add environment variable in Jenkins.</p><p>Manage Jenkins →Configure System → Global properties → Check Environment variables box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h7NEYxsQ9D7RcEGNEnG5BA.png" /></figure><p>Like this, you can add desired environment variables in Jenkins.</p><p>To create a pipeline:</p><p>New Item → Enter the job name →Choose Pipeline → OK</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V0UAXmTjWRQYCLkNJL9pQw.png" /></figure><p>Then in the pipeline section configure SCM. Configure credentials to authenticate your repository using SSH/HTTPS authentication and choose that credential from the drop-down. Add Jenkinsfile path in script path and apply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bKz36Xuf_bKGEbv96N1fSg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mNpvgyb9p9LbLfaEEo8frg.png" /></figure><p>Now, Let’s build a pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K3IK_7MO2tjA2KxElJSrQg.png" /></figure><p>Build Success!! and now you can check the container images in the ECR console. Later you can add the Kubernetes deployment stage in the pipeline and deploy it to a Kubernetes cluster.</p><p><a href="https://github.com/raino007/kaniko-jenkins">GitHub - raino007/kaniko-jenkins</a></p><h4><strong>References</strong></h4><p>Kaniko: <a href="https://github.com/GoogleContainerTools/kaniko">https://github.com/GoogleContainerTools/kaniko</a></p><p>Jenkins Helm Chart: <a href="https://github.com/jenkinsci/helm-charts">https://github.com/jenkinsci/helm-charts</a></p><p>k3s: <a href="https://k3s.io/">https://k3s.io/</a></p><p>AWS ECR: <a href="https://aws.amazon.com/ecr/">https://aws.amazon.com/ecr/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d6712e0458f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>