<?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 Olusola Onajobi on Medium]]></title>
        <description><![CDATA[Stories by Olusola Onajobi on Medium]]></description>
        <link>https://medium.com/@sholjoe?source=rss-2423a6fdae50------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DUUoWew0EHg-qa1I7Qq7iw.jpeg</url>
            <title>Stories by Olusola Onajobi on Medium</title>
            <link>https://medium.com/@sholjoe?source=rss-2423a6fdae50------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:32:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sholjoe/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[Implementing Serverless QR Code Generation with Azure Functions and Continuous Deployment]]></title>
            <link>https://medium.com/@sholjoe/implementing-serverless-qr-code-generation-with-azure-functions-and-continuous-deployment-2d19b64a091b?source=rss-2423a6fdae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d19b64a091b</guid>
            <dc:creator><![CDATA[Olusola Onajobi]]></dc:creator>
            <pubDate>Fri, 26 Jul 2024 13:17:06 GMT</pubDate>
            <atom:updated>2024-07-26T13:17:06.044Z</atom:updated>
            <content:encoded><![CDATA[<p>QR codes have become widespread, appearing on everything from event tickets to restaurant menus. Their ability to quickly connect users to digital content has made them an essential tool for businesses. However, generating QR codes at scale can be challenging, especially when you need a solution that’s both cost-effective and easy to maintain. This is where serverless computing and Azure Functions come into play.</p><p>Serverless computing doesn’t actually mean that there are no servers involved; rather, it means you don’t have to manage or worry about them. The servers are still there, running in the cloud, but the cloud provider takes care of all the infrastructure management, including provisioning, scaling, and maintaining the servers. This allows you to focus solely on writing and deploying your code without dealing with the complexities of server management.</p><p>okay, lets see how this is done!</p><p>The prerequisites are:</p><p>1.<a href="https://nodejs.org/en"> Node.js</a></p><p>2. <a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=linux%2Cisolated-process%2Cnode-v4%2Cpython-v2%2Chttp-trigger%2Ccontainer-apps&amp;pivots=programming-language-csharp">Azure Functions Core Tools</a></p><p>3. Azure CLI</p><p>4. An Azure account and an Azure Blob Storage account.</p><p>Open your terminal and</p><h3>1. Clone the Repository</h3><pre>git clone https://github.com/rishabkumar7//azure-qr-code.git<br>cd azure-qr-code/qrCodeGenerator</pre><h3>2. Install Dependencies</h3><pre>npm install</pre><h3>3. Go to Azure portal &gt; Azure function</h3><p>Create function app &gt; select App service plan as hosting options (for fully isolated and dedicated environments to run multiple applications and functions)</p><p>Create a new resource group: project5demo-rg</p><p>Function app name: project5demoapp</p><p>Runtime stack: Node.js</p><p>Version 18LTS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*vk4v73ud5esDu3zfniIskw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*Uu1YDbBmS06CblYEEUbIzA.png" /><figcaption>Create a storage account</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*ELglZsm9S9IGzAY4uY6v2w.png" /><figcaption>enable public access</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*hlKWqdy3AclMSxm4qZJRiQ.png" /><figcaption>Disable Github CD beacuse we will be using azure CICD</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*MqN4PXSZ1UunpCegByWOHg.png" /><figcaption>Review and create the function app</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zkzi4QusRXmeAZJZL6nYSg.png" /><figcaption>go to resource then click on configuration</figcaption></figure><p>you ‘d see the app settings that has been created below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O5hiTjQcfmVeIR95g9BAmg.png" /></figure><p>on your terminal, create a file local.settings.json</p><pre>{<br>    &quot;IsEncrypted&quot;: false,<br>    &quot;Values&quot;: {<br>        &quot;AzureWebJobsStorage&quot;: &quot;&quot;,<br>        &quot;FUNCTIONS_WORKER_RUNTIME&quot;: &quot;node&quot;,<br>       &quot;STORAGE_CONNECTION_STRING&quot;:&quot;&lt;YOUR_STORAGE_CONNECTION_STRING&gt;&quot;<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*coQNDwNfoSSKs4po9Gwa_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GfbGXIwGqP-3lmUF9f5eWQ.png" /><figcaption>check the connection string here</figcaption></figure><h3>4. Run Locally</h3><p>To start the function app locally, make sure you have Azure Functions Core Tools installed, then run:</p><pre>func start</pre><h3>5. Deploy to Azure</h3><p>Deploy your function app to Azure using the following command</p><p>To start the function app locally, make sure you have Azure Functions Core Tools installed, then run:</p><pre>func azure functionapp publish &lt;YOUR_FUNCTION_APP_NAME&gt;</pre><p>To push your connection string</p><pre>az functionapp config appsettings set --name functionappname --resource-group myResourceGroup --settings &quot;STORAGE_CONNECTION_STRING=Defaultetc<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKLQZmHLIhrldkfXoBp46Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bVmRBXd6DHpISjqvXGIKpQ.png" /><figcaption>connection string has been added</figcaption></figure><h3>Lets see if the function app has been deployed successfully</h3><p>go to the function app&gt; overview&gt; generate qr code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pd64VqHvVTSTta2PdztWKw.png" /></figure><p>click on code+Test &gt; Test/Run to test the api call. (i will be using the http method)</p><p>input your query : url and website you want to test. in my case https://olusolaonajobi.xyz</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvftEyW_q0vtXJqLz3Y-oQ.png" /></figure><p>if you get the Error: Public access is not permitted on this storage account</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gN9n4-XVafWEYFbjEnDf4A.png" /></figure><p>go to your storage account &gt; settings&gt; configuration and enable Blob anonymous access and storage account key access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*PA7le2emvzxmLCtP1wnoig.png" /></figure><p>Test and run the api again, you should have a 200 Ok response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JNemosgIn3njjjrdFz2JmA.png" /></figure><p>The function app generated a png file which has been uploaded to the blob storage account.</p><p>check the link to download the QR code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*iG5F3RmqMMmdPqOFVDO-EQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*t9tdxQ_upjNvwOnNlZoCyw.jpeg" /><figcaption>scanned the bar code to see the website</figcaption></figure><h3>To deploy the app on azure DevOps</h3><p>Create a new project on dev.azure.com : serverless-project</p><p>Import the repository <a href="https://github.com/rishabkumar7//azure-qr-code.git">https://github.com/rishabkumar7//azure-qr-code.git</a></p><p>Create a new pipeline using azure repos git, select the severless project, select your subscription and validate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jdott6xJBDHE9euiyValJw.png" /><figcaption>configure the pipeline using Node.js</figcaption></figure><p>Your pipeline YAML file will look like this</p><pre># Node.js Function App to Linux on Azure<br># Build a Node.js function app and deploy it to Azure as a Linux function app.<br># Add steps that analyze code, save build artifacts, deploy, and more:<br># https://docs.microsoft.com/azure/devops/pipelines/languages/javascript<br><br>trigger:<br>- iac-implementation<br><br>variables:<br><br>  # Azure Resource Manager connection created during pipeline creation<br>  azureSubscription: &#39;&lt;Your subscription ID&gt;&#39;<br><br>  # Function app name<br>  functionAppName: &#39;&lt;Function App Name&gt;&#39;<br><br>  # Environment name<br>  environmentName: &#39;&lt;Function App Name&gt;&#39;<br>  system.debug: true<br><br>  # Agent VM image name<br>  vmImageName: &#39;ubuntu-latest&#39;<br><br>stages:<br>- stage: Build<br>  displayName: Build stage<br>  jobs:<br>  - job: Build<br>    displayName: Build<br>    pool:<br>      vmImage: $(vmImageName)<br><br>    steps:<br>    - task: NodeTool@0<br>      inputs:<br>        versionSpec: &#39;18.x&#39;<br>      displayName: &#39;Install Node.js&#39;<br><br>    - script: |<br>        cd qrCodeGenerator<br>        npm install<br>        npm run build --if-present<br>        npm run test --if-present<br>      displayName: &#39;Prepare binaries&#39;<br><br>    - task: CopyFiles@2<br>      inputs:<br>        SourceFolder: &#39;$(System.DefaultWorkingDirectory)/qrCodeGenerator/GenerateQRCode/&#39;<br>        Contents: &#39;**&#39;<br>        TargetFolder: &#39;$(System.DefaultWorkingDirectory)/qrCodeGenerator/&#39;<br>    - task: ArchiveFiles@2<br>      displayName: &#39;Archive files&#39;<br>      inputs:<br>        rootFolderOrFile: &#39;$(System.DefaultWorkingDirectory)/qrCodeGenerator/&#39;<br>        includeRootFolder: false<br>        archiveType: zip<br>        archiveFile: $(Build.ArtifactStagingDirectory)/qrCodeGenerator/$(Build.BuildId).zip<br>        replaceExistingArchive: true<br><br>    - upload: $(Build.ArtifactStagingDirectory)/qrCodeGenerator/$(Build.BuildId).zip<br>      artifact: drop<br><br>- stage: Deploy<br>  displayName: Deploy stage<br>  dependsOn: Build<br>  condition: succeeded()<br>  jobs:<br>  - deployment: Deploy<br>    displayName: Deploy<br>    environment: $(environmentName)<br>    pool:<br>      vmImage: $(vmImageName)<br>    strategy:<br>      runOnce:<br>        deploy:<br>          steps:<br>          - task: AzureFunctionApp@2<br>            inputs:<br>              connectedServiceNameARM: &#39;&lt;Your service connection&gt;&#39;<br>              appType: &#39;functionApp&#39;<br>              appName: &#39;$(functionAppName)&#39;<br>              package: &#39;$(Pipeline.Workspace)/drop/$(Build.BuildID).zip&#39;<br>              deploymentMethod: &#39;zipDeploy&#39;</pre><p>edit your pipeline to have your function app name and your subscription.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TQfVu5yprZS-aoK-mwgLCA.png" /><figcaption>build stage was succesfull</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yXDGyGkOOO_Gpn_xAVyb0g.png" /><figcaption>Deploy stage was successful</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pShsSkuL4NjPuE4dkY2UPg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d19b64a091b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Kubernetes cluster locally and in the cloud]]></title>
            <link>https://medium.com/@sholjoe/setting-up-kubernetes-cluster-locally-and-in-the-cloud-fd503551e743?source=rss-2423a6fdae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd503551e743</guid>
            <dc:creator><![CDATA[Olusola Onajobi]]></dc:creator>
            <pubDate>Tue, 25 Jun 2024 10:00:12 GMT</pubDate>
            <atom:updated>2024-06-25T10:00:12.352Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Objectives</strong></p><p>In this project, we are going to see how to set up Kubernetes cluster from the local machine, to AWS cloud, local test environments and production environments.</p><p><strong>scenario</strong></p><p>1. You have already containerized an application e.g using docker or any container runtime environment and have created images.</p><p>2. Its time to test it locally and on the cloud.</p><p><strong>Tools</strong></p><p>1. <strong>Minikube</strong>: Setting Up a Single-Node Kubernetes Cluster Locally on Your Machine Using Oracle VM VirtualBox</p><p>2. <strong>Kubeadm</strong>: Setting Up a Multi-Node, Production-Grade Cluster Locally and in the Cloud</p><p>3. <strong>Kops</strong>: Setting Up a Production-Grade Kubernetes Cluster on AWS Cloud</p><p>4. <strong>AWS EKS</strong>: setting up Kubernetes cluster on EKS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*91gJ6VJAtOjMcMsQZ2YKfw.png" /></figure><p>Resources : clone the <a href="https://github.com/devopshydclub/vprofile-project">source code</a> :</p><ol><li><strong>Minikube: Setting Up a Single-Node Kubernetes Cluster Locally on Your Machine Using Oracle VM VirtualBox</strong></li></ol><p>install minikube on powershell using</p><p>choco install minikube kubernetes-cli -y</p><p>Check if minikube is installed using</p><p>minikube.exe -help</p><p>then open your terminal and run minikube start</p><p>This is going to download an image and bring up a VM on oracle virtual box</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*OY8I1erlXB9F284FNsY5IQ.png" /></figure><p>to see the master or control node, run kubectl get nodes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*0kPvGzTmovV183cNq-BOVw.png" /><figcaption>control node is ready</figcaption></figure><p>lets run few more test from the <a href="https://minikube.sigs.k8s.io/docs/start/?arch=%2Flinux%2Fx86-64%2Fstable%2Fbinary+download">documentatio</a>n</p><p>kubectl create deployment hello-minikube-image=kickbase/echo-server:1.0</p><p>this command created a deployment named fetch image from a container registry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*8tZaqnzNtSJ7mEcCFcEWCg.png" /><figcaption>A deployment is created</figcaption></figure><p>Check to see the pod running from the deployment using</p><p>kubectl.exe get pod</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*suJGFKR4wuliZk_Hvae3nw.png" /></figure><p>and kubectl.exe deployto see the deployment running the pod</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*gptl0fPOR_4tP_95bFILcg.png" /></figure><p>then you can expose the deployment</p><pre>kubectl expose deployment hello-minikube --type=NodePort --port=8080</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*hWZrXCUiPNWohubKUuZ_kw.png" /></figure><p>and finally, check the url of the application by running</p><p>minikube service hello-minikube -url</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*e469FtyCCSLCGoLs1T0Nag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*eCIHG4gSGk-4cxMFWIsFUw.png" /></figure><p>This confirms that your minicube cluster is up and running and you are able to create pod, deployment and expose service for it.</p><p>you can delete the service, deployment and the cluster</p><p>kubectl.exe delete svc hello-minikube</p><p>kubectl.exe delete deploy hello-minikube</p><p>minikube.exe stop</p><p>minikube.exe delete</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*lJEnOiqL4gLw4cD0BOwfdw.png" /></figure><p><strong>2. Kubeadm: Setting Up a Multi-Node, Production-Grade Cluster Locally and in the Cloud</strong></p><p>for this, you will have to install kubeadm using the <a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/">documentation</a> as a guide.</p><p>our goal is to set up kubeadm cluster on virtual machines (3 ubuntu vms with1 master and 2 worker nodes</p><p>on your terminal, get into the directory where we have the the vagrant file (from <a href="https://github.com/devopshydclub/vprofile-project.git%20)">here</a>) then run vagrant upto bring up the the 3 vms kubemaster, kubenode 1 and kubenode 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*r5gwOSDRQgyZ8oXcE_tTUA.png" /><figcaption>3 vms are up and running</figcaption></figure><p>when the vms are up, run the command vagrant ssh kubemaster to login to the master node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*7YD2g_3g7YLyjg60OgUlhg.png" /></figure><p>Check the nodes using kubectl get nodes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*kaN3IQUOOPJDu-7K1EGs_A.png" /></figure><p>test it by creating deployment and exposing it</p><p>switch to root user and run</p><pre>kubectl create deployment hello-kubeadm - image=kicbase/echo-server:1.0<br>kubectl expose deployment hello-kubeadm - type=NodePort - port=8080</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*Ck3lKJfHgAggKjaPWyI-6Q.png" /></figure><p>you should have pods created from the deployment as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*LUvtQ6YwJgZTRGq9HCkX5A.png" /></figure><p>and the service as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*xCYpnIfHgY2sABUbMsR85A.png" /></figure><p>to describe the pods and also to check which pod is running, run :</p><pre>Kubectl get pods<br>Kubectl describe pod (pod name)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Vi_U0tQLnjXPeFhMe9-GdQ.png" /></figure><p>Testing the master node 192.168.56.2:32748</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*_aFiVtG41D8VVjbwzW9itw.png" /></figure><p><strong>3. Kops: Setting Up a Production-Grade Kubernetes Cluster on AWS Cloud</strong></p><p>Prerequisites</p><p>· Domain for Kubernetes DNS records</p><p>· Create a Linux VM (EC2 instance) to set up the kops, kubectl, ssh keys and awscli</p><p>· S3 bucket, IAM user for AWSCLI , Route53 hosted zone (sub domain)</p><p>The first thing to do is to launch an EC2 instance using ubuntu 22 ami</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*GYYGc0iqTMUBIQnCqClLrw.png" /><figcaption>kopsserver EC2 instance</figcaption></figure><p>you need to create an IAM user to generate access key. this is to ensure that only authorized user can access the resources</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*bM2fubZ8dQFp_xLP8Fj9Fw.png" /><figcaption>IAM user as garawadmin</figcaption></figure><p>you will also create an S3 bucket. my bucket name is garawa10. Note: these are all created in the same region as the instance in us-east-1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*tgUoni7tplhNHbbvn0e9cQ.png" /></figure><p>And then a Route 53 hosted zone will be created to add the name servers url to a domain: olusolaonajobi.xyz</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*wl9WbykLns9RQXmo2C3aIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*90bktxb-9QqWIFqWATcc-A.png" /></figure><p>open your terminal, and ssh into it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*N1WtmBzr6_JQv-qUkGQ_Vw.png" /></figure><p>generate the ssh keys which will be used by kops by running the command ssh-keygen</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*0etxbju4p6yw0VIQwlzXFQ.png" /><figcaption>The public key will be pushed to the instance</figcaption></figure><p>Next, install AWSCLI by running the command</p><pre>Sudo apt update &amp;&amp; sudo apt install awscli -y </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*iT-tcXC42wwHLTsJr6W5mQ.png" /></figure><p>configure it using aws configure through the access keys created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*393FDv4-Oll0f1e1JlC0DQ.png" /></figure><p>Next, you will install kubectl from the documentation <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/"><strong>here</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*odVx2LorvtN3lq6KJAbumA.png" /></figure><p>grant it executable permission by chmod +x ./kubectl</p><p>then move it to usr/local/bin so you can access it from anywhere</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*87Vc7mDElvbX3HtdK2unCQ.png" /></figure><p>The final tool to install is the kops</p><p>Run the command from the <a href="https://kops.sigs.k8s.io/getting_started/install/">documentation</a>, and make it executable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*USoAB8h3TtYHa18AAooQjg.png" /></figure><p>ensure that the domain is verified, to resolve the four name servers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*yGX5Nmod7yoWKAXyfSZKWQ.png" /></figure><p>then run the kops command that will create the Kubernetes cluster.</p><p>It will create the configuration for the cluster and store it in the s3 bucket.</p><pre>kops create cluster - name=kubeevpro.olusolaonajobi.xyz \<br>&gt; - state=s3://garawa10 - zones=us-east-1a,us-east-1b \<br>&gt; - node-count=2 - node-size=t3.small - master-size=t3.medium - dns-zone=kubeevpro.olusolaonajobi.xyz \<br>&gt; - node-volume-size=8 - master-volume-size=20</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Q1ZL_3jjxd3pEX0T19h9Gg.png" /></figure><p>update the cluster</p><pre>kops update cluster - name kubeevpro.olusolaonajobi.xyz - state=s3://garawa10 - yes - admin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OTMl3yIdoHMqh9XtbU8SdQ.png" /></figure><p>and validate the cluster</p><pre>kops validate cluster - state=s3://garawa10</pre><p>kops validate cluster — state=s3://garawa10</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*vwnUUrWZj7-rjDYr2OlpAg.png" /></figure><p>When a Kubernetes cluster is created using kops, a configuration file for kubectl is generated automatically. This file is located in your home directory at ~/.kube/config. The kubectl command uses this configuration file to connect to the cluster.</p><p>By running kubectl get nodes, you will be able to see the nodes in your cluster, including the control-plane node labeled as the master and two additional worker nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*IpycPmxKt2VSdPvWkPs7Yg.png" /></figure><p>You can also verify that some instances were created in the AWS console. These instances were provisioned by the auto-scaling group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*pCdHr_Inr_JfzQPZVDtA2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*XKucyu6XyKFcqgZOd-nQQw.png" /></figure><p>a VPC was also created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*-5Bqkrw59549Y5AgjX7lpQ.png" /></figure><p>Then you can delete the cluster and power off your instance vm.</p><pre>kops delete cluster - name kubeevpro.olusolaonajobi.xyz - state=s3://garawa10 –yes</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*q6NWOPjxoGFPcMLooZNioQ.png" /></figure><p><strong>4. AWS EKS: setting up Kubernetes cluster on EKS</strong></p><p>Launch a Vagrant VM to set up provisioning tools for the cluster setup. First, navigate to the source code directory where a Vagrantfile is located. This Vagrantfile will execute the setup script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*mYtRCtAYqh1H4YINqJD1MQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*MHeUj9b9jqvt4WzyEdFhMg.png" /></figure><p>Create a keypair (this time, i choose us-east-2 region) the Keys will be used to login to worker node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*H41XSCmwhgEcOOp-4JOedA.png" /></figure><p>run vagrant upto bring up the vms</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*73TSxY3uTuTKG8vLR636kA.png" /></figure><p>Vm is up, so login into it using vagrant ssh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*NNo22FfJDyCZw6V13-pP1A.png" /></figure><p>Check the three tools to see if it was rightly installed</p><p>aws --version</p><p>eksctl version</p><p>kubectl version</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*AxwnYHkZkPFnB9PTlAAVsQ.png" /></figure><p>create an IAM user, create an access key, then do aws configure</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*S_LuzCYNxNBqUbjZRhYIcA.png" /></figure><p>Cd into the vagrant directory to see the cluster setup script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*oqOLgQwoi8GQoB4kU4Zv3g.png" /></figure><p>make the script executable and run it</p><pre>chmod +x eks-cluster-setup.sh<br>./eks-cluster-setup.sh</pre><p>after running it, you might get some error because the cluster version from the script is version1.20 which is no longer supported</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*MyUShchD5eTc3beO3_dOEA.png" /></figure><p>therefore, change the eks version from 1.20 to 1.28 using vim editor and save it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*JtUMh4acJBtDUcRFPIDgig.png" /></figure><p>run the script once again</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*6E0a6m3Ih9tYnV_LsH772A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*OPtP45qD27Iz3MYVd6Zl7Q.png" /><figcaption>cluster has been created successfully</figcaption></figure><p>Checking amazon EKS to see the created cluster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*-wO4_RwpxJON0P0YqtmDFg.png" /></figure><p>Also a new NAT gateway, VPC with multiple subnets created by the eksctl command</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*lIHGEzYG6rdY7-RFCefLsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*-mx2jva4IIQKsA4d8k1KCg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Ys2OUFBRII_zI9oppiPudA.png" /></figure><p>These were created through the two cloud formation template. One for the cluster and one for the node group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*PdwMY6yibM6fzPKb4xrYkg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*oaKmozMSE_g7-jc_kH4kyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*v1TKtSu6FgZViwue_ea8Zg.png" /><figcaption>EKS is active</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*omFSFUCa11Up0B9bic44Wg.png" /><figcaption>two desired nodes</figcaption></figure><p>on your terminal, run the command kubectl get nodes to see the two worker nodes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*z_R16H6DKfqJxSBMFj1DFA.png" /></figure><p>finally, you can delete your cluster</p><p>kubectl get nodes</p><pre>eksctl delete cluster vprofile-eks-cluster</pre><p>We have explored various methods for setting up Kubernetes clusters using different tools and environments.</p><p>These tools offer flexibility and scalability, enabling the creation of Kubernetes environments tailored to development, testing, and production deployments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd503551e743" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing Continuous Integration with Jenkins, Nexus, SonarQube, and Slack]]></title>
            <link>https://medium.com/@sholjoe/optimizing-continuous-integration-with-jenkins-nexus-sonarqube-and-slack-39a4c644a15c?source=rss-2423a6fdae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/39a4c644a15c</guid>
            <dc:creator><![CDATA[Olusola Onajobi]]></dc:creator>
            <pubDate>Tue, 11 Jun 2024 17:22:22 GMT</pubDate>
            <atom:updated>2024-06-11T17:22:22.223Z</atom:updated>
            <content:encoded><![CDATA[<p>I took on a project to automate our Continuous Integration and Continuous Deployment (CI/CD) process using Jenkins Pipelines. In this project, I’ll share my experience and provide a step-by-step guide on how I efficiently optimized and continuously integrated a web application using declarative syntax.</p><p><strong>Goal of the Project</strong></p><p>1. Efficient Automation of CI/CD Processes: Streamline the continuous integration and continuous deployment processes to reduce manual intervention.</p><p>2. Enhanced Code Quality and Security: Detect and address bugs, vulnerabilities, and code issues early in the development lifecycle.</p><p>3. Artifact Management: Efficiently manage build artifacts by storing them in a centralized repository, ensure traceability and consistency of artifacts across different environments.</p><p>4. Robust Testing Framework: automate unit testing and integrate it into the CI pipeline. generate comprehensive test reports and quality metrics.</p><p>5. Scalability and Flexibility: Design a scalable CI/CD pipeline that can handle increasing workloads and evolving project requirements. ensure the pipeline is flexible enough to adapt to different projects and environments.</p><p>Some of Problems it solves</p><p>1. <strong>Manual Build and Deployment Challenges</strong></p><p>2. <strong>Inconsistent build Environments</strong></p><p>3. <strong>Delayed Detection of Code Issues</strong></p><p>4. <strong>Inefficient Artifact Management</strong></p><p>5. <strong>Lack of Continuous Feedback</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*7kAA6P7UQlyeWy3xgngzOg.png" /><figcaption>project architecture</figcaption></figure><p><strong>Prerequisites</strong></p><ol><li><strong>Jenkins Installation</strong>: I launched an EC2 instance on AWS and installed Jenkins. To access Jenkins, I used the public IP address of the instance and accessed it via a web browser.</li><li><strong>Nexus Repository Manager</strong>: I set up Nexus as my artifact repository. It allowed me to store, manage and build my artifact.</li><li><strong>SonarQube</strong>: SonarQube is essential for code quality analysis. I installed SonarQube on another EC2 instance and configured it to analyze my codebase</li></ol><p>Now let’s dive into the details of my automation process</p><p><strong>Step 1. setting up my pipeline</strong></p><p>In Jenkins, I created a new job by selecting “New Item” and choosing “Pipeline” as the job type. Named it vprofile-ci-pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Nmfpihjc5wM_Vzw8DIslZw.png" /></figure><p>I configured the job to pull the code from our Git repository</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*pYj_pHipZcYr4Ee1Eze-tQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*SwOcw4_uE5zcCWSwuhzShA.png" /></figure><p>Jenkins will use the same key to authenticate my GitHub account. Therefore, I SSH into the Jenkins server to securely store the GitHub credentials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*83OxPYs6I7XEVOo4IqzDOw.png" /></figure><p>After this, I launched nexus server using ec2 instance, then I created a repository “vprofile-release” that will store the artifact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*7J1v5cGn10x6cbnIrIaVlA.png" /></figure><p>which now prompted me to create the following repositories:</p><p>1. maven central to store the maven dependencies</p><p>2. Vprofile snapshot for snapshot repo concept</p><p>Then I grouped the three repositories into vpro-maven-group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*aa1L0pPc7iNf_I8Bt4W8aw.png" /></figure><p>Now I am ready to craft a pipeline script to compile artifacts from the source code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*9HXBDeMbrXBMN7nhoXN5DQ.png" /></figure><p>I tested the build and it was okay</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*-YHpQYDSoT-I7JgHOoxk3w.png" /></figure><p>NB: I ensured that Jenkins security group allows port 8080 from anywhere.so it can always allow automatic build jobs whenever there is a commit.</p><p>using standard practices, i had to add jenkins ip to webhooks on my repository settings to trigger automatic build and seamless integration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*iKd-U1_TBcCoZs9Q3iby9A.png" /></figure><p>Next, I added a post-build step to archive my artifacts, included a unit test (using mvn test) to generate a report for SonarQube, and performed a Checkstyle analysis to identify any code issues and suggest best practices for addressing vulnerabilities. Finally, I committed and pushed the changes to test the setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*R3nMEL8uYtHj_uEJW9zDaw.png" /></figure><p><strong>Step 2: Set up code analysis with sonarqube</strong></p><p>I configured SonarQube to conduct thorough reviews of my pipeline code, ensuring high-quality standards, bug detection, vulnerability checks, and comprehensive unit testing. Leveraging SonarQube’s intuitive dashboard, I access detailed reports derived from both the checkstyle-checker.xml and unit test outcomes. By seamlessly integrating with Jenkins, I streamlined the process, facilitating automatic report generation and uploading to the SonarQube server for meticulous review and ongoing monitoring.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*tJjSplpsmTEEE9Kcvm36Bw.png" /></figure><p>I used the private IP of the SonarQube server (since it is static) and an authentication token for Jenkins to securely communicate with the SonarQube server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*G7RK3WAvxNV8PzSdoDs60A.png" /></figure><p>then I added sonarserver and sonarscanner (as environment storing as variables) to the pipeline. check documentations <a href="https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/jenkins-extension-sonarqube/">Here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*R05ivfofeJJYKrE_AjKAfg.png" /></figure><p>the stage and steps was enhanced by incorporating additional test parameters as outlined in the documentation. Additionally, I’ve included other relevant test parameters to ensure comprehensive testing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ZVi-GSXMQG3Kk0OWNNeBUg.png" /></figure><p>after my Commit and push, I checked sonarqube for the report using default quality gates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Y4CNmnJbjRyg1oLXi6ybBQ.png" /><figcaption>reports from sonarQube dashboard</figcaption></figure><p>To test the pipeline by setting a condition that will fail the Quality Gates, I created Quality Gates with a condition based on the number of bugs. Since there are 32 bugs in the report, I set the condition to fail the Quality Gates if the number of bugs exceeds 25. This ensures that the pipeline will fail as part of the test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*827HsmmQwmpWUJrg60YQAw.png" /></figure><p>Next, I Created a webhook on sonarqube to send the results of the test to jenkins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*pypOcUGBXjuP9lF1QwuCLw.png" /></figure><p>Updated the pipeline to include the quality gate stage</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*sOsuEW9Ytq2dThLwjoEEyQ.png" /></figure><p>Quality gates failed the pipeline because bugs exceeded he set 25</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*MwtvohftirHadl27RF7pAQ.png" /></figure><p>then I updated the condition to ensure that quality is passed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*BHduA_z1Y5YGg_dHRKaZMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Nv3o5bfUTBWu_1_nwDI-2A.png" /></figure><p><strong>Step 3 : Its time to publish the artifacts to the nexus repository</strong></p><p>following <a href="https://github.com/jenkinsci/nexus-artifact-uploader-plugin">documentations</a>,</p><p>here is the steps to upload the artifacts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*oPr1b9Nh4fj8XIoEy2yjzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*N3OPOZz_PL_ZxXbpV3llsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*LXVmNDx_DZ5c2JIQHldYKw.png" /></figure><p><strong>Step 4: created a slack channel for notification</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*DjFi5AqdPty4hV0B4UNdYA.png" /></figure><p>Added slack to my workspace using <a href="https://slack.com/help/articles/202035138-Add-apps-to-your-Slack-workspace">docs</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Dypox26BoY3uEU-62mXekw.png" /></figure><p>also created a slack post installation step that sends the notifications</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*F7cnX16EVSbrOJaMwCXm3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*5zVS2IZxlyP-Ed_g2M70Rw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*awh46mfwfNgKnNFrBPKtrA.png" /></figure><p>Automating CI/CD with Jenkins Pipelines has streamlined web development process. Now, every code change triggers the pipeline, ensuring consistent builds, tests, and deployments. I have been able to improve code quality, reduced manual intervention, and accelerated software delivery.</p><p>Continuous improvement and monitoring are crucial for maintaining a robust CI/CD pipeline.</p><p>Happy automating!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39a4c644a15c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Portable and Scalable Java Applications with Docker]]></title>
            <link>https://medium.com/@sholjoe/building-portable-and-scalable-java-applications-with-docker-b0758ea863b2?source=rss-2423a6fdae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0758ea863b2</guid>
            <dc:creator><![CDATA[Olusola Onajobi]]></dc:creator>
            <pubDate>Wed, 05 Jun 2024 22:01:32 GMT</pubDate>
            <atom:updated>2024-06-05T22:01:32.980Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s fast-paced software development landscape, building Java applications that are both portable and scalable is crucial. With the rise of containerization technology, Docker has emerged as a powerful tool to achieve these goals seamlessly. In this article, we’ll explore how Docker enables developers to create Java applications that are easy to deploy, maintain, and scale across different environments.</p><p><strong>Why Docker?</strong></p><p>Docker revolutionizes the way we package, distribute, and run applications by encapsulating them within lightweight containers. Unlike traditional virtual machines, Docker containers share the host operating system kernel, resulting in faster startup times and reduced overhead. This makes Docker an ideal choice for deploying Java applications, where resource efficiency and consistency are paramount.</p><p><strong>Portability with Docker</strong></p><p>One of the key advantages of Docker is its portability. By encapsulating the application and its dependencies within a Docker image, developers can ensure consistent behavior across different environments, from development to production. This eliminates the notorious “it works on my machine” problem and simplifies the deployment process.</p><p>With Docker, Java applications can be packaged into self-contained units that can run on any platform with Docker support, whether it’s a developer’s laptop, a testing server, or a cloud-based infrastructure. This portability streamlines the development workflow and accelerates time-to-market for Java projects.</p><p>Scalability is another area where Docker shines. Docker’s container-based architecture enables easy replication and orchestration of Java applications, making it simple to scale horizontally to handle increased workload or user demand.</p><p>Tools like Docker Swarm and Kubernetes provide robust solutions for managing containerized applications at scale. By leveraging these orchestration platforms, developers can deploy Java applications across a cluster of machines, automatically scaling resources up or down based on demand. This ensures high availability, fault tolerance, and efficient resource utilization, making Docker the go-to choice for building scalable Java applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*EVziTgjIZZXb4wywlpvNwg.png" /><figcaption>Architecture</figcaption></figure><p>Here is how I containerized a java application using docker in a project,</p><p><strong>Project Scope:</strong></p><p>In an agile environment, as part of our operational or DevOps teams, we managed a multi-tier application stack comprising numerous services. These services run across various infrastructures, including VMs, physical machines in our datacenter, operating systems, or cloud environments. To keep pace with agile methodologies, we must conduct frequent deployments characterized by continuous changes</p><p>The project center on containerizing Java applications using Docker.</p><p>It will encompass the creation of Dockerfiles, the process of building Docker images, and the execution of containerized Java applications.</p><p><strong>Problem it solves:</strong></p><p>Traditionally, deploying Java applications can be a challenge due to dependencies specific to the environment they run in. These dependencies can vary from system to system, causing inconsistencies and deployment roadblocks.</p><p>Containerization with Docker tackles this problem by packaging the application along with all its required dependencies into a single, self-contained unit. This unit, called a container, ensures consistent behavior regardless of the underlying system. This simplifies deployment and maintenance significantly.</p><p>By achieving these goals, this project will equip developers with the tools and knowledge to build Java applications that are portable, scalable, and run flawlessly across various environments.</p><p>The application will need images for the following services</p><p>1. Tomcat (need to create customized image from base image)</p><p>2. MySQL (need to create customized image from base image)</p><p>3. Memcached (use base image and override settings)</p><p>4. RabbitMQ (use base image and override settings)</p><p>5. Nginx (need to create customized image from base image)</p><p>Project pre-requisities:</p><p>· VirtualBox setup or AWS account</p><p>· DockerHub account</p><p><strong>Step1: Provisioning.</strong></p><p>Services</p><p>1. Nginx =&gt; Web Service</p><p>2. Tomcat =&gt; Application Server</p><p>3. RabbitMQ =&gt; Broker/Queuing Agent</p><p>4. Memcache =&gt; DB Caching</p><p>5. ElasticSearch =&gt; Indexing/Search service</p><p>6. MySQL =&gt; SQL Database</p><p>The setup should be done in the following order</p><p>MySQL (Database SVC)</p><p>Memcache (DB Caching SVC)</p><p>RabbitMQ (Broker/Queue SVC)</p><p>Tomcat (Application SVC)</p><p>Nginx (Web SVC)</p><p><strong>Step 2: Docker hub setup</strong></p><p>The images will be stored in <a href="https://hub.docker.com/">Docker-hub</a>. So I Sign up on docker hub then I searched for the right base images.</p><p><strong>Step 3: Set up Docker engine</strong></p><p>I created an Ubuntu machine with Vagrant to run my Docker commands. First, I created a new directory called docker-engine. Then, I ran the vagrant init ubuntu/bionic64 command, which set up an Ubuntu 18.04 environment.</p><p><em>Mkdir docker-engine<br> cd docker-engine<br> vagrant init bento/ubuntu-18.04</em></p><p>I updated the Vagrantfile to access the VM. which will create a private network for the host. This will also allow me to test the container on the browser.</p><pre>vim Vagrantfile<br><br>### Uncomment the config.vm.network in the Vagrantfile like below ###<br><br># Create a private network, which allows host-only access to the machine<br><br># using a specific IP.<br><br>config.vm.network &quot;private_network&quot;, ip: &quot;192.168.56.72&quot;</pre><p>I will bring up the VM and ssh into it</p><pre>vagrant up<br>vagrant ssh </pre><p>Checking the Docker <a href="https://docs.docker.com/engine/install/ubuntu/">documentatio</a>n for the installation steps on Ubuntu 18</p><pre>sudo docker run hello-world</pre><p>I ran that command just to confirm if my docker is running.</p><p>Executing as a root user, I added vagrant user to Docker group so I can run docker commands</p><p>commands</p><pre>usermod -aG<br>id vagrant</pre><p>Then I logged out and logged back in using vagrant ssh.</p><p>To write the Dockerfile and build the image, I fetched the application’s source code (using VS Code) into the directory where I created my Vagrantfile.</p><p>Next, I switched to the container-docker branch and navigated to the Docker-files directory, where I will create the images.</p><p><strong>Step 4: Setup Dockerfile for App images:</strong></p><p>I created an app directory under Docker-files directory. Then I wrote the dockerfile script for the app. guided by the dockerfile reference <a href="https://docs.docker.com/reference/dockerfile/">documentation</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*xz8JO4YL-G8AIajEaghF1Q.png" /></figure><p><strong>Step-5: Setup Dockerfile for DB Image[MYSQL]</strong></p><p>I created a db directory under Docker-files directory. Then I wrote the dockerfile script for the db.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*Yp-SVF8FCfrJDl35w80Aag.png" /></figure><p><strong>Step-6 :Setup Dockerfile for Web Image[NGINX]</strong></p><p>I created a web directory under Docker-files directory. Then I wrote the Dockerfile script for the web.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*hpVSM0rV8EovrZWbtbtuSg.png" /></figure><p>Then I also created an nginxvproapp.config file under web directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*5V5quS8lmUS4Xzk9oaJEUw.png" /></figure><p><strong>Step-7: Building and testing Images using docker compose. check documentation </strong><a href="https://docs.docker.com/compose/install/"><strong>here</strong></a></p><p>First, I wrote a<strong> </strong>docker-compose.yml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*bVZr3eElJLtvzr1-QuX6eQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*rb7kRtoD6dj9WkcNIizXwg.png" /></figure><p>Before building the images, I validated the artifact in the target directory target/vprofile-v2.war</p><p>Then I checked the docker compose.yml file to ensure that indentations are correct:</p><pre>vim docker-compose.yml</pre><p>its time to build, so I used the command:</p><p>its time to build, so I used the command</p><pre>Docker compose build</pre><p>To build the images from the docker file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lQ5NwJfnNvjWFjPTdpTGFQ.png" /></figure><p>also ran the command below to check the images</p><pre>docker images</pre><p>and checked if the images are working using</p><pre>docker-compose up -d</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*PqlRDRsfCfDqWvdX0k1gxQ.png" /></figure><p>To see my container running, I used the command</p><pre>Docker ps</pre><p>I had to access the web container (using the private ip: 192.168.56.72 of the vagrant file from step3) which will route to the tomcat, and that in turn will access the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*KH6ym624HcgqngIqGwNt0w.png" /></figure><p>I also validated the other services</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*N3ZzIrf8fzQ_FzAc8vHxFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*3zfPnnnb8oWcVtqAONmyUQ.png" /></figure><p><strong>Step-8: Push Images to Docker Hub</strong></p><p>Finally, I commited the source code to push the images.</p><p>By logging in to Docker Hub with command</p><p><em>docker login</em></p><p>to push the images,</p><p><em>docker push sholjoe/vprofiledb<br> docker push sholjoe/vprofileapp<br> docker push sholjoe/vprofileweb</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*eJXcefzuZuGjtElUnE_R_A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0758ea863b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>