<?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 DLMade on Medium]]></title>
        <description><![CDATA[Stories by DLMade on Medium]]></description>
        <link>https://medium.com/@dlmade?source=rss-3036f08fa8b6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*gi4Os5SaQyAuviHaqsjECQ.jpeg</url>
            <title>Stories by DLMade on Medium</title>
            <link>https://medium.com/@dlmade?source=rss-3036f08fa8b6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 21:49:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dlmade/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[CI/CD with Github action and AWS EKS]]></title>
            <link>https://codeburst.io/ci-cd-with-github-action-and-aws-eks-5fd9714010cd?source=rss-3036f08fa8b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fd9714010cd</guid>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[DLMade]]></dc:creator>
            <pubDate>Wed, 13 Sep 2023 17:44:55 GMT</pubDate>
            <atom:updated>2023-09-13T17:44:55.229Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of software engineering, CI stands for Continuous Integration, and CD stands for Continuous Delivery or Deployment. In today’s fast-paced software development landscape, it’s crucial to streamline our software deployment process. To do this, we need automation at every stage, from building and testing to deploying the application. This is where CI/CD comes in handy, automating repetitive tasks and allowing us to save time on deployments and testing, enabling us to focus on core development.</p><p>In this blog, we’ll guide you through creating a GitHub action that accomplishes several key tasks: building a Docker image, pushing it to the Amazon Elastic Container Registry (ECR), and ultimately deploying it to an Amazon Elastic Kubernetes Service (EKS) cluster. We’ll break down each step in this tutorial. It’s worth noting that our primary focus in this blog will be on CI/CD processes, so we won’t dive too deeply into the code or Docker aspects.</p><p><strong>Prerequisites</strong></p><ol><li>AWS account and cli</li><li>Docker</li><li>Eksctl</li><li>GitHub Account</li></ol><p>Let’s begin by setting up all the necessary resources:</p><p>1. Create an ECR repository.</p><ul><li>Go to the AWS console and search for “Elastic Container Registry”.</li><li>Enter your desired repository name and click “Create Repository”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Kp9law8GJ6hpDkICrTfxcA.png" /></figure><p>2. Create an IAM user</p><ul><li>In the AWS console, search for “IAM Users.”</li><li>Click “Create User.”</li><li>Provide a username and click “Next.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*EHZl62mVfvaLCbagxvNh2A.png" /></figure><ul><li>For this demo, we’ll attach the administrator access policy (Note: This is not recommended for production use; policies should be customized to specific needs).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*TndPTFVTaMcL-PLY96CTZg.png" /></figure><ul><li>Review and create a user.</li></ul><p>3. Generate the access and secret key of the user that we created.</p><ul><li>Open the user that we created and click “create access key”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*NvIRh_nN3Zq8VTDhG5rA6w.png" /></figure><ul><li>Select “CLI” as the Use case and click next.</li><li>Click “Create access key”.</li><li>Download the CSV file containing the access key and secret key for future reference. These keys will be needed when working with GitHub.</li></ul><p>4. Setting Up the EKS cluster.</p><ul><li>Make sure you have the AWS CLI installed on your device. If not, you can install it by visiting <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">this page</a>.</li><li>Configure your AWS CLI by following the instructions <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-methods">here</a>.</li><li>Next, you’ll need to install Eksctl to create the EKS cluster. You can find the installation steps <a href="https://eksctl.io/introduction/#installation">here</a>.</li><li>Once everything is set up, you can create your EKS cluster using the following command:</li></ul><pre>eksctl create cluster - name cluster-name \ <br> - region region-name \<br> - node-type instance-type \<br> - nodes-min 2 \<br> - nodes-max 2</pre><ul><li>For example</li></ul><pre>eksctl create cluster - name Kubernetes-demo \<br> - region us-east-1 \<br> - node-type t3.micro</pre><p>Creating the cluster will take approximately 10–15 minutes.</p><p>With these prerequisites in place, we’re ready to proceed with setting up our CI/CD code.</p><p><strong>Code</strong></p><p>You can review the code repository we’ll use for this tutorial at this link: <a href="https://github.com/dlmade/flask-kubernetes-deploy">GitHub Repository</a>.</p><p>Now, let’s dig into setting up GitHub Actions for our CI/CD pipeline. These actions will handle tasks such as creating a Docker image, pushing it to Amazon Elastic Container Registry (ECR), and finally deploying it to Amazon Elastic Kubernetes Service (EKS) using the manifests we’ve prepared.</p><p>To get started with GitHub Actions, we’ve organized our project’s structure as follows:</p><p><strong>GitHub actions yaml</strong></p><ul><li>We’ve created a folder named .github/workflows within our project directory.</li><li>Inside this folder, you’ll find the deploy.yaml file, which contains the configuration for our GitHub Actions.</li><li>This deploy.yaml file is where we define how our CI/CD pipeline will function. It orchestrates the entire process, from building the Docker image to deploying the application on EKS.</li></ul><pre>name: Deploy to ECR<br><br>on:<br> <br>  push:<br>    branches: [ master ]<br><br>env:<br>  ECR_REPOSITORY: flask-app<br>  EKS_CLUSTER_NAME: Kubernetes-demo <br>  AWS_REGION: us-east-1<br><br>jobs:<br>  <br>  build:<br>    <br>    name: Deployment<br>    runs-on: ubuntu-latest<br><br>    steps:<br><br>    - name: Set short git commit SHA<br>      id: commit<br>      uses: prompt/actions-commit-hash@v2<br><br>    - name: Check out code<br>      uses: actions/checkout@v2<br>    <br>    - name: Configure AWS credentials<br>      uses: aws-actions/configure-aws-credentials@v1<br>      with:<br>        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br>        aws-region: ${{env.AWS_REGION}}<br><br>    - name: Login to Amazon ECR<br>      id: login-ecr<br>      uses: aws-actions/amazon-ecr-login@v1<br><br>    - name: Build, tag, and push image to Amazon ECR<br>      env:<br>        ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}        <br>        IMAGE_TAG: ${{ steps.commit.outputs.short }}<br>      run: |<br>        docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f docker/Dockerfile .<br>        docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG<br><br>    - name: Update kube config<br>      run: aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --region $AWS_REGION<br><br>    - name: Deploy to EKS<br>      env:<br>        ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}        <br>        IMAGE_TAG: ${{ steps.commit.outputs.short }}<br>      run: |<br>        sed -i.bak &quot;s|DOCKER_IMAGE|$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG|g&quot; manifests/hello-app-deployment.yaml &amp;&amp; \<br>        kubectl apply -f manifests/hello-app-deployment.yaml<br>        kubectl apply -f manifests/hello-app-service.yaml</pre><p>Let’s dive into the details of the GitHub Actions YAML file provided:</p><ul><li><strong>Trigger</strong>: This GitHub Action is triggered when someone pushes to the “master” branch (lines 3–6).</li><li><strong>Environment Variables</strong>: Defines environment variables like the ECR repository name, EKS cluster name, and AWS region (lines 8–11).</li><li><strong>Jobs</strong>: The “build” job is specified, which runs on the latest Ubuntu environment (lines 13 onwards).</li><li><strong>Steps</strong>: The steps within the job are as follows:</li><li><strong>Set short git commit SHA:</strong> This step retrieves the commit hash, which is used to tag the Docker image (lines 23–24).</li><li><strong>Check out code</strong>: The action checks out the code from the &quot;master&quot; branch into the CI/CD Ubuntu environment (lines 26-27).</li><li><strong>Configure AWS credentials</strong>: Configure AWS credentials using secrets from GitHub (lines 29–34). This step will fetch secrets from Git Hub. We will see how to set secrets when we will create a GitHub repo.</li><li><strong>Login to Amazon ECR</strong>: Log in to the Amazon Elastic Container Registry to push the Docker image (lines 36–38).</li><li><strong>Build, tag, and push the image to Amazon ECR</strong>: This step builds the Docker image, tags it, and pushes it to ECR (lines 40–46).</li><li><strong>Update kube config</strong>: Fetches the Kubernetes configuration to interact with the EKS cluster (lines 48–49).</li><li><strong>Deploy to EKS</strong>: This part of the script applies Kubernetes manifests to deploy the application in EKS. It replaces a placeholder (DOCKER_IMAGE) in the manifest with the actual image location (lines 51-58).</li></ul><p><strong>Github</strong></p><p>Here are the steps to set up your GitHub repository, configure AWS secrets, and deploy your application:</p><ol><li><strong>GitHub Repository Setup</strong>:</li></ol><p>Begin by creating a new GitHub repository on <a href="https://github.com/">github.com</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*aMgMux-D2zjv0Z9JPLOQmw.png" /></figure><p>2. <strong>Configuring AWS Secrets</strong>:</p><ul><li>To enable your CI/CD pipeline to access AWS resources (ECR registry and EKS cluster), you need to add your AWS secrets. These secrets are AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.</li><li>Navigate to your GitHub repository’s settings.</li><li>Find the “Secrets and Variables” section, Inside it, click on actions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Un1K2i7zZ3x1wAsrxGw3HA.png" /></figure><p>2.1. <strong>Adding New Repository Secrets</strong>:</p><ul><li>Click on “New Repository Secret.”</li><li>Provide the following secrets:</li><li>AWS_ACCESS_KEY_ID</li><li>AWS_SECRET_ACCESS_KEY</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*uNQZ9EajFN2rHvn_QTpVVw.png" /></figure><p>Once you’ve added the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY secrets, your repository settings should look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*mgsEVs_8LnTaAsmKY_Mm7g.png" /></figure><p>3. <strong>Pushing Your Code:</strong></p><p>Now, we can push your code to the GitHub repository. As soon as we push our code, GitHub Actions will automatically detect it and start running your defined actions.</p><p>4. <strong>Monitor GitHub Actions:</strong></p><p>You can monitor the progress of your CI/CD pipeline by visiting the “GitHub Actions” tab in your repository. Here, you’ll see the status of each step in your workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ycGBwIvzAh5mwWErHPiEag.png" /></figure><p>5. <strong>Accessing Your Application:</strong></p><ul><li>After your CI/CD pipeline is successfully completed, you can go to the AWS console.</li><li>Search for the load balancer associated with your application to find the URL or DNS name.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7uAIH2rDKmStZOo6k37tFw.png" /></figure><ul><li>To access your app, add port 8080 to the URL (e.g., http://your-app-url:8080) and you&#39;ll be able to use your deployed application.</li></ul><p>These steps will help you set up your GitHub repository, securely configure AWS secrets, and deploy your application using GitHub Actions.</p><p><strong>Cleaning Up All resources</strong></p><p>When you need to clean up all resources within your Kubernetes environment, you can use the following kubectl commands to safely remove deployments, pods, and services.</p><p>1. <strong>Delete All Deployments</strong>.</p><ul><li>To delete all deployments, you can use the following command.</li></ul><pre>kubectl delete deployments - all</pre><p>This command ensures that no active deployment instances in the default namespace are left in your cluster.</p><p>2. <strong>Delete All Pods</strong>.</p><ul><li>To delete all pods, which can be either manually created or created by deployments, and hold your app containers, you can use this command:</li></ul><pre>kubectl delete pods — all</pre><p>This command ensures that no active pod instances in the default namespace are left in our cluster.</p><p>3. <strong>Delete All Services</strong>.</p><ul><li>To delete services that expose our applications to the network, you can use this command.</li></ul><pre>kubectl delete services — all</pre><p>4. <strong>Deleting an Amazon EKS Cluster</strong></p><ul><li>To remove all the resources associated with the Amazon EKS cluster created through eksctl, including instances, networking, and other resources, you can use the following command.</li></ul><pre>eksctl delete cluster — name {your cluster name} — region {your region name}</pre><p>For example</p><pre>eksctl delete cluster — name Kubernetes-demo — region us-east-1</pre><p>These commands will help you safely clean up and remove resources from your Kubernetes environment and Amazon EKS cluster when you’re finished using them.</p><p>Thank you for following along with this guide. We hope it has been helpful in your journey toward a well-organized and efficient CI/CD environment. If you have any questions or need further assistance, please don’t hesitate to reach out.</p><p><strong>Happy coding! </strong>😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fd9714010cd" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/ci-cd-with-github-action-and-aws-eks-5fd9714010cd">CI/CD with Github action and AWS EKS</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Trip planner: End-to-end Gpt project with Flask and Lambda]]></title>
            <link>https://medium.com/swlh/trip-planner-end-to-end-gpt-project-with-flask-and-lambda-6ff756053e3f?source=rss-3036f08fa8b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ff756053e3f</guid>
            <category><![CDATA[portfolio]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[freelancing]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[DLMade]]></dc:creator>
            <pubDate>Sun, 09 Jul 2023 07:49:51 GMT</pubDate>
            <atom:updated>2023-07-09T07:49:51.368Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfW5vdUkWs6riuSuPIMDKQ.png" /></figure><p>Hi Everyone, have you ever come across a situation where a potential client or employer asked you to showcase your online portfolio in order to get a gig and you did not have one? I can relate.</p><p>As a freelancer, I’ve connected with many clients. However, it’s not easy to gain their trust without an online portfolio of past work. That’s why I decided to create a portfolio and deploy it on the cloud. One major problem with cloud deployment is the cost incurred. I was determined not to spend an excessive amount of money on my portfolio demo website. Consequently, I began exploring an alternative approach that could offer me free-of-charge cloud environments.</p><p>Finally, I figured out that if somehow I could manage to deploy my website on AWS lambda, it will be an incredibly cost-effective solution as AWS provides a certain amount of free requests and computing resources. These make it an ideal choice for my portfolio website. Since this website is primarily intended for client demos, it is unlikely to receive a significant amount of traffic.</p><p>So, Now I decided to create a small application with the help of OpenAI API using Python Flask and deploy it on AWS Lambda to showcase as my portfolio. In this blog, we will explore the entire process step by step in detail. Buckle up and let’s take a walkthrough.</p><h4>Requirement</h4><ul><li>AWS account</li><li>Python</li></ul><p>In this tutorial, our main focus will be on the backend and deployment aspects, rather than the user interface side.</p><h3>Development</h3><p>Here is the <a href="https://github.com/dlmade/trip-planner-blog">Github link</a> to the Flask application for travel itinerary planners.</p><p>Let’s begin with the Python code which will do the magic when we deploy the code on a cloud.</p><pre>##https://github.com/dlmade/trip-planner-blog/blob/main/app.py<br>from flask import Flask, render_template, request, jsonify<br>from chat_completions import generate_response<br><br>app = Flask(__name__,<br>            static_url_path=&#39;&#39;, <br>            static_folder=&#39;templates&#39;,)<br><br>@app.route(&#39;/&#39;)<br>def index():<br>    return render_template(&#39;index.html&#39;)<br><br><br>@app.route(&#39;/get_response&#39;, methods=[&#39;POST&#39;])<br>def get_response():<br>    user_query = request.form[&#39;query&#39;]<br>    response = generate_response(user_query)<br>    return jsonify({&#39;response&#39;: response})<br><br><br>if __name__ == &#39;__main__&#39;:<br>    app.run(debug=True)</pre><p>This is the Flask code where we initially render the index.html page. That will ask users about their destination place and days to create the travel itinerary.</p><pre>## https://github.com/dlmade/trip-planner-blog/blob/main/chat_completions.py<br>import openai<br><br># Replace the code below with your api key<br>openai.api_key = &#39;YOUR_OPENAI_KEY&#39;<br><br>def generate_response(query):<br>    # Your logic to generate response using OpenAI Chat Completions API<br>    # Replace the code below with your implementation<br><br>    temperature = 0.2<br>    top_p = 1<br>    engine = &#39;gpt-3.5-turbo&#39;<br><br>    messages=[<br>    {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: &quot;You are a travel iternary planner. You will get the travel destination with the days. Need to create a iternary out of it. If you not able to understand the destination you can give error meesage.&quot;},<br>    {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: query}]<br>    response = openai.ChatCompletion.create(<br>    model=engine,<br>    messages = messages,<br>    # prompt=prompt,<br>    temperature=temperature,<br>    # max_tokens=min(4096-estimated_prompt_tokens, max_tokens),<br>    top_p=top_p<br>    )<br><br>    response = response[&#39;choices&#39;][0][&#39;message&#39;][&#39;content&#39;].strip()<br>        <br>    return response</pre><p>After we get the user input we call a get_response function which will generate a travel plan with the help of the Openai. Make sure to replace YOUR_OPENAI_KEY before running the code.</p><p>These are the main two files which are needed to be changed as per our requirement. The GitHub <a href="https://github.com/dlmade/trip-planner-blog#run-the-project-in-local">readme file</a> contains detailed instructions on how to run the code locally.</p><h3><strong>Deployment</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*O2wHyCQ4uRGdBOzAJlMmVw.png" /></figure><h4>Lambda</h4><ol><li><strong>Find Lambda in AWS console.</strong></li></ol><p>Once we have the local trip planner app running, we can deploy it. For that first, we need to open the AWS console and search for the lambda and click on it as per the below reference image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*NWejuobvRCUXnsqv4Rti9Q.png" /><figcaption>Aws console</figcaption></figure><p>2. <strong>Create a lambda resource.</strong></p><p>Once we click on lambda we can see the below-like screen. Now we have to hit the create function button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*k5av-O30UIXXHy7pojie2w.png" /><figcaption>Lambda</figcaption></figure><p>It will ask for basic details. We only have to provide the name and runtime of the lambda and leave the other value default as per the following image and create the function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*9Yt13GH7F08GenXIFR7Xtw.png" /></figure><p>Now we have our Lambda resource ready. But we will require the code to upload which is in our GitHub repo.</p><p>3. <strong>Upload the code in AWS Lambda.</strong></p><p>Let’s jump back to the code. <a href="https://github.com/dlmade/trip-planner-blog#run-the-project-in-lambda">GitHub Readme</a> contains steps to create a zip. After zip creation, we can upload the zip file to lambda as per shown in the below image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5cxv2yjl3DELKZ_ahx5KHQ.png" /></figure><p>4. <strong>Modify the configurations of AWS Lambda.</strong></p><p>We have a handler file in our zip which will be the main entry point for the lambda. So we need to point the lambda to our handler file. For that, we can click on the edit button and write “handler.lambda_handler” in the Handler textbox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*KXlutgBLd3mWeuwBBx6uTA.png" /></figure><p>Also, make sure that we increase the timing of the lambda timeout to 15 minutes. As lambda have a 3 seconds default timeout which can break our website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d_IodZorNCKl_uKHw2imcg.png" /></figure><p>We have done the work on the lambda aspects. Now the question is how can we interact with Lambda from our browser? So for that, we will create the API Gateway.</p><h4><strong>API Gateway</strong></h4><ol><li><strong>Find API Gateway.</strong></li></ol><p>For Create an API Gateway open the AWS console and search for “API gateway” then click on the first option. Now we will get to see the below-like screen, Click on the build button in the REST API box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*uSOtpGUqDmrKpT5XXR2_kw.png" /></figure><p>2. <strong>Create an API Gateway.</strong></p><p>It will ask for the following details where we will provide the API name and leave other values default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*GK2xIJL3gNKzoV8cuqUQcw.png" /></figure><p>We have an API gateway resource created. Now we have to create the resources inside an API gateway to define the routes of the website.</p><p>3. <strong>Create Resources and Methods in an API Gateway</strong></p><p>We will start with creating a method of Any. We can achieve this by following steps. We can also view below-given reference image for a better understanding.</p><blockquote>1. Click on Actions.</blockquote><blockquote>2. Select Create method.</blockquote><blockquote>3. Select the ANY from given choice.</blockquote><p>We can see the following screen where we need to enter the following details.</p><ul><li>integration type: Lambda function</li><li>proxy integration: Make it selected</li><li>Lambda Region: We can select the region where we created lambda.</li><li>Lambda function: Either enter the name of the function or arn of the function.</li></ul><p>Click on save which will create the main route where the initial request comes in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*RBZg-wGyRH5gYhq5kDYbLQ.png" /></figure><p>We will require one more resource which can route all the proxies.</p><p>To create a proxy resource follow the following steps.</p><blockquote>1. Click on ANY method that we recently created.</blockquote><blockquote>2. Press the actions button and select Create Resource.</blockquote><blockquote>3. Now select “<strong>Configure as </strong><a href="https://docs.aws.amazon.com/console/apigateway/proxy-resource"><strong>proxy resource</strong></a><strong>” and “Enable API Gateway CORS” and </strong>then hit create resource.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*c8_m4fmTp8XwmdC2ZOk-VA.png" /></figure><blockquote>4. It will create the ANY method by default. So we need to provide details for ANY method. Where we provide a Lambda name and hit the SAVE button.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nF3ymC27FeXgYcQfJD7kGQ.png" /></figure><p>4. <strong>Deploy API</strong></p><p>We have created all the routes which were required. Now we can deploy the API. For that first click on “/” Resource then hit the Actions and select deploy API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*HYRIzHhPFnPudG4puhX4Yw.png" /></figure><p>We need to create a deployment stage before deploying API. We will give “dev” as the name of the stage and hit Deploy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*kXPJvrI2dMZepc0ROwMtcw.png" /></figure><p>Finally, we have our URL where we can interact with the web application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ahmY6xdshMjwRyWAqM4gIw.png" /></figure><h4>Magic✨</h4><p>As soon as we hit that URL we can see our live portfolio ready to showcase the potential clients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iu3-mC-tHms-XtjvDr8IWw.png" /></figure><p><strong>If you like this post, HIT Buy me a coffee! Thanks for reading.</strong>😊</p><figure><a href="https://www.payumoney.com/paybypayumoney/#/147695053B73CAB82672E715A52F9AA5"><img alt="" src="https://cdn-images-1.medium.com/max/417/1*-aubdwm03fkW39OOplP4ag.png" /></a></figure><p>Your every small contribution will encourage me to create more content like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ff756053e3f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/trip-planner-end-to-end-gpt-project-with-flask-and-lambda-6ff756053e3f">Trip planner: End-to-end Gpt project with Flask and Lambda</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Autoscale on AWS with EC2, Python, Flask, and Nginx Part3]]></title>
            <link>https://medium.com/analytics-vidhya/autoscale-on-aws-with-ec2-python-flask-and-nginx-part3-9ab0abeeeea6?source=rss-3036f08fa8b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ab0abeeeea6</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[scaling]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[ec2]]></category>
            <dc:creator><![CDATA[DLMade]]></dc:creator>
            <pubDate>Sun, 21 Nov 2021 11:45:07 GMT</pubDate>
            <atom:updated>2021-11-30T06:40:29.585Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*XDgM41VG_gP0WCs_.jpg" /><figcaption>Image generated using <a href="https://imgflip.com/i/5uvg9h">Imgflip</a></figcaption></figure><p>Previously, we <a href="https://dlmade.medium.com/autoscale-on-aws-with-ec2-python-flask-and-nginx-part1-240c6bbf5c35">set up an EC2 server</a>, accessed it via Putty, <a href="https://dlmade.medium.com/autoscale-on-aws-with-ec2-python-flask-and-nginx-part2-f5640e406105">created a Flask server</a> with waitress WSGI, also created ubuntu service, and configured an Nginx server. Now, we are going to create an auto-scale group.</p><p>Before creating an autoscale group we will require an AMI, Target group, Launch templates. So let’s start with creating an AMI.</p><h3><strong>AMI</strong></h3><p>An AMI(Amazon Machine Image) provides the information required to launch an instance. It will basically store every configuration that we have done in our instance from which we are going to create AMI.</p><ul><li>Go to EC2 instances and select the instance for which you want to create an image. Then click on actions → Images and templates <strong>→</strong> Create image.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*saU_ryBJKv98ZsQEZ9ENSw.png" /></figure><ul><li>Give image name and description and leave other things as defaults.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*DbjxZ-gzvojCPaTRMpldpg.png" /></figure><ul><li>Our image is created. Now let’s create Launch templates.</li></ul><h3>Launch Template</h3><ul><li>The launch template will tell our auto scale group to launch every new instance with AMI that we have created earlier with the given set of instructions like Instance type and Network setting.</li><li>On the left of the EC2 dashboard side, you can see Launch templates click on it. Give template name and version as per your choice.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*nyVq66LEcqCpB3sN5ecq_Q.png" /></figure><ul><li>Go to the AMI section. Where you have to select the image we have created earlier.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*PeVWwzWUwcedrZ3T-VmPgw.png" /></figure><ul><li>To select the image you can simply type your image name in the search box and your image will come in the MY AMIs section.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*EwfjvQHmJvqkFg0Yv1rrxw.png" /></figure><ul><li>Now scroll down where you will see instance type and key pair section. Select instance type and key pair as per your choice. Whenever a new instance will be created it will use this instance type and key pair file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*11wjmauCFB_SOjYhvZ0fqg.png" /></figure><ul><li>In the Network setting please make sure you will select the security groups that we create in the first part. This will enable ssh and HTTP rules without this you will not able to access your instance via the internet or SSH(Like putty).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*nNC_k09hOOG0yztO-dlJzA.png" /></figure><ul><li>Keep all things as default and click on Create launch template. Our launch template is ready so let’s move on Target group. which will help load balancer to route traffic to all instances which are created in the autoscale group.</li></ul><h3>Target group</h3><ul><li>You can find the Target group in the load balancing section in the ec2 dashboard. Here we will select target type as an instance because we are creating this for ec2. Give Target group name as per your choice and click Next.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*y6WMDtOaNUokWbLiN5QyCw.png" /></figure><ul><li>Select the ec2 instance you created first part. Now click on include as pending below. It will register our instance in this target group.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*AQPnKsjJvHdOJYbGzI09KA.png" /></figure><ul><li>Scroll down a bit and you will see an instance is registered in the target group. Click on create target group. Till here we have created a Launch template, AMI, And target group now we have all things which are required for the Autoscale group.</li></ul><h3><strong>Auto Scaling Group</strong></h3><ul><li>You can find the Autoscaling group in the auto-scaling section at bottom of the left side in the EC2 dashboard. Click on the auto-scaling group then click Create auto-scaling group.</li><li>First, enter an Autoscaling group name of your choice. Select the launch template that we have created earlier and ensure the version of the launch template is the latest.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*-PVe4maGwbBGCS5zt0GCRg.png" /></figure><ul><li>Select the VPC same that you have used at the time of your instance creation. Select all Availability zones.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*Al_nQEN4QIyt_5fhXK3c0g.png" /></figure><ul><li>Now we will create our load balancer and include our target group. Select the “Attach new load balancer” radio button and load balancer type as “Application load balancer” as we are going to control HTTP and HTTPS traffic.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*0ZgYCTVR1ZO-UkErm06-9Q.png" /></figure><ul><li><strong>Load Balancer</strong></li></ul><ol><li>Create load balancer name as per your choice.</li><li>Select load balancer scheme ad internet-facing as we want our customers to access the app.</li><li>Select the VPC and availability zones same as per the instance we have created earlier.</li><li>In listener and routing select the target group which we have created earlier.</li><li>Click Next.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*F6XlITQNjitFk8RM87dHtg.png" /></figure><ul><li>In group size, we can select the capacity of the server which is required as per our requirements. For demo purposes, I will keep desired capacity as 1, Minimum capacity as 1, and maximum capacity as 2.</li><li>Scaling Policies is a metric that will tell the Autoscaling group when to increase or decrease server. Here we are keeping a 50% threshold for CPU utilization. So if CPU utilization goes above 50% it will add a new instance or if we have more than the minimum instance than required and CPU utilization goes below 50% it will decrease instances. Warm-up seconds are the time till when your instance is utilization reached threshold and keep above that threshold for this much time then Autoscale group will increase/decrease instance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*pGETO3dUprLwp6gN1FSbmQ.png" /></figure><ul><li>Leave all the steps as default, review, and launch the Auto Scaling group.</li><li>That’s all we have created the auto-scaling group. Now let’s verify how it’s working.</li></ul><h3><strong>Access site</strong></h3><ul><li>For Access your site you can go to load balancer → select to the load balancer → Copy DNS name → paste in your browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*ZRBAeAuxTFx3h-t24YkMlA.png" /></figure><ul><li>If you are not able to access the site make sure you try DNS names with HTTPS and HTTP. if it doesn’t work try to change the security group of the load balancer with the same as the instance security group.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*_4Fe4r_nek6ufHLz9RLzBw.png" /></figure><ul><li>For change security group select load balancer then scroll down you will get an option for the security group.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*Y3S2QTiN8P0lQmKMoZHpNw.png" /></figure><ul><li>To check auto-scale’s performance, let’s create some artificial load on the site. There are many options that you can find <a href="https://geekflare.com/web-performance-benchmark/">here</a>.</li><li>I am going with <strong>Apache Benchmark</strong>. We’ll send 10000 requests with 100 concurrent users. The results will be saved in the test1.txt file.</li></ul><pre>ab -n 100000 -c 100 load_balancer_dns_name &gt; test1.txt</pre><ul><li>It will generate 15–20 % CPU usage. You can change the autoscale CPU usage parameter to 10% so you can verify.</li><li>To check CPU usage run the following command. which will command will show CPU usage in percentage in every second</li></ul><pre>mpstat 1</pre><p>If you like this post, HIT Buy me a coffee! Thanks for reading.</p><figure><a href="https://www.payumoney.com/paybypayumoney/#/147695053B73CAB82672E715A52F9AA5"><img alt="" src="https://cdn-images-1.medium.com/max/417/1*RPDyXqHjKKbesbJgLZ96mQ.png" /></a></figure><p>Your every small contribution will encourage me to create more content like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ab0abeeeea6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/autoscale-on-aws-with-ec2-python-flask-and-nginx-part3-9ab0abeeeea6">Autoscale on AWS with EC2, Python, Flask, and Nginx Part3</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Autoscale on AWS with EC2, Python, Flask, and Nginx Part2]]></title>
            <link>https://medium.com/analytics-vidhya/autoscale-on-aws-with-ec2-python-flask-and-nginx-part2-f5640e406105?source=rss-3036f08fa8b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5640e406105</guid>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[services]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[DLMade]]></dc:creator>
            <pubDate>Sun, 21 Nov 2021 11:42:25 GMT</pubDate>
            <atom:updated>2021-11-30T06:39:23.561Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*_k-cWwkrFLtiOp9A" /><figcaption>Photo by <a href="https://unsplash.com/@garyhtou">Gary Tou</a> on <a href="https://unsplash.com/photos/ktpymCAIvGc">Unsplash</a></figcaption></figure><p>In our <a href="https://dlmade.medium.com/autoscale-on-aws-with-ec2-python-flask-and-nginx-part1-240c6bbf5c35">1st part</a>, we have set up an EC2 server and accessed it via Putty. Now, we are going to create a Flask server, Ubuntu service, and configure an Nginx server. So <strong>First Let’s Create our Flask Server.</strong></p><h3><strong>Flask Server</strong></h3><ul><li>Install the requirements on the server. As EC2 instance only provide us python installation so we have to Install an additional python module with help of the pip module.</li></ul><pre>sudo apt install python3-pip<br>pip3 install flask<br>pip3 install waitress</pre><ul><li>Create project directory <strong>autoscale_app </strong>or whatever you like in the server and go in that directory.</li></ul><pre>mkdir autoscale_app<br>cd autoscale_app</pre><ul><li>Create a file called <strong>app.py</strong> where we will write our flask server code. Here I have created a flask server on 5000 port number which will display “A simple flask server” text on the browser when we go to our website.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/652e36d0dd3b927e3296c2aa2260f1b3/href">https://medium.com/media/652e36d0dd3b927e3296c2aa2260f1b3/href</a></iframe><ul><li>Our Flask app Is ready we can able to run and able to look at the app on our browser but it is currently running on port 5000 so access the web we have to include port number 5000 with our IP address and we have to allow 5000 port in our server inbounds. So to access the app directly on IP address without a port we will use an Nginx server which will manage the traffic on our server and route it to our application.</li></ul><h3><strong>Nginx</strong></h3><ul><li>Install Nginx</li></ul><pre>sudo apt install nginx</pre><ul><li>We will use an <strong>OpenSSL</strong> to create an SSL certificate and a key file that will allow our application to run our website on an HTTPS server.</li></ul><pre>sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt</pre><ul><li>We will create a <strong>self-signed.conf</strong> file where we will write our certificate and key file path. we will provide this file in Nginx configuration.</li></ul><pre>sudo vi /etc/nginx/snippets/self-signed.conf</pre><ul><li>Paste the below content into the <strong>self-signed.conf</strong> file.</li></ul><pre>ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;<br>ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;</pre><ul><li>Below are some more parameters that can make the Nginx server more secure. You may refer <a href="https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-nginx-in-ubuntu-18-04">here</a> for an in-depth guide to the service.</li></ul><pre>sudo vi /etc/nginx/snippets/ssl-params.conf</pre><ul><li>Copy below content into the file.</li></ul><pre>ssl_protocols TLSv1.2;<br>ssl_prefer_server_ciphers on;<br>ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;<br>ssl_ecdh_curve secp384r1; # Requires nginx &gt;= 1.1.0<br>ssl_session_timeout  10m;<br>ssl_session_cache shared:SSL:10m;<br>ssl_session_tickets off; # Requires nginx &gt;= 1.5.9<br>ssl_stapling on; # Requires nginx &gt;= 1.3.7<br>ssl_stapling_verify on; # Requires nginx =&gt; 1.3.7<br>resolver 8.8.8.8 8.8.4.4 valid=300s;<br>resolver_timeout 5s;<br># Disable strict transport security for now. You can uncomment the following<br># line if you understand the implications.<br># add_header Strict-Transport-Security &quot;max-age=63072000; includeSubDomains; preload&quot;;<br>add_header X-Frame-Options DENY;<br>add_header X-Content-Type-Options nosniff;<br>add_header X-XSS-Protection &quot;1; mode=block&quot;;</pre><ul><li>Now we are going to create an Nginx configuration file where we can define the routes, server name, HTTP server, and give SSL certificate.</li></ul><pre>sudo vi /etc/nginx/sites-available/default</pre><ul><li>Below content creates two server blocks one for HTTP (port 80) and another for HTTPS (port 443). You can also combine them in one. It will tell Nginx to route any traffic which comes on the server to the localhost 5000 port.</li></ul><pre>server {<br>        listen 80;<br>        listen [::]:80;<br>        location / {<br>            proxy_pass <a href="http://127.0.0.1:5000/">http://127.0.0.1:5000</a>;<br>            proxy_set_header X-Real-IP $remote_addr;<br>        }<br>}<br>server {<br>    listen 443 ssl;<br>    listen [::]:443 ssl;<br>    include snippets/self-signed.conf;<br>    include snippets/ssl-params.conf;<br> location / {<br>            proxy_pass <a href="https://127.0.0.1:5000/">https://127.0.0.1:5000</a>;<br>            proxy_set_header X-Real-IP $remote_addr;<br>        }<br>}</pre><h3><strong>Create ubuntu service to run Flask app</strong></h3><ul><li>We have configured the flask app and Nginx server. Now we are ready to launch our app but before that, we have to make sure if our server restarts then our app should start automatically for that we will create a ubuntu service. Which will start our app automatically whenever the server reboot so we don’t have to do any manual tasks.</li></ul><pre>sudo vi /etc/systemd/system/autoscale.service</pre><ul><li>Below Content gives commands to ubuntu server that when server restart then automatic this service also start. Make sure you can change the working directory path with your project directory. Exec start is a command which is going to fire by service when service starts. We are going to start our flask app with python3.6 so I have given the absolute path of python3.6 and our app.py.</li></ul><pre>[Unit]<br>Description=Autoscale Flask project<br>After=network.target<br>[Service]<br>User=ubuntu<br>Group=www-data<br>#WorkingDirectory=/home/ubuntu/autoscale_app     ## replace with your project directory path<br>ExecStart=/usr/bin/python3.6 /home/ubuntu/autoscale_app/app.py</pre><pre>[Install]<br>WantedBy=multi-user.target</pre><ul><li>Now we will start and enable the service. By enabling the service we are telling the server that this service is going to run on every reboot. If our service is disabled out the app will not run when the server restart.</li></ul><pre>sudo systemctl start autoscale.service<br>sudo systemctl enable autoscale.service</pre><ul><li>We will also restart the Nginx server as we have changed the configuration of Nginx. Without restart, our configuration wants to reflect.</li></ul><pre>sudo systemctl restart nginx</pre><ul><li>Go to your instance&#39;s public IP address you can see our app is running.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*CodtZ9tG5htD-cJcUWitEQ.png" /></figure><p>That’s all for part 2. we will meet again in the next article.</p><p>If you like this post, HIT Buy me a coffee! Thanks for reading.</p><figure><a href="https://www.payumoney.com/paybypayumoney/#/147695053B73CAB82672E715A52F9AA5"><img alt="" src="https://cdn-images-1.medium.com/max/417/1*RPDyXqHjKKbesbJgLZ96mQ.png" /></a></figure><p>Your every small contribution will encourage me to create more content like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5640e406105" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/autoscale-on-aws-with-ec2-python-flask-and-nginx-part2-f5640e406105">Autoscale on AWS with EC2, Python, Flask, and Nginx Part2</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Autoscale on AWS with EC2, Python, Flask, and Nginx Part1]]></title>
            <link>https://medium.com/analytics-vidhya/autoscale-on-aws-with-ec2-python-flask-and-nginx-part1-240c6bbf5c35?source=rss-3036f08fa8b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/240c6bbf5c35</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2]]></category>
            <dc:creator><![CDATA[DLMade]]></dc:creator>
            <pubDate>Sun, 21 Nov 2021 11:40:50 GMT</pubDate>
            <atom:updated>2021-11-30T06:39:15.800Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*jLcgjc2iTf0ZGrb2" /><figcaption>Photo by <a href="https://unsplash.com/@6heinz3r">Gabriel Heinzer</a> on <a href="https://unsplash.com/photos/xbEVM6oJ1Fs">Unsplash</a></figcaption></figure><p>AWS Auto Scaling monitors your applications and automatically adjusts capacity to maintain steady, predictable performance at the lowest possible cost.</p><p>Imagine going shopping for groceries and the store hands you all the items in just one bag. You’ll have to carry the bag with one hand which weighs more than 5 kgs.</p><p>Imagine the same case but where the store gives you the items with the same weight but divided into 3 different bags. Sounds relieving, right?</p><p>Similarly, let’s suppose you want to manage large traffic on your site and your hardware resources are fully utilized on the current server and you want to add more hardware on runtime as per the traffic. This is where scaling can be applied. There are many ways scaling can be achieved.</p><p>One such way is using AWS Auto Scaling. AWS auto-scaling can help us to increase or decrease the instance as per traffic on our servers.</p><p>You may refer to the following link for an in-depth guide to the service: <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-benefits.html">https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-benefits.html</a></p><p><strong>Points to be covered</strong>:</p><p>1. Create an EC2 server and access through putty. (Part1)</p><p>2. Create Flask app and configure Nginx on EC2 server (Part2)</p><p>3. Configure Autoscaling group (Part3)</p><p>In our first part, we will create an EC2 instance, Convert the .pem file to a .ppk file with the help of Puttygen and then access our EC2 instance with putty.</p><h3>Create Ec2 server</h3><p>Amazon EC2 allows us to create a virtual machine with our choice of hardware and software configuration. Let’s create one.</p><ul><li>Search for EC2 from the search bar and click on the <strong>EC2</strong> service.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*O8A0qZjmwIV2ivM0kGJbkg.png" /></figure><ul><li>Click on <strong>instances(running)</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*VzG4qVq-hYHTgxD-_nqAjg.png" /></figure><ul><li>Click on <strong>launch instance</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*ZzCM41SEGX8DjWBFx3nfgw.png" /></figure><ul><li>Let’s select an OS that suits our requirements. For this guide, I’ll go with <strong>Ubuntu Server 18.04</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*tOgBfAE8snWWQoPKOnNhZA.png" /></figure><ul><li>Now we get options of the instance types. Where we can see how much RAM and vCPU we are going to get. I will go with the <strong>t2.micro</strong> free tier.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*HEqjvJlcTDCHzALsHDp6Rw.png" /></figure><ul><li>Click <strong>Next </strong>in <strong>steps 3,4 and 5</strong> with default configurations. Now on Step 6 Make sure you allow HTTP port by clicking add rule button. The SSH rule allows us to access instances from software like putty. The HTTP rule allows port 80 which will allow internet traffic on our server.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*sePhCiwXeb3RwRjVZVgblw.png" /></figure><ul><li>In the last step, you can create new key pair or choose an existing one it will help you to access your instance with the SSH rule. Give a name to the key pair file and download this file because you will not get this file again.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*ASEWLjVACS0yx_h-XxD59Q.png" /></figure><h3><strong>Access Instance</strong></h3><ul><li>Now we will access this instance with the help of putty. Putty accepts a .ppk file to connect the server and AWS gives us a .pem file so we have to convert the .pem file into a .ppk file with help of Puttygen.</li></ul><pre>Open puttygen → Click load button → select the file that you get from AWS → click save private key button → save file as .ppk file.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*8AQ0onxjq0w2sXiGneSgYw.png" /></figure><ul><li>To access the instance through Putty, we require an IP address of our instance. For finding the IP address of the instance select the instance from the EC2 dashboard and go to the details section where we will get the public ipv4 address of our EC2 instance copy this IP address.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*Nh2loWGE-2KC8uzLgGfplg.png" /></figure><ul><li>Open Putty software and paste the public IP address which you got from AWS in hostname.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*hYL-LouLUIn_g0Yqlqa1EA.png" /></figure><ul><li>To access the instance we have to provide a private key of our instance for that go to the auth section in putty software and browse the .ppk file that we have just generated from Puttygen tool. Now click on open.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*cNHGIG5vYL7XhRw1AeU1qg.png" /></figure><ul><li>If you get any prompt like below accept it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*hhmPh-j79cCq--WkqqMr4w.png" /></figure><ul><li>Give your instance username. For most cases, by default, it will be ubuntu.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*xQVTK6jI7hDnQtUbzoSm9A.png" /></figure><p>After we have given the username now we are successfully signed in and we are able to use instance.</p><p>That’s all for this part. we will create a Flask server and configure Nginx in the second part. See you soon in the next article.</p><p>If you like this post, HIT Buy me a coffee! Thanks for reading.</p><figure><a href="https://www.payumoney.com/paybypayumoney/#/147695053B73CAB82672E715A52F9AA5"><img alt="" src="https://cdn-images-1.medium.com/max/417/1*RPDyXqHjKKbesbJgLZ96mQ.png" /></a></figure><p>Your every small contribution will encourage me to create more content like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=240c6bbf5c35" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/autoscale-on-aws-with-ec2-python-flask-and-nginx-part1-240c6bbf5c35">Autoscale on AWS with EC2, Python, Flask, and Nginx Part1</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rasa Advanced Deployment: Finale(CI/CD)]]></title>
            <link>https://medium.com/swlh/rasa-advanced-deployment-finale-ci-cd-5d21b0d58904?source=rss-3036f08fa8b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d21b0d58904</guid>
            <category><![CDATA[rasa]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[continuous-delivery]]></category>
            <dc:creator><![CDATA[DLMade]]></dc:creator>
            <pubDate>Sun, 20 Dec 2020 10:01:41 GMT</pubDate>
            <atom:updated>2020-12-20T10:01:41.820Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to the final part of the Rasa Advanced Deployment Series. As a recap, we learned installing rasa into VM, scaling pods, connecting our git repo into rasa-x, registering custom actions, and starting them. We also learned about Conversation driven development. Now we will learn about CI/CD. Even though developing a contextual assistant is different from developing traditional software, we should still follow software development best practices. Setting up a Continuous Integration (CI) and Continuous Deployment (CD) pipeline ensures that incremental updates to your bot are improving it, not harming it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*81ux4-QbP3ZH6DcyKCCSQg.png" /></figure><p>Continuous Integration (CI) is the practice of merging in code changes frequently and automatically testing changes as they are committed. Continuous Deployment (CD) means automatically deploying integrated changes to a staging or production environment. Together, they allow you to make more frequent improvements to your assistant and efficiently test and deploy those changes.</p><p>If your rasa-x is still connected with GitHub then first disconnect it before we will create our Github actions.</p><p>You can do it by clicking the setting icon which is on the top-right side in the git section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*7EDPJno7d3oD79BGGt_3mg.png" /></figure><p>Let’s build our first GitHub action to make our testing job automated.</p><p>Step 1: Go in your fork repo create a new file on this path .github/workflows/ci_on_push.yml by clicking add file and copy below-given code.</p><pre>name: CI on push<br>on:<br> push:<br>   paths-ignore:<br>   - &quot;README.md&quot;<br> <br>jobs:<br> ci:<br>   name: CI job<br>   runs-on: ubuntu-latest<br>   steps:<br>   - uses: actions/checkout@v2<br>   - name: Set up Python 3.7<br>     uses: actions/setup-python@v2<br>     with:<br>       python-version: 3.7<br>   - name: Install dependencies<br>     run: |<br>       python -m pip install -U pip<br>       pip install -r requirements.txt<br>   - name: Test it all<br>     working-directory: ${{ github.workspace }}<br>     run: |<br>       rasa train --quiet<br>       rasa test --fail-on-prediction-errors</pre><p>Let’s try to understand what this file means.</p><p>The first-line Name is the name of our action then on push says it will run when we push something to the repo. Now if we don’t want to run an action when changes are done only in the “readme.md” while we push then we can ignore it.</p><p>In the jobs section, we have created one job with the name CI job which will run on ubuntu&#39;s latest os. In the steps, we defined our python version which is 3.7 here then about install dependencies, and after that about training and testing the model.</p><p>Now we can connect our GitHub repo with the rasa-x and we have to push some changes into GitHub to see our actions working. So for that let’s create a test user link and try to generate new data.</p><p>Till now we know how to create a test user link, Review it and Annotate it. So I am supposing you have done some changes.</p><p>Now we have some changes to push on git so let’s push it into git. As soon as we push some changes we can go to the Github repo. we can see a new branch is created when we go in that branch we can see something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*9F0WCMcce7bOYYQH8tX8iQ.png" /></figure><p>Here we can see yellow dots that shows that our GitHub action is running. To see details we can click on the yellow dot and then click on details.</p><p>When it will be finished and if everything works fine we can see a green check sign otherwise a red cross sign. Now if everything looks good we can merge this branch with our master branch.</p><p>Github action will run again on a master branch when we merge our new branch. If you don’t want to run it twice then you can change on push line in GitHub action with on pull request. So it will run only when someone creates a pull request.</p><p>Now everything merged wait till our rasa-x sync the latest data. Then you can train, activate, and talk with the new model.</p><p>Extra Commands:</p><ul><li>For delete all cluster inside namespace</li></ul><pre>kubectl delete namespace my-namespace</pre><ul><li>Change nginx external IP. like we are here accessing localhost:8000.</li></ul><pre>kubectl -n my-namespace edit service my-release-rasa-x-nginx</pre><ul><li>Get pod</li></ul><pre>kubectl -n my-namespace get pod</pre><ul><li>Run bash in containers.</li></ul><pre>kubectl -n my-namespace exec -it [pods name] -- /bin/bash</pre><ul><li>To view the environment variable in bash of containers</li></ul><pre>env | grep RASA_X_TOKEN</pre><p>Here we can specify any environment name like here we use RASA_X_TOKEN.</p><ul><li>To make curl request on services</li></ul><pre>curl http://my-release-rasa-x-rasa-x:5002/api/config?token=asdfrewq1234</pre><p>You will get this token by executing the above-given environment variable command.</p><p>That’s all in the series of advance deployment of the Rasa chatbot.</p><p>References:</p><ul><li><a href="https://rasa.com/docs/rasa-x/">Introduction to Rasa X</a></li><li><a href="https://info.rasa.com/advanced-deployment-workshop/">Rasa Advanced Deployment Workshop</a></li></ul><p>If you like this post, HIT Buy me a coffee! Thanks for reading.</p><figure><a href="https://www.payumoney.com/paybypayumoney/#/147695053B73CAB82672E715A52F9AA5"><img alt="" src="https://cdn-images-1.medium.com/max/417/1*RPDyXqHjKKbesbJgLZ96mQ.png" /></a></figure><p>Your every small contribution will encourage me to create more content like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d21b0d58904" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/rasa-advanced-deployment-finale-ci-cd-5d21b0d58904">Rasa Advanced Deployment: Finale(CI/CD)</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rasa Advanced Deployment: Part 5(Conversation driven development)]]></title>
            <link>https://medium.com/analytics-vidhya/rasa-advanced-deployment-part-5-conversation-driven-development-264365e10587?source=rss-3036f08fa8b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/264365e10587</guid>
            <category><![CDATA[conversational-ai]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[rasa]]></category>
            <dc:creator><![CDATA[DLMade]]></dc:creator>
            <pubDate>Sun, 20 Dec 2020 09:56:58 GMT</pubDate>
            <atom:updated>2021-03-07T15:38:59.772Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to the 5th part of the Rasa Advanced Development Series. Here, we will talk about Conversation driven development.<br>Conversation-Driven Development (CDD) is the process of listening to your users and using those insights to improve your AI assistant. It is the overarching best practice approach for chatbot development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*81ux4-QbP3ZH6DcyKCCSQg.png" /></figure><p>Developing great AI assistants is challenging because users will always say something you didn’t anticipate. The principle behind CDD is that in every conversation users are telling you — in their own words — exactly what they want. By practicing CDD at every stage of bot development, you orient your assistant towards real user language and behavior.</p><p>CDD includes the following actions:</p><ul><li><strong>Share</strong> your assistant with users as soon as possible</li><li><strong>Review</strong> conversations on a regular basis</li><li><strong>Annotate</strong> messages and use them as NLU training data</li><li><strong>Test</strong> that your assistant always behaves as you expect</li><li><strong>Track</strong> when your assistant fails and measure its performance over time</li><li><strong>Fix</strong> how your assistant handles unsuccessful conversations</li></ul><h4>Share</h4><p>Let’s first share the bot with the test user or end-user. You can find the share option in the model section of rasa-x.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*IbQhW3DQKYyV8ChnCiKMCg.png" /></figure><p>In assistant detail either you can write your chatbot title or anything that you want. In the description, you can write what the chatbot is doing and how the test user can interact with it.</p><h4>Review</h4><p>When the guest tester will use our bot we will see the conversation that the guest tester has in our conversation section of rasa-x.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bh3GjGs2TIYTOMysP1MtWQ.png" /></figure><h4>Annotate</h4><p>Now if we look into the awesome text we can find that our chatbot is identifying this as <strong>mood_unhappy </strong>intent which is written down in text. which is wrong. so if we found any conversation is wrong then we can correct it from here by clicking the pencil button near our text. Then we can add that corrected data into training data.</p><p>It’s a best practice that after correcting the conversation we can tag that conversation as reviewed so we don’t look at the same conversation again for correction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2xenwhE7e2pyCW3QyqHLJw.png" /><figcaption>Annotating Data</figcaption></figure><p>If we look closer at the git section in rasa-x, the color changes to yellow as we have some changes in our data. Let’s push that data into git first, so that our data is up-to-date.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*7EDPJno7d3oD79BGGt_3mg.png" /></figure><p>Click on “Add changes to Git server” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*kT1XCQB7I1wR-FSSC0fbpg.png" /></figure><p>Now, whenever we will add changes to our Git rasa-x will create a new branch. So we can verify the change and if it looks good then we will merge with the master branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*ljT65ZemZCyY2E_5L60vcg.png" /></figure><p>We can compare the changes and create a pull request to merge those changes with the master branch by clicking on the Compare &amp; pull request button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*_07fm2L7oFR__I7QWjVsyQ.png" /></figure><p>Here we have to change the repository that we have to merge. As we have forked the repo we will see the master branch of the original repo on the left side. So we have to change it to our master branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*fssbQWGpTvB7GK1k1HJlaQ.png" /></figure><p>Here we can write what changes we have done for future perspectives and also for a developer who is going to merge this branch. Now we can create a pull request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*_mCP1XW72OC-rQXszvbxJg.png" /></figure><p>Here we can merge changes with the master branch.</p><h4>Test, Track &amp; Fix</h4><p>As we merge here our rasa-x will try to sync with the master branch changes. we have to wait for git to sync when it will finish we can see git section color will be changed to green and our new data in NLU data. Now we can train it again, then activate the new model and talk with it.</p><p>Now we have our new model so we can again give this URL to the test user and we will keep track of the conversation. Also wherever we will find the conversation is predicted wrong we can fix that and repeat the process.</p><p>That’s all for today in the series of advance deployment of the Rasa chatbot. Keep an eye on the series of this blog. Till then, Happy Coding!!!</p><p>References:</p><ul><li><a href="https://rasa.com/docs/rasa-x/">Introduction to Rasa X</a></li><li><a href="https://info.rasa.com/advanced-deployment-workshop/">Rasa Advanced Deployment Workshop</a></li></ul><p>If you like this post, HIT Buy me a coffee! Thanks for reading.</p><figure><a href="https://www.payumoney.com/paybypayumoney/#/147695053B73CAB82672E715A52F9AA5"><img alt="" src="https://cdn-images-1.medium.com/max/417/1*RPDyXqHjKKbesbJgLZ96mQ.png" /></a></figure><p>Your every small contribution will encourage me to create more content like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=264365e10587" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/rasa-advanced-deployment-part-5-conversation-driven-development-264365e10587">Rasa Advanced Deployment: Part 5(Conversation driven development)</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rasa Advanced Deployment: Part 4 (Custom Action Server)]]></title>
            <link>https://medium.com/swlh/rasa-advanced-deployment-part-4-custom-action-server-d5c0a83fb905?source=rss-3036f08fa8b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5c0a83fb905</guid>
            <category><![CDATA[rasa]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[chatbots]]></category>
            <dc:creator><![CDATA[DLMade]]></dc:creator>
            <pubDate>Sun, 20 Dec 2020 09:49:08 GMT</pubDate>
            <atom:updated>2020-12-20T16:36:12.421Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are familiar with rasa then you know that we can’t achieve everything without creating custom action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*81ux4-QbP3ZH6DcyKCCSQg.png" /></figure><p>Custom actions turn your assistants into magic. A custom action is where you put most of your assistant’s code written in Python. This can be used to make an API call or to query a database for example.</p><p>So let’s create your custom action server.</p><p>For running the custom action first we have to connect the git repo and we know how to do it the same as we talked about in the <a href="https://dlmade.medium.com/rasa-advanced-deployment-part-3-git-connection-373792fbd54a">previous blog</a>.</p><p>Do the following steps to connect the git repo.</p><ol><li>Fork <a href="https://github.com/RasaHQ/deployment-workshop-bot-2">https://github.com/RasaHQ/deployment-workshop-bot-2</a></li></ol><p>2. Navigate to your forked copy</p><p>3. Copy the SSH URL from your GitHub repository</p><p>4. Connect Integrated Version Control in Rasa X</p><ul><li>Specify the branch you want to use as master</li><li>Check “Require users to add changes to a new branch”</li><li>Do step 5 first, then click on “Verify connection”</li></ul><p>5. Copy/paste the Deploy Key in your GitHub repository settings</p><ul><li>Check “Allow write access”</li></ul><p>Now we have connected our git and we will train our model. Let’s make active to our newly trained model.</p><p>Now training is not sufficient to talk with a bot we required to start an action server. For that, we have to create a docker image of our custom actions. So let’s see how can we achieve that.</p><p>Open a VM and issue the below-given commands</p><ul><li>clone your forked repo to the VM</li></ul><pre>git clone https://github.com/[YOUR-GITHUB-NAME]/deployment-workshop-bot-2.git</pre><ul><li>Change directory</li></ul><pre>cd deployment-workshop-2</pre><ul><li>Build docker</li></ul><pre>docker-compose build</pre><p>When the build is done at that time we will see this URL localhost:32000/deployment-workshop-bot-2-action-server:0.0.1 which we use in the following command.</p><ul><li>Here we will do a container registry of our image into our cluster.</li></ul><pre>docker push localhost:32000/deployment-workshop-bot-2-action-server:0.0.1</pre><p>While pushing you might get some error like connection refused or reset by peer then you can solve that problem by following this great article.</p><p><a href="https://code-maze.com/docker-hub-vs-creating-docker-registry/">Docker Hub vs Creating a Local Docker Registry - Code Maze</a></p><p>The steps I have done to solve the problem are as follows.</p><ul><li>Start a registry</li></ul><pre>docker run -d -p 32000:5000 --restart always --name registry registry:latest</pre><ul><li>Edit C:/Windows/system32/drivers/etc/hosts file</li></ul><pre>#Add this line in docker edited part<br>127.0.0.1 localhost<br>::1 localhost</pre><p>Now try to push the image and if it’s work then try to remove the line that we added in C:/Windows/system32/drivers/etc/hosts and then pull the image docker pull localhost:32000/deployment-workshop-bot-2-action-server:0.0.1 . if it&#39;s work then leave it as it is otherwise add that line again.</p><p>Till now our action server is pushed on the registry but not started yet. So let’s see how we can start the action server.</p><p>Step 1: Add the docker image URL into the values.yml file.</p><pre># custom action server<br>app:<br>    # from microk8s build-in registry<br>    name: &quot;localhost:32000/deployment-workshop-bot-2-action-server&quot;<br>    tag: &quot;0.0.1&quot;</pre><p>Step 2: Upgrade helm chart</p><p>On VM issue this command.</p><pre>helm --namespace my-namespace upgrade --values values.yml my-release rasa-x/rasa-x</pre><p>Remember when we do some changes in values.yml it will not come in actions until we will run this command.</p><p>Let’s check if our custom action is running or not by navigating the talk to bot section in rasa-x.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*fMAvw5S-EcTP654UL3mzXQ.png" /></figure><p>We can see that greet comes from our custom actions.</p><p>That’s all for today in the series of advance deployment of the Rasa chatbot. Keep an eye on the series of this blog. Till then, Happy Coding!!!</p><p>References:</p><ul><li><a href="https://rasa.com/docs/rasa-x/">Introduction to Rasa X</a></li><li><a href="https://info.rasa.com/advanced-deployment-workshop">Rasa Advanced Deployment Workshop</a></li></ul><p>If you like this post, HIT Buy me a coffee! Thanks for reading.</p><figure><a href="https://www.payumoney.com/paybypayumoney/#/147695053B73CAB82672E715A52F9AA5"><img alt="" src="https://cdn-images-1.medium.com/max/417/1*RPDyXqHjKKbesbJgLZ96mQ.png" /></a></figure><p>Your every small contribution will encourage me to create more content like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5c0a83fb905" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/rasa-advanced-deployment-part-4-custom-action-server-d5c0a83fb905">Rasa Advanced Deployment: Part 4 (Custom Action Server)</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rasa Advanced Deployment: Part 3(Git Connection)]]></title>
            <link>https://medium.com/analytics-vidhya/rasa-advanced-deployment-part-3-git-connection-373792fbd54a?source=rss-3036f08fa8b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/373792fbd54a</guid>
            <category><![CDATA[rasa]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[DLMade]]></dc:creator>
            <pubDate>Sun, 20 Dec 2020 09:42:53 GMT</pubDate>
            <atom:updated>2021-03-07T15:38:53.139Z</atom:updated>
            <content:encoded><![CDATA[<p>Till now we learned about installing rasa in VM and scaling pods. Now let’s connect our chatbot with git so we can keep track of changes and sync rasa-x data with the git. So that rasa-x automatically updates data if it finds any changes in the master branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*81ux4-QbP3ZH6DcyKCCSQg.png" /></figure><p>Here are the steps to connect the git repo with the Rasa-x.</p><p>Step 1: Fork <a href="https://github.com/RasaHQ/deployment-workshop-bot-1">https://github.com/RasaHQ/deployment-workshop-bot-1</a></p><p>Step 2: Navigate to your forked copy</p><p>Step 3: Copy the SSH URL from your GitHub repository</p><p>Step 4: Connect Integrated Version Control in Rasa X</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6PnONHFS9OAx2IMn0d--eA.png" /></figure><p>4.a. Specify the branch you want to use as master</p><p>4.b. Check “Require users to add changes to a new branch”</p><p>4.c. Do step 5 first, then click on “Verify connection”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tqgqzFeZyjRmgt5TMGYWaQ.png" /></figure><p>5. Copy/paste the Deploy Key in your GitHub repository settings</p><p>5.a. Check “Allow write access”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pE_-ZNRNgvX4BL_xTTyJjg.png" /></figure><p>Once you click verify connection, you’ll see something like this in a few minutes. This means our git connection succeeded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*MUcs_n6IqJU4_qILykfqWg.png" /></figure><p>By connecting GitHub rasa will now sync data from our repo. We can verify this in rasa-x nlu data.</p><p>Now let’s train the chatbot. Before that, we will see the training process in logs so let’s start the logs.</p><p>Issue this command to see your pods name</p><pre>kubectl -n my-namespace get pods</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*TM0udyKswHBTHthkQfkF7w.png" /></figure><p>We have to run logs on rasa-worker pods. So issue this command with rasa-worker pods name.</p><pre>kubectl -n my-namespace logs my-release-rasa-worker-7984cdb4fb-89j9g --follow --tail 20</pre><ul><li>my-release-rasa-worker-7984cdb4fb-89j9g is my rasa worker pod name.</li><li>— follow means it will sync with the new logs that come in the pod.</li><li>— tail 20 means it will show us the last 20 records of logs.</li></ul><p>Now click the train button in rasa-x and navigate into logs to see the process of training</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XlUrMh0650zLSaktjaX0vw.png" /></figure><p>After the model is trained. We have to make the model active to interact with it. Navigate to the model section in rasa-x where you will find your models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*I5667Gbz6Vdr5jdoS-S3Bw.png" /></figure><p>It will take some time to finish. When it will finish. You can see something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*5pG_5Dt-zN72etL8rlNxQw.png" /></figure><p>Now our assistant is up so let’s can click on the talk to bot button to check how your new model is working.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*C1c_PkBJ9jUbGVtVOcZhJg.png" /></figure><p>Great, it’s working fine. So now whenever we make changes in the master branch of the repo which is connected to rasa-x, it will sync the new data. Then we can train the model on the new synced data, activate it, and talk with it.</p><p>That’s all for today in the series of advance deployment of the Rasa chatbot. Keep an eye on the series of this blog. Till then, Happy Coding!!!</p><p>References</p><ul><li><a href="https://rasa.com/docs/rasa-x/">Introduction to Rasa X</a></li><li><a href="https://info.rasa.com/advanced-deployment-workshop">Rasa Advanced Deployment Workshop</a></li></ul><p>If you like this post, HIT Buy me a coffee! Thanks for reading.</p><figure><a href="https://www.payumoney.com/paybypayumoney/#/147695053B73CAB82672E715A52F9AA5"><img alt="" src="https://cdn-images-1.medium.com/max/417/1*RPDyXqHjKKbesbJgLZ96mQ.png" /></a></figure><p>Your every small contribution will encourage me to create more content like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=373792fbd54a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/rasa-advanced-deployment-part-3-git-connection-373792fbd54a">Rasa Advanced Deployment: Part 3(Git Connection)</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rasa Advanced Deployment: Part 2(Scaling pods and Cluster requirements)]]></title>
            <link>https://medium.com/analytics-vidhya/rasa-advanced-deployment-part-2-scaling-pods-and-cluster-requirements-e1bc507aa333?source=rss-3036f08fa8b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1bc507aa333</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[rasa]]></category>
            <dc:creator><![CDATA[DLMade]]></dc:creator>
            <pubDate>Sun, 20 Dec 2020 09:39:19 GMT</pubDate>
            <atom:updated>2021-01-25T16:51:33.269Z</atom:updated>
            <content:encoded><![CDATA[<p>In the previous blog, we installed rasa in the VM. The installation is done with only one Pod for each deployment running in our application. When traffic increases, we will need to scale the application to keep up with user demand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*81ux4-QbP3ZH6DcyKCCSQg.png" /></figure><h4>Scale Pods</h4><p><strong>Scaling</strong> is accomplished by changing the number of replicas in a Deployment.</p><p>Method 1:</p><p>On the VM, Issue this command to check how much pods we have for our deployments:</p><pre>kubectl -n my-namespace get deployment</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*DKdLn2KJitOCAr55ca46eQ.png" /></figure><p>Here we have Ready 1/1 it means we have 1 pod for that deployment.</p><p>On the VM, Issue this command to scale the pods:</p><pre>kubectl -n my-namespace scale deployment my-release-rasa-production --replicas=2</pre><ul><li>-n my-namespace : Name of the namespace in which rasa is installed</li><li>my-release-rasa-production : Name of the deployment which you want to scale you can see the name in the above-given image.</li><li>— replicas=2 : It means we want 2 pods for our my-release-rasa-production deployment.</li></ul><p>Let’s again check the pods are scaled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*rHVSBNfOb3VxD2U5Fa23aQ.png" /></figure><p>We can see in my-release-rasa-production now we have 2 pods ready.</p><p>To scale it down issue this command</p><pre>kubectl -n my-namespace scale deployment my-release-rasa-production --replicas=1</pre><p>Note:</p><p>You can also use this command to restart any pod.</p><pre>kubectl -n my-namespace scale deployment my-release-rasa-production --replicas=0</pre><p>It will delete that pod now you can again initialize the new pod.</p><pre>kubectl -n my-namespace scale deployment my-release-rasa-production --replicas=1</pre><p>it will restart the my-release-rasa-production pod.</p><p>Method 2: Helm</p><p>We can define replicaCount in the “values.yml”</p><pre># rasa: Settings common for all Rasa containers<br>rasa:<br>    versions:<br>       # rasaProduction is the container which serves the production environment<br>       rasaProduction:<br>           # replicaCount of the Rasa Production container<br>           replicaCount: 2</pre><p>Now issue this command on VM</p><pre>helm --namespace my-namespace upgrade --values values.yml my-release rasa-x/rasa-x</pre><p>It will work in the same manner as the command-line method. But, here we can keep track of all the values defined in the values.yml file.</p><h4>Cluster requirements</h4><p>We can specify how much of each resource a container requires or is allowed to use in the values.yml of the helm chart, eg. for the rasa-production container if we want 2vcpu and 2GB ram then we can define this thing as follows.</p><ul><li>Edit Values.yml file</li></ul><pre>rasa:<br> versions:<br>   rasaProduction:<br>     # resources which rasaProduction is required / allowed to use<br>     resources:<br>       requests:<br>         cpu: &quot;2000m&quot;<br>         memory: &quot;2Gi&quot;</pre><ul><li>Upgrade the installation</li></ul><pre>helm --namespace my-namespace  upgrade --values values.yml my-release rasa-x/rasa-x</pre><p>This will assign the resources as we have described in the values.yml.</p><p>That’s all for today in the series of advance deployment of the Rasa chatbot. Keep an eye on the series of this blog. Till then, Happy Coding!!!</p><p>References:</p><ul><li><a href="https://rasa.com/docs/rasa-x/">Introduction to Rasa X</a></li><li><a href="https://info.rasa.com/advanced-deployment-workshop">Rasa Advanced Deployment Workshop</a></li></ul><p>If you like this post, HIT Buy me a coffee! Thanks for reading.</p><figure><a href="https://www.payumoney.com/paybypayumoney/#/147695053B73CAB82672E715A52F9AA5"><img alt="" src="https://cdn-images-1.medium.com/max/417/1*RPDyXqHjKKbesbJgLZ96mQ.png" /></a></figure><p>Your every small contribution will encourage me to create more content like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1bc507aa333" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/rasa-advanced-deployment-part-2-scaling-pods-and-cluster-requirements-e1bc507aa333">Rasa Advanced Deployment: Part 2(Scaling pods and Cluster requirements)</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>