<?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 Priyanshi Garg on Medium]]></title>
        <description><![CDATA[Stories by Priyanshi Garg on Medium]]></description>
        <link>https://medium.com/@gargpriyanshi39?source=rss-3474912cf7a8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5vigKpxQmU7JS_M2pO4-lw.jpeg</url>
            <title>Stories by Priyanshi Garg on Medium</title>
            <link>https://medium.com/@gargpriyanshi39?source=rss-3474912cf7a8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 23:54:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gargpriyanshi39/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[Deploy Wordpress Application On Kubernetes , RDS Database (AWS) Using Terraform]]></title>
            <link>https://medium.com/@gargpriyanshi39/deploy-wordpress-application-on-kubernetes-rds-database-aws-using-terraform-8991ee13e388?source=rss-3474912cf7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/8991ee13e388</guid>
            <category><![CDATA[aws-rds]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Priyanshi Garg]]></dc:creator>
            <pubDate>Fri, 04 Sep 2020 16:31:17 GMT</pubDate>
            <atom:updated>2020-09-04T16:31:17.513Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/815/0*KfZ3mUW2JEWQKYpx.png" /></figure><h3>Deploy Wordpress Application On Kubernetes , RDS Database (AWS) Using Terraform</h3><h3>Kubernetes :</h3><p>It is an open-source system for automating deployment, scaling, and management of containerized applications .</p><p>With Kubernetes you can:</p><ul><li>Make better use of hardware to maximize resources needed to run your enterprise apps.</li><li>Control and automate application deployments and updates.</li><li>Scale containerized applications and their resources on the fly.</li><li><a href="https://www.redhat.com/en/topics/containers/what-is-kubernetes-deployment">Declaratively manage services</a>, which guarantees the deployed applications are always running the way you intended them to run.</li><li>Health-check and self-heal your apps with autoplacement, autorestart, autoreplication, and autoscaling.</li></ul><h3>RDS Database :</h3><p>Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. It provides cost-efficient and resizable capacity while automating time-consuming administration tasks such as hardware provisioning, database setup, patching and backups. It frees you to focus on your applications so you can give them the fast performance, high availability, security and compatibility they need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*P1R3KTpS_AZE5M9q.png" /></figure><h3>Terraform :</h3><p>Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions. Configuration files describe to Terraform the components needed to run a single application or your entire datacenter.</p><h3>Our Main Objective :-</h3><p>Deploy the Wordpress application on Kubernetes and AWS using terraform including the following steps ;</p><ol><li>Write an Infrastructure as code using terraform which automatically deploy the Wordpress Application .</li><li>On AWS use RDS service for the relational database for Wordpress Application .</li><li>Deploy the wordpress as a container either on the top of Minikube or EKS or Fargate service on AWS .</li><li>The Wordpress application should be accessible from the public world if deployed on AWS or through workstation if deployed on Minikube .</li></ol><h3>So Let’s Begin !</h3><p>Here I’m using MySQL as RDS engine in AWS . And will create whole infrastructure using terraform code .</p><p><strong><em>Pre-requisites :</em></strong></p><ol><li>Account on AWS .</li><li>AWS CLI installed in our local system , in my case it is windows .</li><li>Terraform installed in our local system .</li></ol><p>Create a seperate working space for the project . So on Desktop I have created an directory named “aws-rds” . In this directory I have created two more directories one for Wordpress and other for MySQL .</p><p><strong><em>To login into the AWS account using terraform we have two ways .</em></strong></p><ol><li>Provide access key and secrete key in configuration file . But usually we make our code public by either pushing on GitHub . If we do so our account will be at risk .</li><li>Create an IAM user / profile with limited powers . Login into account in our local system and provide profile name in the config. file . This is a safer way .</li></ol><p>So I have created a new profile “ mypriyanshi “ .</p><p><em>Login into aws account ( “mypriyanshi” ) through our local system .</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HMdwgK-JtvgVpqxL2_oQ9w.png" /></figure><p>Now install all the required plugins</p><pre>terraform init</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cRbWJY808GxaTKKSG4KqIA.png" /></figure><blockquote><strong>STEP 1 :</strong> Write an Infrastructure as code using terraform which automatically deploy the Wordpress Application on top of Kubernetes (Minikube) .</blockquote><p># Code</p><pre>provider &quot;kubernetes&quot; {<br>  config_context_cluster   = &quot;minikube&quot;<br>}</pre><pre>resource &quot;kubernetes_service&quot; &quot;service&quot; {<br>  metadata {<br>    name = &quot;service-nodeport&quot;<br>  }<br>  spec {<br>    selector = {<br>      app = &quot;wp&quot;<br>    }<br>    session_affinity = &quot;ClientIP&quot;<br>    port {<br>      port        = 80<br>      target_port = 80<br>      node_port = 30000<br>    }</pre><pre>type = &quot;NodePort&quot;<br>  }<br>}</pre><pre>resource &quot;kubernetes_deployment&quot; &quot;wp-deploy&quot; {<br>  metadata {<br>    name = &quot;wp-deploy&quot;<br>  }</pre><pre>spec {<br>    replicas = 3</pre><pre>selector {<br>      match_labels = {<br>        app = &quot;wp&quot;<br>      }<br>    }</pre><pre>template {<br>      metadata {<br>        labels = {<br>          app = &quot;wp&quot;<br>        }<br>      }</pre><pre>spec {<br>        container {<br>          image = &quot;wordpress&quot;<br>          name  = &quot;wp-con&quot;<br>        }<br>      }<br>    }<br>  }<br>}</pre><p>I have exposed the wordpress site in public world on Port Number 30000 . Also created 3 replicas of pod for load balancing .</p><p>Now apply this code</p><pre>terraform apply --auto-approve</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IFmcQy8FCIeGmRy7UaRj9A.png" /></figure><p>So we can see launched pods :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e2GhP6ZQ6Ln1XXNnlfp6tw.png" /></figure><blockquote><strong>STEP 2 :</strong> Now w<em>rite </em>a terraform code which automatically create a MySQL database using RDS of AWS</blockquote><p># Code</p><pre>provider &quot;aws&quot; {<br>  region     = &quot;ap-south-1&quot;<br>  profile    = &quot;mypriyanshi&quot;<br>}</pre><pre>resource &quot;aws_security_group&quot; &quot;sg&quot; {<br>  name        = &quot;mysql-sg&quot;</pre><pre># Allowing traffic only for MySQL and that too from same VPC only.<br>  ingress {<br>    description = &quot;Allow All&quot;<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }</pre><pre># Allowing all outbound traffic<br>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }</pre><pre>tags = {<br>    Name = &quot;mysql-sg&quot;<br>  }<br>}</pre><pre>resource &quot;aws_db_instance&quot; &quot;mysql-db&quot; {<br>  allocated_storage    = 20<br>  storage_type         = &quot;gp2&quot;<br>  engine               = &quot;mysql&quot;<br>  engine_version       = &quot;5.7.30&quot;<br>  instance_class       = &quot;db.t2.micro&quot;<br>  vpc_security_group_ids = [aws_security_group.sg.id]<br>  identifier           = &quot;mysqldb&quot;<br>  name                 = &quot;mysqldb&quot;<br>  username             = &quot;priyanshi&quot;<br>  password             = &quot;priyanshi123&quot;<br>  parameter_group_name = &quot;default.mysql5.7&quot;<br>  publicly_accessible = true<br>  skip_final_snapshot = true<br>}</pre><p>Created a security group which allows all inbound traffic to enter and attached it to the database . Then created a MySQL database having name “mysqldb” . Gave UserName and Password . Made it publically accessible and skipped the formation of final snapshot ( forms when database is deleted ) so that there will be no problem while destroying the Infrastructure as it won’t create snapshot .</p><p>Again here we have to install all the required plugins</p><pre>terraform init</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AdkYWgTBsELxR9lOy0Tbfg.png" /></figure><p>Now apply the code</p><pre>terraform apply --auto-approve</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*42ZiON62QCxxhjHrDK0lGQ.png" /></figure><p>So now we can see that our MySQL database is ready to use .</p><p>SECURITY GROUP (“mysql-sg”) :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mvtA25MHje9sZqro97scYg.png" /></figure><p>DATABASE (“mysqldb”)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*D3YOdxor_EK_LzsJ4u_bfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*zHcUEfCFtmvBqczW7wP7LA.png" /></figure><p>I will use the end point of above created database to connect WordPress with MySQL .</p><p><strong><em>Installation of WordPress .</em></strong></p><p>Open Wordpress site using &lt;Minikube-IP&gt; :&lt;Port-Number&gt;. In my case it is [ 192.168.99.105:30000 ] .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DI5KXsYkKSypVyCq7v_ZJQ.png" /></figure><p>Provide the above created authentication credentials of MySQL database .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vqVG8NCTv7yXyOI3Ruotgg.png" /></figure><p>Set UserName and Password for WordPress site .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6CJGEqmp7j-INppJ7vu2iw.png" /></figure><p>Login with the above created authentication credentials .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*120CfiVSLCYcX_Xaq8QbIA.png" /></figure><p>Finally we can write a own blog here .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FqiX_rJHzZdlYCQBKEFrpQ.png" /></figure><p>My Wordpress Application :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CrN2AMP_tR0tarxw1skW3g.png" /></figure><p>To destroy whole infrastructure</p><pre>terraform destroy --auto-approve</pre><p>My GitHub Repository :- <a href="https://github.com/Priyanshi-Garg/cloud-task6.git">https://github.com/Priyanshi-Garg/cloud-task6.git</a></p><p>Thanks For Reading :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8991ee13e388" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Devops Task-6 : CI / CD Pipeline Using Groovy]]></title>
            <link>https://medium.com/@gargpriyanshi39/devops-task-6-ci-cd-pipeline-using-groovy-a6764f2cfd77?source=rss-3474912cf7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6764f2cfd77</guid>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[groovy]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Priyanshi Garg]]></dc:creator>
            <pubDate>Sun, 02 Aug 2020 12:43:04 GMT</pubDate>
            <atom:updated>2020-08-02T12:48:01.612Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q4Fs4wqXdR6uZBx1" /></figure><h3>Devops Task-6 : CI / CD Pipeline Using Groovy</h3><h3>CI / CD Pipeline</h3><p>A CI/CD Pipeline implementation, or Continuous Integration/Continuous Deployment, is the backbone of the modern DevOps environment. It bridges the gap between development and operations teams by automating the building, testing, and deployment of applications.</p><p>In Jenkins, a pipeline is a group of events or jobs which are interlinked with one another in a sequence.</p><p>In simple words, Jenkins Pipeline is a combination of plugins that support the integration and implementation of <strong>continuous delivery pipelines</strong> using Jenkins. A pipeline has an extensible automation server for creating simple or complex delivery pipelines “as code,” via pipeline DSL (Domain-specific Language).</p><h3>Jenkins File</h3><p>Jenkins pipelines can be defined using a text file called <strong>JenkinsFile. </strong>You can implement pipeline as code using JenkinsFile, and this can be defined by using a domain specific language (DSL). With JenkinsFile, you can write the steps needed for running a Jenkins pipeline.</p><p>The benefits of using J<strong>enkinsFile are</strong>:</p><ul><li>You can create pipelines automatically for all branches and execute pull requests with just one <strong>JenkinsFile.</strong></li><li>You can review your code on the pipeline</li><li>You can audit your Jenkins pipeline</li><li>This is the singular source for your pipeline and can be modified by multiple users.</li></ul><p>Jenkins use groovy (DSL : domain specific language ) for creating the code for jenkins file .</p><h3>Groovy</h3><p>Groovy is a <strong>powerful</strong>, <strong>optionally typed</strong> and <strong>dynamic</strong> language, with <strong>static-typing and static compilation</strong> capabilities, for the Java platform aimed at improving developer productivity thanks to a concise, <strong>familiar and easy to learn syntax</strong>. It integrates smoothly with any Java program, and immediately delivers to your application powerful features, including scripting capabilities, <strong>Domain-Specific Language</strong> authoring, runtime and compile-time <strong>meta-programming</strong> and <strong>functional</strong> programming.</p><h3>Task Description :</h3><ol><li>Create container image that’s has Jenkins installed using dockerfile Or You can use the Jenkins Server on RHEL 8/7 .</li></ol><p>2. When we launch this image, it should automatically starts Jenkins service in the container.</p><p>3. Create a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins</p><p>4. Job1 : Pull the Github repo automatically when some developers push repo to Github.</p><p>5. Job2 : By looking at the code or program file, Jenkins should automatically start the respective language interpreter installed image container to deploy code on top of Kubernetes ( eg. If code is of PHP, then Jenkins should start the container that has PHP already installed )</p><p>- Expose your pod so that testing team could perform the testing on the pod</p><p>- Make the data to remain persistent .</p><p>6. Job3 : Test your app if it is working or not.</p><p>7. Job4 : If app is not working , then send email to developer with error messages and redeploy the application after code is being edited by the developer.</p><p>All the above task must be done by using the codefile/groovy script.</p><p>In this task, developer can push an groovy script on github and with the help of that script jobs are created..Just a seed job needs to be created with dsl plugin installed , this job will pull the script and save it…</p><p>For better understanding Please go through my Task-3 first on below provided link .</p><p><a href="https://medium.com/@gargpriyanshi39/devops-task-3-upgradation-of-task-2-using-kubernetes-d8c53ebce802">DevOps Task-3 : Upgradation Of Task-2 Using Kubernetes</a></p><h3>SO LET’S BEGIN :</h3><p>For this task I have used Jenkins Server on RHEL 8/7 . Few more softwares that we require configured in our base os :</p><ol><li>Open JDK java for running Jenkins</li><li>Docker</li><li>Kubernetes</li></ol><p>Create a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins . So I have created a Jenkins file for all the JOBS and also created a build pipeline view using Groovy (DSL).</p><p>Plugins Required :</p><ol><li>GitHub</li><li>Build Pipeline</li><li>Job DSL</li></ol><blockquote><strong>SEED JOB : T</strong>his job will pull the script and form other 4 JOBS .</blockquote><p>It will copy the script form GitHub</p><p>You can view whole script here :- <a href="https://github.com/Priyanshi-Garg/dev-task6.git">My GitHub Repo</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2foHnQ1ZgM-jn2Tr6hzSMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KHxQLV1n821p4nEta9YQxg.png" /></figure><p>In build step we want to process Job DSL . Specify the DSL script “task6.groovy”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OHiw_wh9dvZkpXinm-tKUQ.png" /></figure><p>NOTE :- When we build this JOB , it fails .</p><p><strong>Console Output :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*aC2H1aTPkc9DUcei1ATNkA.png" /></figure><p>So we have to approve the script first . Go to &gt;&gt; Manage Jenkins &gt;&gt; In-process Script Approval &gt;&gt; Approve</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*djWsVDTC34WiaM33ERVk4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*NGbFwo-pKWup2mwG7dFu-w.png" /></figure><p>Now again build the job . This time it will be successfully build .</p><p>CONSOLE OUTPUT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*530ZlErmVYgKKTWU5T1hiA.png" /></figure><p>We can also see that all the Job are created automatically . So Powerful 😎</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYncUKwjglhNXsCbr97EqQ.png" /></figure><p>Now let’s see the configuration done by jenkins file in each JOB .</p><blockquote><strong>JOB 1 :</strong> Pull the Github repo automatically when some developers push repo to Github.</blockquote><p>You see all the Webpages and YML file here :- <a href="https://github.com/Priyanshi-Garg/dev-task6-code.git">My GitHub Repo</a></p><p># Code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20556f313c7b7bf1c97d102dab753872/href">https://medium.com/media/20556f313c7b7bf1c97d102dab753872/href</a></iframe><p>Configuration of JOB 1 :-</p><p>Description added and became a GitHub project . Used Poll SCM as triggers so that whenever developer uploads a code jenkins automatically download it and build the JOB .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LrMWb6s3Iu2zjCzUdW9P0w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XbEtVP1mlRBz16ZvyyoRpw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YQSg7-OELLqPBqtOxI5mNg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tv6MhzIC1fa97ynyyquLSg.png" /></figure><p>Here I have created a seperate directory and copied all the GitHub files in it .</p><p># Execute Shell</p><pre>if ls / | grep task6-ws<br>then<br>sudo cp -rf * /task6-ws<br>else<br>sudo mkdir /task6-ws<br>sudo cp -rf * /task6-ws<br>fi</pre><p>CONSOLE OUTPUT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EPDrDtcs0Ni36j-6zMK2dg.png" /></figure><blockquote>JOB 2 : By looking at the code or program file, Jenkins should automatically start the respective language interpreter installed image container to deploy code on top of Kubernetes ( eg. If code is of PHP, then Jenkins should start the container that has PHP already installed )</blockquote><p>- Expose your pod so that testing team could perform the testing on the pod</p><ul><li>Make the data to remain persistent</li></ul><p># Code for JOB 2</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0721e8b77e5bb5788a721c2d5fa125a5/href">https://medium.com/media/0721e8b77e5bb5788a721c2d5fa125a5/href</a></iframe><p>Configuration of JOB 2:</p><p>Added description</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQrz8n_HRUOJ2ffc6SgJ3w.png" /></figure><p>Set a JOB 1 as upstream project and created an authentication token “deploy”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*phPVW8iyKwUmVc2v3u4-YA.png" /></figure><p>Execute Shell</p><p>Here I have classified the code according to it’s extension . I have only checked for “.html” extension . You can do same for other extensions also . Copied the all the html files in “/task6-ws/ws-html” folder .</p><p>Then launched deployment using “task-6.yml” config file . For better understanding go through my <a href="https://medium.com/@gargpriyanshi39/devops-task-3-upgradation-of-task-2-using-kubernetes-d8c53ebce802?source=friends_link&amp;sk=1fb15bb18ed9af247632df894836bf1e">Task-3</a> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YspT9XNJnynXoR0pWxWXEg.png" /></figure><p>CONSOLE OUTPUT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l_ELVzK97SCYiRRJC7ItiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZacQCMLPw5wr2u7ghx1chw.png" /></figure><blockquote><strong>JOB 3 :</strong> Test your app if it is working or not.</blockquote><p># Code for JOB 3</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d638fd617f61d9ba41c8a2b058181ec/href">https://medium.com/media/0d638fd617f61d9ba41c8a2b058181ec/href</a></iframe><p>Configuration of JOB 3:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eFUQ1x0zxwBFnue2CeaZuw.png" /></figure><p>Set JOB 2 as upstream project .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BFduoY4aDpeBnMbkszFr0A.png" /></figure><p>Check whether the site is running fine or not . If status code is == 200 then working fine otherwise exit the job with code 1 i.e Failure .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MEDUW1sg2eXYicskFVwz1w.png" /></figure><p># Code</p><pre>status=$(curl -o /dev/null  -s  -w &quot;%{http_code}&quot;  <a href="http://192.168.99.105:30000/">http://192.168.99.105:30000</a>)<br>if [ $status == 200 ]<br>then<br>exit 0<br>else<br>exit 1<br>fi</pre><p>CONSOLE OUTPUT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3tcUjoVl9Cbb68rxf8gTgQ.png" /></figure><blockquote><strong>JOB 4 : </strong>If app is not working , then send email to developer with error messages and redeploy the application after code is being edited by the developer.</blockquote><p># Code for JOB 4</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e81af3e6a4e103d01988ae7de199b466/href">https://medium.com/media/e81af3e6a4e103d01988ae7de199b466/href</a></iframe><p>Configuration of JOB 4 :</p><p>Added a desc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mxmEi1SdZeSuLGGl2hqUTg.png" /></figure><p>Set JOB 3 as it’s upstream project .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5rww3BagtPfQc0QK4F8a_w.png" /></figure><p>If the deployment exist than print everything is fine otherwise send mail to the developer woth error msg. and redeploy the pods .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IJcZ14hMdhJAzNSitMoK7w.png" /></figure><p># Code</p><pre>if sudo kubectl get deployments | grep html-deploy<br>    then<br>    echo &quot;Everything is fine&quot;<br>    else<br>    sudo python3 /root/mail.py<br>    sudo curl -I --user admin:&lt;password&gt; <a href="http://192.168.99.102:8080//job/dev-t6-job2/build?token=deploy">http://192.168.99.102:8080//job/dev-t6-job2/build?token=deploy</a><br>    fi</pre><p>CONSOLE OUTPUT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I7tSETLbL_vw-dpfTEvd6A.png" /></figure><p>Mail.py file :-</p><pre>import smtplib, ssl</pre><pre>port = 465 # FOR SSL<br>smtp_server = &quot;smtp.gmail.com&quot;<br>sender_email = &quot;<a href="/service/mailto:gargpriyanshi39@gmail.com">&lt;</a>username&gt;&quot;<br>reciever_email = &quot;<a href="/service/mailto:gargpriyanshi39@gmail.com">&lt;</a>username&gt;&quot;<br>password = &quot;&lt;password&gt;&quot;<br>message = &quot;&quot;&quot;\<br>Subject: Task-6 Error<br>OOPs !! Testing Failed  . &quot;&quot;&quot;</pre><pre>context = ssl.create_default_context()<br>with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:<br>    server.login(sender_email, password)<br>    server.sendmail(sender_email, reciever_email, message)<br>~</pre><p>Error Notification :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8xuLUM-wm5ldVrLqicQI_A.png" /></figure><p>Website :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GfYyq4C9N3D70hnMwywUDw.png" /></figure><blockquote><strong>Build Pipeline View</strong></blockquote><p># Code for the same</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e53a21e09f105d92d316ec8ad74db9ef/href">https://medium.com/media/e53a21e09f105d92d316ec8ad74db9ef/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K14WI0yoqNfrsgJBBigz-g.png" /></figure><p>Hope You Liked This Article</p><p>Thank You For Reading :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6764f2cfd77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Task-4 Create Dynamic Jenkins Slave And Launch Application Using Kubernetes]]></title>
            <link>https://medium.com/@gargpriyanshi39/task-4-create-dynamic-jenkins-slave-and-launch-application-using-kubernetes-ca1e1e70492?source=rss-3474912cf7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca1e1e70492</guid>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Priyanshi Garg]]></dc:creator>
            <pubDate>Sat, 01 Aug 2020 10:04:28 GMT</pubDate>
            <atom:updated>2020-08-02T05:07:04.563Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/945/0*tFyz_JIjfnKK-cOO.png" /></figure><h3>Task-4 : Launch Application In Dynamic Jenkins Slave Using Kubernetes</h3><p><strong>JENKINS : </strong>Jenkins is an open-source automation tool written in Java with plugins built for Continuous Integration purposes. Jenkins is used to build and test your software projects continuously making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. It also allows you to continuously deliver your software by integrating with a large number of testing and deployment technologies.</p><p><strong>Advantages to include Jenkins :</strong></p><ul><li>It is an open-source tool with great community support.</li><li>Too easy to install.</li><li>It has 1000+ plugins to ease your work. If a plugin does not exist, you can code it and share it with the community.</li><li>It is free of cost.</li><li>It is built with Java and hence, it is portable to all the major platforms.</li></ul><p>This single Jenkins server was not enough to meet certain requirements like:</p><ul><li>Sometimes you might need several different environments to test your builds. This cannot be done by a single Jenkins server.</li><li>If larger and heavier projects get built on a regular basis then a single Jenkins server cannot simply handle the entire load.</li></ul><p>To address the above-stated needs, Jenkins distributed architecture came into the picture.</p><h3>Jenkins Distributed Architecture</h3><p>Jenkins uses a Master-Slave architecture to manage distributed builds. In this architecture, Master and Slave communicate through TCP/IP protocol.</p><h3><strong>Jenkins Master</strong></h3><p>Your main Jenkins server is the Master. The Master’s job is to handle:</p><ul><li>Scheduling build jobs.</li><li>Dispatching builds to the slaves for the actual execution.</li><li>Monitor the slaves (possibly taking them online and offline as required).</li><li>Recording and presenting the build results.</li><li>A Master instance of Jenkins can also execute build jobs directly.</li></ul><h3>Jenkins Slave</h3><p>A Slave is a Java executable that runs on a remote machine. Following are the characteristics of Jenkins Slaves:</p><ul><li>It hears requests from the Jenkins Master instance.</li><li>Slaves can run on a variety of operating systems.</li><li>The job of a Slave is to do as they are told to, which involves executing build jobs dispatched by the Master.</li><li>You can configure a project to always run on a particular Slave machine or a particular type of Slave machine, or simply let Jenkins pick the next available Slave.</li></ul><p>In General we can create slave in two ways :-</p><ol><li>Static</li><li>Dynamic</li></ol><p>Static slave require huge amount of resources hence is more costlier than dynamic . So we generally create dynamic jenkins slaves .</p><h3>Problem Statement :</h3><ol><li>Create container image that’s has Linux and other basic configuration required to run Slave for Jenkins. ( example here we require kubectl to be configured )</li></ol><p>2. When we launch the job it should automatically starts job on slave based on the label provided for dynamic approach.</p><p>3. Create a job chain of job1 &amp; job2 using build pipeline plugin in Jenkins</p><p>4. Job1 : Pull the Github repo automatically when some developers push repo to Github and perform the following operations as:</p><p>a. Create the new image dynamically for the application and copy the application code into that corresponding docker image</p><p>b. Push that image to the docker hub (Public repository)</p><p>( Github code contain the application code and Dockerfile to create a new image )</p><p>5. Job2 ( Should be run on the dynamic slave of Jenkins configured with Kubernetes kubectl command): Launch the application on the top of Kubernetes cluster performing following operations:</p><p>1. If launching first time then create a deployment of the pod using the image created in the previous job. Else if deployment already exists then do rollout of the existing pod making zero downtime for the user.</p><p>2. If Application created first time, then Expose the application. Else don’t expose it.</p><blockquote><strong><em>NOTE</em></strong> :- First of all we have to do some setup like add -H tcp://0.0.0.0:4243 in /usr/lib/systemd/system/docker.service file so that docker service of this VM can be used by another machine[this process is called socket binding ].</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*FqlBBInIllNbZHUw0GY_Uw.png" /></figure><p>and then reload and restart your docker services</p><pre>systemctl daemon-reload</pre><pre>systemctl restart docker</pre><blockquote><strong>Step 1 :</strong> Creating the container image that’s has Linux and other basic configuration required to run Slave for Jenkins. ( example here we require kubectl to be configured ).</blockquote><p>It is always a good practice to create a new workspace . So I have created a new directory “/root/dev-t4” in my base os i.e. rhel8 and put all the files , certificates , keys etc required for building the image .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Bj82jZmD7oU18WiemHYBQ.png" /></figure><p>This is my Dockerfile for dynamic jenkins slave :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*STsr6DHqa2Ew1HI3Lv6MHw.png" /></figure><p># Code</p><pre>FROM centos:latest<br>COPY kubernetes.repo /etc/yum.repos.d/kubernetes.repo<br>RUN yum install kubectl -y<br>RUN chmod +x ./kubectl<br>RUN mv ./kubectl /usr/bin/<br>RUN kubectl version --client<br>RUN mkdir /root/.kube<br>COPY config /root/.kube/<br>COPY *.crt /root/<br>COPY client.key /root/<br>RUN yum install java -y<br>RUN yum install openssh-server -y<br>RUN mkdir /root/jenkins-ws<br>RUN ssh-keygen -A<br>COPY ssh_config /etc/ssh/<br>RUN echo root:redhat | chpasswd<br>CMD [&quot;/usr/sbin/sshd&quot; , &quot;-D&quot;] &amp;&amp; / bin/bash<br>RUN yum install sudo -y<br>RUN yum install git -y</pre><p>Since we want kubectl to be configured in the dynamic slave so we have to download and install kubectl in it using Dockerfile .</p><p>I have installed kubectl using Native Package Management . So first of all created a kubernetes.repo file using cmd :-</p><pre>cat &lt;&lt;EOF &gt; /etc/yum.repos.d/kubernetes.repo<br>[kubernetes]<br>name=Kubernetes<br>baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64<br>enabled=1<br>gpgcheck=1<br>repo_gpgcheck=1<br>gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg<br>EOF</pre><p><strong>Kubernetes.repo file :-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X2J4fbkglfeSDJESr6MXNg.png" /></figure><p>Then install kubectl cmd using :-</p><pre>yum install kubectl -y</pre><p>Create a .kube folder and copy config file in it .</p><p><strong>Config file :-</strong></p><pre>apiVersion: v1<br>kind: Config</pre><pre>clusters:<br>- cluster:<br>    server: <a href="https://192.168.99.101:8443/">https://192.168.99.105:8443</a><br>    certificate-authority: /root/ca.crt<br>  name: pgcluster</pre><pre>contexts:<br>- context:<br>    cluster: pgcluster<br>    user: Priyanshi</pre><pre>users:<br>- name: Priyanshi<br>  user:<br>    client-key: /root/client.key<br>    client-certificate: /root/client.crt</pre><p>Also copy all the certificates and keys using COPY cmd in /root folder of node. Install ssh software so that jenkins can connect to the newly launched dynamic node through ssh . Set a password to login using ssh . Also create a ssh_config file .</p><p>ssh_config file :-</p><pre>Port 22<br>Protocol 2<br>Hostkey /etc/ssh/ssh_host_rsa_key<br>Hostkey /etc/ssh/ssh_host_dsa_key<br>Hostkey /etc/ssh/ssh_host_ecda_key<br>Hostkey /etc/ssh/ssh_host_ed25519_key</pre><pre>LoginGraceTime 120<br>PermitRootLogin yes<br>StrictModes yes<br>RSAAuthentication yes<br>PubkeyAuthentication yes<br>usePAM yes</pre><p>Create a directory which is used as jenkins working directory “/root/jenkins-ws” so all the github files will be downloaded in it by default . Install git and sudo softwares also .</p><p>Now we have to build the image using cmd :-</p><pre>docker build -t k8s:v1 .</pre><p>After building first tag and then push this image in docker hub</p><p>Tag :-</p><pre>docker tag k8s:v1 priyanshigarg/k8s:v1</pre><p>Push :-</p><pre>docker push priyanshigarg/k8s:v1</pre><p>Image :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D8ZYdZwEi0WZy4BKF_lwnQ.png" /></figure><p>So our image is ready . Now we have to setup Jenkins Cloud . For this we have to install Docker , Biuld Pipeline , Gihub plugins .</p><p>Then go to &gt;&gt;Manage Jenkins &gt;&gt; Manage Nodes and Clouds &gt;&gt;Configure Clouds . And do following configurations .</p><p>Set Host URL :- tcp://{IP of VM in which this dynamic cloud will bw launched}:4243</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pjSdG8bO1QUB_gpqvjICpg.png" /></figure><p>Give a Label to the cloud , Use above created Docker Image “priyanshigarg/k8s:v1” and specify the Root File System Root as “/root/jenkins-ws” which is the jenkins workspace for this node .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FdO72WA6u82MTs62Zq-3YQ.png" /></figure><p>Choose connect method :- SSH and give the login credentials . In my case it is “root:redhat” . Then Apply &amp; Save .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E_fV3N5-kqlgSyuL7rNgog.png" /></figure><p>So setup of cloud is done !! . Now we have to create Jenkins jobs .</p><blockquote><strong>JOB 1 : </strong>Pull the Github repo automatically when some developers push repo to Github and perform the following operations as:</blockquote><p><strong>a</strong>. Create the new image dynamically for the application and copy the application code into that corresponding docker image</p><p><strong>b</strong>. Push that image to the docker hub (Public repository)</p><p>( Github code contain the application code and Dockerfile to create a new image )</p><p><strong>Dockerfile for the creation of image which is used to lauch application:</strong></p><pre>FROM centos:latest<br>RUN yum install httpd -y <br>WORKDIR /root/jen-ws<br>COPY  *.html  /var/www/html<br>CMD /usr/sbin/httpd -DFOREGROUND &amp;&amp; /bin/bash<br>EXPOSE 80</pre><p>In this I have installed httpd ( apache webserver ) for deploying website . Created working directory “/root/jen-ws” and copied all the webpages in it . Started httpd services and exposed port number 80 .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*CBbc4ey8JzYp6Ks5H9IWvQ.png" /></figure><p><a href="https://github.com/Priyanshi-Garg/devops-task4.git">My Github Repo</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oGTMOdtLRygfYAMNQOHFQg.png" /></figure><p>Added Build triggers so that whenever the developer uploads a new code jenkins JOB automatically gets triggered . Here I have used Poll SCM .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8xV-nloipQgY2fW6jAXZ5w.png" /></figure><p><strong>Execute Shell</strong></p><p>Create a seperate Workspace “/dev-task4” and copy the GitHub files in it .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M_WUoYJujFIgN495GHUtLw.png" /></figure><p># Code</p><pre>sudo rm -rvf /dev-task4<br>sudo mkdir /dev-task4<br>sudo cp -vrf * /dev-task4</pre><p>Now add Post Build Actions : [ Biuld / Publish Docker Image ] for building and pushing the image to docker hub using Jenkins .</p><p>Specify the Directory for Dockerfile . Since I have copied all the GitHub files in “/dev-task4” directory so I have to specify this particular directory only . Give the cloud name “docker” . Then Give the name to the image which is to be build . And specify the docker hub credentials so that jenkins can login and push the image .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2B6NAG3fysyPpnboOFAkvg.png" /></figure><p>Console output after Build :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YsPk0Pyi_YNl3ui2fgf9CQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q-eJIa7C4lzkKdyJ9XMeZw.png" /></figure><p>Image pushed on docker hub :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9IZUn33Ohise1gQfMLxiHA.png" /></figure><blockquote><strong>JOB 2 : </strong>( Should be run on the dynamic slave of Jenkins configured with Kubernetes kubectl command): Launch the application on the top of Kubernetes cluster performing following operations:</blockquote><p>1. If launching first time then create a deployment of the pod using the image created in the previous job. Else if deployment already exists then do rollout of the existing pod making zero downtime for the user.</p><p>2. If Application created first time, then Expose the application. Else don’t expose it.</p><p>Since we want that this Job run on the above created cloud , so we have to Restrict where this project builds . While setting up cloud I have gave the label “dyn-k8s” to it , so I have specified this .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*4uGPpKh5RAWGqGCwNaQctg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BI4e0gfuKSIxSQ7u1_84dA.png" /></figure><p><strong>Execute Shell :-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dyF6CWbupRFqPULB_qFvjQ.png" /></figure><p># Code</p><pre>sudo cp *.yml /root/<br>if sudo kubectl get deploy | grep t4-deploy<br>then<br>sudo kubectl rollout restart deployment/t4-deploy<br>sudo kubectl rollout status deployment/t4-deploy<br>else <br>sudo kubectl create -f /root/task4.yml<br>sudo kubectl expose deploy t4-deploy --port=80 --type=NodePort<br>fi<br>kubectl get all</pre><p>So I have copied the “task4.yml” file in “/root/” folder of the dynamic jenkins slave . Created deployment and exposed it an if already exists then rollout .</p><p><strong>My “task4.yml” file :-</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a4334c68944e89f34232fe61359f9c3/href">https://medium.com/media/6a4334c68944e89f34232fe61359f9c3/href</a></iframe><p>I have created a deployment so that without any downtime our application can be rolled out . For load balancing created 3 replicas . And used the image which is created in JOB 1 .</p><p>Console Output :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZqgO2yRAPw4kgxKw1Yp8bA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NQX3sXLAK5pUF6Wq1DuW8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*CffNuhficXkKWcpHP75o8g.png" /></figure><p>Now we can see our Website using [ IP of minikube ]:[ Port number on which our pod is exposed ] ie [ 192.168.99.105:32608 ]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_FTP-AClx94yKy2guyWRKw.png" /></figure><p>Now If I change the code of my webpage I can see my new webpage without any downtime .</p><p>Since I change the code and pushed to GitHub so JOB 1 will automatically start and build the image with new application . After successful build of JOB 1 , JOB 2 automatically trigger and rollout pods .</p><p>Console Output of JOB 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hSPYuGsL3hq6v-rIjY5prw.png" /></figure><p>New Webpage :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pORYI0SEDxhFM_NS4j-C0g.png" /></figure><p>Biuld Pipeline View :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*anXmW9mbJTwBgfjqatTq4w.png" /></figure><p>Hope You Liked This Article</p><p>Thanks For Reading :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca1e1e70492" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Task-3 : VPC Architecture Using Terraform]]></title>
            <link>https://medium.com/@gargpriyanshi39/task-3-vpc-architecture-using-terraform-d626cd7155ca?source=rss-3474912cf7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/d626cd7155ca</guid>
            <dc:creator><![CDATA[Priyanshi Garg]]></dc:creator>
            <pubDate>Wed, 15 Jul 2020 19:49:38 GMT</pubDate>
            <atom:updated>2020-07-16T19:10:29.079Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*Z14O-YNIjLx20pjo.png" /></figure><h3>Task-3 : VPC Architecture Using Terraform</h3><h3>NAAS ( Network As A Service ) -</h3><p>The network as a service provides networking infrastructure to the customers, who don’t want to build their own application. The third party can deliver the network infrastructure. NaaS includes services such as Wide Area Networking Connectivity, Datacenter Connectivity, Bandwidth on Demand, and other applications. It includes the optimization of resource allocations by making network and computing resources as a unified whole.</p><h4>In AWS service which provides NAAS is known as VPC(Virtual Private Cloud).</h4><h3>VPC -</h3><p>A virtual private cloud (VPC) is a virtual network dedicated to your AWS account. It is logically isolated from other virtual networks in the AWS Cloud. You can launch your AWS resources, such as Amazon EC2 instances, into your VPC.</p><p>When you create a VPC, you must specify a range of IPv4 addresses for the VPC in the form of a Classless Inter-Domain Routing (CIDR) block; for example, 10.0.0.0/16. This is the primary CIDR block for your VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*0rT-V83bBnfav0-y.png" /></figure><h3>Main Objective :-</h3><p>We have to create a web portal for our company with all the security as much as possible.So, we use WordPress software with dedicated database server.Database should not be accessible from the outside world for security purposes.We only need to public the WordPress to clients.</p><p>Steps :-</p><p>1) Write a Infrastructure as code using terraform, which automatically create a VPC.</p><p>2) In that VPC we have to create 2 subnets:</p><p>a) public subnet [ Accessible for Public World! ]</p><p>b) private subnet [ Restricted for Public World! ]</p><p>3) Create a public facing internet gateway for connect our VPC/Network to the internet world and attach this gateway to our VPC.</p><p>4) Create a routing table for Internet gateway so that instance can connect to outside world, update and associate it with public subnet.</p><p>5) Launch an ec2 instance which has Wordpress setup already having the security group allowing port 80 so that our client can connect to our wordpress site.</p><p>Also attach the key to instance for further login into it.</p><p>6) Launch an ec2 instance which has MYSQL setup already with security group allowing port 3306 in private subnet so that our wordpress vm can connect with the same.</p><p>Also attach the key with the same.</p><p>Note: Wordpress instance has to be part of public subnet so that our client can connect our site. Mysql instance has to be part of private subnet so that outside world can’t connect to it.</p><p>For creating this whole architecture we will use Terraform code . It is a good practice to always create a seperate workspace . So here I have created “task3-ws” directory on Desktop.</p><p><strong>STEP 1</strong> : First provide the provider which we will be using i.e. “aws”</p><pre>provider &quot;aws&quot; {<br>  region     = &quot;ap-south-1&quot;<br>  profile    = &quot;mypriyanshi&quot;<br>}</pre><p>Here “mypriyanshi” is a IAM user .</p><p>Now initialize it so that terraform can download the appropriate plugins using command :-</p><pre>terraform init</pre><p><strong>STEP 2</strong> : Create VPC and provide a CIDR block range .</p><pre>resource &quot;aws_vpc&quot; &quot;t3-vpc&quot; {<br>  cidr_block       = &quot;192.168.0.0/16&quot;<br>  instance_tenancy = &quot;default&quot;<br>  enable_dns_hostnames = &quot;true&quot;<br>  tags = {<br>    Name = &quot;t3-vpc&quot;<br>  }<br>}</pre><p>Here I have provided “192.168.0.0/16” IP range . Give a unique name to the vpc it is “t3-vpc” in my case and enable dns hostname .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6jfZHNJDARTZyoqq3XYm4w.png" /></figure><p>Now In this VPC we have to create 2 subnets:</p><p>a) public subnet :- If a subnet’s traffic is routed to an internet gateway, the subnet is known as a <em>public subnet</em>.</p><p>b) private subnet : If a subnet doesn’t have a route to the internet gateway, the subnet is known as a <em>private subnet</em>.</p><p><strong>STEP 3 </strong>: Create a Public Subnet for WordPress site and give IPv4 IP range which should be in the VPC IP range .</p><pre>resource &quot;aws_subnet&quot; &quot;public-subnet&quot; {<br>  vpc_id     = &quot;${aws_vpc.t3-vpc.id}&quot;<br>  cidr_block = &quot;192.168.0.0/24&quot;<br>  availability_zone = &quot;ap-south-1a&quot;<br>  map_public_ip_on_launch = &quot;true&quot;<br>  tags = {<br>    Name = &quot;public-subnet&quot;<br>  }<br>}</pre><p>So here I have provided “192.168.0.0/24” IP range . Also we have to specify the availability zone to this subnet . Now we have to enable “map_public_ip_on_launch” so that when we launch any instance in this subnet it automatically assigns a public IP to it .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nPp1I5t2YlyudtXeVqgbUA.png" /></figure><p><strong>STEP 4</strong> : Create a Private subnet for MySQL database and a give IPv4 IP range which should be in the VPC IP range and unique from other subnets .</p><pre>resource &quot;aws_subnet&quot; &quot;private-subnet&quot; {<br>  vpc_id     = &quot;${aws_vpc.t3-vpc.id}&quot;<br>  cidr_block = &quot;192.168.1.0/24&quot;<br>  availability_zone = &quot;ap-south-1b&quot;<br>  tags = {<br>    Name = &quot;private-subnet&quot;<br>  }<br>}</pre><p>So I have provided “192.168.1.0/24” to this subnet . Also we have to specify the availability zone to this subnet but different from other other subnet for disaster management .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E4eL_109U-5garnlzyTJ1Q.png" /></figure><p><strong>STEP 5</strong> : Create an Internet Gateway and attach it to our VPC .</p><p>Internet Gateway :- An internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows communication between your VPC and the internet.</p><p>An internet gateway serves two purposes: to provide a target in your VPC route tables for internet-routable traffic, and to perform network address translation (NAT) for instances that have been assigned public IPv4 addresses.</p><pre>resource &quot;aws_internet_gateway&quot; &quot;t3-igw&quot; {<br>  vpc_id = &quot;${aws_vpc.t3-vpc.id}&quot;</pre><pre>tags = {<br>    Name = &quot;t3-igw&quot;<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FsAkT2h1Xvid5zTTTOVjcA.png" /></figure><p>Creating Internet Gateway is not sufficient for internet connectivity . For proper internet connectivity we have to create route table and associate it with the internet gateway .</p><p><strong>Route Table</strong> :- A <em>route table</em> contains a set of rules, called <em>routes</em>, that are used to determine where network traffic from your subnet or gateway is directed.</p><p><strong>STEP 6 </strong>: Create a Route Table in order to connect our public subnet to the Internet Gateway .</p><pre>resource &quot;aws_route_table&quot; &quot;t3-route&quot; {<br>  vpc_id = &quot;${aws_vpc.t3-vpc.id}&quot;</pre><pre>route {<br>    cidr_block = &quot;0.0.0.0/0&quot;<br>    gateway_id = &quot;${aws_internet_gateway.t3-igw.id}&quot;<br>  }<br>  tags = {<br>    Name = &quot;t3-route&quot;<br>  }<br>}</pre><p>Now Associate this Route Table to the public subnet .</p><pre>resource &quot;aws_route_table_association&quot; &quot;t3-route-association&quot; {<br>  subnet_id      = aws_subnet.public-subnet.id<br>  route_table_id = aws_route_table.t3-route.id<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ol7tLg3pXU-n--z6X_VEeg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-qLKCqYc5C3w1mvUAYUprg.png" /></figure><p>Now we launch our WordPress and MySQL ec2-instances . But first we have to create Key Pairs and Security Groups for these instances . Here I have used same key-pair for both ec2-instances but it is a good practice to create seperate key-pairs .</p><p><strong>STEP 7 </strong>: Create a Key Pair .</p><pre>provider &quot;tls&quot; {}<br>resource &quot;tls_private_key&quot; &quot;t&quot; {<br>    algorithm = &quot;RSA&quot;<br>}<br>resource &quot;aws_key_pair&quot; &quot;test&quot; {<br>    key_name   = &quot;task3-key&quot;<br>    public_key = &quot;${tls_private_key.t.public_key_openssh}&quot;<br>}<br>provider &quot;local&quot; {}<br>resource &quot;local_file&quot; &quot;key&quot; {<br>    content  = &quot;${tls_private_key.t.private_key_pem}&quot;<br>    filename = &quot;task3-key.pem&quot;<br>       <br>}</pre><p>So here I have created key pair and saved a local copy in our working directory .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zdxdmqw_WsPMpwH5o_cHPQ.png" /></figure><p><strong>STEP 8</strong> : Create Security Group for WordPress instance which allow following protocols</p><ul><li>HTTP</li><li>SSH</li><li>ICMP</li></ul><pre>resource &quot;aws_security_group&quot; &quot;wp-sg&quot; {<br>  name        = &quot;wp-sg&quot;<br>  description = &quot;Allow HTTP and SSH inbound traffic&quot;<br>  vpc_id      = &quot;${aws_vpc.t3-vpc.id}&quot;<br>  ingress {<br>    description = &quot;SSH&quot;<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br>  ingress {<br>    description = &quot;HTTP&quot;<br>    from_port   = 80<br>    to_port     = 80<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br>  ingress {<br>    description = &quot;ICMP&quot;<br>    from_port   = 8<br>    to_port     = 0<br>    protocol    = &quot;icmp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br>  tags = {<br>    Name = &quot;wp-sg&quot;<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NbPaq688Pt3jV0VxdvOASg.png" /></figure><p><strong>STEP 9</strong> : Now launch a WordPress instance using above created Key pair (“task3-key”) and “wp-sg” Security Group in Public subnet .</p><pre>resource &quot;aws_instance&quot; &quot;wp-os&quot; {<br>  ami           = &quot;ami-7e257211&quot;<br>  instance_type = &quot;t2.micro&quot;<br>  key_name = &quot;task3-key&quot;<br>  vpc_security_group_ids = [ aws_security_group.wp-sg.id ]<br>  subnet_id = aws_subnet.public-subnet.id<br>  tags = {<br>    Name = &quot;wp-os&quot;<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*Fz8KaPJwqwry9PvFP8JTMw.png" /></figure><p><strong>STEP 10</strong> : Create a Security Group for MySQL instance which allow only MySQL port number i.e. “3306” in the above created vpc</p><pre>resource &quot;aws_security_group&quot; &quot;mysql-sg&quot; {<br>  name        = &quot;basic&quot;<br>  description = &quot;Allow TLS inbound traffic&quot;<br>  vpc_id      = &quot;${aws_vpc.t3-vpc.id}&quot;</pre><pre>ingress {<br>    description = &quot;mysql-security_group&quot;<br>    from_port   = 3306<br>    to_port     = 3306<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br>  tags = {<br>    Name = &quot;mysql-sg&quot;<br>  }<br>}</pre><p>Since we don’t want to connect our database to the public world so we only expose port number 3306</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ug2-tnqd8giUMhPhk4aR-Q.png" /></figure><p><strong>STEP 11</strong> : Launch a MySQL instance using above created Key Pair (“task3-key”) and “mysql-sg” Security Group in the private subnet .</p><pre>resource &quot;aws_instance&quot; &quot;mysql-os&quot; {<br>  ami           = &quot;ami-08706cb5f68222d09&quot;<br>  instance_type = &quot;t2.micro&quot;<br>  key_name      = &quot;task3-key&quot;<br>  subnet_id =  aws_subnet.private-subnet.id<br>  vpc_security_group_ids = [ aws_security_group.mysql-sg.id ]<br>  tags = {<br>    Name = &quot;mysql-os&quot;<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*HUiqjUS1eCHJgS4IgvlLWg.png" /></figure><p><strong>STEP 12</strong> : Create whole architecture using cmd :-</p><pre>terraform apply --auto-approve</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xOXYLwY5lPlxLlL5fpVICw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CfpSkyasEFEEhd-GClbkjg.png" /></figure><p>By using Public IP or Public DNS we can access our WordPress site.</p><p>WordPress site :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qjUbWZDJKJvyIyxKJUFShA.png" /></figure><p>Now we can write blogs in this wordpress site .</p><p>Hope you enjoyed reading this article .</p><p><strong>Thanks for reading :-)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d626cd7155ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DevOps Task-3 : Upgradation Of Task-2 Using Kubernetes]]></title>
            <link>https://medium.com/@gargpriyanshi39/devops-task-3-upgradation-of-task-2-using-kubernetes-d8c53ebce802?source=rss-3474912cf7a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8c53ebce802</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <dc:creator><![CDATA[Priyanshi Garg]]></dc:creator>
            <pubDate>Sat, 11 Jul 2020 11:41:02 GMT</pubDate>
            <atom:updated>2020-07-13T11:08:05.336Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kj8QAT3NLRHDRPZd.png" /></figure><h3>DevOps Task-3 : CI/CD Pipeline Using Jenkins , Kubernetes , GitHub</h3><p><strong>Kubernetes :</strong></p><p>Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.</p><p>Why do we need Kubernetes if all our work can be done using docker ?</p><p>Ans :- Kubernetes manages the pods running by itself , hence we dont require to do monitoring of pods and do load balancing . It also provides an extra feature of persistent volume through which we can make our data persistent .</p><blockquote><strong>Task Description :</strong></blockquote><p>1. Create container image that has Jenkins installed using dockerfile .</p><p>2. When we launch this image, it should automatically starts Jenkins service in the container.</p><p>3. Create a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins</p><p>4. Job1 : Pull the Github repo automatically when some developers push repo to Github.</p><p>5. Job2 : By looking at the code or program file, Jenkins should automatically start the respective language interpreter installed image container to deploy code on top of Kubernetes ( eg. If code is of PHP, then Jenkins should start the container that has PHP already installed ) .</p><p>6. Expose your pod so that testing team could perform the testing on the pod</p><p>7. Make the data to remain persistent .</p><p>8. Job3 : Test your app if it is working or not.</p><p>9. Job4 : If app is not working , then send email to developer with error messages and redeploy the application after code is being edited by the developer .</p><p><strong>NOTE</strong> :- Since kubernetes is a container <strong>orchestration tool</strong> . Hence we don’t have to create a extra Job for monitoring . Kubernetes do monitoring by itself .</p><p><strong><em>Let me first describe “task-3.yml” file through which we will create Service , PV , PVC , Deploment in k8s.</em></strong></p><h4><strong>Service</strong> :-</h4><p>A service can be defined as a logical set of pods. It can be defined as an abstraction on the top of the pod which provides a <strong>single IP address</strong> and <strong>DNS name</strong> by which pods can be accessed. With Service, it is very easy to manage <strong>load balancing</strong> configuration. It helps pods to <strong>scale</strong> very easily.</p><p>If you use a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/">Deployment</a> to run your app, it can create and destroy Pods dynamically. Each Pod gets its own IP address, however in a Deployment, the set of Pods running in one moment in time could be different from the set of Pods running that application a moment later. This leads to a problem .</p><p>Hence to resolve this problem we create a Service which provides all pods a single IP . The IP will remain same even after all the pods destroy .</p><p># Code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d363e502310dc2071aab982bfa5f0a7/href">https://medium.com/media/8d363e502310dc2071aab982bfa5f0a7/href</a></iframe><p>NOTE :- It will expose all the pods having label env : production to port Number 30000 .</p><p><strong>Persistent Volume ( PV ):-</strong></p><p>Container storage via a container&#39;s root file system is ephemeral, and can disappear upon container deletion and creation. To provide a durable location to prevent data from being lost, you can create and use persistent volumes to store data outside of containers.</p><p>A persistent volume offers persistent storage that enables your data to remain intact, regardless of whether the containers to which the storage is connected are terminated.</p><p># Code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b46264de72599e954e73bc097ac5eee/href">https://medium.com/media/2b46264de72599e954e73bc097ac5eee/href</a></iframe><p>Here the hostPath is the path of a folder in minikube . I have created hostPath a PersistentVolume .</p><p>Minikube :- A tool that runs a single-node Kubernetes cluster in a virtual machine on your personal computer .</p><p><strong>Persistent Volume Claim ( PVC ):-</strong></p><p>A persistent volume claim (PVC) is a request for storage, which is met by binding the PVC to a persistent volume (PV). A PVC provides an abstraction layer to the underlying storage. For example, an administrator could create a number of static persistent volumes that can later be bound to one or more persistent volume claims. If none of the static persistent volumes match the user’s PVC request, the cluster may attempt to dynamically create a new PV that matches the PVC request.</p><p># Code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e09d6022da67b052d1a9c27cdfad15ac/href">https://medium.com/media/e09d6022da67b052d1a9c27cdfad15ac/href</a></iframe><p><strong>Deployment :-</strong></p><p><em>Deployments</em> represent a set of multiple, identical <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/pod">Pods</a> with no unique identities. A Deployment runs multiple replicas of your application and automatically replaces any instances that fail or become unresponsive. In this way, Deployments help ensure that one or more instances of your application are available to serve user requests. Deployments are managed by the Kubernetes Deployment controller .</p><p># Code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14f255110de1608e8bf1567d693ea67f/href">https://medium.com/media/14f255110de1608e8bf1567d693ea67f/href</a></iframe><p>I have created 3 replicas of pod for load balancing . By default the strategy used by Deployment is Rolling Update .</p><p><strong>Rolling updates</strong> allow Deployments update to take place with zero downtime by incrementally updating Pods instances with new ones.</p><p>Lastly mounted the above created PVC to the “/usr/local/apache2/htdocs” folder of httpd image , because all the webpages are usually stored in this folder . So we made this folder to be persistent so that whenever the pod terminates due to any reason our data don’t loose .</p><p><strong>Now come to hand’s on part</strong></p><blockquote>Create container image that has Jenkins installed using dockerfile .When we launch this image, it should automatically starts Jenkins service in the container.</blockquote><p>Dockerfile :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*I7Z8hhNkRCao1HcvmVQqag.png" /></figure><p>Now to create image from this Dockerfile we have to just run command :-</p><pre><em>docker build -t jenkins:latest .</em></pre><p>Launch a container using this image .</p><pre>docker run -it — privileged -p 8888:8080 -v /:/host jenkins:latest</pre><p>Creation of jenkins installed image I have explained in detail in Task-2 . So please first go through my Task-2 .</p><p><a href="https://www.linkedin.com/pulse/task-2-cicd-pipeline-using-github-jenkins-docker-priyanshi-garg">Task -2 :- CI/CD Pipeline Using GitHub, Jenkins And Docker</a></p><p>So now directly jump to Jenkins Jobs .</p><p><em>Jenkins :- It is an open source CI/CD tool.</em></p><blockquote><strong>Job1 :</strong> Pull the Github repo automatically when some developers push repo to Github.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Ct7Ffoz6NCDo75xErmyRQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*--MbP34GV0Rh4w9UtyU66g.png" /></figure><p>Used GitHub Webhooks so that whenever a developer pushes code on GitHub , Jenkins Job will automatically trigger .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*inzBEBVdy-i5B6t2Igtu1A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jBB4tt9syyTS8EyRpt1CSg.png" /></figure><p>Shell Script :-</p><p>First of all checked whether there is any pre-created directory having same name as “task3-ws” in /host folder . If present then remove it and create a new one . And copy all github files in that .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1NN6wVO915TQkbG9nqDDeg.png" /></figure><blockquote><strong>JOB 2</strong> : By looking at the code or program file, Jenkins should automatically start the respective language interpreter installed image container to deploy code on top of Kubernetes ( eg. If code is of PHP, then Jenkins should start the container that has PHP already installed ) .</blockquote><p>Set Build triggers so that this Job will automatically trigger after successful build of JOB 1 .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kqlc_WwnT0H_iTBTeFtmpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QsnDTeWbTZyWi-1M072d6w.png" /></figure><p>Full Code :-</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f50610476ede08cc8009ba3c507b187d/href">https://medium.com/media/f50610476ede08cc8009ba3c507b187d/href</a></iframe><p><strong>Explaination of above code step by step :-</strong></p><p><strong>“ <em>chroot</em> “</strong> :- A chroot environment provides functionality similar to that of a virtual machine, but it is a lighter solution.</p><p>1 . So firstly create a new environment using chroot . For detailed explanation of chroot you can go through my <a href="https://www.linkedin.com/pulse/task-2-cicd-pipeline-using-github-jenkins-docker-priyanshi-garg">Task-2</a>.</p><p>2 . Then checked whether the files are of html or php , here I have checked only for html but you can use same approach to check for other extentions also .</p><p>3 . Create a new directory “ws-html” particularly for HTML files inside “task3-ws” , if directory already present then firstly removed it and creat a new one. Check all the files and copied only those which are having same extention i.e. “.html” using cmd :-</p><pre>cp -rvf /task3-ws/*.html /task3-ws/ws-html</pre><p>4 . Now create service , pv , pvc and deployment through “task-3.yml” file using cmd :-</p><pre>sudo kubectl create -f task-3.yml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H7SLL_d7_xNGav8Gb_Bqmw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q2pXruRU48fWoQoMALS5ng.png" /></figure><p>5 . And Finally copy all the files present in “ws-html” directory in the minikube directory “/home/docker/devops-task3” using cmd :-</p><pre>sshpass -p &quot;&lt;minikube_password&gt;&quot; scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r * docker@192.168.99.101:/home/docker/devops-task3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yQxnRARLfNOHfqNsozbQ_w.png" /></figure><p>Console Output :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ocpR6rTjXJ24lI2hkBOQsA.png" /></figure><blockquote><strong>JOB 3</strong> : Test your app if it is working or not.</blockquote><p>Set Build triggers so that this job automatically runs after successful build of Job 2 .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c-UZaAqBhM91R_TaiYBO3Q.png" /></figure><p>This Job will check the status code of webpage . If it is 200 then it will terminate with exit code 0 else exit with status code 1 .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UfxyRsF33Symum70NyARRg.png" /></figure><p>NOTE :- 192.168.99.101 is my minikube IP .</p><p>Added Post build actions to trigger JOB 4 if this JOB fails .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CV7EecgXm_QXKR8YdXRxpQ.png" /></figure><p>Console Output :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l2jy2LSqVNM1BiuIWw5dww.png" /></figure><p>My webpage “index.html” :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QJF4jELrVQG5g9bfw_xMEA.png" /></figure><blockquote><strong>JOB 4</strong> : If app is not working , then send email to developer with error messages .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jV-iBigKJahd4TY202aJ0g.png" /></figure><p>Mail.py file :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*y6VeSbo_hbSq6rQJFeDJdw.png" /></figure><p>Email Notification if the Job 3 fails :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T_s0X5UKQL926FomxT8reQ.png" /></figure><p>Build Pipeline :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rOY08LBaUklXx23hyAksuQ.png" /></figure><p><a href="https://github.com/Priyanshi-Garg/devops-task3.git">My GitHub Repository</a></p><p>Thanks for reading :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8c53ebce802" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>