<?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 Rohan Khandelwal on Medium]]></title>
        <description><![CDATA[Stories by Rohan Khandelwal on Medium]]></description>
        <link>https://medium.com/@rkwal-007?source=rss-8b96d37f8e0d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*s4R9d5qO9qzJotIj</url>
            <title>Stories by Rohan Khandelwal on Medium</title>
            <link>https://medium.com/@rkwal-007?source=rss-8b96d37f8e0d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:52:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rkwal-007/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[Cybercrime & Confusion Matrix]]></title>
            <link>https://rkwal-007.medium.com/cybercrime-confusion-matrix-1f2e8ab3a1f0?source=rss-8b96d37f8e0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f2e8ab3a1f0</guid>
            <category><![CDATA[confusion-matrix]]></category>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Rohan Khandelwal]]></dc:creator>
            <pubDate>Sun, 06 Jun 2021 16:05:42 GMT</pubDate>
            <atom:updated>2021-06-06T16:05:42.344Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LTucnFxNIC4h-MFxLS6zwQ.png" /></figure><h3>Cybercrime</h3><p>Cybercrime is any criminal activity that involves a computer, networked device or a network. While most cybercrimes are carried out in order to generate profit for the cybercriminals, some cybercrimes are carried out against computers or devices directly to damage or disable them, while others use computers or networks to spread malware, illegal information, images or other materials. Some cybercrimes do both — i.e., target computers to infect them with a computer virus, which is then spread to other machines and, sometimes, entire networks.</p><p>A primary effect of cybercrime is financial; cybercrime can include many different types of profit-driven criminal activity, including ransomware attacks, email and internet fraud, and identity fraud, as well as attempts to steal financial account, credit card or other payment card information. Cybercriminals may also target an individual’s private information, as well as corporate data for theft and resale. As many workers settle into remote work routines due to the pandemic, cybercrimes are expected to grow in frequency in 2021, making it especially important to protect backup data.</p><h3>Confusion Matrix</h3><p>Confusion matrices represent counts from predicted and actual values. The output “TN” stands for True Negative which shows the number of negative examples classified accurately. Similarly, “TP” stands for True Positive which indicates the number of positive examples classified accurately. The term “FP” shows False Positive value, i.e., the number of actual negative examples classified as positive; and “FN” means a False Negative value which is the number of actual positive examples classified as negative. One of the most commonly used metrics while performing classification is accuracy. The accuracy of a model (through a confusion matrix) is calculated using the given formula below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*QjppS3kfVEeDJ72EtfWPIA.png" /></figure><p>Accuracy can be misleading if used with imbalanced datasets, and therefore there are other metrics based on confusion matrix which can be useful for evaluating performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vbfuOkRGdcNkUXp8uEi4BA.png" /></figure><p>There are two possible predicted classes: “positive/yes” and “negative/no”.</p><h4>Let’s now define the most basic terms</h4><ul><li><strong>true positives (TP):</strong> These are cases in which we predicted positive , and it’s true.</li><li><strong>true negatives (TN):</strong> We predicted no, and it’s true.</li><li><strong>false positives (FP):</strong> We predicted positive, but it’s false. (Also known as “Type I error.”)</li><li><strong>false negatives (FN):</strong> We predicted negative, but it’s false. (Also known as “Type II error.”)</li></ul><h3>Types of cybercrime</h3><ul><li>Email and internet fraud.</li><li>Identity fraud (where personal information is stolen and used).</li><li>Theft of financial or card payment data.</li><li>Theft and sale of corporate data.</li><li>Cyberextortion (demanding money to prevent a threatened attack).</li><li>Ransomware attacks (a type of cyberextortion).</li><li>Cryptojacking (where hackers mine cryptocurrency using resources they do not own).</li><li>Cyberespionage (where hackers access government or company data).</li></ul><blockquote>Let’s look into cyber crime cases using confusion matrix</blockquote><blockquote>Let’s understand it with the help of theft of financial data:</blockquote><p>Digital payments of various forms are rapidly increasing across the world. Payments companies are experiencing rapid growth in their transactions volume. For example, PayPal processed ~$578 billion in total payments in 2018. Along with this transformation, there is also a rapid increase in financial fraud that happens in these payment systems. Preventing online financial fraud is a vital part of the work done by cybersecurity and cyber-crime teams. Most banks and financial institutions have dedicated teams of dozens of analysts building automated systems to analyze transactions taking place through their products and flag potentially fraudulent ones. Therefore, it is essential to explore the approach to solving the problem of detecting fraudulent entries/transactions in large amounts of data in order to be better prepared to solve cyber-crime cases.</p><h3>Objective</h3><p>This model is to detect fraud financial transactions. Outcome of the project will help streamline the analysis and detection of fraudulent transactions.</p><h3>Methodology Phases</h3><ol><li><strong>Understanding the data set:<br>-&gt;</strong>Report on the summary of the data set and each variable it contains along with necessary visualizations</li><li><strong>Exploratory Data Analysis:<br>-&gt;</strong>Report on analysis conducted and critical findings with a full description of data slices considered  <br>-&gt;Hypothesis about the separation between fraud and nonfraud transactions<br>-&gt;Visualizations and charts that show the differences between fraud and non-fraud transactions<br>-&gt;Python code of the analysis performed</li><li><strong>Modeling<br>-&gt;</strong>Report on the results of the different techniques tried out, iterations that were experimented with, data transformations and the detailed modeling approach<br>-&gt;Python code used to build machine learning models</li></ol><h4>Data Sources</h4><p>Due to the private nature of financial data, there is a lack of publicly available datasets that can be used for analysis. In this project, a synthetic dataset, publicly available on Kaggle, generated using a simulator called PaySim is used. The dataset was generated using aggregated metrics from the private dataset of a multinational mobile financial services company, and then malicious entries were injected.</p><blockquote>Let’s directly move to the Modeling Phase</blockquote><h3>Steps Before Creating a Model</h3><ul><li>Dataset Creation</li><li>Standardizing the data</li><li>Create train and test datasets</li></ul><h3>Classification Model for Fraud detection</h3><p>To measure the performance of the models, Recall is a useful metric. High-class imbalance datasets typically result in poor Recall, although accuracy may be high. Precision will also be a consideration because reduced precision implies that the company that is trying to detect fraud will incur more cost in screening the transactions. In fraud detection problems, though, accurately identifying fraudulent transactions is more critical than incorrectly classifying legitimate transactions as fraudulent.</p><h4>Random Forest Model</h4><p>In this model, we repeat the same steps using a different classification algorithm such as Random Forest, and we calculate the mean recall score.</p><p>After checking the output, we can see that the Random Forest model seems to produce excellent results on the training dataset. If we plot the confusion matrices for the training and testing datasets and we check the precision and recall in each case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*yzfUYvq2o7wztvdQqBd4MQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*uLT-Zq1t-haUjeg-LBZ7YA.png" /></figure><blockquote><strong>Let’s try to understand Confusion Matrix now:</strong></blockquote><ul><li><strong>true positives (TP):</strong> These are cases in which it predicted as fraud, and it actually is fraud too.</li><li><strong>true negatives (TN):</strong> It predicted not as fraud, and it actually is not fraud too.</li><li><strong>false positives (FP):</strong> It predicted as fraud, but it is actually not fraud. (Also known as “Type I error.”)</li><li><strong>false negatives (FN):</strong> It predicted as not fraud, but it is actually fraud. (Also known as “Type II error.”)</li></ul><p>In this case, we can’t afford the type I error and minimum type II error. But it may vary in different cases.</p><p>So, we can conclude that the Random Forest algorithm gave almost perfect results.</p><h4>Thank you for reading…</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f2e8ab3a1f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GUI Container on Docker]]></title>
            <link>https://rkwal-007.medium.com/gui-container-on-docker-3c951c9b9d7a?source=rss-8b96d37f8e0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c951c9b9d7a</guid>
            <dc:creator><![CDATA[Rohan Khandelwal]]></dc:creator>
            <pubDate>Tue, 01 Jun 2021 12:27:36 GMT</pubDate>
            <atom:updated>2021-06-01T12:51:16.782Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PfsaUoCuzgbieeP8oDM_8A.png" /></figure><h3>Task:</h3><p>Launch a container on docker in GUI mode</p><p>Run any GUI software on the container</p><h3>Implementation:</h3><ol><li>For launching a container on docker in GUI mode, we can use the following command:</li></ol><blockquote>docker run -it — — name task2— — net=host — — env=”DISPLAY” — — volume=”$HOME/.Xauthority:/root/.Xauthority:rw” centos</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*K46IrDzgoqoHd7199G-QPA.png" /></figure><p>Now we are in the centos container. To prove it, we can run any program which is installed in the base OS but not in the container. Here, we tried to run the firefox program but as we can see, it says “command not found”</p><p>2. Now to run any GUI software on the container, we need to install a GUI based software.<br>We can install firefox using yum</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*7ss9i1g-RaIcesv0pUb0vQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*uHyJ6PiVoaqtHk7RP0L5sA.png" /></figure><p>Now, we can finally run the firefox program…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*0aQ-Pj6j9ifcd3yHVdZ9zw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*EED8tSUBkriWhhRje0DJ-g.png" /></figure><h3>Thanks for reading</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c951c9b9d7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine Learning Model on Container]]></title>
            <link>https://rkwal-007.medium.com/machine-learning-model-on-container-1c734afa9be3?source=rss-8b96d37f8e0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c734afa9be3</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[Rohan Khandelwal]]></dc:creator>
            <pubDate>Sat, 29 May 2021 18:26:37 GMT</pubDate>
            <atom:updated>2021-05-29T18:26:37.410Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hrQR5njSy6GAWJ45Vus1Hg.jpeg" /></figure><h3>What are containers?</h3><p>Containers are a form of operating system virtualization. A single container might be used to run anything from a small microservice or software process to a larger application. Inside a container are all the necessary executables, binary code, libraries, and configuration files. Compared to server or machine virtualization approaches, however, containers do not contain operating system images. This makes them more lightweight and portable, with significantly less overhead. In larger application deployments, multiple containers may be deployed as one or more container clusters.</p><h3>Benefits of containers</h3><ul><li><strong>Less overhead</strong><br>Containers require less system resources than traditional or hardware virtual machine environments because they don’t include operating system images.</li><li><strong>Increased portability</strong><br>Applications running in containers can be deployed easily to multiple different operating systems and hardware platforms.</li><li><strong>More consistent operation</strong><br>DevOps teams know applications in containers will run the same, regardless of where they are deployed.</li><li><strong>Greater efficiency</strong><br>Containers allow applications to be more rapidly deployed, patched, or scaled.</li><li><strong>Better application development</strong><br>Containers support agile and DevOps efforts to accelerate development, test, and production cycles.</li></ul><h3>Task :</h3><p>Pull the Docker container image of CentOS image from DockerHub and create a new container</p><p>Install the Python software on the top of docker container</p><p>In Container you need to copy/create machine learning model which you have created in jupyter notebook</p><h3>Let’s Get Started</h3><ol><li>We need to pull container image of CentOS from DockerHub. We can do that with the help of the following command:</li></ol><pre>docker pull centos:version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*qeGFEfRiDUVWXEdcvhTeQw.png" /></figure><p>2. Now we need to run the container and copy the dataset &amp; the python program in the container. To do that, we can use the following command:</p><pre>docker run -it -v /dir_in_baseos:/dir_in_container --name task-1 cetos</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*9bFxBuVHvT6lrEubuU4sqA.png" /></figure><p>Now we have copied the directory and successfully launched our container.</p><p>3. So to be able to create and use our machine learning model, we need to set up the environment first.<br> We need to install python first in our container. We can use “yum” to install it</p><pre>yum install python3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*eh_r20V0Vxs6JjV1oaO4RA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*q8VvBfCxWiAtPPlXE8q4qg.png" /></figure><p>This will install the python 3 successfully for us</p><p>But we still can’t create our model yet as we still need to install the required python libraries. We need the following libraries:</p><p>=&gt; numpy<br>=&gt; pandas<br>=&gt; scikit-learn</p><p>We can use pip3 to install them</p><pre>pip3 install numpy pandas scikit-learn</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*M0WJwcNk3RNYpsFx3BZT3Q.png" /></figure><p>Now our environment is set to create and use our Machine Learning model</p><p>4. Create the model</p><p>This is the final step of our task.<br>- First we need to go inside the directory where we copied our dataset and program.<br>- Now we can start with training our model and predicting the salary on the basis of year of experience</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*hTf2W2iZ_WPTiO1w_-aorg.png" /></figure><p>As we can see… it successfully predicted the salary.</p><h4>Thank You for reading this article</h4><p>My LinkedIn: <a href="http://linkedin.com/in/rohan-k-078818136">Rohan Khandelwal</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c734afa9be3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Webserver On K8s Using Groovy]]></title>
            <link>https://rkwal-007.medium.com/deploying-webserver-on-k8s-using-groovy-b4ecaa714f26?source=rss-8b96d37f8e0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4ecaa714f26</guid>
            <category><![CDATA[groovy]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Rohan Khandelwal]]></dc:creator>
            <pubDate>Mon, 01 Mar 2021 11:43:29 GMT</pubDate>
            <atom:updated>2021-03-01T11:43:29.304Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*U6bkJtTZhGq0hoafWetdQg.png" /></figure><blockquote>Perform <a href="https://rkwal-007.medium.com/ci-cd-pipeline-automation-using-kubernetes-98d8e8ad2ece">previous task</a> with the help of Jenkins coding file ( called as jenkinsfile approach ) and perform the with following phases:</blockquote><ol><li>Create container image that’s has Jenkins installed using dockerfile Or You can use the Jenkins Server on RHEL 8/7.</li><li>When we launch this image, it should automatically starts Jenkins service in the container.</li><li>Create a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins.</li><li>Job2 ( Seed Job ) : Pull the Github repo automatically when some developers push repo to Github.</li><li>Further on jobs should be pipeline using written code using Groovy language by the developer.</li><li>Job1 : <br> 1. 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 )<br> 2. Expose your pod so that testing team could perform the testing on the pod<br> 3. Make the data to remain persistent using PVC ( If server collects some data like logs, other user information )</li><li>Job3 : Test your app if it is working or not.</li><li>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.</li></ol><h3>Let’s Get Started:</h3><p><strong>Apache Groovy</strong> is a Java-syntax-compatible object-oriented programming language for the Java platform. It is both a static and dynamic language with features similar to those of Python, Ruby, and Smalltalk.</p><p><strong>Other Tools:</strong></p><ul><li>Git / GitHub -&gt; Source Code Management &amp; Version Controlling</li><li>Jenkins -&gt; Automate software development related to deploying</li><li>Kubernetes -&gt; container-orchestration system for automating application deployment, scaling, and management</li><li>Docker -&gt; Container Engine Kubernetes will manage</li><li>RHEL8</li><li>Minikube on MacOS</li></ul><p>We will start by setting up a GitHub repository. A Webhook is configured as well so that whenever a push is done, Job 1 build starts. When Developer changed something into GitHub then Jenkins Job-1 should be triggered automatically. For this, we have to create a webhook trigger on Github so that it automatically can trigger. But we have to remember one thing, Github belongs to the public world and my Jenkins is running into my RHEL8 which has private IP. So the Public world can’t connect to the private world. But we have one way. We can create a tunnel something like this so that the public world connect to my private world. <strong><em>ngrok</em></strong><em> is a software that I used to expose my private IP on the internet.</em></p><p>My entire setup is done on the top of RHEL8. First, we have to make change some changes in the docker service file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*eHqX1X9WEM6zJpir64syjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*ci3Uzrnby0iqjbs87LdGrQ.png" /></figure><pre>systemctl daemon-reload<br>systemctl restart docker.service</pre><p>The following plugins to be downloaded in Jenkins</p><ul><li>job DSL</li><li>Cloudbees docker build and publish plugin</li><li>script-security plugin</li></ul><p>Go to Manage Jenkins-&gt;Configure Global Security and disable script security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*btzwVXwR00wqMN5oLp8MbQ.png" /></figure><p>Now we will be doing a seed job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*OWiAIWMT9dVb3o4qkp6ZSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*i8rg0GhMilhijwTqJjeSpw.png" /></figure><p>After you build it, you get three new jobs and a new view in Build Pipeline.</p><p>You have to manually build the job1, job2, and job3 respectively. After the successful build of these jobs, you’ll get the following outputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gfvaMptFU6CxP9Dm_CzKOA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*wPe-p7ZCuJIFTCyF00sMuw.png" /></figure><p>job1 output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0dcTZRiIa-iROW9Dos5xw.png" /></figure><p>job2 output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*zSsf0dTReB8ThApB2qRS2A.png" /></figure><p>job3 output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iBr-24B6F4TZ2xNT6SrEgg.png" /></figure><p>EMAIL notification after successful built of job3</p><p>THANK YOU!</p><p>My Linkedin — <a href="http://linkedin.com/in/rohan-k-078818136">Rohan Khandelwal</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4ecaa714f26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Prometheus with Grafana]]></title>
            <link>https://rkwal-007.medium.com/integrating-prometheus-with-grafana-27bbf034e1be?source=rss-8b96d37f8e0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/27bbf034e1be</guid>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[prometheus]]></category>
            <dc:creator><![CDATA[Rohan Khandelwal]]></dc:creator>
            <pubDate>Mon, 01 Mar 2021 10:13:47 GMT</pubDate>
            <atom:updated>2021-03-01T10:13:47.832Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*WTNoKzyBLTLQ6RVsI4ktWw.jpeg" /></figure><blockquote>Integrate Prometheus and Grafana and perform in following way:</blockquote><ol><li>Deploy them as pods on top of Kubernetes by creating resources Deployment, ReplicaSet, Pods or Services.</li><li>And make their data to be remain persistent.</li><li>And both of them should be exposed to outside world.</li></ol><h3>Let’s Start…</h3><p>We need to create a PVC (Persistence Volume Claim) for Prometheus. Following YAML code to do the same is as follows:</p><pre>apiVersion: v1<br>  kind: PersistentVolumeClaim<br>  metadata: <br>    name: pvc-prometheus<br>    labels:<br>      name: pvcprometheus<br>  spec:    <br>    accessModes:<br>    - ReadWriteOnce<br>    resources:<br>      requests:   <br>       storage: 4Gi</pre><p>Now, we need to create a service for exporting the Prometheus using NodePort.</p><pre>apiVersion: v1<br>   kind: Service<br>   metadata:<br>     name: prometheus-svc<br>     labels:<br>       app: prometheus-service<br>   spec:<br>     selector:<br>       app: prometheus<br>   type: NodePort<br>   ports:<br>   - nodePort: 2300<br>     port: 9090<br>     targetPort: 9090<br>     name: prometheus-port</pre><p>Now, we created a deployment for Prometheus. I’ve used an image that was available on Docker Hub. However, you can easily create your own &amp; push it on the Docker Hub as per your requirement. Since creating own image has been discussed in very detail in many of my earlier projects,</p><p>The YAML code to creare the Deployment is as follows:</p><pre>apiVersion: apps/v1<br>  kind: Deployment<br>  metadata:<br>    name: prometheus-deployment<br>  spec:<br>    replicas: 1<br>    selector:<br>      matchLabels: <br>        tier: monitor<br>    template:<br>      metadata:<br>        labels:<br>          tier: monitor<br>      spec:<br>        containers:<br>        - name: prometheus<br>          image: prom/prometheus          ports:<br>          - containerPort: 9090          volumeMounts:<br>          - name: prometheus-volume<br>            mountPath: /data       volumes:<br>       - name: prometheus-volume<br>         persistentVolumeClaim:<br>             claimName: pvc-prometheus</pre><p><em>Now we do the same steps with Grafana</em></p><p>Now Creating PVC for Grafana</p><pre>apiVersion: v1<br> kind: PersistentVolumeClaim<br> metadata: <br>   name: pvc-grafana<br>   labels:<br>     name: pvcgrafana<br> spec:<br>   accessModes:<br>     - ReadWriteOnce<br> resources:<br>   requests:<br>      storage: 4Gi</pre><p>Next, we create a service to expose the Grafana using NodePort.</p><pre>apiVersion: v1<br>    kind: Service<br>    metadata:<br>      name: grafana-svc<br>      labels:<br>        app: grafana-service<br>    spec:<br>      selector:<br>        app: grafana<br>      type: NodePort<br>      ports:<br>      - nodePort: 2301<br>        port: 3000<br>        targetPort: 3000<br>        name: port-grafana</pre><p>Now, we create a deployment for Grafana. Here also , We have used an available image for Grafana from Dokcer Hub.</p><pre>apiVersion: apps/v1<br>  kind: Deployment<br>  metadata:<br>    name: grafana<br>    labels: <br>      app: grafana<br>      tier: deploy<br>  spec:<br>    replicas: 1<br>    selector:<br>      matchLabels: <br>        tier: monitoring<br>    template:<br>      metadata:<br>        labels:<br>          tier: monitoring<br>      spec:<br>        containers:<br>        - name: grafana-container<br>          image: grafana/grafana:latest          ports:<br>          - containerPort: 3000          volumeMounts:<br>          - name: grafana-volume<br>            mountPath: /var/lib/grafana        volumes:<br>        - name: grafana-volume<br>          persistentVolumeClaim:<br>            claimName: pvc-grafana</pre><p>Now that all our components are ready, we’ll create a kustomization file in which we will mention the sequence in which all these files will be created. We only need to run this kustomization file &amp; everything will be done.</p><pre>apiVersion: kustomize.config.k8s.io/v1beta1<br>   kind: Kustomization   resources:<br>    - pvcprometheus.yml<br>    - pvcgrafana.yml<br>    - prometheusdeploy.yml<br>    - grafanadeploy.yml <br>    - prometheusservice.yml<br>    - grafanaservice.yml</pre><p>We can create this file by going to the folder in this file is present &amp; running the following command in present &amp; running the following commnad in cmd prompt:</p><pre>$ kubectl apply -k</pre><p>Prometheus &amp; Grafana both will be launched on Kubernetes &amp; connected to a PVC to ensure there is no data loss in the process. Both the pods will be exposed to hte outside world. Since we have used Deployment to launch this arch., we need not to worry about the pod crash. The Replica Set (RS) working in background will relaunch the pods with same PVC in case they crash somehow. No data will be lost.</p><p>All you need to do now is to open the Prometheus &amp; Grafana in your browser using Minikube IP &amp; the mentioned port port &amp; start working ..!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*FsEeaaQAv5jh-i0VmuUfGg.png" /></figure><p>THANK YOU!</p><p>My Linkedin — <a href="http://linkedin.com/in/rohan-k-078818136">Rohan Khandelwal</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27bbf034e1be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI/CD pipeline using Dynamic Cluster]]></title>
            <link>https://rkwal-007.medium.com/ci-cd-pipeline-using-dynamic-cluster-583488d22943?source=rss-8b96d37f8e0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/583488d22943</guid>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Rohan Khandelwal]]></dc:creator>
            <pubDate>Mon, 01 Mar 2021 09:52:46 GMT</pubDate>
            <atom:updated>2021-03-01T09:52:46.015Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ymQPMEq_16panUbkSPKytw.png" /></figure><blockquote>Create A dynamic Jenkins cluster and perform <a href="https://rkwal-007.medium.com/ci-cd-pipeline-automation-using-kubernetes-98d8e8ad2ece">previous task</a> using the dynamic Jenkins cluster.</blockquote><p><strong>Steps to proceed as:</strong></p><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><li>When we launch the job it should automatically starts job on slave based on the label provided for dynamic approach.</li><li>Create a job chain of job1 &amp; job2 using build pipeline plugin in Jenkins .</li><li>Job1 : Pull the Github repo automatically when some developers push repo to Github and perform the following operations as:<br> 1. Create the new image dynamically for the application and copy the application code into that corresponding docker image<br> 2. Push that image to the docker hub (Public repository) <br> ( Github code contain the application code and Dockerfile to create a new image )</li><li>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:<br> 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.<br> 2. If Application created first time, then Expose the application. Else don’t expose it.</li></ol><h3>Let’s get started :</h3><p><strong>Step 1. 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 ).</strong></p><p>First I have created one workspace named as devtask in / directory. In this workspace I have created one Dockerfile for build the image that has linux and other basic configuration required to run Slave for Jenkins. ( example here we require kubectl to be configured ).In this workspace I have added one hidden folder “.kube” in which all the certificates ,key and config file that is required by kubectl to connect to kubernetes is added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*SWegGPkaDI3Fva2OGjCpRA.png" /></figure><p>This is the Dockerfile that I’ve created. I have copied the “.kube” directory that contains all the requirements for kubectl to connect with kubernetes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*lj0uVqhOZ8fA9zy5emlcNw.png" /></figure><p>Now simply build a Docker image using Dockerfile using following command :</p><pre>$ docker build -t jenkins4:v1 .</pre><p>For our requirement we need to tag this image in order to upload it on docker hub. We can tag a image using following command.</p><pre>$ docker tag jenkins4:v1 rohan4840/jenkins4:v1</pre><p>To push this image on Dokcer hub use following command</p><pre>$ docker push rohan4840/jenkins4:v1</pre><p>After the image has been uploaded to docker hub successfully we need to do some settings so that jenkins can be able to create dynamic slave for running the second job over it.</p><p>For this go to the docker host . In docker host first run “ systemctl status docker”. After this go to file — /usr/lib/systemd/system/docker.service and edit this file by command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*qCphzOig1cwF-KZm3mquaA.png" /></figure><p>After adding this line to this file we have to run two commands :</p><pre>$ systemctl daemon-reload<br>$ systemctl restart docker</pre><p>These commands are use to apply the changes we have done in the above file.</p><p><strong>Step 2. After launching the job jenkins should automatically start the job on the dynamic slave based on the labels , so for that we need to configure the jenkins and we have to also install 2 plugins “<em>Docker and Yet Another Docker”.</em></strong></p><p>Go to jenkins → Manage Nodes and clouds — -&gt; Configure clouds</p><p>In the Docker Host Uri — give the ip of dockerhost</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PUG4g_Ag4Uz8K6qwNcOuIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8e7Ed6y7swPgGyO-_3BiPg.png" /></figure><p><strong>Step 3. Creating the first job for the task</strong></p><p>Through this job jenkins will pull the Github repo automatically when some developers push repo to Github.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BJnvkPTJF6Gq5cq29dN6tw.png" /></figure><p>In this Github repository developer uploaded a application code and a Dockerfile.</p><p>This job will simply create a new docker image dynamically for the application and copy the application code into that corresponding docker image push that image to the docker hub (Public repository)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J9pkDHzFerOknnyzI0QK_A.png" /></figure><p><strong>Step 4. creating the second job that will run on dynamic slave. In this job we are giving the labels that we have assign at the time of configure the cloud so that by using this labels Jenkins will know that they have to run this job on dynamic slave and start creating slave dynamically for running this job.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ynMP_2uuvoCx5OAtOY1BmA.png" /></figure><p>Job 2 should run on the dynamic slave of Jenkins configured with K8s kubectl command.</p><p>Launch the application on the top of K8s cluster performing following operations:</p><ol><li>If launching for the first time then create a deployment of the pods 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.</li><li>If application created first time, then expose the application. Else don’t expose it.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nWAEKWaf0_XZD-q6s6-EKg.png" /></figure><p>As you can see the deployment has been created successfully on top of kubernetes cluster . All the pods are running fine and service has also created for exposing this deployment to outside world. The pods are running with the image that we have created in the first job.</p><p>The site is up running successfully on top of K8s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7YCQuW6XQvZH1uxBXv9JHQ.png" /></figure><p>THANK YOU!</p><p>My Linkedin — <a href="http://linkedin.com/in/rohan-k-078818136">Rohan Khandelwal</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=583488d22943" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI/CD Pipeline Automation Using Kubernetes]]></title>
            <link>https://rkwal-007.medium.com/ci-cd-pipeline-automation-using-kubernetes-98d8e8ad2ece?source=rss-8b96d37f8e0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/98d8e8ad2ece</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Rohan Khandelwal]]></dc:creator>
            <pubDate>Mon, 01 Mar 2021 08:30:41 GMT</pubDate>
            <atom:updated>2021-03-01T08:30:41.682Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*2QbQaPzMVAPewQbHG2XU8A.jpeg" /></figure><p><strong>Kubernetes</strong> (commonly stylized as <strong>k8s</strong>) is an open-source container orchestration system for automating application deployment, scaling, and management. It aims to provide a “platform for automating deployment, scaling, and operations of application containers across clusters of hosts”. It works with a range of container tools, including Docker. In other words, you can cluster together groups of hosts running Linux containers, and Kubernetes helps you easily and efficiently manage those clusters.</p><p>It helps you fully implement and rely on a container-based infrastructure in production environments. And because Kubernetes is all about automation of operational tasks, you can do many of the same things other application platforms or management systems let you do — but for your containers.</p><p>In order to meet changing business needs, your development team needs to be able to rapidly build new applications and services. Cloud-native development starts with microservices in containers, which enables faster development and makes it easier to transform and optimize existing applications.</p><p>In this article, I’m going to perform the following tasks…</p><ol><li>Create container image that’s has Jenkins installed using dockerfile or can use the Jenkins Server on RHEL 8/7.</li><li>When we launch this image, it should automatically starts Jenkins service in the container.</li><li>Create a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins.</li><li>Job1 : Pull the Github repo automatically when some developers push repo to Github.</li><li>Job2 : <br> 1. 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 )<br> 2. Expose your pod so that testing team could perform the testing on the pod<br> 3. Make the data to remain persistent ( If server collects some data like logs, other user information )</li><li>Job3 : Test your app if it is working or not.</li><li>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.</li></ol><p><strong>Step 1: Start minikube and get its IP.</strong></p><ul><li>minikube start</li><li>minikube ip</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*QSLLOTbOi3jTeIEPJQ8USw.png" /></figure><p><strong>Step 2: Copy these three files from windows to rhel8 for configuration.</strong></p><blockquote>C:\Users\ROHAN\.minikube\ca.crtC:\Users\ROHAN\.minikube\profiles\minikube\client.crtC:\Users\ROHAN\.minikube\profiles\minikube\client.key</blockquote><p>Step 3: Create a Jenkins image with kubectl installed on it. Configuration files will be given to it by mounting a directory.</p><p>Dockerfile:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zw_9NplwzzXja1qSq6w3CA.png" /></figure><p>Now use the build command:</p><pre>docker build -t jenkin:kubectl .</pre><p><strong>Step 4: Now start the container, login and set up the Jenkins.</strong></p><pre>docker run -it -v ~/kube-files:/root/.kube -P jenkin:kubectl</pre><p>The contents of the config file :</p><pre>apiVersion: v1<br>clusters:<br>- cluster:<br>    certificate-authority: ca.crt<br>    server: <a href="https://192.168.99.100:8443/">https://192.168.99.100:8443</a><br>name: minikube<br>contexts:<br>- context:<br>    cluster: minikube<br>    user: minikube<br>  name: minikube<br>current-context: minikube<br>kind: Config<br>preferences: {}<br>users:<br>- name: minikube<br>  user:<br>    client-certificate: client.crt<br>    client-key: client.key</pre><p>Now our kubectl is completely configured on the rhel8 workstation.</p><p><strong>Step 6: Job2 execute shell commands.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tq8JsFXx4uY8N9mDTx8ITw.png" /></figure><p><strong>Step 7: Integrate Job3 with the following code to copy the files from GitHub to our pods.</strong></p><pre>#!/usr/bin/python3<br>  <br>import oscmd = os.popen(&quot;kubectl get pods | grep webserver&quot;)<br>cmd_op = cmd.read()<br>x = cmd_op.split(&#39;\n&#39;)<br>del x[-1]<br>for y in x:<br>    z = y.split()<br>    print(z)<br>    os.system(&quot;kubectl cp /root/.jenkins/workspace/job1/* {}:/usr/local/apache2/htdocs/&quot;.format(z[0]))</pre><p><strong>Step 8: Job4 will notify you using email if this build fails.</strong></p><p>Now, we don’t require a monitoring job as this will be handled by k8s.</p><p>Now test it by connecting to minikube,</p><pre>C:\Users\ROHAN\.minikube\profiles\minikube&gt; kubectl get all<br>NAME                             READY   STATUS    RESTARTS   AGE<br>pod/webserver-85b3b5597d-78rwl   1/1     Running   0          4h<br>pod/webserver-85b3b5597d-kvnzc   1/1     Running   0          4h<br>pod/webserver-85b3b5597d-pwkzc   1/1     Running   0          4hNAME                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE<br>service/kubernetes   ClusterIP   10.96.0.1      &lt;none&gt;        443/TCP        4h<br>service/webserver    NodePort    10.96.68.216   &lt;none&gt;        80:32040/TCP   5hNAME                        READY   UP-TO-DATE   AVAILABLE   AGE<br>deployment.apps/webserver   3/3     3            3           4hNAME                                   DESIRED   CURRENT   READY   AGE<br>replicaset.apps/webserver-85b3b5597d   3         3         3       4h</pre><p>Now testing the webserver,</p><pre>C:\Users\ROHAN&gt;curl 192.168.99.100:32040Welcome!!!!</pre><p><strong>THANK YOU!!</strong></p><p>My Linkedin - <a href="http://linkedin.com/in/rohan-k-078818136">Rohan Khandelwal</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98d8e8ad2ece" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Task 1]]></title>
            <link>https://rkwal-007.medium.com/task-1-b8b6aecee49a?source=rss-8b96d37f8e0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8b6aecee49a</guid>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[righteducation]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Rohan Khandelwal]]></dc:creator>
            <pubDate>Fri, 17 Jul 2020 08:13:19 GMT</pubDate>
            <atom:updated>2020-07-17T08:13:19.301Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ymQPMEq_16panUbkSPKytw.png" /></figure><h3>What is DevOps?</h3><p>DevOps is a set of practices that combines software development and IT operations. It aims to shorten the systems development life cycle and provide continuous delivery with high software quality. DevOps is complementary with Agile software development; several DevOps aspects came from Agile methodology.</p><h4>GitHub</h4><p>GitHub, Inc. is a United States-based global company that provides hosting for software development and version control using Git. It has been a subsidiary of Microsoft since 2018. It offers the distributed version control and source code management functionality of Git, plus its own features.</p><h4>Docker</h4><p>Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels.</p><h3>Getting started with the task</h3><h4>JOB 1</h4><p>If Developer push to test branch then Jenkins will fetch from dev and deploy on test-docker environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1b0RIYPgxdCkZb7ZaPb0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XRrLILQhgYy4MHsRU9OV2A.png" /></figure><h4>JOB 2</h4><p>If Developer push to master branch then Jenkins will fetch from master and deploy on master-docke environment.<br>both dev-docker and master-docker environment are on different docker containers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dve71eyl6SpJGM_XcjJ0Ow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*38sYyPVaR-ViAYANRsZRMg.png" /></figure><h4>JOB 3</h4><p>Manually the QA team will check (test) for the website running in test-docker environment. If it is running fine then Jenkins will merge the test branch to master branch and trigger job 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oz4Xkcx-4PN9zA5q-Ce6NA.png" /></figure><h4>Thanks for reading…</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8b6aecee49a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying WordPress, MySQL, Prometheus & Grafana on Amazon EKS]]></title>
            <link>https://rkwal-007.medium.com/deploying-wordpress-mysql-prometheus-grafana-on-amazon-eks-33787b732b68?source=rss-8b96d37f8e0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/33787b732b68</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-eks]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[prometheus]]></category>
            <dc:creator><![CDATA[Rohan Khandelwal]]></dc:creator>
            <pubDate>Sun, 12 Jul 2020 05:51:54 GMT</pubDate>
            <atom:updated>2020-07-12T05:51:54.730Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*dabeSf4DI7GLqwbsbtrMOw.jpeg" /></figure><h3>Amazon EKS</h3><p>Amazon Elastic Kubernetes Service (Amazon EKS) is a fully managed <a href="https://aws.amazon.com/kubernetes/">Kubernetes</a> service. Customers such as Intel, Snap, Intuit, GoDaddy, and Autodesk trust EKS to run their most sensitive and mission critical applications because of its security, reliability, and scalability.</p><p>EKS is the best place to run Kubernetes for several reasons. First, you can choose to run your EKS clusters using <a href="https://aws.amazon.com/fargate/">AWS Fargate</a>, which is serverless compute for containers. Fargate removes the need to provision and manage servers, lets you specify and pay for resources per application, and improves security through application isolation by design. Second, EKS is deeply integrated with services such as Amazon CloudWatch, Auto Scaling Groups, AWS Identity and Access Management (IAM), and Amazon Virtual Private Cloud (VPC), providing you a seamless experience to monitor, scale, and load-balance your applications. Third, EKS integrates with <a href="https://aws.amazon.com/app-mesh/">AWS App Mesh</a> and provides a Kubernetes native experience to consume service mesh features and bring rich observability, traffic controls and security features to applications. Additionally, EKS provides a scalable and highly-available control plane that runs across multiple availability zones to eliminate a single point of failure.</p><p>EKS runs upstream Kubernetes and is certified Kubernetes conformant so you can leverage all benefits of open source tooling from the community. You can also easily migrate any standard Kubernetes application to EKS without needing to refactor your code.</p><h3>Setting up the environment</h3><p>To start using the service, first we need to set up the following</p><ol><li><strong>AWS CLI </strong>— The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts. <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html">Click here</a> for the complete information about setting up AWS CLI.</li><li><strong>eskctl — </strong>It<strong> </strong>is a simple CLI tool for creating clusters on EKS — Amazon’s new managed Kubernetes service for EC2. It is written in Go, uses CloudFormation, was created by <a href="https://www.weave.works/">Weaveworks</a> and it welcomes contributions from the community.</li><li><strong>kubectl — </strong>kubectl controls the Kubernetes cluster manager. <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/">Click here</a> for the complete information about setting up kubectl.</li></ol><h3>Creating Cluster</h3><p>There are multiple ways to create a cluster in Amazon EKS. One of the best way is using a YAML file. We need to provide the details like instance type we need, our desired capacity, the region and if we need to login then we need to provide a key for ssh. The syntax is:</p><blockquote>apiVersion: eksctl.io/v1alpha5<br>kind: ClusterConfig</blockquote><blockquote>metadata:<br> name: taskcluster<br> region: ap-south-1</blockquote><blockquote>nodeGroups:</blockquote><blockquote>-name: node</blockquote><blockquote>instanceType: t2.micro<br> desiredCapacity: 5<br> ssh:<br> publicKeyName: key1</blockquote><p>Now we need to run the following command to create a cluster using this file</p><pre>eksctl create cluster -f cluster.yml</pre><h4>Launching WordPress using MySQL database</h4><p>We need to just create 3 files for the entire setup</p><p>For WordPress:</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: wordpress<br>  labels:<br>    app: wordpress<br>spec:<br>  ports:<br>    - port: 80<br>  selector:<br>    app: wordpress<br>    tier: frontend<br>  type: LoadBalancer<br>---<br>apiVersion: v1<br>kind: PersistentVolumeClaim<br>metadata:<br>  name: wp-pv-claim<br>  labels:<br>    app: wordpress<br>spec:<br>  accessModes:<br>    - ReadWriteOnce<br>  resources:<br>    requests:<br>      storage: 5Gi<br>---<br>apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2<br>kind: Deployment<br>metadata:<br>  name: wordpress<br>  labels:<br>    app: wordpress<br>spec:<br>  selector:<br>    matchLabels:<br>      app: wordpress<br>      tier: frontend<br>  strategy:<br>    type: Recreate<br>  template:<br>    metadata:<br>      labels:<br>        app: wordpress<br>        tier: frontend<br>    spec:<br>      containers:<br>      - image: wordpress:4.8-apache<br>        name: wordpress<br>        env:<br>        - name: WORDPRESS_DB_HOST<br>          value: wordpress-mysql <br>        - name: WORDPRESS_DB_PASSWORD<br>          valueFrom:<br>            secretKeyRef:<br>              name: mysql-pass<br>              key: password<br>        ports:<br>        - containerPort: 80<br>          name: wordpress<br>        volumeMounts:<br>        - name: wordpress-persistent-storage<br>          mountPath: /var/www/html<br>      volumes:<br>      - name: wordpress-persistent-storage<br>        persistentVolumeClaim:<br>          claimName: wp-pv-claim</pre><p>For MySQL:</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: wordpress-mysql<br>  labels:<br>    app: wordpress<br>spec:<br>  ports:<br>    - port: 3306<br>  selector:<br>    app: wordpress<br>    tier: mysql<br>  clusterIP: None<br>---<br>apiVersion: v1<br>kind: PersistentVolumeClaim<br>metadata:<br>  name: mysql-pv-claim<br>  labels:<br>    app: wordpress<br>spec:<br>  accessModes:<br>    - ReadWriteOnce<br>  resources:<br>    requests:<br>      storage: 5Gi<br>---<br>apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2<br>kind: Deployment<br>metadata:<br>  name: wordpress-mysql<br>  labels:<br>    app: wordpress<br>spec:<br>  selector:<br>    matchLabels:<br>      app: wordpress<br>      tier: mysql<br>  strategy:<br>    type: Recreate<br>  template:<br>    metadata:<br>      labels:<br>        app: wordpress<br>        tier: mysql<br>    spec:<br>      containers:<br>      - image: mysql:5.6<br>        name: mysql<br>        env:<br>        - name: MYSQL_ROOT_PASSWORD<br>          valueFrom:<br>            secretKeyRef:<br>              name: mysql-pass<br>              key: password<br>        ports:<br>        - containerPort: 3306<br>          name: mysql<br>        volumeMounts:<br>        - name: mysql-persistent-storage<br>          mountPath: /var/lib/mysql<br>      volumes:<br>      - name: mysql-persistent-storage<br>        persistentVolumeClaim:<br>          claimName: mysql-pv-claim</pre><p>Kustomization.yml:</p><pre>apiVersion: kustomize.config.k8s.io/v1beta1<br>kind: Kustomization<br>secretGenerator:<br>- name: mysql-pass<br>  literals:<br>  - password=redhat<br>resources:<br>  - mysql-deployment.yaml</pre><pre>- wordpress-deployment.yaml</pre><p>Now we need to run the following command to launch the entire setup:</p><pre>kubectl create -k .</pre><p>The setup will now look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NoInnCNakuZJ691wiI9DvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_1dEq7zWwpKt2qVbJpyUWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a8Fs36U1md8OUnh9OJITRg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LAv6jNdy-dQUsvsjn6EZDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*59QifxwRrWXSpL07AMi9eA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fQp57Fd0Qc87prFEQiKIwQ.png" /></figure><h3>Setting up HELM, Prometheus &amp; Grafana</h3><h4>HELM</h4><p>Helm helps you manage Kubernetes applications — Helm Charts help you define, install, and upgrade even the most complex Kubernetes application.</p><p>We need to run following commands to setup the helm according to our requirements:</p><pre># helm init<br># helm repo add stable https://kubernetes-charts.storage.googleapis.com/<br># helm repo list<br># helm repo update<br><br># kubectl -n kube-system create serviceaccount tiller <br># kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller <br># helm init --service-account tiller<br># kubectl get pods --namespace kube-system</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xW5plezDQJH-ZogXZKZQaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ik6RbUtJY1uIkY63z2oMg.png" /></figure><p>For launching Prometheus and Grafana, we need to do scaling to balance the load. We can use the following command</p><pre>eksctl scale nodegroup --cluster taskcluster --nodes=10 --name=node --nodes-max=15 --region ap-south-1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u_Yo4kc8-pm-Aioc3VtlPw.png" /></figure><p>After this we can now setup Prometheus &amp; Grafana</p><h4>Prometheus</h4><p>Prometheus is an open-source systems monitoring and alerting toolkit originally built at <a href="https://soundcloud.com/">SoundCloud</a>. Since its inception in 2012, many companies and organizations have adopted Prometheus, and the project has a very active developer and user <a href="https://prometheus.io/community">community</a>. It is now a standalone open source project and maintained independently of any company. To emphasize this, and to clarify the project’s governance structure, Prometheus joined the <a href="https://cncf.io/">Cloud Native Computing Foundation</a> in 2016 as the second hosted project, after <a href="https://kubernetes.io/">Kubernetes</a>.</p><h4>Grafana</h4><p>Grafana is a multi-platform open source analytics and interactive visualization web application. It provides charts, graphs, and alerts for the web when connected to supported data sources. It is expandable through a plug-in system. End users can create complex monitoring dashboards using interactive query builders.</p><p>Since we have everything setup now, we can now launch Prometheus using the following commands:</p><p>First we need to create a namespace for Prometheus using the command:</p><pre># kubectl create namespace prometheus</pre><p>Now, commands to setup Prometheus</p><pre># helm install  stable/prometheus     --namespace prometheus     --set alertmanager.persistentVolume.storageClass=&quot;gp2&quot;     --set server.persistentVolume.storageClass=&quot;gp2&quot;</pre><pre># kubectl get svc -n prometheus<br># kubectl -n prometheus  port-forward svc/nameprovided-server  8888:80</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FAQXwBf9g41OXL0kftM52Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h2geMZDKhGk1dN-H2xTuHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O1z9qD9W7OnBTGPGBup9RQ.png" /></figure><h4>For Grafana:</h4><p>First we should create a namespace for Grafana using the command:</p><pre># kubectl create namespace grafana</pre><p>Now, commands to setup Grafana</p><pre><br># helm install stable/grafana  --namespace grafana     --set persistence.storageClassName=&quot;gp2&quot; --set adminPassword=&#39;GrafanaAdm!n&#39;    --set datasources.&quot;datasources\.yaml&quot;.apiVersion=1     --set datasources.&quot;datasources\.yaml&quot;.datasources[0].name=Prometheus   --set datasources.&quot;datasources\.yaml&quot;.datasources[0].type=prometheus    --set datasources.&quot;datasources\.yaml&quot;.datasources[0].url=<a href="http://prometheus-server.prometheus.svc.cluster.local/">http://prometheus-server.prometheus.svc.cluster.local</a>   --set datasources.&quot;datasources\.yaml&quot;.datasources[0].access=proxy     --set datasources.&quot;datasources\.yaml&quot;.datasources[0].isDefault=true  --set service.type=LoadBalancer</pre><pre># kubectl get  secret  worn-bronco-grafana   --namespace  grafana  -o yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Om9phSe5nNuuJR_cdPNLLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DOsAQv_rMfyaO3rhentOmA.png" /></figure><p>Thank You for reading!!</p><p><a href="http://linkedin.com/in/rohan-k-078818136">LinkedIn</a> Profile</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33787b732b68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MLOps Task]]></title>
            <link>https://rkwal-007.medium.com/mlops-task-e17cf0a91576?source=rss-8b96d37f8e0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e17cf0a91576</guid>
            <dc:creator><![CDATA[Rohan Khandelwal]]></dc:creator>
            <pubDate>Tue, 19 May 2020 17:54:07 GMT</pubDate>
            <atom:updated>2020-05-19T17:54:07.253Z</atom:updated>
            <content:encoded><![CDATA[<p>Creating face recognition model using transfer learning:</p><p>Successfully completed the task of face recognition on a new dataset using transfer learning</p><p>Code/Approach below for the reference</p><p>Dataset link: https://www.kaggle.com/danupnelson/14-celebrity-faces-dataset</p><p><strong>GitHub link:</strong> https://github.com/BattleKingRet/transfer-learning/tree/master</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XwcmxMwlb894DNgEsQ3mgw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jWyIKtbMMj2pJQOKveG0eQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PpLxDF1bC7fFBMi5orKfAA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ibilkIZQ2l0EZQndCqz2Q.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fOSyM_AkCAn5-bXNgm_9iQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OQDIyCRH5tKNzH1BHK9Xww.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NHhU5SquPgcjkIYGeHEJ3A.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e17cf0a91576" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>