<?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"><channel><title><![CDATA[Devops-blog]]></title><description><![CDATA[Devops-blog]]></description><link>https://devopsblog1.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Sep 2026 10:40:30 GMT</lastBuildDate><atom:link href="https://devopsblog1.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Computer Networking for devops]]></title><description><![CDATA[ab samajthey hey ae computer networking kiun important hey
as a devops engineer aapko kuch kuch task karni hothi hey - jaisey infra structure management
aapko vm setup karna hotha hey apna server setup karna padtha hey - us server mey internet routin...]]></description><link>https://devopsblog1.hashnode.dev/computer-networking-for-devops</link><guid isPermaLink="true">https://devopsblog1.hashnode.dev/computer-networking-for-devops</guid><dc:creator><![CDATA[Vaseem Shaik]]></dc:creator><pubDate>Sun, 29 Jun 2025 12:29:39 GMT</pubDate><content:encoded><![CDATA[<p>ab samajthey hey ae computer networking kiun important hey</p>
<p>as a devops engineer aapko kuch kuch task karni hothi hey - jaisey infra structure management</p>
<p>aapko vm setup karna hotha hey apna server setup karna padtha hey - us server mey internet routing karna padtha hey - us server ko proper connectivity milri hey kya , security milri hey kya , automation key thriugh create hora hey kya</p>
<p>devops engineer boltha hey ek server instance create kar saktha hun , ismey ipv4 use karoe , ipv6 jab devops confuse hojatha hey</p>
<p>phir ae aatha hey ki on primise ka setup jamana gaya</p>
<p>aws aap netwroking mey kaisa karogey hum olenge , train with shubha ney bola ec2 mey instance create karthey hey - client aakey bolega isko na aek vpc key andar dalo , hum phir sey confuse hojathey vpc ek private cloud hey internet kaisa milega vpc key andar aisey aapko bohot saare situations and scenarios aathey hey jismey networking bohot use aathi hey</p>
<h3 id="heading-how-does-the-internet-work">How does the internet work ?</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751187463826/24baa509-8059-4a6d-b913-6f824223bdfb.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>ae jo internet hey ae kaisa chaltha hey . - internet jabbi in logeney start kiya tha basically pura globe mey alag alag continent hey - in logon ko connect karnekey liye network hey one person to another person mai india mey hun sumiya poland hey unko kaisa connect karey us cheez key liye optic fibers use huey baically wires jaisa rehthey hey samundhar ey andar jakey jakey connect karwathey hey</p>
</li>
<li><p>pura world mey internet flow hotha hey data transfer hotha hey through optical fiber which is kept inside the river</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751187495784/dcf86e93-42a7-4ff3-a7b6-46b3f321affc.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>ae optic fiber kiska hey - ae tier 1 companies ka big big companies ka hey - ab tier2 company bolthi hey bhaiyya aap ka jo optic fiber hey ne vo humko rent mey dedo kiunki hamara shyaam vo usney bandhi sey bath karni hey ae tier1 ney $$ mey tier 2 ko rent ko dey dethi hey ae tier2 ney tier3 like vodaphone in companies ko dethi hey</p>
</li>
<li><p>why do you prefer optical cable over satilite</p>
<ul>
<li>because distance</li>
</ul>
</li>
<li><p>ae kaisa access hotha hey - samajlo ek badasa duniya hey - tier1 sabka jaal bana key raka hey - tie2 rent lekey rakha hey tier3 companies like codaphone , airtel insey lekey humsey paisa lekey internet server kartha hey data provide karra hey</p>
</li>
<li><p>tier 3 companies ae kaisa kaam karthey hey</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751187828094/dd097451-6a6f-495d-842b-9ab19da45593.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>aisa samjlo ki aas pass hamara dost rehtha hey u broadband , jio , airtel broadband ae aapko internet deneykey liye tayar hey - ae ek isp hey</p>
</li>
<li><p>ae basically ek level pey kaam karra hey ae city key level key level pey aapko network provide karra hey usko bolthey hey MAN → metropolitan area network</p>
</li>
<li><p>agar aehi cheez lets say u broad band airtel sey lera hoga airtel tier2 company hey ae , aisa b ho saktha hey u broadband airtel key pass jatha hey boltah hey ki hu,mko rent pey dedo humsey thoda paisey lelo aisa airtel kithney ko b dey sakthey ae WAN wide area network mey kaam kartha hey bada hey na badi comapny bohot saarey logon ko dey sakthey hey</p>
</li>
<li><p>ab aapka isp aapkey gharthak internet paunchatha hey ae aatha hey LAN - local area network</p>
</li>
</ul>
<p>OSI Model : full form → open system inter-connection ab samajthey ae osi kya hey</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751187958874/009c2dcf-82db-423e-9238-19b0e01601e6.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751188713124/9d7a9acd-a95f-42f7-a5af-0fb8e3d57040.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>aisa samajlo ae aek logical kind of standard set kar diya hey</p>
</li>
<li><p>ae kaisa chaltha hey - chalo nibba and nibbi hey apney</p>
</li>
<li><p>nibba and nibbi kaisa bath karrey hey ae ho kya raha hey - kounsa application mey bath karrey hey for ex: whatsup</p>
</li>
<li><p>aap kisi nibba nibbi ko message bhejthey ho - aapko ek msg dikhatha hey uppar end to end encryption</p>
</li>
<li><p>beech mey na presentation layer rehthi hey inki bathon ko format karthi hey encrytp karthi hey thaki inki bathon ko na koi b na sun sakey kiunki ae log privacy sey bath kar sakey</p>
</li>
<li><p>jab nibba and nibbi online dikhthi hey thab message kar sakthey hey in dono ko beech mey session maintain hothi hey - jab dono online mey ho</p>
</li>
<li><p>jab inkey dono neech mey dil ki bath aajthi hey transport hojath hey nibba nibbi ki bathey</p>
</li>
<li><p>pehley three layers are software lawyer - ek baar transport honey laga phir jo messages janey lagey ne vo internet through jayega iskey badh network layer hey - network toh milgaya ab nibbi ka address kya device address - yaa data-link layer - ek baar dil judgaya phir nibbi key pass wifi connectivity - router physical layer honi chahiye nibbi key pass agar wifi nahi hey aa kithey b messages bhejo nahi reach hoyenge usko</p>
</li>
<li><p>ae transport sey na hardware lawyers hey</p>
</li>
<li><p>nibbi key pass physical layer honi chahiye phir device address i mean data -link - phir network hona chahiye</p>
</li>
</ul>
<hr />
<p>Soft of OSI</p>
<p>ae 7 layers kaisey kaam karthey hey - ae jo application layer hey ae ui hotha hey vo browser hotha hey jispey aap basically internet ko access karthey hey</p>
<p>phir aapka presentation layer hotha hey aapka jo data alag format hey hotha hey , network ko thoda jumbled way mey samaj mey aatha hey isko format kartha hey presentation layer</p>
<p>phir session layer aap key pass ek client hey - aap aur aap key client key beech mey session maintain rakhna hey jo break na ho isliye session layer ek security maintain kartha hey sirf dono ko beech mey ae sab rehtah hey software part phir aatha hey</p>
<p>Hard of OSI :</p>
<ul>
<li><p>transport layer - basically data ko transport kartha hey using some types of protocals , matlab set of rules is device sey us device ko bhejna hey kuch set of rules hey for ex: tcp /ip → transmission conrol protocal or internet protocal ae kuch rules hey jiskey vajhasey vo data transfer ho patha hey isliye ae center mey rehtah hey</p>
</li>
<li><p>ek baar aapka data transfer honey laga - aapko vo data transfer honey key liye aapko ek network lagtha hey toh aapko chahiye network layer is network layer mey baically saarey protocals rehthey hey [ip] - internet protocal for ex: file transfer karni hey iskey liye particular tyr ka protocal , dns ko , email ko is cheezon ko particaular type of protocals rehthey hey phir aatha hey</p>
</li>
<li><p>data-link - ae aisa samajlo network decide hogaya but vo jo nibba and nibbi hey unkey pass jo device hey unkey device ka mac address , ip address kya hey vo data link layer pey ip , mac address ae sab patha chaljatha hey jiskey liye alag protocals rehthey hey like [ARP , RARP]</p>
<p>  mac ko find kartha hey arp and ip address ko find kartha hey using RARP.</p>
</li>
<li><p>last ab cables aathey hey physical layers mey aathey hey , cables , NIC Network integrated chip , wifi , lan cables.</p>
</li>
</ul>
<p>AB SAMAJTHEY HEY TCP/IP MODEL</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751189847607/9d95360d-9b53-4fa3-832d-066641427354.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>OSI model aek standard iso ney standard bana diya tha but reality ki bath aathi hey ek model use aathi hey TCP/IP model hi use hothi hey</p>
</li>
<li><p>osi ek logical model -jo real life mey use karthey hey in the way of tcp/ip model both are same .</p>
</li>
<li><p>[ TCP / IP ] -</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751190689163/dc9d866d-4305-48ed-bacb-0ca2a0dc4a37.png" alt class="image--center mx-auto" /></p>
</li>
</ul>
<ul>
<li><ol>
<li><p>applicaton layer → ismey aapka ui , broser , snapchat , whastup rahega but usmey protocals use hothey hey vo b mention kara na hey web pages browse hothey hey html mey jab b browser mey http , agar mail karrey ho - smtp -simple mail transfer protocal ae sab cheeze batani honi chahiye</p>
<ol start="2">
<li><p>Transport layer → jaha pey actual mey aapka data tarnsfer hoga - ek nibba hey usney nibbi ko hi bheja uskey jagah jakey hi chudel karkey gaya isney bheja hi dear - nibbi key pass pahuncha hi chudel ae aisa na ho is layer mey error checking , checksome , packets kithey transfer horehey , ae packets securely jarehey yah nahi , is cheez key liye transport layer mey protocals hey jaisey TCP - transmission control protocal aek secure connection banadetha hey for ex:</p>
<p>ek nibba ney ek nibbi ko msg bheja - ae msg gaya , nahi gaya is cheez ka ek acknowledgement aatha hey agar vo acknowledgement nibba key pass aayage thab hi aagey badega ae tcp hey na ae aek three way handshake and secure protocal hotha hey ae transport layer mey hotha hey</p>
<p>omegel mey UDP → user datagram protocal mey aapka nibba aapkey nibbi ko msg bhejtha rahega agar pahuncha toh theek hey nahi toh koi bath nahi yaha secure nahi hey send hojatha hey response miljatha hey basically acknowledgement wala thing nahi rahtha</p>
<p>udp connection less hotha hey</p>
</li>
</ol>
</li>
</ol>
</li>
</ul>
<ol start="3">
<li><p>Network layer / internet layer : pey aapkey ip address pey bath hori hothi hey - aap ka source ip kya hey , destination ip kya hey in sab cheezon pey bath hothi hey</p>
<ul>
<li><p>jab mai www.google.com - &gt; first application layer hey ae phir iskey badh transport layer baically data ghoomkey jayega phir iskey badh network layer aathi hey ismey source ip and destination ip kaisa patha karthi hey isko trace arna hey traceroute google.com → ae hey mera ip iskey badh ip hey internet service provider</p>
</li>
<li><p>ip locater → sourceip find → yaha sey request kaha pey gayi isp pey → phir vaha sey mumbai aaya ae tcp hey ab ae california ko gaya vaha google ka server pey gaya → kuch packet drop nahi hua</p>
</li>
<li><p>ab samajthey hey Network access layer hey vo kya kartha hey hamae transport layer samaj mey aagaya</p>
</li>
<li><p>address resource protocal [arp] aapki source ka ip , mac ip and , reciever ip bhejdetha hey lekin mac ip patha nahi hotha hey is cheez ko na braodcast kar detha hey ip address key sath network mey jo registered address dikha detha hey</p>
</li>
</ul>
</li>
</ol>
<p>    Mac address: ek physical device address hotah hey thaki recognize kar sakey , agar mac address patha karna hey isliye ek protocal rehtha hey arp → address resource protocal -→ mac address remains same - bacially aap ki ip address key sath ek mac address jud jatha hey</p>
<p>    abhi mummy and papa tv dekhre merko unka mac ip patah karna hey mai apney roter mey login karunga , 198.168.0.1 -→ login karo ae karnekey badh mere ghar ka computer networking chalra hey dhcp clients mey bata tha hey ki koun koun is router mey juda hua hey - ip address aek logical address , mac address ek physical address hey</p>
<p>    kabhi kabhi mac address appko patha nahi rehta isliye arp - mujhey mera mac ka patha nahi toh mai router ko bolunga mera mac ka mac address dedo mai isko bolunga mujhko apna id address dedo us ip ko mai broadcast karunga ussey jo b connected hey ame network mey hey mujhko uska mac address miljayega vo mac address mai aapko dedunga</p>
<p>    <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751193737157/60255008-cd86-4ae9-b7ea-910f13bdf4dc.png" alt class="image--center mx-auto" /></p>
<p>    by roadcasting it will braidcast and by unicasting it will send mac address to you personally .</p>
<p>CAN - campus area network</p>
<p><mark>dhcp</mark>: DYNAMIC HOST CONFIGURATION PROTOCAL - through this we can restrict the access , we can give the access .</p>
<ul>
<li>RARP: same tharikey sey RARP same process hotha hey ip address patha nahi rehtha vo miljatha hey .</li>
</ul>
<p>IMPORTANT PROTOCALS :</p>
<ul>
<li><ol>
<li><p>dns - domain name system : jab b aap likhthey ho www.trainwithshubham.com ae ek domain name iskey background mey ek server hey mai server mei jaunga nahi mai sirf tws.com likhunga ae tws domain map kiya gaya hey aek ip sey aek address sey map hp chuka hey</p>
<ul>
<li>go to go daddy - ae ek platform where we can register our domain name - here now i can purchase the domain mainey aws pey yah kahi pey server liya aur us server oey us website dali , ab aisa kuch ho mai tws.com lu background mey server khulgaye ae kartha hey godaddy - go to manage dns and -dns records - is address book mey ek domain lekey address assign kardetha hun</li>
</ul>
<ol start="2">
<li><p>FTP: [file transfer protocal] -&gt; aek aisa connection bitaletha hey client ki thaki ek sercurely files ko transfer kar pau .</p>
<ul>
<li><p>index of games - toh ek ftp ka server hey</p>
</li>
<li><p>mai ek ftp client like filezilla leletha hun aur jo b merko chahiye from sever download kar letha hun</p>
</li>
</ul>
</li>
<li><p>telnet : (terminal network ) - ae first protocal tha jissey ki aap kisi b remote ko acess karthey they</p>
<ul>
<li>mujhey yaha baitkey kisi remote server ko connect karna hey yah toh mai ssh , or telnet sey b kar saktha hun telnet sey ui b dekhsaktha hun</li>
</ul>
</li>
<li><p>SMTP : [ simple mail transfe protocal ] - aap ubuntu mey ubuntu smtp setup sendemail</p>
</li>
<li><p>SNMP [ simple network management protocal] - kisi network ko manage karna hey snp use karthey hey bohot rarely use hotha hey</p>
</li>
<li><p>http [ hyper text transfer protocal ] - api calls , jithey b web pages load , request api calls hothey hey http protocal through .</p>
<ul>
<li><p>http pa port number 80</p>
</li>
<li><p>https ka 443</p>
</li>
<li><p>→ ae http methods bohot important hey ae client and server https through aek server sey bathey karna chahtha hey</p>
</li>
<li><p>client sends request and server sends responce what he wil talk , either he wants to read , write , update , and delete the data</p>
</li>
<li><p>agar aapko read karna hey get method , agar write karna hey post method , agar update karna hey - put method and delete karna hey - delete method .</p>
</li>
</ul>
</li>
</ol>
</li>
</ol>
</li>
</ul>
<h3 id="heading-data-link-physical-layer-combines-network-access-layer">Data-link + physical layer combines = Network access layer</h3>
<ul>
<li><ol start="4">
<li>Network access layer :</li>
</ol>
</li>
</ul>
<p>AWS Practical :</p>
<ul>
<li><p>Is duniya mey kithna sara internet hoga , kithna sara ip address hoa , kithney saare ip address hogi</p>
</li>
<li><p>ae mera ghar mai mummy , papa , didi mere pass ek phone hey ek lap hey ek har , mummy , papa , and didi jey pass mobile hey aek har ek devices ko ek ip assign hotha hey aisa ek gharmey 7 devices ip address aisey ek mohelley mey kithne ghar honge</p>
</li>
<li><p>aapmey shehar mey kitne honge aisey kithne shehar kithne honge aise aise shehar kithey countries mey honge ithne sarey ip address manage nahi kar sakthey toh</p>
</li>
</ul>
<p>IPV4 - internet protocal version 4 limited ip address detha hey -→ no of ip address in ipv4 424 croces agar peoples badh gaye toh thab aaya <strong>ipv6</strong> ae bada internet hey ismey chota chota internet banayenge like subnets is subnets mey aap ip address banavo subnet mey ip address unique honge</p>
<p>ae jo vpc hey ae aapka personal network hey - is ko design karn ahey is vpc ko aap ek region mey banathey ho , ismey vpc daloge ismey subnet dalogey basically chota chota internet , agar aapka koi device hey public ko face karani hey vo hoga aapka public subnet agar aapka kuch data base hey privately rahna hey toh aapka private subnet</p>
<ul>
<li><p>ab ae toh ban gaya is vpc mey internet kaisa ghuseka iskey liye ek internet gateway banan hey thaki vpc mey internet ki acacces hojaye , bahar ki duniya sey bathey hopaye isliye gateway chahiye</p>
</li>
<li><p>is public subnet mey ek ec2 instance hey , private subnet mey rds hey</p>
</li>
<li><p>ae public subnet aur private subnet ko kaisa patha chalega ki internet ko kaha route karana hey , yah phir kis ip address ko kya routing honi chahiye is cheez key ek route table b chahiye hoga jaha pey aap apney public aur private subnet ka info dedoge</p>
</li>
<li><p>ki bhaiyya is private subnet mey jithney b hey sab ko internet dedo -→ agar aapko internet access karana hey OSI model ko follow karna padtha hey → physical karwana hey</p>
</li>
<li><p>mai devops engineer mey task mila hey ujhey secure tarikey sey secure instances chalana hey mujhey sabsey vpc mey chalo → region select karlo - us region mey vpc create karunga → vpc and more → name tws-networking</p>
</li>
<li><p>ab preview dekho aapka jo vpc name - uskey andar kithne subnets banana hey humko delect karna hey</p>
</li>
<li><p>ab question aatha hey ab CIDR BLOCK kya hotha hey - us subnets mey jithney b devices rahenge un sabko ip address kya kya assign honge → classless interdomain routing —&gt; basically aapkey subnets mey kithney ip address assign kiya ja saktha hey ek notaton rehta hey —&gt; google karo cidr xyz</p>
</li>
<li><p>will i really get 65536 ips no aws khu 5 ips letha hey khud support key liye detha hey</p>
</li>
<li><p>pehley vpc phir , subnets ismey a.z phir subnets ko internet chahiye na jithney b ips hey isko route chahiye na isliye public ko ek route table private 2 ko 2 private route tables</p>
</li>
<li><p>internate gateway rehtha hey public subnet key liye</p>
</li>
<li><p>s3 gateway hoga private subnet key liye → create vpc</p>
</li>
</ul>
<p>now create the instane in under your vpc and give info based on your requirement.  </p>
<hr />
<h3 id="heading-hin-english-explanation"><strong>Hin-English Explanation</strong></h3>
<p><strong>Kyun Computer Networking Important Hai for DevOps?</strong></p>
<p>Ek DevOps engineer ke liye networking bohot zaroori hai kyunki aapko infrastructure manage karna padta hai. Jaise:</p>
<ul>
<li><p><strong>VM ya Server Setup</strong>: Aapko virtual machines (VM) ya servers setup karne padte hain. Isme internet routing, connectivity, aur security ensure karna hota hai.</p>
</li>
<li><p><strong>Automation</strong>: Servers ya instances ko automate karna padta hai, jaise provisioning ke through.</p>
</li>
<li><p><strong>IPv4 vs IPv6 Confusion</strong>: Jab aap ek instance create karte ho, toh IPv4 ya IPv6 ka use hota hai. IPv6 thoda complex lagta hai kyunki isme zyada IPs hote hain.</p>
</li>
<li><p><strong>On-Premise vs Cloud</strong>: On-premise setup mein networking ka kaam alag hota hai, aur cloud (jaise AWS) mein VPC (Virtual Private Cloud) ke saath kaam karna padta hai. Client bolta hai, “Isko VPC ke andar daal do,” aur yeh confuse karta hai kyunki VPC private hota hai, toh internet kaise milega?</p>
</li>
</ul>
<p><strong>AWS mein Networking Kaise Kaam Karta Hai?</strong> AWS mein, jab aap ek EC2 instance create karte ho, client bolta hai, “Isko VPC ke andar daal do.” VPC ek private cloud jaisa hai, jisme aap subnets banate ho (public aur private). Public subnet internet se connect hota hai, private subnet secure rehta hai (jaise database ke liye). Internet access ke liye Internet Gateway banate hain, aur routing ke liye Route Tables use hote hain jo decide karte hain kaunsa traffic kahan jayega.</p>
<p><strong>Internet Kaise Kaam Karta Hai?</strong></p>
<ul>
<li><p><strong>Global Connectivity</strong>: Internet pure globe ko connect karta hai. Alag-alag continents ke beech optical fiber cables hote hain, jo samundar ke neeche bichhe hote hain. Yeh cables data transfer karte hain.</p>
</li>
<li><p><strong>Tier System</strong>:</p>
<ul>
<li><p><strong>Tier 1 Companies</strong>: Yeh badi companies hoti hain jo optical fibers ka network banati hain aur own karti hain.</p>
</li>
<li><p><strong>Tier 2 Companies</strong>: Yeh Tier 1 se fibers rent pe leti hain aur Tier 3 ko deti hain.</p>
</li>
<li><p><strong>Tier 3 Companies</strong> (jaise Airtel, Vodafone): Yeh ISPs (Internet Service Providers) hote hain jo humein internet provide karte hain. Yeh city level pe kaam karte hain aur MAN (Metropolitan Area Network) banate hain.</p>
</li>
</ul>
</li>
<li><p><strong>LAN, MAN, WAN</strong>:</p>
<ul>
<li><p><strong>LAN (Local Area Network)</strong>: Ghar ya office ke andar ka network.</p>
</li>
<li><p><strong>MAN</strong>: City-level network jo ISP provide karta hai.</p>
</li>
<li><p><strong>WAN (Wide Area Network)</strong>: Bada network jo multiple cities ya countries connect karta hai.</p>
</li>
</ul>
</li>
<li><p><strong>Optical Fiber vs Satellite</strong>: Optical fiber zyada pasand kiya jata hai kyunki satellite se distance aur latency zyada hoti hai. Optical fiber fast aur reliable hota hai.</p>
</li>
</ul>
<p><strong>OSI Model Kya Hai?</strong> OSI (Open System Interconnection) ek logical standard hai jo networking ko layers mein samjhta hai. Yeh 7 layers hote hain:</p>
<ol>
<li><p><strong>Application Layer</strong>: Yeh UI hota hai (jaise browser, WhatsApp). Yahan HTTP, SMTP jaise protocols kaam karte hain.</p>
</li>
<li><p><strong>Presentation Layer</strong>: Data ko format aur encrypt karta hai (jaise end-to-end encryption WhatsApp mein).</p>
</li>
<li><p><strong>Session Layer</strong>: Client aur server ke beech session maintain karta hai (jaise jab dono online hote hain).</p>
</li>
<li><p><strong>Transport Layer</strong>: Data transfer karta hai using protocols jaise TCP (secure, acknowledgement deta hai) ya UDP (fast, no acknowledgement).</p>
</li>
<li><p><strong>Network Layer</strong>: IP addresses aur routing handle karta hai (jaise source aur destination IP).</p>
</li>
<li><p><strong>Data-Link Layer</strong>: Device ke MAC address aur IP address ka pata lagata hai (ARP, RARP protocols use hote hain).</p>
</li>
<li><p><strong>Physical Layer</strong>: Cables, NIC (Network Interface Card), Wi-Fi jaise hardware hote hain.</p>
</li>
</ol>
<p><strong>TCP/IP Model Kya Hai?</strong> TCP/IP model OSI ka practical version hai jo real-world mein use hota hai. Iske 4 layers hote hain:</p>
<ol>
<li><p><strong>Application Layer</strong>: Browser, WhatsApp, email (HTTP, SMTP protocols).</p>
</li>
<li><p><strong>Transport Layer</strong>: Data transfer ke liye TCP (secure, three-way handshake) ya UDP (fast, no acknowledgement).</p>
</li>
<li><p><strong>Internet Layer</strong>: IP addresses aur routing (source aur destination IPs).</p>
</li>
<li><p><strong>Network Access Layer</strong>: Data-Link aur Physical layer combine hote hain. Yeh MAC address, cables, aur hardware handle karta hai.</p>
</li>
</ol>
<p><strong>Important Protocols</strong>:</p>
<ul>
<li><p><strong>DNS</strong>: Domain names (jaise <a target="_blank" href="http://trainwithshubham.com">trainwithshubham.com</a>) ko IP address se map karta hai.</p>
</li>
<li><p><strong>FTP</strong>: Files securely transfer karta hai.</p>
</li>
<li><p><strong>Telnet/SSH</strong>: Remote server access ke liye.</p>
</li>
<li><p><strong>SMTP</strong>: Email transfer ke liye.</p>
</li>
<li><p><strong>SNMP</strong>: Network management ke liye (rarely used).</p>
</li>
<li><p><strong>HTTP/HTTPS</strong>: Web browsing ke liye (port 80 aur 443).</p>
</li>
<li><p><strong>ARP/RARP</strong>: MAC address aur IP address find karne ke liye.</p>
</li>
</ul>
<p><strong>AWS Practical</strong>:</p>
<ul>
<li><p><strong>VPC Setup</strong>: AWS mein VPC create karte ho ek region mein. Isme subnets banate ho (public aur private).</p>
</li>
<li><p><strong>CIDR Block</strong>: Yeh decide karta hai kitne IP addresses ek subnet mein honge (jaise /16 mein 65,536 IPs, lekin AWS 5 IPs reserve karta hai).</p>
</li>
<li><p><strong>Internet Gateway</strong>: Public subnet ko internet se connect karta hai.</p>
</li>
<li><p><strong>Route Tables</strong>: Decide karte hain kaunsa traffic kahan jayega.</p>
</li>
<li><p><strong>S3 Gateway</strong>: Private subnet ke liye S3 access ke liye.</p>
</li>
</ul>
<p><strong>Example</strong>:</p>
<ol>
<li><p>VPC create karo (name: tws-networking).</p>
</li>
<li><p>Subnets banao (public aur private).</p>
</li>
<li><p>Internet Gateway attach karo public subnet ke liye.</p>
</li>
<li><p>Route Tables banao aur IPs assign karo.</p>
</li>
<li><p>EC2 instance public subnet mein aur RDS private subnet mein rakh do.</p>
</li>
</ol>
<hr />
<hr />
<h3 id="heading-full-english-explanation"><strong>Full English Explanation</strong></h3>
<p><strong>Why is Computer Networking Important for DevOps?</strong> For a DevOps engineer, networking is critical because it underpins infrastructure management. Key tasks include:</p>
<ul>
<li><p><strong>VM and Server Setup</strong>: Setting up virtual machines (VMs) or servers requires configuring internet routing, ensuring connectivity, and securing the infrastructure.</p>
</li>
<li><p><strong>Automation</strong>: Automating server provisioning and instance creation is a core responsibility.</p>
</li>
<li><p><strong>IPv4 vs IPv6</strong>: DevOps engineers often work with IPv4 for simplicity, but IPv6 can be confusing due to its vast address space.</p>
</li>
<li><p><strong>On-Premise vs Cloud</strong>: On-premise setups involve physical networking, while cloud environments (like AWS) use Virtual Private Clouds (VPCs). Clients may request instances to be placed in a VPC, which can be confusing as VPCs are private by default, raising questions about internet access.</p>
</li>
</ul>
<p><strong>Networking in AWS</strong> In AWS, you create EC2 instances and place them in a VPC, which acts like a private cloud. A VPC contains subnets:</p>
<ul>
<li><p><strong>Public Subnet</strong>: Connects to the internet (e.g., for web servers).</p>
</li>
<li><p><strong>Private Subnet</strong>: Isolated for secure resources (e.g., databases). To enable internet access, you attach an <strong>Internet Gateway</strong> to the VPC. <strong>Route Tables</strong> define how traffic is routed between subnets and the internet.</p>
</li>
</ul>
<p><strong>How Does the Internet Work?</strong></p>
<ul>
<li><p><strong>Global Connectivity</strong>: The internet connects the globe via optical fiber cables laid under oceans, enabling data transfer across continents.</p>
</li>
<li><p><strong>Tier System</strong>:</p>
<ul>
<li><p><strong>Tier 1 Companies</strong>: Own and manage the global optical fiber network.</p>
</li>
<li><p><strong>Tier 2 Companies</strong>: Rent bandwidth from Tier 1 and provide it to Tier 3.</p>
</li>
<li><p><strong>Tier 3 Companies</strong> (e.g., Airtel, Vodafone): Act as Internet Service Providers (ISPs), delivering internet to end-users at the city level, forming a <strong>Metropolitan Area Network (MAN)</strong>.</p>
</li>
</ul>
</li>
<li><p><strong>LAN, MAN, WAN</strong>:</p>
<ul>
<li><p><strong>LAN (Local Area Network)</strong>: Connects devices within a home or office.</p>
</li>
<li><p><strong>MAN</strong>: Covers a city, managed by ISPs.</p>
</li>
<li><p><strong>WAN (Wide Area Network)</strong>: Connects multiple cities or countries.</p>
</li>
</ul>
</li>
<li><p><strong>Optical Fiber vs Satellite</strong>: Optical fibers are preferred over satellites due to lower latency and higher reliability. Satellites have higher latency because of the distance signals must travel.</p>
</li>
</ul>
<p><strong>What is the OSI Model?</strong> The OSI (Open System Interconnection) model is a logical framework that standardizes networking functions into 7 layers:</p>
<ol>
<li><p><strong>Application Layer</strong>: Provides user interfaces (e.g., browsers, WhatsApp). Uses protocols like HTTP, SMTP.</p>
</li>
<li><p><strong>Presentation Layer</strong>: Formats and encrypts data (e.g., WhatsApp’s end-to-end encryption).</p>
</li>
<li><p><strong>Session Layer</strong>: Maintains sessions between client and server (e.g., ensuring both are online).</p>
</li>
<li><p><strong>Transport Layer</strong>: Handles data transfer using protocols like TCP (secure, with acknowledgements) or UDP (fast, no acknowledgements).</p>
</li>
<li><p><strong>Network Layer</strong>: Manages IP addresses and routing (source and destination IPs).</p>
</li>
<li><p><strong>Data-Link Layer</strong>: Handles device addressing (MAC and IP addresses) using protocols like ARP (Address Resolution Protocol) and RARP (Reverse ARP).</p>
</li>
<li><p><strong>Physical Layer</strong>: Involves hardware like cables, Network Interface Cards (NICs), and Wi-Fi.</p>
</li>
</ol>
<p><strong>What is the TCP/IP Model?</strong> The TCP/IP model is a practical implementation of the OSI model, used in real-world networking. It has 4 layers:</p>
<ol>
<li><p><strong>Application Layer</strong>: Includes user interfaces and protocols like HTTP, SMTP, and FTP.</p>
</li>
<li><p><strong>Transport Layer</strong>: Manages data transfer with TCP (reliable, with three-way handshake) or UDP (fast, connectionless).</p>
</li>
<li><p><strong>Internet Layer</strong>: Handles IP addressing and routing.</p>
</li>
<li><p><strong>Network Access Layer</strong>: Combines Data-Link and Physical layers, managing MAC addresses, cables, and hardware.</p>
</li>
</ol>
<p><strong>Key Protocols</strong>:</p>
<ul>
<li><p><strong>DNS (Domain Name System)</strong>: Maps domain names (e.g., <a target="_blank" href="http://trainwithshubham.com">trainwithshubham.com</a>) to IP addresses.</p>
</li>
<li><p><strong>FTP (File Transfer Protocol)</strong>: Enables secure file transfers.</p>
</li>
<li><p><strong>Telnet/SSH</strong>: Allows remote server access (SSH is more secure).</p>
</li>
<li><p><strong>SMTP (Simple Mail Transfer Protocol)</strong>: Used for email transfer.</p>
</li>
<li><p><strong>SNMP (Simple Network Management Protocol)</strong>: Manages networks (rarely used).</p>
</li>
<li><p><strong>HTTP/HTTPS</strong>: Powers web browsing (ports 80 and 443).</p>
</li>
<li><p><strong>ARP/RARP</strong>: Resolves MAC and IP addresses.</p>
</li>
</ul>
<p><strong>AWS Practical Networking</strong>:</p>
<ul>
<li><p><strong>VPC Creation</strong>: Create a Virtual Private Cloud in a specific AWS region. A VPC contains subnets (public and private).</p>
</li>
<li><p><strong>CIDR Block</strong>: Defines the range of IP addresses for a subnet (e.g., /16 provides 65,536 IPs, but AWS reserves 5 IPs for internal use).</p>
</li>
<li><p><strong>Internet Gateway</strong>: Connects public subnets to the internet.</p>
</li>
<li><p><strong>Route Tables</strong>: Define traffic routing for public and private subnets.</p>
</li>
<li><p><strong>S3 Gateway</strong>: Provides private subnets access to S3 without internet exposure.</p>
</li>
</ul>
<p><strong>Example AWS Workflow</strong>:</p>
<ol>
<li><p>Create a VPC (e.g., name: tws-networking).</p>
</li>
<li><p>Define subnets (public for EC2 instances, private for RDS).</p>
</li>
<li><p>Attach an Internet Gateway to the VPC for public subnet connectivity.</p>
</li>
<li><p>Configure Route Tables to route traffic appropriately.</p>
</li>
<li><p>Launch an EC2 instance in the public subnet and an RDS instance in the private subnet.</p>
</li>
</ol>
<hr />
<p>This explanation covers the importance of networking, how the internet functions, OSI and TCP/IP models, key protocols, and practical AWS networking concepts, presented in both Hin-English and full English for clarity. Let me know if you need further details or specific clarifications!</p>
]]></content:encoded></item><item><title><![CDATA[Kubernates Basic to Advance]]></title><description><![CDATA[Kubernates

Google ney 2014 mey google key websites scale nai ho parey - system robust nahi tha , vo ek time key badh crash hojarithi

2014 mey un honey ek system banaya borg jithney b applications hey vo automatic heal , scaleup and inhoney kubernat...]]></description><link>https://devopsblog1.hashnode.dev/kubernates-basic-to-advance</link><guid isPermaLink="true">https://devopsblog1.hashnode.dev/kubernates-basic-to-advance</guid><dc:creator><![CDATA[Vaseem Shaik]]></dc:creator><pubDate>Wed, 18 Jun 2025 09:33:01 GMT</pubDate><content:encoded><![CDATA[<p>Kubernates</p>
<ul>
<li><p>Google ney 2014 mey google key websites scale nai ho parey - system robust nahi tha , vo ek time key badh crash hojarithi</p>
</li>
<li><p>2014 mey un honey ek system banaya borg jithney b applications hey vo automatic heal , scaleup and inhoney kubernates ka initial name borg tha phir ae opensource kar diya</p>
</li>
<li><p>Kubernates ia as orchestration tool hey , aapkey jo docker containers rehthey hey ae saare docker containers ek dusrey sey bathey karthey hey , kab kisko heal hona hey , scale hona hey ae sab kubernates karatha hey</p>
</li>
<li><p>CNCF is an organization , its a community</p>
</li>
</ul>
<p>Kubernates kiun use karthey hey - jo bohot saarey applications monolithic banthey they ab microservice use karrey</p>
<h3 id="heading-monolithic-and-microservice">Monolithic and microservice.</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748939452079/b92c740a-bde9-4fa8-8936-347ecafd0108.png" alt class="image--center mx-auto" /></p>
<p>Monolithic - &gt; sambo ek dmart hey - badi si dukhan hey sab miljayega sab kuch ek hi jagah miljayega , monolith ek bada application ek hi application mey saari ek hi repo mey daley hey , is mey problem 1. manage karna difficult hey - stoc mey ek service ghadbad hogai - pura ka pura application shutdown hojatha hey - socho ek thodi ki cheez update karna hey toh saara application update karna padtha hey , manage karna bohot difficult hey</p>
<p>solution is Microservice- chotey chotey store- multiple stores like micro services - badey application ko chotey chotey services ko divide kar diya -</p>
<ul>
<li><p>microservices ko manage karna easy hey - chotey services docker key through chala sakthey hey - docker key through chali hui service ko manage and orchestrate karna hey aap kubernates use kar sakthey hey .</p>
</li>
<li><p>aap ko pata chalna hey ki aap kiun sikhre - kiunki microservice architecture bohot zyada use karrey isliye</p>
</li>
</ul>
<h3 id="heading-kubernates-architecture">Kubernates Architecture:</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748939474959/1037ea80-d147-450e-93c4-8933f86591c8.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>Kubernates ka logo kiun wheel jaisa - ship ka captain steering wheel hey na ae kubernates chalatha hey</p>
</li>
<li><p>aap kisi company mey jatha hey - startup matlab docker container - na scale kar patha hey - kabhi chaltha hey kabhi down hojatha hey</p>
</li>
<li><p>samjo mnc - mnc ka kuch architecture hotha hey - kubernates ka jo architecture hotha hey usmey aek aisa server rehtha hey - jo bakhi servers ko manage kartha hey</p>
</li>
<li><p>Cluster k8s mey hum cluster pey kaam karthey hey - multiple node ho sakthey hey - ek node hey master - dusrey nodes hey - worker nodes</p>
</li>
<li><p>mnc sey pov mey dekho - uska jo headquarter hey kahi dhoor rehthea hey - headquarter newyork - yaha pey actual kaam nahi hotha hey , vaha pey manager ceo log baidthey hey</p>
</li>
<li><p>india mey pune 1 node , banglore node , noida node ae node pey actuall log jakey work karthey hey</p>
</li>
<li><p>kubernates mey b aisa ek architecture rehtha hey - ek master node rehtha hey jaha pey ek aisey services hey jo worker node pey kaam karvaney key liye baiti hui hey - worker node mey actually docker key container chalre honge ae chalva rahehey vo master node pey baitey huey rehthey hey</p>
</li>
</ul>
<h3 id="heading-master-node-mey-kuch-services-rehthey-hey">master node mey kuch services rehthey hey</h3>
<ul>
<li><ul>
<li><p>apiserver: jo purey workernode mey kya kya cheeze chalri hey , master node mey kya kya cheeze chalre hey vo ek info rakhtha hey like Team lead - aapka team lead kahi dhoor bairta rehtha hey mumbai yah phir delhi vaha hey aapkey manager yah aapko kaam batata rehtah hey - api server ek aisa unit service hey jo communicate gateway rehtha hey har ek component key sath , aapkey team lead bola ki hamara requirement hey ek devops person ki jo ,placement karwatah hey vo HR - SCHEDULAR</p>
<p>    * schedular: ek aisi service hey schedular aapkey containers ko woker node pey scheduler karwathi hey , ab hr ney toh opening nikaldhi aapko job lagwadi , aapka jo data rahega ki aapney kab vo pod create kiya , kab opening hui kab job mili ae saara data base rehtha hey us db ko kubernates mey bola jatha hey - etcd</p>
<p>    * etcd: ae ek db hey - jo b cluster mey chalra sab data information etcd mey rehtha hey - data store rehtha hey , ab ek vo rehtha hey na pura ka pura bada sa head manager - dekhtha hey ki merey sare location mey kaam hora hey yah nahi hamra project manager</p>
<p>    * Controll manager : dekhtha hey sab saarey achesey chalre yah nahi - vaisey controll manager rehtah ehy - ae dekhtha hey ki , pods, services, nodes, cluster sahis ey chalra yah nahi dekhtha rehtha hey</p>
</li>
</ul>
</li>
<li><p>Worker node jaha pey actual mey kaam chalra hoga udhar mey b kuch services rehthey hey like udhar b manager rehtha hey</p>
<ul>
<li><p>kubelet: jo ensure kartah hey aap aarey yah nahi , aap task karreho yah nahi , sahi sey login karra, sahi sey task submit karra yah nahi , kubelet apiserver ko bata tha hey - api sever controll manager ko bata hey aur db mey save kartha hey , pods isolate rehtha hey usko access nahi karsakthey hey , ek proxy rehtha hey idhar ka udhar chulbuli kartha hey</p>
</li>
<li><p>service or kube proxy: as a user api server ko bolkey , kubelet ko bolkey andar key pods ko access kar sakthey hey</p>
</li>
<li><p>CNI network : master to worker node communication chalatha hey</p>
</li>
<li><p>kubetcl - director ceo - aisa karo vaisa karo karkey bata tha hey</p>
<p>  aapkey k8s ko instructions dena hey , dikhav kithey node chlarehey kithne pods chalre - pure key pure cluster ko aadesh dey sakthey hey</p>
</li>
<li><p>pod: pod is a smallet unit in kubernates in which dokcer containers will be running , pod to pod communicate we make through service</p>
</li>
</ul>
</li>
</ul>
<h3 id="heading-setup-on-local">Setup On Local:</h3>
<ul>
<li><p>Kubernates Installation in various types</p>
<ul>
<li><p>kubeadm</p>
</li>
<li><p>Miniqube</p>
</li>
<li><p>KIND Cluster</p>
</li>
<li><p>Eks/Aks/Gke</p>
</li>
</ul>
</li>
<li><p>Rancher - enterprice , Civo - ae sab like aws - enterprice ka hey</p>
</li>
<li><p>t1.medium lelo - connect karo - kind cluster - google karlo - or Kubestarter repo mey Kind-cluster mey jakey copy karkey install kardo</p>
</li>
<li><p>cluster create karey kind mey yaml likhna padtha hey - yaml - after configuring yaml</p>
<ul>
<li><p>kind create cluster —name=tws-cluster —config=config.yml</p>
</li>
<li><p>kubectl cluster-info --context kind-tws-cluster</p>
</li>
<li><p>kithney nodes hey - <code>kubectl get nodes --context kind-was-cluster</code></p>
</li>
</ul>
</li>
</ul>
<p>create a folder called miniqube: and install the miniqube</p>
<p>how to change kubectl set context default in kind</p>
<ul>
<li><p><code>kubectl config use-context kind-tws-cluster</code></p>
</li>
<li><p><code>kubectl get nodes</code></p>
</li>
</ul>
<p>- Kubeadm : Agar aapko kubeadm . bare metal aapko agar k8s cluster banana ho</p>
<ul>
<li><p>aap ek master banakey multiple nodes ko join kara sakthey hey</p>
</li>
<li><p>ek master node pey kubeadm init hoga jaha pey b kubernates initialize hotha hey vo hojathe hey master node phir aap jithney b nodes chahiye aap join kar sakthey ey - ae jo worker nodes join hothey hey 6443 port number pey join hothey hey</p>
<ul>
<li>Now kubeadm has been installed</li>
</ul>
</li>
</ul>
<p>Aapko ek docker ka container ko chalathey ho ek pod mey - ek pod mey ek sey yah zyada containers chalathey hey</p>
<ul>
<li><p>kubernates mey aap autosale , autoheal is cheez chalney key liye deployment chahiye</p>
</li>
<li><p>is deployment ko bahari duniya ko access devoge - isliye service ki zaroori hothi hey jab service banthi hey jabhi as a user aap access karavoge</p>
</li>
<li><p>aekhi cluster pey nginx , mysql b chalra hey toh confussion hotha hoga na kaisey in cheezon ko manage karsakey</p>
</li>
<li><p>jaisa whatsup mey group hotha hey like , family group , friends group isi tarah sey k8s mey b groups hothey hey jismey us group key related jithne b resources hey like pod , deployment , service - us group ko bolthey hey namespcae (ns)</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748982584412/23ae577b-a220-4a8e-9695-9c9ac2ad6bac.png" alt class="image--center mx-auto" /></p>
<p>Namespace: ae ek unit hey us particular namespace mey jithney b resources hey us group mey rehthey hey - ek group key resources aur ek group key resources ko disturb nahi karthey , complete isolation jaisa ki aapko manage karnemey easy rahega</p>
<ul>
<li><p>cd kind-cluster</p>
</li>
<li><p><code>kubectl get namespace (or) kubectl get ns</code> - agar aapney koi b name space nahi diyetoh ae by default namespace mey jatha hey</p>
</li>
<li><p><code>kubectl get pods</code> - jo default ns usmey kuch b pods nahi hey</p>
</li>
<li><p><code>kubectl get pods -n kube-system</code> - cluster key pods is namespace mey rehthey hey</p>
</li>
<li><p>isliye kubernates mey bohot sarey applications chala sakthey hey alag alag namespace sey</p>
</li>
<li><p><code>kubectl create ns nginx</code> - to create the namespace</p>
</li>
<li><p><code>kubectl run nginx --image=nginx</code> → is used to run the pods inside the pod nginx container will be running</p>
</li>
<li><p>galthi sey aapka pod hey default mey create hoga - aap pod ko delete ko b delete hosakta hey</p>
<ul>
<li><code>kubectl delete pod nginx</code></li>
</ul>
</li>
<li><p><code>kubectl run nginx --image=nginx -n nginx</code></p>
<ul>
<li><p><code>kubectl get pods -n nginx</code></p>
</li>
<li><p>is tarikhey sey pods - namespaces create kar sakthey - aap ae saari cheeze vi yaml banayenge - isko manifest file bolthey hey - aap jo chahthey hey manifest mey banado vahi run hothey hey</p>
</li>
</ul>
</li>
<li><p>kubectl pod delete nginx</p>
</li>
<li><p>kubectl delete ns nginx</p>
</li>
</ul>
<ol>
<li><p>namespcace: jaisa humne kind cluster diya is ka b kind namespace , version api ka v1 , ab jo info deni heyna vo rehthi hey metadata object mey rehthi hey , metadata mey name: nginx</p>
<ul>
<li>kubectl apply -f namespace.yml - isko apney apiserver pey lekey jav aur create kardo , jab aap apply karthey ho thab aapka object ban jatha hey</li>
</ul>
</li>
<li><p>pod.yml : kind pod rahega , apiVersion: v1 rahega , aur info metadata mey name: nginx-pod , ae pod kisi group or kisi namespace mey create karna chahtha hun - namespace: nginx iska spec google mey k8s pod - aur aapko yaha mey pod yaml milthey hey , spec mey containers bana sakthey hey usmey containers bana sakthey hey ek aur ek sey zyada usko name banana padtha hey , spec: name: nginx , image : nginx:latest ,ports: - containerPort: 80 - ae banigai manifest pod</p>
<ul>
<li><p>kubectl apply -f pod.yml -→ kubectl get pods -n namespace</p>
</li>
<li><p>nginx container mey kaisa ghusey -→ kubectl exec -it pod nginx-pod -n nginx -- bash</p>
</li>
<li><p>curl 127.0.0.1 -→ aapka nginx chalra aap browser mey chalayetoh maza aatha hey</p>
</li>
<li><p>ae pod dhang sey chalra yah nahi - kubectl describe pod/nginx-pod -n nginx -→ aapkey pod key sath kya kya hua ae sab bata detha hey</p>
</li>
<li><p>is pod banana khasiyath nahi hey is pod ko scalable banana toh deployment lagega</p>
</li>
</ul>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748982544375/51d8d6da-91b1-4fec-979e-8af9bf29ae46.png" alt class="image--center mx-auto" /></p>
<ol start="3">
<li><p><strong>deployment</strong>: kind : deployment , aur apiVersion: apps/v1 - google k8s deployment - ismey aapko manifest rahega - apiVersions differ rehthey hey harrek service key liye apiVersion alag rehtha hey phir metadata rahega , name: nginx-deployment , namespace: nginx -→ spec:</p>
<ul>
<li><p>deployment kiun chahiye - autoheal , scalable karna hey thab deployment ki jaruri rehthi hey replicas - ae replica banakey dega Replicaset/statefulset/deploymentset</p>
<ol>
<li><strong>deployment</strong>: Replication controller - ek pod ko pura traffic nahi dey sakthey vo crash hojayega -aap uska replica banathey hey - replica controller pod key replicas ko manage kartha hey like clone</li>
</ol>
</li>
</ul>
</li>
</ol>
<ul>
<li><p>deployment aur replica same rehtha hey - ae aapko ek feauture detha hey rollingUpdate - without downtime rolling update one by one it makes down the pod and update the pod</p>
</li>
<li><p>ae jo mera pod hey - is pod mey jo nginx chalra heyna uskey 2 replica chahiye - toh deployment ko pod pehchan mey aana chahiye -isiliye is pod ko label dena chahiye , us pod ko select karnekey liye selectors b chahiye - pod ka label and deployment ka selector criteria match hojai toh usko replica kardo</p>
</li>
<li><p><code>kubectl apply -f deployment.yml</code></p>
</li>
<li><p><code>kubectl delete -f pod.yml</code></p>
</li>
<li><p><code>kubectl scale deploymeny/nginx-deployment -n nginx —replicas=5</code></p>
</li>
<li><p><code>kubectl scale deploymeny/nginx-deployment -n nginx —replicas=1</code></p>
</li>
<li><p>kubectl set image deployment/nginx-deployment -n nginx nginx=nginx:1.27.1</p>
</li>
<li><p>kubectl rollout deployment/nginx-deployment -n nginx set image=nginx:1.27.3</p>
<p>  rolling update karthey karthey error b aagaya aapkey saare pods pey error nahi aayega kuch pods run horey hongey kuch pods update horey honge sequenctially</p>
</li>
<li><p>rollingupdate kiunn karthey hey suppose merko v1 key pods hey - isko latest version v2 sey update karna hey thab deployment without downtime isko rollback kardega , replicaset mey na sab kuch delete kar detha phir update kartha hey</p>
</li>
<li><p><code>kubectl delete -f deployment.yml</code></p>
</li>
<li><p><code>cp deployment.yml replicaset.yml</code></p>
<ul>
<li><strong>2. ReplicaSet</strong> : agar aapney bola hey ae pod ki temple image use karni hey nginx ki replica honi hey 4 , 4 pods banjayenge lekin ismey jab roling update mey downtime aatha hey -</li>
</ul>
</li>
<li><p>kubectl apply -f replicaset.yml</p>
</li>
<li><p>replica mey rollout -→ roleback nahi karsakthey</p>
</li>
<li><p>kubectl get replicasets -n nginx</p>
</li>
<li><p>replicaset using the same deployment technology - deployment is far advanced .</p>
<ul>
<li><ol start="3">
<li><strong>Statefulset</strong> : har ek pod kabhi bhi create / delete hosakthi hey satateful set kya bolthi hey harrek pod ko numbering dedunga 1 , 2 ,3 4 - har ek pod ki state by number sequence mey maintain rahegi</li>
</ol>
</li>
<li><p><strong>4..daemonset:</strong> ae jo pods hey -n nginx ae kisko miley hey aapkey pass 3 workers hey</p>
</li>
</ul>
</li>
<li><p>kubectl get pods -o wide -→ ae pods kispey assign hue - worker 3 mey nahi mil paye</p>
</li>
<li><p>deamon sets ensure karthey hey jithney b aapkey node hey atleast usmey ek pod toh chalthey rahey -</p>
</li>
<li><p>kubectl apply -f daemonset.yml</p>
</li>
<li><p>kubectl get pods -n nginx</p>
</li>
<li><p>kuectl get pods -o wide - daemonset worker1 pey ek pod , worker2 pey 2 , worker3 - 1 ensure kartha hey .</p>
<ul>
<li>saare ek kaam hi karthey hey - relication control hi karthey hey</li>
</ul>
</li>
<li><p>daemonset ka kaam hotha hey har ek node mey atleast ek (replica)pod run kartha hey</p>
</li>
<li><p>replicaset - jithey b aap boley uthey replicas maintain kartha hey</p>
</li>
<li><p>satefulset : ka kaam jithey replica ho vo apney sath ek state maintain karthey chale</p>
</li>
<li><p>deployment- jithne b replica hey , rolling update , scaling , auto healing karthey rahey</p>
</li>
</ul>
<p>4.Jobs&amp; CronJobs</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748983676691/0208708a-64b4-4405-8c47-86bfdb9aee08.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748982909824/dcd77e25-7e77-49da-a05c-94b9108dbd6a.png" alt class="image--center mx-auto" /></p>
<ol>
<li><ul>
<li><p>jobs: aapko ek container sey ek single task karana hey - aap nahi chalthey vo cheez as a sever chalthi rahey forex: tws as a sever chaltha hi rehtha hey , aap chahthey ho ek hi job hey vo chaley aur khatham hojaye</p>
<ul>
<li><p>like it can be comething like - paching , system update , backup ,, or creating directory</p>
</li>
<li><p>vim job.yml → ab jo aap banaraheho vo single chalega yah batches mey chalega - like single thread</p>
<ul>
<li><p>aaya backup liya khatham</p>
</li>
<li><p>or ae jo task hey parallel li chalado three pods same task pey toot padey hey</p>
</li>
<li><p>spec important completism: 1 parralelism: 1 agar 2 rakhdunga toh same task 2 pods create hokey job run hongey</p>
</li>
<li><p>busybox ek image rehtha hey is ka kaam sirf commands chalane ka rehtha hey</p>
</li>
<li><p>kubectl apply -f jobs.yml</p>
</li>
<li><p>kubectl get pods -n nginx → status completed → ae job chala vusney 10s hello dst print kiya aur khatham kiya</p>
</li>
<li><p>pod ki b life cycle rehtha hey - state kya rehtha hey - sabsey pehle container creating , running , terminating , phir completed, imgpullbackoff, errpullimg</p>
</li>
<li><p>kubectl logs pod/demo-job-qqrkh -n nginx</p>
</li>
<li><p>mai job ko phirsey run karsakta hun</p>
</li>
<li><p>kubectl delete -f jobs.yml → job ko delete karkey phirsey create karna padega</p>
</li>
</ul>
</li>
</ul>
<ul>
<li><p>Cron: ae jo task hey ae particular schedule pey chale toh is job ko bola jatha hey cron job</p>
<ul>
<li><p>a task that you can schedule ki vo pod chaltha rahega create hotha rahega chaltha rahega but complete tabhi hoga tha vo scedule thabhi complete hoga</p>
</li>
<li><p>vi cron.yml</p>
</li>
<li><p>volumes - ae aapka pod hey uskey andar ek container chalra hey - ae aapka host hey device ae container ae device iskey beech mey data ko persist karana chathey ho kiunki data loss na hojay toh isliye volume bana dethey ho aur us volume ko container sey mount kara dethey hey</p>
<ul>
<li><p>kubectl get pods -n nginx</p>
</li>
<li><p>kubectl logds pod/minute-backup -n nginx</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ol>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> nginx 
1. vi namespace.yml

kind: Namespace
apiVersion: v1
metadata:
  name: nginx

2. vim pod.yml 

kind: Pod
apiVersion: v1
metadata:
  name: nginx-pod
  namespace: nginx
spec:
  containers:
  - name: nginx
    image: nginx:latest
    ports:
    - containerPort: 80

3. deployment.yml

kind: Deployment
apiVersion: apps/v1
metadata:
  name: nginx-deployment
  namespace: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx

  template:
    metadata:
      name: nginx-dep-pod
      labels:
        app: nginx

    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80

4. replicaset 
kind: ReplicaSet
apiVersion: apps/v1
metadata:
  name: nginx-replicasets
  namespace: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx

  template:
    metadata:
      name: nginx-rep-pod
      labels:
        app: nginx

    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80

5. daemonset.yml

kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: nginx-daemonsets
  namespace: nginx
spec:
  selector:
    matchLabels:
      app: nginx

  template:
    metadata:
      name: nginx-dmn-pod
      labels:
        app: nginx

    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80

5. job.yml 
  kind: Job
apiVersion: batch/v1
metadata:
  name: demo-job
  namespace: nginx
spec:
  completions: 1
  parallelism: 1
  template:
    metadata:
      name: demo-job-pod
      labels:
        app: batch-task
    spec:
      containers:
      - name: batch-container
        image: busybox:latest
        <span class="hljs-built_in">command</span>: [<span class="hljs-string">"sh"</span>, <span class="hljs-string">"-c"</span> ,<span class="hljs-string">"echo Hello Dosto! &amp;&amp; sleep 10"</span>]
      restartPolicy: Never

vi cron.yml 

kind: CronJob
apiVersion: batch/v1
metadata:
  name: minute-backup
  namespace: nginx

spec:
  schedule: <span class="hljs-string">"* * * * *"</span>
  jobTemplate:
    spec:
      template:
        metadata:
          name: minute-backup
          labels:
            app: minute-backup

        spec:
          containers:
          - name: backup-container
            image: busybox
            <span class="hljs-built_in">command</span>:
            - sh
            - -c
            - &gt;
              <span class="hljs-built_in">echo</span> <span class="hljs-string">"Backup Started"</span> ;
              mkdir -p /backups &amp;&amp;
              mkdir -p /demo-data &amp;&amp;
              cp -r /demo-data /backups &amp;&amp;
              <span class="hljs-built_in">echo</span> <span class="hljs-string">"Backup Completed"</span> ;
            volumeMounts:
              - name: data-volume
                mountPath: /demo-data
              - name: backup-volume
                mountPath: /backups
          restartPolicy: OnFailure
          volumes:
            - name: data-volume
              hostPath:
                path: /demo-data
                <span class="hljs-built_in">type</span>: DirectoryOrCreate
            - name: backup-volume
              hostPath:
                path: /backups
                <span class="hljs-built_in">type</span>: DirectoryOrCreate
</code></pre>
<p><strong>STORAGE:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748985260486/4e80a09f-6f42-4fef-8ca1-7831403c5051.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>jab hum logoney cron job banyatha ae volumes aur volume mounts kuch toh kiya</p>
</li>
<li><p>samjo jab b aap ek pod banathey ho - vo pod aek server aur ek node pey chalra hotha right , ae pod kabhi bhi delte or destry kuch b ho saktha hey</p>
</li>
<li><p>is pod key andar ka jo b data hoga uska kya karoge agar vo delete hojayetoh</p>
</li>
<li><p>replication boltha hey desired state auto heal artha hey vo jo containers delete hua vo data b chalgaya</p>
</li>
<li><p>aapko aapkey pods ka data ko persist karna padtha hey - persist karaneykey liye aapko host key sath bind (persist) karna padtha hey</p>
</li>
<li><p>us cheez key liye persistent volume and persistent volume claim zaroori hothi hey ae hey kya</p>
</li>
<li><p>aisa samjo ae aapka host machine hey ec2 or docker iskey andar kuch storage hey in 30 gb mey sey kuch kuch section allocate karna chahtha hun 1GB allocate karna chahtha hun mainey 1GB ka persistent volume banaya</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748985772566/81d07b44-13c6-4d8f-a446-9df3e520efe4.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>vim persistentvolu.yml - mainey kind: PersistentVolume liya , apiVersion:v1 liya aur metadata : name:local-v , labels: app: local ismey mainey spec diya - ae p.v iska capacity kithna chahiye - storage :1Gi; accessModes: ReadWriteOnce , mai chahtha hun ki agar mainey delete b kardiya ae jo volume hey host machine mey ae retain kardo → persistentVolumeReclainPolicy: Retain ; storageClassName: local-storage ; hostPath: path: /mnt/data</p>
</li>
<li><p>mai nahi chatha ae sirf aur sirf nginx namespcae may aajaye</p>
</li>
<li><p>kubectl -f apply persistentvol.yml - ae banahua hey available hey isko claim karna padega</p>
</li>
</ul>
<pre><code class="lang-bash">vi persistentvolume.yml

kind: PersistentVolume
apiVersion: v1
metadata:
  name: local-pv
  namespace: nginx
  labels:
    app: <span class="hljs-built_in">local</span>
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  hostPath:
    path: /mnt/data
</code></pre>
<ul>
<li><p>aap ae sipper lekey aagaye kiska hey pata nahi lets say mera hey agar mai claim karunga toh vo mera hey</p>
</li>
<li><p>sirf volume banadiye available hey isko claim karna padtha hey</p>
</li>
</ul>
<pre><code class="lang-bash">kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: local-pvc
  namespace: nginx
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: local-storage
</code></pre>
<ul>
<li><p>kubectl get ns</p>
</li>
<li><p>kubectl get pv</p>
</li>
<li><p>kubectl apply -f pvclaim.yml</p>
</li>
</ul>
<p>mai ek gb request karrahun mai apney persistent volume sey 1gb request karra hun</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748986129260/0d6d5693-5886-4297-bab3-864047dc0b06.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748986272637/25236be5-16c0-4dd6-a817-f27de94d0f2c.png" alt class="image--center mx-auto" /></p>
<p>ab jo pv available tha vo bound hojaya hey pvclain sey , ab ae jo pod mey data delete ho jaratha ab mai kya chhatha hun ae mera pod host machine mey /mnt/data mey apna data bachakey rakhey - toh mainey 1gb ka pv banaya aur us 1gb ka claim banaya ab mai is claim ko ae mai is pod ko dedunga</p>
<p>kubectl get deployment -n nginx -→ kubectl delete deploymentyml</p>
<p>mujehy aisi deployment banana hey jiska data delte na ho kaisa banaunga ae jo container hey usko mai olunga volumeMounts iskey andar jo nginx ka data mount path : /var/www/html vo mount rahey name: my-volume key sath mount rahey ab jo meri volumes hey container key bahar rehtha name hey : my-volume</p>
<p>c</p>
<ul>
<li>is ka jo volume persistentvolumeclaim: claimName: local-pvc</li>
</ul>
<pre><code class="lang-bash">kind: Deployment
apiVersion: apps/v1
metadata:
  name: nginx-deployment
  namespace: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx

  template:
    metadata:
      name: nginx-dep-pod
      labels:
        app: nginx

    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 200m
            memory: 256Mi
        volumeMounts:
          - mountPath: /usr/share/nginx/html
            name: my-volume
      volumes:
        - name: my-volume
          persistentVolumeClaim:
            claimName: local-p
vc
</code></pre>
<ul>
<li><p>kubectl apply -f deployment.yml</p>
</li>
<li><p>kubectl get pv -n nginx</p>
</li>
<li><p>kubectl decribe pod/pod-name -n nginx</p>
</li>
<li><p>kubectl get pods -n nginx -o wide</p>
</li>
<li><p>kubectl get nodes -ae node hey cont</p>
</li>
<li><p>docker ps → docker exec -it cont_id bash → cd /mnt/data/ ls - mainey kuc create nahi kiya</p>
</li>
</ul>
<p>ae deployment bahari duniya ko dikhani hey toh iskey liye service ki zarori hothi hey service lagtha hey - service redirect kar detha hey</p>
<p>ae service bohot saare deployments mey redirect kara dethi hey</p>
<p><strong>service:</strong> kind service rahega , api version rahega v1 aur metadata rahega name and namespace aur spec mey vahapey selctors dena padega aapko ae service kiskey liye expose karni hey , jiska b label app:nginx hey uska expose karunga<br />kaha pey karunga tcp protocal - port - baharki duniya mey kounsi port sey expose karna chahthey ho - targetPort :cont port hey</p>
<ul>
<li>services key alag alag types rehtey hey</li>
</ul>
<p>type: clutser ip , node-port , loadbalancer , external ip , headless service</p>
<ul>
<li><p>agar mai cluster ip kar detha hun aapki cluster hey vo nikal key aatha hey aur uskey andar ek port assign ho jatha hey aur usko aap port map kar sakthey</p>
</li>
<li><p>agar mai nodeport likhdun - aapkey purey node ka port likalna padtha hey like 30000 sey bathis hazzar thak</p>
</li>
<li><p>loadbalancer generally cloud services key liye use karthey hey</p>
</li>
<li><p>aur external ip rehthi hey vo ek external ip usmey aapkp koi aur ip address static ip dalkey laga sakthey hey</p>
</li>
<li><p>headless: generally stateful sets key sath use hothi hey</p>
</li>
</ul>
<pre><code class="lang-bash">vim service.yml

kind: Service
apiVersion: v1
metadata:
  name: nginx-service
  namespace: nginx
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  <span class="hljs-built_in">type</span>: ClusterIP
</code></pre>
<ul>
<li><p>mera nginx service bahar ki duniya ka port number 80 aur andar ka cluster ka port pod ka port number sey map kardega , for anything that has app:nginx</p>
</li>
<li><p><code>kubectl apply -f service.yml</code></p>
</li>
<li><p>agar mai apney browser pey jau - ip :80 nahi access karpayega actually chalna chahiye</p>
</li>
<li><p>nahi chalra kiunki - aapka cluster hey vo ek docker container hey , toh docker container ka port forward karna padtha hey , address ip address expose karna padtha hey</p>
<ul>
<li><p>sudo -E kubectl port-forward service/nginx-service -n nginx 80:80 --address=0.0.0.0</p>
</li>
<li><p>ab access kardo - aek chotasa example lelethey hey - laundheshubham notes-app dev branch - isko mai kubernates project banani hey</p>
</li>
<li><p>git clone <a target="_blank" href="https://github.com/LondheShubham153/django-notes-app.git">https://github.com/LondheShubham153/django-notes-app.git</a><br />  - pehle docker image banaletha hun - &gt; <code>docker build -t notes-app-k8s .</code></p>
</li>
<li><p>ab ae jo meri image hey ae locally nahi chalney vali isko dockerhub mey pahunchana chahiye isliye docker hub ka login chahiye isliye mai dockerhub mey login karlunga - toh mai docker hub mey token bana detha hun</p>
</li>
<li><p><code>docker image tag notes-app-k8s:latest vaseem143/notes-app-k8s:latest</code></p>
</li>
<li><p><code>docker push vaseem143/notes-app-k8s:latest</code></p>
</li>
<li><p>cd k8s → vim deployment.yml</p>
<pre><code class="lang-bash">  kind: Deployment
  apiVersion: apps/v1
  metadata:
    name: notes-app-deployment
    namespace: notes-app
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: notes-app

    template:
      metadata:
        name: notes-app
        labels:
          app: notes-app

      spec:
        containers:
        - name: notes-app
          image: vaseem143/notes-app-k8s:latest
          ports:
          - containerPort: 8000

  vi service.yml

  kind: Service
  apiVersion: v1
  metadata:
    name: notes-app-service
    namespace: notes-app
  spec:
    selector:
      app: notes-app
    ports:
      - protocol: TCP
        port: 8000
        targetPort: 8000
    <span class="hljs-built_in">type</span>: ClusterIP
</code></pre>
<ul>
<li><p>kubectl get pods -n notes-app</p>
</li>
<li><p>kubectl port-forward service/notes-app-service -n notes-app 8000:8000 --address=0.0.0.0</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>    aisa samja agar mai /app - ae app khuley agar mai /nginx karey nginx khuley - toh aisa toh aisa khuley</p>
<ul>
<li>mai chahtha hun ki redirect karey services ko b</li>
</ul>
<p><strong>Ingress</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749038794109/b3646255-91f5-4ff8-8069-2776746fc262.png" alt class="image--center mx-auto" /></p>
<ul>
<li>iskey liye aapko ek cheez use karni padthi hey ingress - ingress aapka traffic re -routing kartha hey is cheex ko bolthey hey ingress</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749042047032/d649192a-535d-47a5-a6ae-c28c0cce6042.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>ek high level diagram sey dekhetoh ae aapka cluster hey ismey bohot saare pods hey - ae pods manage horey ek deploymen sey - aur is deployment ko access karnekey liye ek service ki zaroorath padthi hey iskey liye aap service create kardiye aisa hi alag deployment service aur 2 hey</p>
</li>
<li><p>multiple services ko kaisa route karna hey iskey liye ingress use hotha hey</p>
<p>  toh ingress jo hotha hey basically ek service hothi hey it allows us to manage service and traffic</p>
</li>
<li><p>agar mai /nginx/ karegetoh nginx jana agar mai /app kareth notes appp redirect honi hey in saarey cheezkon ko mai ek hi namespace mey chalana chahtha hun</p>
</li>
<li><p>service ko b - so delete kardo deployment and svc ko edit karkey namespace phir sey create karo</p>
</li>
<li><p>mere pass ninx ki and notes-app ki service b hey - mai ae jo daigram banana chahtha hey vo bangayi chalo isko redirect kar wathey hey</p>
</li>
<li><p>aap jo ingress karrehono isko ingress conroller lagtha hey jo aapko cluster level pey routing karwaney mey help kartha hey - nginx controller aur b controllers hey</p>
</li>
<li><p>k8s ingress controller - load balancing and redirecting mey b help kartha hey</p>
</li>
<li><p>aapko kind cluster document mey jakey ingress click karo</p>
</li>
<li><p>cd /home/ubuntu/kubernates-in-one-short - ab mai kubectl apply -f nginx-ingress apply karunga -→ kubectl apply -f <a target="_blank" href="https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx">https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx</a> - ek ingress controllers services banaey honge</p>
</li>
<li><p>kubectl get ns</p>
</li>
<li><p>kubectl get pods -n ingress-nginx</p>
</li>
<li><p>similarly aapko services b karni hey get → kubectl get svc - isi service ko badh mey expose karna padega</p>
</li>
<li><p>ab mai apney nginx mey jakey ek nayi file banaunga - ingress.yml</p>
</li>
</ul>
<pre><code class="lang-bash">apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-notes-ingress 
  namespace: nginx 
  annotations:
       nginx.ingress.kubernates.io/rewrite-target: / <span class="hljs-comment"># usmey jo / hey usko rewrite karna hey rewrite </span>
               <span class="hljs-comment"># rewrite karkey /nginx kardo </span>
spec:
  rules:
  - http:
      paths:
      - pathType: Prefix
        path: /nginx <span class="hljs-comment"># jab b ae path nginx ai redirect kardo </span>
        backend:
          service:
            name: nginx-service <span class="hljs-comment"># redirect kardo nginx-service per </span>
            port:
              number: 80 <span class="hljs-comment"># service ka port hey </span>
      - pathType: Prefix
        path: / <span class="hljs-comment"># jab b mai bolum / app redirect to notes-app-service</span>
        backend:
          service:
            name: notes-app-service
            port:
              number: 8000
</code></pre>
<ul>
<li><p><code>kubectl apply -f ingress.yml</code></p>
</li>
<li><p><code>kubectl get ing -n nginx</code></p>
</li>
<li><p><code>kubectl get all -n nginx</code> -→ ae jo ingress hey ae ek ingress controller key sath chalra hey jo ingress nginx name ka controller hey jo kind cluster mey install kiye usko expose karna hey</p>
</li>
<li><p><code>kubectl get svc -n ingress-nginx</code></p>
</li>
<li><p><code>sudo -E kubectl port-forward service/ingress-nginx-controller -n ingress-nginx 8080:80 --address=0.0.0.0</code></p>
</li>
<li><p>ab mai ip:8080 - ismey nginx chalra aur / pey aur /nginx - nginx b port 80 i mean / mey chalega agar mai /nginx sey karun mera nginx open huey isliye annotations matlab extra information</p>
</li>
<li><p>ingress ki specifications ko customize kar sakthey ho</p>
</li>
<li><p><code>kubectl apply -f ingress.yml</code></p>
</li>
<li><p><code>sudo -E kubectl port-forward service/ingress-nginx-controller -n ingress-nginx 8080:80 --address=0.0.0.0</code></p>
</li>
<li><p>kubectl delete -f namespace.yml - sab jo b nginx namespace key andar hey sab delete hojathey hey</p>
</li>
</ul>
<p><strong>Statefulset:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749042800826/75ad4cd6-6544-4c00-9e73-48e13537d4d9.png" alt class="image--center mx-auto" /></p>
<p>mkdir mysql</p>
<ul>
<li><p>jab b hamare koi applications hothey hey django , flask , aur springboot apps ae saarey applications ,agar aapkey state maintain nahi hothi hey toh b chaltha hey . UI hey user kabhi use karega band karega → ae basically stateless hothey hey</p>
</li>
<li><p>is ka jo data rahega mysql , mongodb ae saarey db hey vo stateful rehthey hey</p>
</li>
<li><p>mysql ka data hey vo always persisted hona chahite - timeley usmey transactions matlab read write ae sab ek dum sahi sey hona chahiye state key aap kabhi bhi khilwat nahi kar sakthey when it comes to databases</p>
</li>
<li><p>jab b aap stateless applications hothey hey generally app use karthey hey</p>
<ul>
<li>deployment , replicaset , daemonsets etc</li>
</ul>
</li>
<li><p>jab appki stateful applications like mongodb , mysql - use karthey hey stateful sets ismey b replica rehtha hey - ae jo pods banthey hey ae pod apney sath ek state carry karthey hey like 1, 2 ,3 ,4,5 sequence mey numberd hothey hey</p>
</li>
</ul>
<pre><code class="lang-bash">vi statefulset.yml

kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: mysql-statefulset
  namespace: mysql

spec:
  serviceName: mysql-service
  replicas: 3
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - name: mysql
        image: mysql:8.0
        ports:
        - containerPort: 3306
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 200m
            memory: 25Mi
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-secret
              key: MYSQL_ROOT_PASSWORD

        - name: MYSQL_DATABASE
          valueFrom:
            configMapKeyRef:
              name: mysql-config-map
              key: MYSQL_DATABASE 
        volumeMounts:
        - name: mysql-data
          mountPath: /var/lib/mysql

  volumeClaimTemplates:
  - metadata:
      name: mysql-data
    spec:
      accessModes: [ <span class="hljs-string">"ReadWriteOnce"</span> ]
      resources:
        requests:
          storage: 1Gi
</code></pre>
<ul>
<li><p>pehle ek namespace mysql bana dethye hey phir statefulset.yml</p>
</li>
<li><p>mai is valey statefulset ko ek spec dedunga ismey pehle replica:3 , mai lables and selectors use karunga - selector: matchLabels: app: mysql</p>
<p>  important part template mey aatha hey</p>
</li>
<li><p>jo mysql ka container rehtha hey vo always environmnet variables mangtha hey</p>
</li>
<li><p>env : mysql key jo environment dalna hey vo kaisa dalthey hey → k8s stateful environmnet google it</p>
</li>
<li><p>but agar aapko ek mysql ka stateful set banana hey is pod ko jo storage chahiye volume chahiye vo aapko stateful set mey hi dalna padega</p>
</li>
<li><p>mai yaha aek volume banaunga aue volume claim template b ismey hi karunga</p>
</li>
<li><p>jaisa mainey statefulset replica hey uska pod ka ek service b honi chahiye - iski service ki ek khasiyath rehthi hey - headless service - iska sab same rahega</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749044379993/51a019ee-4b3a-4b01-9cfa-3c02eef10cde.png" alt class="image--center mx-auto" /></p>
</li>
<li><pre><code class="lang-bash">              kind: Service
              apiVersion: v1
              metadata:
                name: mysql-service
                namespace: mysql
              spec:
                clusterIP: None
                selector:
                  app: mysql
                ports:
                - name: mysql
                  protocol: TCP
                  port: 3306
                  targetPort: 3306
</code></pre>
<ul>
<li><p>ae service internally use key liye kahi expose nahi hothi , bahari duniya key liye acccess naho honi chahiye isliye agar mere app ko data chahiye thorough service it can able to access</p>
</li>
<li><p>ae jo service sirf aur sirf statefulset key sath bind rahey isliye → statefulset.yml mey jakey bind kardo</p>
</li>
<li><p>kubectl apply -f service.yml</p>
</li>
<li><p>kubectl apply -f statefulset.yml</p>
</li>
<li><p>kubectl get pods -n mysql</p>
</li>
<li><p>kubectl get svc -n mysql</p>
</li>
<li><p>kubectl exec -it mysql-statefulset-0 -n mysql -- bash</p>
</li>
<li><p>mysql -u root -p = root</p>
</li>
<li><p>mainey ek stateful set key sath mysql ki deployment bandiya aur vo b scalable hey</p>
<ul>
<li><p>show databases;</p>
</li>
<li><p>kubectl delete pod mysql-statefulset-0 -n mysql</p>
</li>
<li><p>kubectl get pods -n mysql -→ jab b hum delte karey with the same pod name it creates a new one , that is how k8s maintains the state</p>
</li>
<li><p>pod humesha koi aur create karthey na charoka name random honge , koi b delet kardo koi naya name banjayega but is case mey aisa nahi hotha , is case mey vahi name ka pod delete kiya vahi name sey new vala bantha</p>
</li>
<li><p>iski service, iski volume template , variables , sab tightly coupled rehtha hey , isiliye jab b naya pod bantha hey vo hamesha state ko sath lekey chaltha hey , isiliye known as stateful set</p>
</li>
<li><p>deployment mey jo b pods create banthey hey alag name sey banthey hey .</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p><strong>ConfigMaps:</strong> kaisey aap aapney pod mey jo b variables hey jo b aapka data hey kaisey ek dam secure tarikheysey pauncha sakthey hey chalo dekhthey hey</p>
<p>aisa samjo ki aapney jo create kiye na statefulset banaya ismey ae jo mysql dataabase ki value dalina kal ko agar aapko change karni padegi aapko stateful sey mey aakey change karna padegi</p>
<ul>
<li>ki mai chahtha hun ki jithey b meri environmenyt variables , varibales vo alag ek file mey rahey , jo merey conf rehthey hey vo ek alag file mey rahey</li>
</ul>
<pre><code class="lang-bash">kind: ConfigMap
apiVersion: v1
metadata:
  name: mysql-config-map
  namespace: mysql
data:
  MYSQL_DATABASE: devops
</code></pre>
<ul>
<li><p>- isko aap use karoge stateful set</p>
</li>
<li><p>vim statefulset - jo mera env mysql_Data base hey vo value mai direct nahi liunga liunga valueFrom : name: mysql-config-map ; key: MYSQL_DATABASE; ae as a configMapKeyRef karkey dalna padega</p>
</li>
<li><p>aapki jo config map hey usmey jo aap key dali hui hey key ref sey</p>
</li>
<li><p><code>kubectl apply -f statefulset.yml</code></p>
</li>
</ul>
<p><code>kubectl get statefulset -n mysql</code></p>
<p><code>kubectl delete statefulset -n mysql</code></p>
<p><code>kubectl apply -f statefulset.yml</code></p>
<ul>
<li><code>kubectl get pods -n mysql</code></li>
</ul>
<p>jaisey aapney config maps mey normal plane text valey key:value pair mey data dala usi prakar mey aap agar encode karkey dalna chahthey ho , generally passwords ko encode karna chahthey ho toh secrets mey dalthey hey</p>
<p><strong>Secrets:</strong></p>
<p>vim secret.yml - ismey jo b password hey na usko base64 encode karkey dalna padega</p>
<ul>
<li>echo “root” | base64</li>
</ul>
<pre><code class="lang-bash">apiVersion: v1
kind: Secret
metadata:
  name: mysql-secret
  namespace: mysql
data:
  MYSQL_ROOT_PASSWORD: cm9vdAo=  <span class="hljs-comment"># base64 encoded for "root"</span>
</code></pre>
<p>kubectl apply -f statefulset.yml</p>
<p>kubectl get pods -n mysql</p>
<p><strong>ResourceQuota &amp; Limits</strong> : ek pod hey ae jo aapka pod aapkey host machine mey chalra hotha hoga - ab is machine ka kuch configuration hoga t2.medium like 4gbram 2cpu</p>
<ul>
<li><p>lets say ae pod hey nginx - pod pey aagaya traffic badthey jara jara aur jheltha jara 4gb ki ram ae akela pod hi khagaya</p>
</li>
<li><p>lets say aur ek pod aagya agar nginx pod hi khagaya toh 4gb toh ae bichara dusra pod kya karega isko kuch b nai milega</p>
</li>
<li><p>jab b aap apney pods banathey hey - aap usmey kithna resources aapko chahiye , maximum kithna ley saktha hey pod ae aapko dena padega decide karna padega</p>
</li>
<li><p>meri deployment file hey us file mey humko limit deni hothi hey</p>
</li>
<li><pre><code class="lang-bash">            resources:
                      requests:
                        cpu: 100m
                        memory: 128Mi
                      limits:
                        cpu: 200m
                        memory: 256Mi
</code></pre>
</li>
<li><p>ae toh minimum request , max 2 roti sey zyada nahi chahiye uske liye limits use karthey hey</p>
</li>
<li><p>issey na aapka pod ithna hi resource leyega -→ aap isko create karkey describe kardo</p>
</li>
</ul>
<p><strong>Probes:</strong></p>
<ul>
<li><p>kaam chota sa hi rehtha hey - probes aisa samjo ki vo 3 type key hothey hey</p>
<ol>
<li><p>liveness Probe</p>
</li>
<li><p>readiness probe</p>
</li>
<li><p>startup probe</p>
</li>
</ol>
</li>
<li><p>probe matlab ek request rehthi hey ki ae aapka pod dhang sey kaam karrahey yah nahi - lets say ae pod pey 8000 pey chalra but aapko make sure karna hey ki vo 8000 mey hi chalrahey , agar aapka pod zinda hey yah nahi aapko live hey yah nahi liveness probe test kartha hey</p>
</li>
<li><p>agar aapka pod create hotha hey yah ready ho gaya thab readiness probe test kartha hey</p>
</li>
<li><p>startup probe - jab aapka pod start hora hey startup probe key sath request check kartha hey</p>
</li>
</ul>
<pre><code class="lang-bash">livenessProbe:
          httpGet:
            path: /
            port: 8000
</code></pre>
<ul>
<li><p>is pod mey mera readiness aur liveness probe trigger hua yah nahi</p>
<ul>
<li><p>kubectl describe pod podname -n nginx</p>
</li>
<li><p>probe just check kartha hey internally - yaha pey intervals b dal sakthey hey initial delay ae sab</p>
</li>
</ul>
</li>
</ul>
<p><strong>Taints &amp; Tolerants:</strong></p>
<ul>
<li><p>toh is valey diagrams ko dekhthey hey , mai jabbi apney cluster ko boltha hun kubectl apply -f deploy - api- server scheduler ko boltha hey bhai pod schedule kardo , schedular apney hisab sey dekhta hey pod woker 1 , 2 ,3 kounsey node mey bhejna hey ae schedular decide kartha hey</p>
</li>
<li><p>taint , tont - hum tont marthey hey na , uskey ghar ko nahi jathey na agar ek relative humko tont kartha hi rehthey hetoh</p>
</li>
<li><p>vaisa hi aap schedular ko cahthey hey ki node1 pey pod schedule na karey toh aap node1 ko taint kardogey</p>
</li>
<li><p>taint is a way of telling your k8s cluster ki is particular node mey aap pod nahi schedule karey</p>
</li>
<li><p>kuch kuch relatives taunt tont marthey hey lekin hum ghar chale jathey hey sehlethey hey tolerate</p>
</li>
<li><p>aapki koi tainted server hey lekin aapko chalana chahthey ho usko aap tolerants dal sakthey ho</p>
</li>
<li><p>hum kaisa taint karwana hey</p>
</li>
</ul>
<p>kubectl get ns → cd nginx -→ cat pod.yml - ae aek pod hey ae jo pod hey agar mai chalaunga ae kidar jayega agar mai worker node ko taint kiya toh ae pod us node pey run nahi hoga</p>
<ul>
<li><p><code>kubectl taint node tws-cluster-worker prod=true:NoSchedule</code></p>
</li>
<li><p><code>kubectl taint node tws-cluster-worker2 prod=true:NoSchedule</code></p>
</li>
<li><p><code>kubectl taint node tws-cluster-worker3 prod=true:NoSchedule</code></p>
</li>
<li><p><code>kubectl apply -f namespace.yml</code></p>
</li>
<li><p><code>kubectl apply -f pod.yml</code></p>
</li>
<li><p>kubectl get pods -n nginx - ae pending mey hey kiun matlab , hamare 3 ko 3 nodes tainted hey , jo b taint ho jatha hey usmey schedule nahi kar patha .</p>
</li>
<li><p>ae pod bechara ko ek node dey dethey - <code>kubectl taint node tws-cluster-worker3 prod=true:NoSchedule-</code> - hyphen matlab untainted</p>
</li>
<li><p><strong>Tolerants:</strong></p>
</li>
<li><p>tainted pod mey b mai kaisey chalaunga - pod key spec mey jakey - tolerations: - key: “prod” operator: “Equal” value: “true” - aisa koi b cheeze taint pada hey jismey pod=true and noschedule dala hey tolerate karkey chalado karkey bolre</p>
</li>
</ul>
<pre><code class="lang-bash">tolerations:
    - key: <span class="hljs-string">"prod"</span>
      operator: <span class="hljs-string">"Equal"</span>
      value: <span class="hljs-string">"true"</span>
      effect: <span class="hljs-string">"NoSchedule"</span>
</code></pre>
<p><strong>HPA &amp; VPA: Horizantal pod autoscaling &amp; vertical pod autoscaling :</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749065697094/ce60ce10-03c6-4809-bd70-33ce603d406b.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>sabsey pehley samajthey hey autoscaling - autoscaling ab har koi microservice architecture mey aagaye ab sabko based o traffic autoscale karna chahthey hey</p>
</li>
<li><p>jab autoscale ki bath aathi hey 3 types hey</p>
<ul>
<li><p>HPA: matlab agar aapka jo pod hey mast traffic aagaya ae jo pod hey apney aap scale hojayega like replica ban jathey hey , replica ko badathey ho number badathey hey - normal applications use kar sakthey</p>
</li>
<li><p>VPA: pehley aapka pod aisa tha vo maxium resources 100mb use kartah hey max ae 200mb ka traffic jhel saktha hey - agar isko autoscale karna chahthey ho ae banjayega hulk ae pod ki thakath ko badathey ho , resource and limits ko badathey hey - basically ae stateful applications ko use karthey hey</p>
</li>
<li><p>KEDA - kubernates event driven autoscaling : vo dekhtha hey aapka event kaisa hey , bohot zyada traffic or rerouting hey toh vo either hpa pey lagadeyega bohot zyada overload or stress aara hey ae vpa mey laga dega - based on the nature of your metrics or events keda hpa or vpa sey selct karletha</p>
</li>
<li><p>metrics kya hotha hey - countafiable resources key numbers like cpu and ram kithna use hora hey</p>
</li>
<li><p>kubectl get nodes</p>
</li>
<li><p>ae jo node hey kithna traffic aara hey , kithna kya hora hey iski metrics aapko pata honi chahiye iski metrics</p>
</li>
<li><p>kubectl top node → issey metrics nahi hey - kubesystem mey metrics severs ,hona chahiye and vo metrics server aapkey node mey aapkey pod mey kithne resources , cpu kya scena hey kithney use horey ae sab metrics detha hey</p>
</li>
<li><p>miniqube hey toh usmey karlenge - miniqube addons enable metrics-server- ae karkey badiya chala sakthey hey</p>
</li>
<li><p>kind cluser mey metrics chahiye - toh aap github mey milega - usmey copy karkey idhar run karo -→ github hpa and vpa ey javo</p>
</li>
</ul>
</li>
<li><p>If you are using a Kind cluster install Metrics Server</p>
</li>
</ul>
<pre><code class="lang-bash">kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
</code></pre>
<ul>
<li>Edit the Metrics Server Deployment</li>
</ul>
<pre><code class="lang-bash">kubectl -n kube-system edit deployment metrics-server
</code></pre>
<ul>
<li>Add the security bypass to deployment under <code>container.args</code></li>
</ul>
<pre><code class="lang-bash">- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalIP,Hostname,ExternalIP
</code></pre>
<ul>
<li>Restart the deployment</li>
</ul>
<pre><code class="lang-bash">kubectl -n kube-system rollout restart deployment metrics-server
</code></pre>
<ul>
<li>Verify if the metrics server is running</li>
</ul>
<pre><code class="lang-bash">kubectl get pods -n kube-system
kubectl top nodes
kubectl top pod -n nginx
</code></pre>
<p>jaisey humney coreconcepts key nginx , pv pvc key liye statefulsets mysql , django notes app aek application dekhey</p>
<ul>
<li><p>ab hpa and autoscaling key liye ek naya dekhenge apache - ae b ek httpd server hey</p>
</li>
<li><p>ek namespace banana hey - kubectl create namespace apache , ab mujhey is apache ka deployment banana hey us deployment ko hpa sey automatically scale kar wana hey</p>
</li>
<li><h3 id="heading-steps-to-implement-hpa"><strong>Steps to implement HPA:</strong></h3>
<ul>
<li><p>Update the Deployments:</p>
<ul>
<li>We'll modify the existing Apache deployment YAML files to include resource requests and limits. This is required for HPA to monitor CPU usage.</li>
</ul>
</li>
</ul>
</li>
</ul>
<pre><code class="lang-bash">    vi apache-deployment.yaml

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: apache-deployment
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: apache
      template:
        metadata:
          labels:
            app: apache
        spec:
          containers:
          - name: apache
            image: httpd:2.4
            ports:
            - containerPort: 80
            resources:
              requests:
                cpu: 100m
                memory: 128Mi
              limits:
                cpu: 200m
                memory: 256Mi
</code></pre>
<ul>
<li>sabsey important containers ki resources quota and limit set karni hey</li>
</ul>
<pre><code class="lang-bash">    vi service.yml 

    apiVersion: v1
    kind: Service
    metadata:
      name: apache-service
    spec:
      selector:
        app: apache
      ports:
        - protocol: TCP
          port: 80
          targetPort: 80
      <span class="hljs-built_in">type</span>: ClusterIP
</code></pre>
<ul>
<li><p><code>kubectl get all -n apache</code></p>
</li>
<li><p><code>sudo -E kubectl port-forward svc/apache-service 8081:80 --address 0.0.0.0</code></p>
</li>
<li><p>ae application ko public mey daldethey toh sab log access karengetoh mera cluster ruk saktha hey</p>
</li>
<li><p>mai chahtha hun - kubectl scale deployment apache-deployment -n apache —replicas=3 -→ ae manuall hey - hum dekha samja - ae scalling hey autoscalling nahi - autoscaling key liye hpa banana hey</p>
</li>
<li><pre><code class="lang-bash">            <span class="hljs-comment">#apache-hpa.yaml</span>
            apiVersion: autoscaling/v2
            kind: HorizontalPodAutoscaler
            metadata:
              name: apache-hpa
              namespace: apache
            spec:
              scaleTargetRef:
                apiVersion: apps/v1
                kind: Deployment
                name: apache-deployment
              minReplicas: 1
              maxReplicas: 5
              metrics:
              - <span class="hljs-built_in">type</span>: Resource
                resource:
                  name: cpu
                  target:
                    <span class="hljs-built_in">type</span>: Utilization
                    averageUtilization: 20
</code></pre>
<p>  - kubectl get pods -n apache</p>
</li>
<li><p>kubectl apply -f hpa.yml</p>
</li>
<li><p>kubectl get hpa -n apache</p>
</li>
<li><p>ab ae jo url hey it works - isko load kaisa diyenge load bananey ka tarikha</p>
</li>
<li><p>aek pod banayenge - loadgenerator karkey</p>
</li>
<li><p>kubectl run -it load-generator —image=busybox -n apache — bash</p>
</li>
</ul>
<h3 id="heading-stress-testing"><strong>Stress Testing</strong></h3>
<ul>
<li>To see HPA in action, you can perform a stress test on your deployments. Here is an example of how to generate load on the Apache deployment using 'BusyBox':</li>
</ul>
<pre><code class="lang-bash">    kubectl run -i --tty load-generator --image=busybox /bin/sh
</code></pre>
<ul>
<li>Inside the container, use 'wget' to generate load:</li>
</ul>
<pre><code class="lang-bash">    <span class="hljs-keyword">while</span> <span class="hljs-literal">true</span>; <span class="hljs-keyword">do</span> wget -q -O- http://apache-service.default.svc.cluster.local; <span class="hljs-keyword">done</span>
</code></pre>
<p>    This will generate continuous load on the Apache service, causing the HPA to scale up the number of pods.</p>
<ul>
<li>Now to check if HPA worked or not, open a same new terminal and run the following command</li>
</ul>
<pre><code class="lang-bash">    kubectl get hpa -n apache 
    kubectl get pods -n apache
</code></pre>
<blockquote>
<p>Note: Wait for few minutes to get the status reflected.</p>
</blockquote>
<p>    agar mainey rok diya → watch kubectl get pods -n apache</p>
<ul>
<li><p>kubectl get hba -n apache -→ humko samaj aagaya how HPA automatically scale the application same notes-app mey deployment mey resource and limit use karo and just change name deployment name in HPA.yml</p>
</li>
<li><p><code>kubectl apply -f deployment.yml</code></p>
</li>
<li><p><code>kubectl get pods -n ninx</code></p>
</li>
<li><p><code>kubectl apply -f service.yml</code></p>
</li>
<li><p><code>kubectl apply -f hpa.yml</code></p>
</li>
<li><p><code>kubectl get hpa -n nginx</code></p>
</li>
<li><p>kubectl get pods -n nginx</p>
</li>
<li><p><code>kubectl delete ns nginx .</code></p>
</li>
</ul>
<p>Vertical pod autoscaler key files ko download karna padtha hey</p>
<ul>
<li>For VPA</li>
</ul>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> https://github.com/kubernetes/autoscaler.git
<span class="hljs-built_in">cd</span> autoscaler/vertical-pod-autoscaler
./hack/vpa-up.sh  <span class="hljs-comment"># jo jo prerequisite chahiye vpa key liye vo install karthi hey</span>
</code></pre>
<ul>
<li><p>Verify the pods on VPA</p>
</li>
<li><pre><code class="lang-bash">            kubectl get pods -n kube-system
</code></pre>
</li>
</ul>
<pre><code class="lang-bash">  vim vpa.yml 

apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: apache-vpa
  namespace: apache
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: apache-deployment
  updatePolicy: <span class="hljs-comment"># idhar aap update mode dalthey hey </span>
    updateMode: <span class="hljs-string">"Auto"</span> <span class="hljs-comment"># Options: "Off", "Initial", "Auto"</span>
</code></pre>
<ul>
<li><p><code>kubectl get pods -n apache</code></p>
</li>
<li><p><code>kubectl get hpa -n apache</code></p>
</li>
<li><p><code>kubectl delete -f hpa.yml</code></p>
</li>
<li><p><code>kubectl apply -f vpa.yml</code></p>
</li>
<li><p><code>kubectl get vpa -n apache</code></p>
</li>
<li><p>take another terminal → <code>kubectl get svc -n apache</code></p>
</li>
<li><p><code>kubectl get pods -n apache</code></p>
</li>
<li><p><code>kubectl get vpa -n apache</code></p>
</li>
<li><p><code>kubectl run -i -tty load-genera</code></p>
</li>
<li><p><code>tor —image=busubox -n apache /bin/bash</code></p>
</li>
<li><p><code>while true; do wget -1 -O https://apache-service.apache.svc.cluster.local ; done</code></p>
</li>
<li><p><code>sudo -E kubectl port-forward svc/apache-service 8081:80 --address 0.0.0.0</code></p>
</li>
<li><p><code>kubectl get vpa -n apache</code></p>
</li>
<li><p><code>kubectl top pod -n apache</code> —&gt; this is how you have enlarged your pod resource</p>
</li>
<li><p>kubectl describe pod podname -n apache</p>
</li>
<li><p>kubectl top node</p>
</li>
<li><p>kubectl get pods -n apache -o wide</p>
</li>
<li><p>k8s node affinity</p>
</li>
</ul>
<p><strong>Node Affinity / node selectors : agar aapkey pod ko aapkey node pey schedule karana hey toh us node key bharemey thodasa batado like node name , type , key , resources agar usko match karthey hue milgaya</strong></p>
<ul>
<li>node affinity is opposite to taint and tolerants</li>
</ul>
<h3 id="heading-cluster-administration">Cluster Administration :</h3>
<h3 id="heading-rbac-role-based-acess-control">RBAC( Role based Acess control):</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749071223409/334cbe9c-171f-409b-a089-6099cedf8b37.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749071509438/8a891b4b-9634-4515-a4b4-357c26a640af.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>ae aapka ghar , aap ek ghar mey ho bolnekey liye aapka , lekin papa mummy ka haq hotha hey aap vaha key naukar b hothey hey - aapkey gharmey ek role hotha hey right ,</p>
</li>
<li><p>like kya kya cheeze karne wale - 1. breadearner , 2. house wife</p>
</li>
<li><p>lets say aek role hey mai sabji lekey aaney wala → hamare pass ek user hey shubham ab is shubham ko ae role dedetha hun sabji lekey aana , ae user <code>shubham</code> ae aur ae role ek dusre sey kaisa bath karthey → through <code>role binding</code></p>
</li>
<li><p>jab b aap rbac padthey ho ithna samjo kubernates key resources hothey hey uskey access aapka hey yah nahi uskey liye ek role bantha hey</p>
</li>
<li><p>home = k8s cluster - us cluster key andar kya kya kar sakthey hey kya kya nai kar sakthey hey us cheez ko rbac bola jatha hey</p>
</li>
<li><p>rbac padney key liye do cheeze padni padthi hey</p>
<ol>
<li><p>service account : service account aapka aek temporary user jaisa hi rehtha hey, us service account mey as a user kya karthey hey lets say mai as a user ek anager hun ek manager name ka ek service account ho saktha hey - treated as a user only</p>
<ul>
<li><p>ae namespace level pey b ho saktha hey</p>
</li>
<li><p>namespace level pey hotah hey role - kya deployment ko get , update , delete kar saktah hun - us service account ko is role ko denekey liye role binding</p>
</li>
<li><p>usi prakar cluser level pey role ni hothey us level pey hothey hey cluster role - us cluster role ko bind karnekey liye cluster role binding hotah hey</p>
</li>
</ul>
</li>
<li><p>user : user aapka pura cluster level pey hothey hey - pure key pure cluster level pey</p>
</li>
</ol>
</li>
<li><p>toh jab aap rbac padthey hey ek simple basha mey matlab hotah ehy aapka user or service account ko kithna access dey sakthey ho dena chahthey ho , kithna uska access ko controll kar sakthey hey</p>
</li>
</ul>
<p>2 level pey kar sakthey hey - yah toh namespace level pey resources ko daldo or cluster level pey dal sakthey hey</p>
<ul>
<li><p>kubectl get nodes</p>
</li>
<li><p><code>cd apache → kubectl get ns → kubectl get pods -n apache → kubectl delete -f . →</code></p>
</li>
<li><p>jab b aap rbac samajthey ho <code>- kubectl auth whoami→</code> current user info we will get</p>
</li>
<li><p>kubectl auth can-i get pods</p>
</li>
<li><p>kubectl apply -f namespace.yml</p>
</li>
<li><p>kubectl auth can-i get pods -n apache # iam an admin so mai kisi b namespace mey ghuskey kuch b kar saktha hun</p>
</li>
<li><p>kabhi kabhi aapko alag alag apps banana padtha hey , aap nahi chavoge ki har ek user us application ko access kardo .</p>
</li>
<li><p>i dont want to give admin user to fresher what i he deltes the files so i will create a role</p>
</li>
<li><p>Create Roles and RoleBindings:</p>
<ul>
<li>Role for Managing Apache Deployment.<br />  <code>We'll create a role that allows managing Apache resources within the apache-namespace.</code></li>
</ul>
</li>
</ul>
<pre><code class="lang-bash"><span class="hljs-comment"># apache-role.yaml</span>
apiVersion: rbac.authorization.k8s.io/v1  <span class="hljs-comment"># ae group agar apiGroups mey * devige th sab access </span>
kind: Role
metadata:
  namespace: apache-namespace
  name: apache
rules:
- apiGroups: [<span class="hljs-string">""</span>, <span class="hljs-string">"apps"</span>, <span class="hljs-string">"extensions"</span>]
  resources: [<span class="hljs-string">"deployments"</span>, <span class="hljs-string">"services"</span>, <span class="hljs-string">"pods"</span>]
  verbs: [<span class="hljs-string">"get"</span>, <span class="hljs-string">"apply"</span>,<span class="hljs-string">"list"</span>, <span class="hljs-string">"watch"</span>, <span class="hljs-string">"create"</span>, <span class="hljs-string">"update"</span>, <span class="hljs-string">"patch"</span>, <span class="hljs-string">"delete"</span>]
</code></pre>
<p>kubectl apply —f role.yml</p>
<p>kubectl get role -n apache # is role ko agar mujhey kisiko bind karna hoga toh mai isko bind kardunga</p>
<p>but uskey pehley mujhey service account chahiye - &gt; vim service-account.yml</p>
<ul>
<li>Create Users (Optional):</li>
</ul>
<p><strong>If you are using a Kubernetes distribution that supports user management, you can create users and assign them the respective roles. Here, we'll use basic ServiceAccounts for simplicity.</strong></p>
<pre><code class="lang-bash"><span class="hljs-comment">#apache-serviceaccount.yaml</span>
apiVersion: v1
kind: ServiceAccount
metadata:
  name: apache-user
  namespace: apache
</code></pre>
<ul>
<li><p><code>kubectl apply -f service-account.yml</code></p>
</li>
<li><p><code>kubectl get serviceaccount -n apache</code> # kya mera apache user kya mera deployment ko get kar saktha hey</p>
</li>
<li><p><code>kubectl auth can-i get pods -n apache —as=apache-user</code> # agar mai as a apache-user mai get kar saktha hun kya</p>
</li>
<li><p>just ab thak ek serviceaccount user create hua , aur role create hua but role binding nahi hua</p>
</li>
<li><p>RoleBinding for Apache Manager We'll bind the role to a user or service account.</p>
</li>
</ul>
<pre><code class="lang-bash"><span class="hljs-comment"># apache-rolebinding.yaml</span>
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: apache-manager-binding
  namespace: apache
subjects:
- kind: User
  name: apache-user <span class="hljs-comment"># This should be replaced with the actual user name</span>
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: apache-manager
  apiGroup: rbac.authorization.k8s.io
</code></pre>
<p><code>kubectl apply -f role-binding.yml</code></p>
<p><code>kubectl get rolebinding -n apache</code></p>
<p><code>kubectl auth can-i get pods —as=apache-user</code> <code>-n apache</code></p>
<h2 id="heading-verify-roles-and-rolebinding"><strong>Verify Roles and RoleBinding</strong></h2>
<p><strong>To cross-verify the RBAC setup, you can perform a series of checks and actions to ensure that the roles and permissions are applied correctly. Here’s how you can do it:</strong></p>
<ul>
<li>Check Roles:</li>
</ul>
<pre><code class="lang-bash">kubectl get roles -n apache-namespace
</code></pre>
<p>Ensure apache-manager and nginx-manager roles are listed.</p>
<ul>
<li>Check RoleBindings:</li>
</ul>
<pre><code class="lang-bash">kubectl get rolebindings -n apache-namespace
</code></pre>
<p>Ensure apache-manager-binding and nginx-manager-binding role bindings are listed.</p>
<h3 id="heading-verify-serviceaccounts"><strong>Verify ServiceAccounts</strong></h3>
<ul>
<li>Check ServiceAccounts:</li>
</ul>
<pre><code class="lang-bash">kubectl get serviceaccounts -n apache-namespace
</code></pre>
<p>Ensure apache-user and nginx-user service accounts are listed.</p>
<h3 id="heading-test-access-using-impersonation"><strong>Test Access Using Impersonation</strong></h3>
<p>You can use the 'kubectl auth can-i' command to verify the permissions granted by the roles.</p>
<p><strong>Test Apache User Permissions:</strong></p>
<pre><code class="lang-bash">kubectl auth can-i create deployment -n apache-namespace --as=apache-user
kubectl auth can-i get pods --as=apache-user -n apache 
kubectl auth can-i delete service -n apache-namespace --as=apache-user
</code></pre>
<p># role base access control</p>
<p>jab aapko monitoring , logging us level key cheeze karni hothi hey thab aapko cluster role aur cluster role binding zaroori hothi hey</p>
<p>ab humlog dekhney valaey hey - rbac mey cluster level pey kaam kaisey hotha hey</p>
<ul>
<li><p>cluster level pey kaam karna hey vo kiun karna hey</p>
</li>
<li><p>lets say mai purey cluster key metrics , monitor , logs dekhrahun us level pey mujheko chahiye hotha hey</p>
</li>
<li><p>ki jo hamara rbac service ACCOUNT BANAREY UNKO NAMESPACE LEVEL THAK KA HI ACCESS chahiye</p>
</li>
<li><p>agar aek user cluster level pey bantha hey cluster role an binding use hothi hey kiunki pura cluster ka monitor , logging sab karna hotha hey</p>
</li>
<li><p>ek dir create karenge <strong>mkdir dadhboard</strong></p>
</li>
</ul>
<h2 id="heading-4-setting-up-the-kubernetes-dashboard"><strong>4. Setting Up the Kubernetes Dashboard</strong></h2>
<ul>
<li>Metrics server</li>
</ul>
<p>Deploy the Dashboard Apply the Kubernetes Dashboard manifest:</p>
<pre><code class="lang-bash">kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
</code></pre>
<ul>
<li><p>is ney ek namespace banaya service banaya , secret , role banaya , cluster role b banaya</p>
</li>
<li><p>cluster role already bangaya toh isliye humko user create karkey us role ko role bind karna hey</p>
</li>
</ul>
<p>Create an Admin User Create a dashboard-admin-user.yml file with the following content:</p>
<pre><code class="lang-bash">vim dashboard-admin-user.yml 

apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kubernetes-dashboard
</code></pre>
<p>Apply the configuration:</p>
<pre><code class="lang-bash">kubectl apply -f dashboard-admin-user.yml
</code></pre>
<ul>
<li><p>ab mai jo mera cluster rehtha hey na us chalaney key liye b mehnat padtah hey</p>
</li>
<li><p>Get the Access Token Retrieve the token for the admin-user:</p>
<pre><code class="lang-bash">  kubectl -n kubernetes-dashboard create token admin-user
</code></pre>
<p>  Copy the token for use in the Dashboard login.</p>
<p>  Access the Dashboard Start the Dashboard using kubectl proxy:</p>
<pre><code class="lang-bash">  kubectl proxy <span class="hljs-comment">#--port=8001 --address=0.0.0.0 --accept-hosts="*"</span>
</code></pre>
<p>  Open the Dashboard in your browser:</p>
<pre><code class="lang-bash">  http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
</code></pre>
<p>  Use the token from the previous step to log in.</p>
</li>
<li><p>you have dashboard - ab cd nginx → kubectl apply -f namespace.yml</p>
</li>
<li><ul>
<li><p>kubectl apply -f persistentvolume.yml</p>
<p>    * kubectl apply -f apply .</p>
<p>    * kubectl get all -n nginx —&gt; aap dashboard mey jakey namespace select karlo aap sab dikhega - ae dashboarrd sab metric server, monitoring and logging</p>
</li>
</ul>
</li>
</ul>
<p><strong>Custom resource definition:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749116155899/263f865d-fe5e-47a1-8de3-e2241423ac6a.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749116225164/e9010fbd-bd83-4feb-9e66-31b5ba4aed19.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>agar bath kare custom resource definition ki ki sabsey pehle samajna padtha hey resource kya hotha hey</p>
</li>
<li><p>toh jo k8s mey pods. services, deployment , services ae sab resources hothi hye</p>
</li>
<li><p>ae saare resources kubernates ko already pata hey ae servic e, namespace , ae kya hey is ka structure kya hey isko kaisa patha agar aapko aisey resources banana hey jo k8s mey nahi hey by default like custom resource</p>
</li>
<li><p>mai tws mey bohot saarey batches letha hun mai khudke liye mai saare batches ko store kar sakun.</p>
</li>
<li><p>jo pod ka structure aap khud key liye karna hey usliye custom resource definition use aathey hey</p>
</li>
</ul>
<p>jaisa kind: pod hey vaisa kind:DevOpsBatch -k8s ko ae kya resource karkey pod ka jo taml structure hey vahi structure mey mai hava mey create nahi kar saktah mujhey is spec resource ko define karna padtha hey</p>
<p>custom resource sturuction is a definition with that we can create our own resources</p>
<p>cd crd: vim devops-crd.yml</p>
<pre><code class="lang-bash">apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: devopsbatches.trainwithshubham.com
spec:
  group: trainwithshubham.com
  names: 
    plural: devopsbatches
    singular: devopsbatch
    kind: DevOpsBatch
    shortNames:
      - junoon
      - batches
      - tws
  scope: Namespaced
  versions:
  - name: v1
    served: <span class="hljs-literal">true</span>
    storage: <span class="hljs-literal">true</span>
    schema:
      openAPIV3Schema:
        <span class="hljs-built_in">type</span>: object
        properties:
          spec: 
            <span class="hljs-built_in">type</span>: object
            properties: 
              name:
                <span class="hljs-built_in">type</span>: string
                description: <span class="hljs-string">"This is the name of the DevOps Batch"</span>
              duration:
                <span class="hljs-built_in">type</span>: string
                description: <span class="hljs-string">"This is the duration of the DevOps Batch"</span>
              mode:
                <span class="hljs-built_in">type</span>: string
                description: <span class="hljs-string">"This is the mode of the batch eg. Live/Recorded"</span>
              platform:
                <span class="hljs-built_in">type</span>: string
                description: <span class="hljs-string">"This is the platform of the batch"</span>
</code></pre>
<ul>
<li><p>kubectl apply f crd.yml</p>
</li>
<li><p>kubectl get crd → is ka faida aap isko use karkey ek devops custom resource bana sakthey hey</p>
</li>
</ul>
<pre><code class="lang-bash">vim devops-cr1.yml

kind: DevOpsBatch
apiVersion: trainwithshubham.com/v1
metadata:
  name: junoon-batch-9
spec:
  name: DevOps-Zero To hero Junoon Batch 9
  duration: 3 months from 25th January 2025
  platform: trainwithshubham.com
  mode: Live as always
</code></pre>
<pre><code class="lang-bash">vi devops-cr2.yml

kind: DevOpsBatch
apiVersion: trainwithshubham.com/v1
metadata:
  name: junoon-batch-10
spec:
  name: DevOps-Zero To hero Junoon Batch 10
  duration: 3 months from 25th January 2025
  platform: trainwithshubham.com
  mode: Live as always
</code></pre>
<p>Operators: basically programming mey hothey hey like argocd , prometheuus operators , aur crd key resources ko programm kar sakthey hey</p>
<p><strong>Kubernates-api</strong> : we can access resources via <strong>kubernates</strong>-<strong>api</strong></p>
<ul>
<li>kopf -. python framework with the help of python code you can write</li>
</ul>
<p><strong>image scanning: we can do by using docker scout or trivy</strong></p>
<p><strong>secret-encryption</strong>: we have seen base64 encode and decode,</p>
<p>we cover network policies in cicd gitops , we will see eks in ci and cd , debugging and troubleshoot we have seen , resource utilization</p>
<p>kubectl top pod - resource utilization</p>
<p>kubectl top node</p>
<p><strong>Helm:</strong></p>
<ul>
<li><p>dosto ab thak itnney saari manifest files. overwhelming hojatha ithna manifest files likhna uska kind likhna , template likhna</p>
<ul>
<li><p>ek aisa tool hey jiskey vajhasey aap ae sab manifiest likhnesey muft hosakthey ,mey apt karkey package install karthey hey vaisaey hi aur har ek environmnet key liye laag sey manifest file banana nahi padegi sab kuch package rahega</p>
</li>
<li><p>ae tool ka name hey helm</p>
</li>
<li><p>helm aek package manager hey kubernates ka - ae package kya hey</p>
</li>
<li><p>like ubuntu mey apt key vajhasey aap koi packages install karthey hey aisey hi helm key through cheezon ko install karlethey ho using kubernates manifest file</p>
</li>
</ul>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749118169303/dafc7a1c-91d6-4d68-9e7d-223d26dfa6ff.png" alt class="image--center mx-auto" /></p>
</li>
</ul>
<p>toh helm jo hotah hey ek package manager for k8s, toh aapko for ex: toh bahut saarey manifest files banana padtha hey for nginx , mysql , notes-app ka</p>
<ul>
<li><p>us nginx key liye , aap deployment , service, ingress , hpa, configMap , sercret ae saarey cheeze har application key liye likhthey hey right</p>
</li>
<li><p>har cheez jab same hi honi hey kiun na hum ek package manager use karley aur vo package manager in sab cheezon ko install karega</p>
</li>
</ul>
<p><strong>Create one folder helm and helm key andar install karney wala hun helm charts - mkdir helm → cd helm</strong></p>
<p>lets say nginx mey sab resources .yml hey aapney khud banaya aur aehi cheez automated sey ek pacjage manager key sath banani hothi hey toh helm sey kar sakthey hey pehle isko install karna padtha hey</p>
<h3 id="heading-this-helm-chart-deploys-an-apache-http-server-on-a-kubernetes-cluster"><strong>This Helm chart deploys an Apache HTTP Server on a Kubernetes cluster.</strong></h3>
<h3 id="heading-prerequisites"><strong>Prerequisites</strong></h3>
<ul>
<li><p>Kubernetes cluster running (local, cloud, or KIND).</p>
</li>
<li><p>kubectl installed and configured.</p>
</li>
<li><p>Helm 3 installed. Install Helm with:</p>
</li>
</ul>
<pre><code class="lang-bash">curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

helm version  <span class="hljs-comment"># helm go mey likha hey</span>
</code></pre>
<h2 id="heading-chart-structure"><strong>Chart Structure</strong></h2>
<pre><code class="lang-bash">apache/
├── Chart.yaml         <span class="hljs-comment"># Chart metadata</span>
├── values.yaml        <span class="hljs-comment"># Default values for customization</span>
└── templates/         <span class="hljs-comment"># Kubernetes resource templates</span>
    ├── deployment.yaml
    └── service.yaml
</code></pre>
<ul>
<li><p>humlog ek helm chart banayanege</p>
<ul>
<li><p><code>helm create apache-helm</code> → mai ek chart banara hun</p>
</li>
<li><p>jiskey andar mai apache chalaunga</p>
</li>
<li><p>ls - cd apache-helm → ls hum ko milega chart.yaml , charts , templates , values.yml</p>
</li>
<li><p>tree</p>
</li>
<li><p>templates hey andar - sab resources .yml banadiya thats teh beauty of helm</p>
</li>
<li><p>manifest files likhna zaroori nahi → cd templates → vim deployment.yml - humko sirf values dalni hey bus</p>
</li>
<li><p>aap jo b change karna hey values mey jakey change karo idhar reflect hojayega</p>
</li>
<li><p>kuch b nahi likhna humko , helm ney banakey dega</p>
</li>
<li><p>un templates ko use karna hey values values.yml sey jathey hey</p>
</li>
<li><p>vim values.yml - isme jo b values hey vo udhar pey inject ho jathey hey</p>
</li>
<li><p>humko jo b chahiye vo values.yml mey dal sakthey hey</p>
</li>
<li><p><strong>vim chart.yml</strong> - ae kya hey -ae jo b hum chart banare lets say apache, nginx kuch b uska info idhar rehtha hey</p>
</li>
</ul>
</li>
<li><p>ab mujhey is chart ko package karna gey</p>
</li>
<li><p><strong>helm package .</strong> → is package ko mai export , import kuch b kar saktha hun → cd ..</p>
</li>
<li><p><strong>helm package apache-helm</strong></p>
</li>
<li><p>ab mujhey is chart ko install karna hey -</p>
</li>
<li><p>→ helm install mai aapney chart ko kya name dena chahtha hun like lets say nginx key jagah apache dena chahtha hun</p>
</li>
<li><p>ab mujhey iska dev , prod , stae environment banana hey</p>
</li>
<li><p>mai isko name dey saktha hun → helm install dev-apache apache-helm</p>
</li>
<li><p>default name space key andar apache mey running hey</p>
</li>
<li><p>→ <code>kubectl get deployment</code> → <code>kubectl get pods</code></p>
</li>
<li><p><code>helm uninstall dev-apache</code> → saare deployment hojathey hey</p>
</li>
<li><p>jab b aap koi helm chart install akrthey ho sathi sath mey namespace b dedo</p>
</li>
<li><p><code>helm install dev-apache apache-helm dev-apache —create-namespace</code></p>
</li>
<li><p>agar aap production key banare -<code>helm install prd-apache apache-helm prd-apache —create-namespace</code></p>
</li>
<li><p>mai vales.yml mey 3 replica daldunga ab mai prd upgrade karna chahtha hun</p>
</li>
<li><p>vim chart.yml - change version 1.16.1</p>
</li>
<li><p>helm package apache-helm</p>
</li>
<li><p>helm upgrade prd-apache ./apache-helm -n prd-apache</p>
</li>
<li><p>kubectl get pods -n dev-aapche</p>
</li>
<li><p>kubectl get pods -n prd-apache # so it is eady to maintain the multiple environments</p>
</li>
<li><p>ab question aatha hey mera revision number 1 jismey 3 ki jagah 2 hi hey , uspey roll back karna hey</p>
</li>
<li><p><code>helm rollback prd-apache 1 -n prd-apache</code></p>
</li>
<li><p><code>helm create node-js-app</code></p>
</li>
<li><p>cd node-js-app → vim chart.yml → vim templates/service.yml</p>
<ul>
<li><p>vim values.yml → mai kya kar saktey hey - trainwitshubham/notes-app image → tag: latest ; port:8000 targetPort: 8000 ;</p>
</li>
<li><p>helm package node-js-app</p>
</li>
<li><p>helm install dev-notes-js-app -n node-js-app dev-node —create-namespace</p>
<ul>
<li>dev-env name , chart name - node-js-app and namespace</li>
</ul>
</li>
<li><p>kubectl get pods -n dev-node</p>
</li>
<li><p>kubectl get svc -n dev-node</p>
</li>
<li><p>kubectl port-forward svc/dev-node-js-app 8000:8000 -n dev-node —address=0.0.0.0</p>
</li>
<li><p>within minutes you can run your microservices , you can instal anything and can run</p>
</li>
<li><p>help repo - google → chalo through helm argocd dekhenge</p>
</li>
</ul>
</li>
</ul>
<p><strong>ArgoCD: search in google argocd -select helm</strong></p>
<ul>
<li><p>humko repo add karna padtha hey isliye humko repo serahc karna hey</p>
</li>
<li><p>helm search repo nginx</p>
</li>
<li><p>helm search repo argocd</p>
</li>
<li><p>helm repo add stable <a target="_blank" href="https://charts.helm.sh/stable">https://charts.helm.sh/stable</a></p>
</li>
<li><p>ab aapkey system mey ae stable repo add kardethi hey</p>
</li>
<li><pre><code class="lang-bash">          helm install nginx-helm oci://registry-1.docker.io/bitnamicharts/nginx
</code></pre>
<p>  - helm uninstall nginx-helm</p>
</li>
<li><p>helm uninstall prd-apache -n prd-apache</p>
</li>
<li><p>lets say you are asked to install mongodb</p>
</li>
<li><pre><code class="lang-bash">          helm install mongodb-helm oci://registry-1.docker.io/bitnamicharts/mongodb -n mongo --create-namespace
</code></pre>
<p>  - kubectl get pods -n mongo # agar mai karunga - ek init container chalra hey - aapka mongo db container chalra hoga</p>
</li>
<li><p>kubectl exec -it mongodb-hel, -n mongo — bash → ls → monosh</p>
</li>
<li><p>aisey helm key through ham cheezon ko deploy kar sakthey hey</p>
</li>
<li><p><code>helm list -n mongo</code></p>
</li>
<li><p><code>helm uninstall mongodb-helm -n mongo</code></p>
</li>
</ul>
<p><strong>Side car containers vs Init containers - iska parent topic hey pod - generally hum pods create karthey hey , ismey containers chalathey hey usmey sey b init container hotha hey ek side car container hotha hey</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749151991397/6999a3a5-1856-41da-b2d9-f11877075375.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>diff kya hey → aisa samjo ki ek pod hey jo aap pod key liye manifest file banathey hey iska kind rehtha hey pod</p>
</li>
<li><p>bus uskey andar spec iskey andar containers rehthey hey ek main container rehtha hey jismey aapka application chalna chaiye , bakhi init and side car containers main container ko help karnekey liye rehtha hey</p>
</li>
<li><p>jaisey aap db banare , us db ko bananey key liye main container liya usmey image daldiya - is postegres ki jo main container bannesey pehley lets say koi onnections , path kuch b chahiye hoga - us cheez ko initialize karnekey liye ek init container lagtha hey</p>
</li>
<li><p><strong>init container</strong> jo main container chalnesey pehley jo cheeze chahiye vo init cont dey detha hey</p>
</li>
<li><p>pehle folder banega init container sey phir main container run hoyega</p>
</li>
</ul>
<p><strong>side car</strong> : jaisey batman , batmen pehley akeley ladtha tah ab kisi ka sath liye - ek simple single manifest file banegi iska kind pod ismey spec mey 2 containers rehthey hey - kuch logs copy , yah as aa helper main containers key sath help conatiner jaisa rethate hey</p>
<pre><code class="lang-bash">vim init.yml

kind: Pod
apiVersion: v1
metadata:
  name: init-test

spec:
  initContainers:
  - name: init-container
    image: busybox:latest
    <span class="hljs-built_in">command</span>: [<span class="hljs-string">"sh"</span>,<span class="hljs-string">"-c"</span>, <span class="hljs-string">"echo 'Initalization started ...'; sleep 10; echo 'Initization completed.'"</span>] 

  containers:
  - name: main-container
    image: busybox:latest
    <span class="hljs-built_in">command</span>: [<span class="hljs-string">"sh"</span>,<span class="hljs-string">"-c"</span>, <span class="hljs-string">"echo 'Main container started'"</span>]
</code></pre>
<ul>
<li><p>kubectl apply -f init.yml</p>
</li>
<li><p>kubectl logs init-test -c init-container -c main-container</p>
</li>
<li><p>kubectl logs init-test -c init container</p>
</li>
<li><p>kubectl get pods</p>
</li>
</ul>
<pre><code class="lang-bash">
kind: Pod
apiVersion: v1
metadata:
  name: sidecar-test

spec:

  volumes:
  - name: shared-logs
    emptyDir: {}

  containers:
  <span class="hljs-comment"># produce logs</span>
  - name: main-container
    image: busybox
    <span class="hljs-built_in">command</span>: [<span class="hljs-string">"sh"</span>,<span class="hljs-string">"-c"</span>, <span class="hljs-string">"while true; do echo 'Hello Dosto' &gt;&gt; /var/log/app.log; sleep 5; done"</span>]
    volumeMounts:
    - name: shared-logs
      mountPath:  /var/<span class="hljs-built_in">log</span>/

  <span class="hljs-comment"># display logs</span>
  - name: sidecar-container
    image: busybox
    <span class="hljs-built_in">command</span>: [<span class="hljs-string">"sh"</span>,<span class="hljs-string">"-c"</span>, <span class="hljs-string">"tail -f /var/log/app.log"</span>]
    volumeMounts:
    - name: shared-logs
      mountPath:  /var/<span class="hljs-built_in">log</span>/
</code></pre>
<ul>
<li><p>side by side help karna iska kaam hey</p>
</li>
<li><p>kubectl apply -f side-car.yml</p>
</li>
<li><p>kubectl get pods</p>
</li>
<li><p>kubectl logs side-car-test -c main-container</p>
</li>
<li><p>kubectl logs side-car-test -c sidecar-container</p>
</li>
<li><p>init cont - google k8s</p>
</li>
</ul>
<p><strong>service mesh :</strong></p>
<ul>
<li><p>service mesh , dekho service mesh - service na ek mess hi hothi hey yaha aek pod hey iski service chalri hogi</p>
</li>
<li><p>suppose ek three tier application hey like voting , result, worker iskey alag alag services and ports like 5000, 50001 ,</p>
</li>
</ul>
<p>aapkey pass zomato app hey - jismey ek service chalri hey menu , vaha sey dusri service jatha hun orders , aur events aisey bohot saarey services hey , delivery , hotel kaafi complex app der saari services chalri hogi ae saari services kaha sey jayegi isi cheez key aapko chahiye hotha hey ek <strong>gateway</strong></p>
<ul>
<li><p>us gateway key through saari services jayengi , pune mey hinzwadi mey bohot zyada traffic rehtha hey</p>
</li>
<li><p>ae traffic man controll karta hey kounsa traffic kidar redirect karna hey , is traffic ko redirect karnekey liye we need a tool called service mesh</p>
</li>
<li><p>service mesh ek gateway dey detha hey jissey aap services ko route , redirect kar sakthey hey basically complex service ko aap badiya ek dam distribute karsakthey ho jaisey ki har complexity simplyfy hogai</p>
</li>
<li><p>service mesh key liye ek popular tool hey istio , jo ki kaafi popular tool hey</p>
</li>
<li><p>go to ggole istio demo - lets install - clieck on instll - platform specific - &gt; search kind - clieck on kind-istio</p>
<ul>
<li>cd istio → cd istio-practice</li>
</ul>
</li>
</ul>
<h2 id="heading-download-istio"><strong>Download Istio</strong></h2>
<ol>
<li><p><strong>Go to the</strong> <a target="_blank" href="https://github.com/istio/istio/releases/tag/1.26.1"><strong>Istio release</strong></a> <strong>page to download the installation file for your OS, or</strong> <a target="_blank" href="https://istio.io/latest/docs/setup/additional-setup/download-istio-release/"><strong>download and extract the latest release automatically</strong></a> <strong>(Linux or macOS):</strong></p>
<pre><code class="lang-bash"> $ curl -L https://istio.io/downloadIstio | sh -
</code></pre>
</li>
<li><p><strong>Move to the Istio package directory. For example, if the package is</strong> <code>istio-1.26.1</code>:</p>
<pre><code class="lang-bash"> $ <span class="hljs-built_in">cd</span> istio-1.26.1
</code></pre>
<ul>
<li><p>cat readme.md</p>
</li>
<li><p>istio uses envoy which is a sidecar container /proxy which allows → vo aapkey jithney b services rehthi hey un sarey services key logs ko inject kartha hey</p>
</li>
<li><p>istiod ek control plane service discovery</p>
</li>
</ul>
</li>
<li><p><strong>The installation directory contains:</strong></p>
<ul>
<li><p><strong>Sample applications in</strong> <code>samples/</code></p>
</li>
<li><p>cd samples , cd .. , cd bin → ./istioctl</p>
</li>
<li><p><strong>The</strong> <a target="_blank" href="https://istio.io/latest/docs/reference/commands/istioctl/"><code>istioctl</code></a> client binary in the <code>bin/</code> directory.</p>
</li>
</ul>
</li>
<li><p><strong>Add the</strong> <code>istioctl</code> client to your path (Linux or macOS):</p>
<pre><code class="lang-bash"> $ <span class="hljs-built_in">export</span> PATH=<span class="hljs-variable">$PWD</span>/bin:<span class="hljs-variable">$PATH</span>
</code></pre>
<ul>
<li><p>jaisa kubectl key commands kuectl sey chalathey vaisa hi ./istioctl</p>
</li>
<li><p>cd bin → mv istioctl /usr/local/bin</p>
</li>
</ul>
</li>
<li><p>Install Istio using the <code>demo</code> profile, without any gateways:</p>
</li>
</ol>
<pre><code class="lang-bash">$ istioctl install -f samples/bookinfo/demo-profile-no-gateways.yaml -y
</code></pre>
<p>Add a namespace label to instruct Istio to automatically inject Envoy sidecar proxies when you deploy your application later:</p>
<pre><code class="lang-bash">$ kubectl label namespace default istio-injection=enabled
</code></pre>
<h2 id="heading-install-the-kubernetes-gateway-api-crds"><strong>Install the Kubernetes Gateway API CRDs</strong></h2>
<p>The Kubernetes Gateway API CRDs do not come installed by default on most Kubernetes clusters, so make sure they are installed before using the Gateway API.</p>
<ol>
<li><p><strong>Install the Gateway API CRDs, if they are not already present:</strong></p>
<pre><code class="lang-bash"> $ kubectl get crd gateways.gateway.networking.k8s.io &amp;&gt; /dev/null || \
 { kubectl kustomize <span class="hljs-string">"github.com/kubernetes-sigs/gateway-api/config/crd?ref=v1.3.0"</span> | kubectl apply -f -; }
</code></pre>
</li>
</ol>
<h2 id="heading-deploy-the-sample-application"><strong>Deploy the sample application</strong></h2>
<p>You have configured Istio to inject sidecar containers into any application you deploy in your <code>default</code> namespace.</p>
<ol>
<li><p><strong>Deploy the</strong> <a target="_blank" href="https://istio.io/latest/docs/examples/bookinfo/"><code>Bookinfo</code> sample application</a>:</p>
<pre><code class="lang-bash"> $ kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
</code></pre>
</li>
</ol>
<p>The application will start. As each pod becomes ready, the Istio sidecar will be deployed along with it.</p>
<pre><code class="lang-bash">$ kubectl get services
- kubectl port-forward svc/productpage 9080:9080 
agar merey pass 50 micro services kithno ka service manage and alag karun , url manage ahi sakthey isliye isio lagtha hey 

$ kubectl get pods
</code></pre>
<p>Validate that the app is running inside the cluster by checking for the page title in the response:</p>
<pre><code class="lang-bash">$ kubectl <span class="hljs-built_in">exec</span> <span class="hljs-string">"<span class="hljs-subst">$(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}')</span>"</span> -c ratings -- curl -sS productpage:9080/productpage | grep -o <span class="hljs-string">"&lt;title&gt;.*&lt;/title&gt;"</span>
</code></pre>
<h2 id="heading-open-the-application-to-outside-traffic"><strong>Open the application to outside traffic</strong></h2>
<p>The Bookinfo application is deployed, but not accessible from the outside. To make it accessible, you need to create an ingress gateway, which maps a path to a route at the edge of your mesh.</p>
<ol>
<li><p><strong>Create a</strong> <a target="_blank" href="https://gateway-api.sigs.k8s.io/api-types/gateway/"><strong>Kubernetes Gateway</strong></a> <strong>for the Bookinfo application:</strong></p>
<pre><code class="lang-bash"> $ kubectl apply -f samples/bookinfo/gateway-api/bookinfo-gateway.yaml
 gateway.gateway.networking.k8s.io/bookinfo-gateway created
 httproute.gateway.networking.k8s.io/bookinfo created
</code></pre>
<p> <strong>By default, Istio creates a</strong> <code>LoadBalancer</code> service for a gateway. As we will access this gateway by a tunnel, we don’t need a load balancer. If you want to learn about how load balancers are configured for external IP addresses, read the <a target="_blank" href="https://istio.io/latest/docs/tasks/traffic-management/ingress/ingress-control/">ingress gateways</a> documentation.</p>
</li>
<li><p><strong>Change the service type to</strong> <code>ClusterIP</code> by annotating the gateway:</p>
<pre><code class="lang-bash"> $ kubectl annotate gateway bookinfo-gateway networking.istio.io/service-type=ClusterIP --namespace=default
</code></pre>
</li>
<li><p><strong>To check the status of the gateway, run:</strong></p>
<pre><code class="lang-bash"> $ kubectl get gateway
 NAME               CLASS   ADDRESS                                            PROGRAMMED   AGE
 bookinfo-gateway   istio   bookinfo-gateway-istio.default.svc.cluster.local   True         42s
</code></pre>
</li>
</ol>
<h2 id="heading-access-the-application"><strong>Access the application</strong></h2>
<p>You will connect to the Bookinfo <code>productpage</code> service through the gateway you just provisioned. To access the gateway, you need to use the <code>kubectl port-forward</code> command:</p>
<pre><code class="lang-bash">8$ kubectl port-forward svc/bookinfo-gateway-istio 8080:80
</code></pre>
<h2 id="heading-view-the-dashboard"><strong>View the dashboard</strong></h2>
<p>Istio integrates with <a target="_blank" href="https://istio.io/latest/docs/ops/integrations/">several different telemetry applications</a>. These can help you gain an understanding of the structure of your service mesh, display the topology of the mesh, and analyze the health of your mesh.</p>
<p>Use the following instructions to deploy the <a target="_blank" href="https://istio.io/latest/docs/ops/integrations/kiali/">Kiali</a> dashboard, along with <a target="_blank" href="https://istio.io/latest/docs/ops/integrations/prometheus/">Prometheus</a>, <a target="_blank" href="https://istio.io/latest/docs/ops/integrations/grafana/">Grafana</a>, and <a target="_blank" href="https://istio.io/latest/docs/ops/integrations/jaeger/">Jaeger</a>.</p>
<ol>
<li><p><strong>Install</strong> <a target="_blank" href="https://github.com/istio/istio/tree/release-1.26/samples/addons"><strong>Kiali and the other addons</strong></a> <strong>and wait for them to be deployed.</strong></p>
<pre><code class="lang-bash"> $ kubectl apply -f samples/addons
 $ kubectl rollout status deployment/kiali -n istio-system
 Waiting <span class="hljs-keyword">for</span> deployment <span class="hljs-string">"kiali"</span> rollout to finish: 0 of 1 updated replicas are available...
 deployment <span class="hljs-string">"kiali"</span> successfully rolled out
</code></pre>
</li>
<li><p><strong>Access the Kiali dashboard.</strong></p>
<pre><code class="lang-bash"> $ istioctl dashboard kiali
</code></pre>
<p> for i in $(seq 1 100); do curl -s -o /dev/null "<a target="_blank" href="http://$GATEWAY_URL/productpage">http://localhost:8080/productpage</a>"; done</p>
<h2 id="heading-uninstall"><strong>Uninstall</strong></h2>
<p> To delete the <code>Bookinfo</code> sample application and its configuration, see <a target="_blank" href="https://istio.io/latest/docs/examples/bookinfo/#cleanup"><code>Bookinfo</code> cleanup</a>.</p>
<p> The Istio uninstall deletes the RBAC permissions and all resources hierarchically under the <code>istio-system</code> namespace. It is safe to ignore errors for non-existent resources because they may have been deleted hierarchically.</p>
<pre><code class="lang-bash"> $ kubectl delete -f samples/addons
 $ istioctl uninstall -y --purge
</code></pre>
<p> The <code>istio-system</code> namespace is not removed by default. If no longer needed, use the following command to remove it:</p>
<pre><code class="lang-bash"> $ kubectl delete namespace istio-system
</code></pre>
<p> The label to instruct Istio to automatically inject Envoy sidecar proxies is not removed by default. If no longer needed, use the following command to remove it:</p>
<pre><code class="lang-bash"> $ kubectl label namespace default istio-injection-
</code></pre>
<p> If you installed the Kubernetes Gateway API CRDs and would now like to remove them, run one of the following commands:</p>
<ul>
<li><p><strong>If you ran any tasks that required the experimental version of the CRDs:</strong></p>
<pre><code class="lang-bash">  $ kubectl kustomize <span class="hljs-string">"github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=v1.3.0"</span> | kubectl delete -f -
</code></pre>
</li>
<li><p><strong>Otherwise:</strong></p>
<pre><code class="lang-bash">  $ kubectl kustomize <span class="hljs-string">"github.com/kubernetes-sigs/gateway-api/config/cr</span>
</code></pre>
</li>
</ul>
</li>
</ol>
<h3 id="heading-projects">Projects:</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749189225559/5ab9326a-38d5-4285-be2f-e6fef8566ba0.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1749189291017/e1d2f557-4289-4421-b175-ed887eb29180.png" alt class="image--center mx-auto" /></p>
<p>projects jo hum resume mey add kar sake</p>
<ul>
<li><p>Chat application on kubernates -3 tier application - jaha pey front end react js and backend nodejs pey chalra and mongodb pey chalra</p>
</li>
<li><p>rule key muthabik - docker container aajayega - docker container sey bantha hey pod - iski deployment → is cheez ka service</p>
</li>
</ul>
<p>miniqube start —driver=docker</p>
<p>kubectl get pods</p>
<p>cd projects:</p>
<ul>
<li><p>shubham -full stack chat app → git clone <a target="_blank" href="https://github.com/LondheShubham153/full-stack_chatApp.git">https://github.com/LondheShubham153/full-stack_chatApp.git</a></p>
</li>
<li><p>login to dockerhub</p>
</li>
<li><p>cd backedn → docker build -t vaseem143/chatapp-backend:latest .</p>
</li>
<li><p>image tag and push the image</p>
</li>
<li><p>same with frontend also</p>
</li>
<li><p>now by using these two images and create the pod</p>
</li>
<li><p>create a namespace.yml</p>
<pre><code class="lang-bash">  apiVersion: v1
  kind: Namespace
  metadata:
    name: chat-app
</code></pre>
<ul>
<li>kubectl apply -f namespace.yml</li>
</ul>
</li>
<li><p>kubectl get ns</p>
</li>
<li><p>vi backend-deployment.yml</p>
<pre><code class="lang-bash">  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: backend-deployment
    namespace: chat-app
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: backend
    template:
      metadata:
        name: backend-pod
        namespace: chat-app
        labels: 
          app: backend
      spec:
        containers:
        - name: chatapp-backend
          image: trainwithshubham/chatapp-backend:latest
          ports:
          - containerPort: 5001
          env:
          - name: NODE_ENV
            value: production
          - name: MONGODB_URI
            value: <span class="hljs-string">"mongodb://mongoadmin:secret@mongodb:27017/dbname?authSource=admin"</span>
          - name: JWT_SECRET
            valueFrom:
              secretKeyRef:
                name: chatapp-secrets
                key: jwt 
          - name: PORT
            value: <span class="hljs-string">"5001"</span>
</code></pre>
<pre><code class="lang-bash">  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: frontend-deployment
    namespace: chat-app
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: frontend
    template:
      metadata:
        name: frontend-pod
        namespace: chat-app
        labels: 
          app: frontend
      spec:
        containers:
        - name: chatapp-frontend
          image: trainwithshubham/chatapp-frontend
          ports:
          - containerPort: 80
          env:
          - name: NODE_ENV
            value: production
</code></pre>
<pre><code class="lang-bash">  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: mongodb-deployment
    namespace: chat-app
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: mongodb
    template:
      metadata:
        name: mongodb-pod
        namespace: chat-app
        labels: 
          app: mongodb
      spec:
        containers:
        - name: chatapp-mongodb
          image: mongo:latest
          ports:
          - containerPort: 27017
          env:
          - name: MONGO_INITDB_ROOT_USERNAME
            value: mongoadmin
          - name: MONGO_INITDB_ROOT_PASSWORD
            value: secret
        volumes:
        - name: mongo-data
          persistentVolumeClaim:
            claimName: mongodb-pvc
</code></pre>
<pre><code class="lang-bash">  apiVersion: v1
  kind: PersistentVolume
  metadata:
    name: mongodb-pv
    namespace: chat-app
  spec:
    accessModes:
      - ReadWriteOnce
    capacity:
      storage: 5Gi
    hostPath:
      path: /data
</code></pre>
<pre><code class="lang-bash">  apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: mongodb-pvc
    namespace: chat-app
  spec:
    accessModes:
      - ReadWriteOnce
    resources:
      requests:
        storage: 5Gi
</code></pre>
<ul>
<li><p>kubectl apply -f pv.yml</p>
</li>
<li><p>kubectl get pv -n chat-app</p>
</li>
<li><p>kubectl apply -f pvc.yml</p>
</li>
<li><p>kubectl get pvc -n chat-app</p>
</li>
<li><p>kubectl apply -f mongodb-deployment.yml</p>
</li>
<li><p>kubectl get pods -n chat-app</p>
</li>
<li><p>kubectl apply -f frontend.yml</p>
</li>
<li><p>kubectl apply -f backend.yml</p>
</li>
</ul>
</li>
</ul>
<p>vi backend-service.yml</p>
<pre><code class="lang-bash">apiVersion: v1
kind: Service
metadata:
  name: backend
  namespace: chat-app
spec:
  selector:
    app: backend
  ports:
  - port: 5001
    targetPort: 5001
</code></pre>
<ul>
<li><p>kubectl apply -f backedn-service</p>
</li>
<li><p>kubectl apply -f frontend -service</p>
</li>
<li><p>kubectl apply - ffrontennd-deployment.yml</p>
</li>
<li><p>kubectl get pods -n chat-app</p>
</li>
</ul>
<pre><code class="lang-bash">apiVersion: v1
kind: Service
metadata:
  name: frontend
  namespace: chat-app
spec:
  selector:
    app: frontend
  ports:
  - port: 80
    targetPort: 80
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Jenkins in One shot .]]></title><description><![CDATA[Introduction to Jenkins & CI CD

Jenkins Setup On VM (AWS EC2)

Jenkins Installation

Jenkins UI/Dashboard / Jobs

Jenkins Freestyle Project

📍 Declarative Pipeline

Jenkins Agents (Multi-Node)

Declarative pipeline Demo

Shared Libraries

User Mana...]]></description><link>https://devopsblog1.hashnode.dev/jenkins-in-one-shot</link><guid isPermaLink="true">https://devopsblog1.hashnode.dev/jenkins-in-one-shot</guid><dc:creator><![CDATA[Vaseem Shaik]]></dc:creator><pubDate>Sat, 31 May 2025 18:43:00 GMT</pubDate><content:encoded><![CDATA[<ul>
<li><p>Introduction to Jenkins &amp; CI CD</p>
</li>
<li><p>Je<a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=432s">nkin</a>s Setup On VM (AWS EC2)</p>
</li>
<li><p>Jen<a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=840s">kins</a> Installation</p>
</li>
<li><p>Jenki<a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=1347s">ns UI</a>/Dashboard / Jobs</p>
</li>
<li><p>Jenkin<a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=1718s">s Fre</a>estyle Project</p>
</li>
<li><p>📍 Declara<a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=2170s">tive</a> Pipeline</p>
</li>
<li><p>Jenkins <a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=2550s">Agent</a>s (Multi-Node)</p>
</li>
<li><p>Declarati<a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=3440s">ve pi</a>peline Demo</p>
</li>
<li><p>Shared Lib<a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=6055s">raries</a></p>
</li>
<li><p>User Manage<a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=7238s">ment In</a> Jenkins (Role Based)</p>
</li>
<li><p>CI/CD Projec<a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=7698s">t with</a> Kubernetes, ArgoCD, Prometheus</p>
</li>
<li><p>Shared Librar<a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=14242s">y Realt</a>ime Usecase + Demo</p>
</li>
<li><p>DevSecOps with <a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=17348s">OWASP,</a> Trivy, Sonarqube</p>
</li>
<li><p>Email Notificati<a target="_blank" href="https://www.youtube.com/watch?v=XaSdKR2fOU4&amp;t=21309s">on on P</a>ipeline Fail/Pass</p>
<h1 id="heading-introduction-to-jenkins-amp-ci-cd">Introduction to Jenkins &amp; CI CD</h1>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748554913999/70c8af88-3511-40d1-a2ed-3977bab6c7a3.png" alt class="image--center mx-auto" /></p>
<p>Jenkins hotha kya hey , jenkins ko samajney key pehley aapko samajna padtha hey CI &amp; CD kya hotah hey</p>
<p>Dekho kaisa rehtha hey har ek org mey project hey - github aek tool hey project ko store kar sakthey hey scm key liye use hotha hey , ae code developer likhey dal detha hey github mey - ae docker pey build hotha hey aur k8s or ec2 mey deploy hotha hey - ek baar deploy hogaya usko monitor karthey hey prometheus sey</p>
<p>jab b developer code push karega phir sey build , test , deploy and monitor hoyega ae cheez continusly honi chahiye</p>
<ul>
<li><p>aek ek badh ek baar baar honi chahiye , lets sey aapka build fail hoayega toh aagey deploy nahi hoga monitoring mey b dikkat nahi aayegi</p>
</li>
<li><p>aapka build pass hua toh turanth aapko production thak paunchana hey - time to markey kamm karna hey - isko kamm kartha hey devops engineer—&gt; is puri process ko kam sey kam time mey paunchana</p>
</li>
<li><p>ae jo code , build , deploy , monitor is cheez ko automate kar skathey hey using jenkins</p>
</li>
<li><p>jenkins ka kaam hey in saare cheezon ko automate karna hey</p>
</li>
<li><p>agar devops ka logo dekhey aap toh code , build , test and deploy - as in infinity symbol - infinity process</p>
</li>
<li><p>Jenkins aek aisa tool hey jo aapko CI &amp; CD detha hey -→ continuos integration , and continuos deployment and delivery .</p>
<ul>
<li><p>CI : jaha pey test cases run hothey hey , checkout code , building the code , running the test cases .</p>
</li>
<li><p>CD: continuos delivery - amazon pey kuch order karthey ho vo delivery hothi hey manually aap order karthey hey right , that time you use continuos delivery .</p>
</li>
<li><p>kabhi kabhi instagram mey auto update hojatha hey - vo basically deployment - without manual intervension vo continuos deployment.</p>
</li>
</ul>
</li>
</ul>
<h1 id="heading-jenkins-setup-on-vm">Jenkins setup on Vm :</h1>
<ul>
<li><p>Jenkins is a GUI tool hey -→ go to aws -→ create and jenkins-master →select o.s and create a machine &amp; connect to the machine .</p>
</li>
<li><p>Go to google —&gt; install jenkins - select linux —&gt;</p>
</li>
<li><p>You wil get commands to run , copy and run the commands.</p>
</li>
<li><p>ae ek gui based tool , devloped by java - jo aapko ci and cd ko automate kar saktha hey</p>
</li>
<li><p>jenkins install karnesey pehley java install karna padega</p>
</li>
<li><p>sabsey pehle -→ sudo apt-get update -y</p>
</li>
<li><p>sudo apt-get install openjdk-17-jdk -y</p>
</li>
<li><p>to ensure java is there or not -→ java -version.</p>
</li>
<li><p>Now execute the commads to install jenkins from long-support.</p>
</li>
<li><p>sudo apt-get install jenkins</p>
</li>
<li><p>aapey system mey status dekhna jenkins ka -→ sudo systemctl status jenkins .</p>
</li>
<li><p>hum chahthey ho agar mera system restart ho jenkins b restart ho</p>
</li>
<li><p>#systemctl enable jenkins</p>
</li>
<li><ul>
<li>ab mera jenkins chalra hoga port number 8080 -→ enable the 8080 port number</li>
</ul>
</li>
<li><p>aapka jenkins aapkey samney hey - unlock jenkins - install suggested plugins</p>
</li>
<li><p>give username and password : admin and admin -→ ab ek admin user banya</p>
</li>
<li><p>Now jenkins is ready</p>
</li>
<li><p>Chalo jab 2018 mey mai pehlri baar dekha hey shock hoayatha - ae sab dashboard kya hey karkey</p>
</li>
<li><p>This is jenkins ka ui , ae ui browser pey chaltha hey</p>
</li>
<li><p>iskey andar aap - job banasakthey ho , agents , cloud configure kar sakthey ho</p>
</li>
<li><p><strong>Job</strong>: jenkins mey kuch b automate karana hey ci &amp; cd pipeline banani hey vo ek job , git configure vo ek job , scripting vo ek job , jenkins ka logo dekho vo ek buttler - vo wait karra hum ko order do hum vo kaam karthey hey</p>
</li>
</ul>
<p>jenkins mey hum log generally jobs hum log create karthey hey</p>
<ul>
<li><p>Create a job - item types - ab is item ka name → first job</p>
<ul>
<li><p>is job ka name dediye - is item ka types - ispey automate kar sakthey hey</p>
</li>
<li><p>pipeline mey declarative pipelines banana padtha hey</p>
</li>
<li><p>multi-configuration - aapko multiple environmnets mey like dev , test , prod mey karna hey</p>
</li>
<li><p>multi -branch - git mey bohot saarey branches rehthey hey us branch mey automation kara na hey</p>
</li>
<li><p>organization mey ek folder bana diya - us org folder key andar aap bohot saare job sbana saktehy hey</p>
</li>
</ul>
</li>
<li><p>ab hum free style click karney key badh - ek form khultha hey - aapko kya kaam kara na hey ismey configure kara na hey</p>
<ul>
<li><ul>
<li><p>job key builds rehthey hey - merey builds ko discards karna hey - like storage ko bacha sakthey hey</p>
<p>    * log rotation aisa hey aapley pass 10 days key builds hey usme aapko sirf 2 days key store karna hey aap log rotation use kar sakthey hey</p>
<p>    * github- project -→ idhar jo project karna hey git ka project url idhar dey sakthey hey</p>
<p>    * parameterized- koi parameters pass karreho</p>
<p>    * throtle builds: agar baar baar click karenge phir b ek build pe ruk jayega</p>
<p>    * concurrent build - agar aapko parallel mey chalana hey</p>
</li>
</ul>
</li>
<li><p>scm - github sey idhar project use kar sakthey hey</p>
</li>
<li><p>build triggers:</p>
<ul>
<li><p>is builds ko chalaney key liye scripts sey chalana hey builds remotely use karthey hey</p>
</li>
<li><p>ek job ko khatam honekey badh chalana chathey ho isko chala sathey jey - build after other jobs</p>
</li>
<li><p>build periodically - daily 6 baje aapka build chalna chathey ho</p>
</li>
<li><p>github hook - aap chahthey ho developer push kiya pipeline build chal jaye is option use kar sakthey hey</p>
</li>
</ul>
</li>
<li><p>Build environment:</p>
<ul>
<li>jismey secret use karna hey - idhar use kar sakthey hey</li>
</ul>
</li>
<li><p>build scripts:</p>
<ul>
<li><p>execute scripts :</p>
<ul>
<li><p>aapko ek command shell open hoyega - ismey jo b command dalege chal jayega</p>
</li>
<li><p>jo b idhar diya - vo chalayega .</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p>go to dashboard and click on build - continuos delivery manually click karrey</p>
</li>
</ul>
</li>
</ul>
<h1 id="heading-declarative-pipelines">Declarative pipelines:</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748588456641/1d5b759e-d914-4505-853a-7ed8664b9f25.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>aisa samajlo ae aapka tap hey - ae aapka garden hey ab is garden mey pani jana hey - aap pipe laga dogey - is garden mey pani jana hey aap sprinklen laga dogey</p>
<ul>
<li><p>aapko na ae pani shud hokey jana hey filter laga dogey</p>
</li>
<li><p>aek source sey ek destination mey jarey ho using piepeline - beechmey stages lagarey</p>
</li>
<li><p>jenkins b ci and cd pipelines banatha hey - stages key through pipeline bana key destination bana sakthey ho</p>
</li>
<li><p>go to dashboard click on new item - name demo-cicd —&gt; selct pipeline and click on ok and save.</p>
</li>
</ul>
</li>
<li><p>click on configure - pipeline script - try sample pipeline first → hello world - heloo name ki stage hey</p>
</li>
<li><p>Aap key pass multi -stage pipeline b ho sakthi hey - multiple stages</p>
<ul>
<li><p>output aapko stage by stage perform hotha hey</p>
</li>
<li><p>isko bolthey hey groovy syntax - isko build kardo</p>
</li>
<li><p>cd /var/lib/jenkins/workspace mey aapka job store kiye rehthey</p>
</li>
</ul>
</li>
</ul>
<h1 id="heading-agents">Agents :</h1>
<ul>
<li><p>idhar hum agent</p>
</li>
<li><p>any rakhey - industry mey master and nodes rehtha - jenkins master rehta hey - ae workload nodes mey distribute kartha hey</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748589293516/c0653dc6-059a-498c-ac0a-7034dd293ac1.png" alt class="image--center mx-auto" /></p>
</li>
</ul>
<ul>
<li><p>ae aapka jenkins ka master server rehtah hey - jenkins nodes ko kaam deyega aur yaah pey actually job run hoaga , jisseki jenkins mey memory issues na aaye jenkins safe rahey</p>
</li>
<li><p>build in node mastlab jaa pey jenkins hey vahi pey builds job chalrehongey usko bolthey built in nod e- it is not safety and industry standards so distribute the laod</p>
</li>
<li><p>go to aws create the three VM instance , mai idhar nodes agnets banara hun agent kya hotha hey → aap generally build in nodes m=pey jobs nahi chalathey - aap order dethey nodes ko , agents pey jobs chalthey hey</p>
</li>
<li><p>aap key agents mey java hona chahiye → connect to vm install the java</p>
</li>
<li><p>→ ae agent connect honge kaisey → toh jenkins ssh through connect karega -aap ek server sey dusre server ko connect kar sakthey hey throuh ssh -using public na private key</p>
</li>
<li><p>private stores itself and pulich should be there in agent</p>
</li>
<li><p>go to the master machine → cd ~/.ssh → ssh-keygen → ls → cat id → copy it and go to the agent → under the → cd ~/.ssh</p>
</li>
<li><p>go to the jenkins - dashbode - agents - click on new node → agent-vaseem → permanent agent - create it → no of executers - ek sath mey kithne jobs ek time pe chalan achathey hey - 1</p>
<ul>
<li><p>remote dir: /home/ubuntu</p>
</li>
<li><p>labels: label jo hotah hey isi sey saara kaam hotah hey pipeline mey ae label name agent any key replace akrney label name dalthey</p>
</li>
<li><p>use this node as much as possible - launch via ssh → host ip → copy ip address → credentials agent ki jo connect karnekey liye key - mai aapney master mey aunga - private key copy karlunag - add credentials - select ssh uername with privatekey → ubuntu-key → description → username: ubuntu → enter directly - paste it</p>
<p>  -→ Host-key stategy kardo non host</p>
</li>
<li><p>host -ip - click on agent - failed to connect →ssh authentication failed because agent mey public key nahi hai toh public key agent .ssh mey authorized keys mey add kardo .</p>
</li>
<li><p>ab agent mey jakey click on launcg agent - now it will successfully connected .</p>
</li>
</ul>
</li>
<li><p>ab pipeline mey jakey agent any key place mey { label: “vinod”}</p>
</li>
<li><p>vinod us agent ka label hey - usmey vahapey koi b folder nahi hey → agar mai pipeline run karunga toh udhar pey folder banna chahiye thab mai confirm kar saktha hun mera ci and cd process achesey chalra .</p>
</li>
</ul>
<h1 id="heading-declarative-pipeline">Declarative pipeline:</h1>
<p>click on new item → djanjoCICD</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748599141837/8f7bf83c-ab4b-450f-8654-e324599ef889.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>Description - this is ci and cd pipeline</p>
</li>
<li><p>github ki url dedunag → <a target="_blank" href="https://github.com/LondheShubham153/django-notes-app.git">https://github.com/LondheShubham153/django-notes-app.git</a></p>
</li>
<li><p>DisplayName: Django Notes App</p>
</li>
<li><p>hothub hook trigger for GITScm polling click</p>
</li>
<li><p>Advanced description , pipeline - ab pipeline likhna sikhanege</p>
</li>
</ul>
<pre><code class="lang-bash">@Library(<span class="hljs-string">'Shared'</span>)_
pipeline{
    agent { label <span class="hljs-string">'dev-server'</span>}

    stages{
        stage(<span class="hljs-string">"Code clone"</span>){
            steps{
                sh <span class="hljs-string">"whoami"</span>
            git url: <span class="hljs-string">"https://github.com/LondheShubham153/django-notes-app.git"</span>,branch:<span class="hljs-string">"main"</span>
            <span class="hljs-built_in">echo</span> <span class="hljs-string">" This is cloning the code"</span>
            }
        }
        stage(<span class="hljs-string">"Code Build"</span>){
            steps{
            <span class="hljs-built_in">echo</span> <span class="hljs-string">" Building the code"</span>
            sh <span class="hljs-string">"whoami"</span>
            sh <span class="hljs-string">"docker build -t notes-app:latest ."</span>
            }
        }

        stage(<span class="hljs-string">"Push to Docker Hub"</span>){
            steps{
                withCredentials([usernamePassword(credentialsId:<span class="hljs-string">"dockerHubCred"</span>,passwordVariable:<span class="hljs-string">"dockerHubPass"</span>,usernameVariable:<span class="hljs-string">"dockerHubUser"</span>)]){
                sh <span class="hljs-string">"docker tag notes-app:latest <span class="hljs-variable">${env.dockerHubUser}</span>/notes-app:latest"</span>
                sh <span class="hljs-string">"docker login -u <span class="hljs-variable">${env.dockerHubUser}</span> -p <span class="hljs-variable">${env.dockerHubPass}</span>"</span>
                sh <span class="hljs-string">"docker push <span class="hljs-variable">${env.dockerHubUser}</span>/notes-app:latest"</span>
                }
            }
        stage(<span class="hljs-string">"Deploy"</span>){
            steps{
                <span class="hljs-built_in">echo</span> <span class="hljs-string">"Deploying the code"</span>
                sh <span class="hljs-string">"docker run -d -p 8000:8000 notes-app:latest"</span>
            }
        }
            stage(<span class="hljs-string">"Deploy"</span>){
            steps{
                <span class="hljs-built_in">echo</span> <span class="hljs-string">"Deploying the code"</span>
                sh <span class="hljs-string">"docker compose up -d "</span>
            }
        }

    }
}
</code></pre>
<ul>
<li><p>pehle pipeline → phir ae pipeline aek agent mey chalna hey agent aur label likhdo - phir hamari pepeline stages pey chalengi toh stages likhdo</p>
</li>
<li><p>ab build kardo → mujhko aisa chahiye ki idhar pipeline dikhana hey iskey liye pluglins download karo</p>
</li>
<li><p>pipeline stage view - plugin usko kardo install</p>
</li>
<li><p>ab iskey andar actual masala dalna hey - code vali stage mey github ka code clone hojaye</p>
</li>
<li><p>ab build iskey liye docker chahiye - isko mai agent mey docker install kardunga → sudo usermod -aG docker ubuntu &amp;&amp; newgroup docker -→ docker ps</p>
</li>
<li><p>ab merey pass hey dockerfile docker file sey docker image banthi hey</p>
</li>
<li><p>echo “whoami” dekey user dekhlo → ubuntu ko permission dedo -→ agent mey sudo reboot karenge</p>
</li>
<li><p>mater mey jenkins ko restrat kardo -→ sudo systemctl restart jenkins - &gt; ab build hogi → ab run karengey → configure mey jakey</p>
</li>
<li><p>deploy ka configure karkey - build now kardo - now take your instance ip : and enable the port 8000 - now browse karo -→ ae application jenkins pipeline key sath deploy kiya - aur badiya kaisey kar sakthey hey</p>
</li>
<li><p>docker compose key through b deploy kar sakthey hey → docker compose - agent mey install kardo</p>
</li>
<li><p>docker run hum production mey run nahi karthey - docker compose up -d agar container hey toh kuch nahi kahega , agar container nahi hey create karega</p>
</li>
<li><p>aur kya acha kar sakthey hey - iskoa jo build image hey -isko dockerhub mey push kara sakthey hey -→ iskey liye docker login karna padtah hey iskey liye credentials chahiye rehtah hey</p>
</li>
<li><p>mujey deploy karnesey pehley aur ek stage aajayegi push to docker hub</p>
</li>
<li><p>docker image tag default image sey docker user name sey tag karey aur → docker login kare - merko credentials dalna hey isko mai expose nahi kartha toh variables banakey pipeline mey reffer karunga -→ credentials binding karna padtha hey - liek hide karkey kartha hun env variables mey</p>
</li>
<li><p>isko save karlo -→ dashboard mey jav → credentials mey javo - global credentials mey - username and password - docker mey ek token banalo personal access token → give full access</p>
</li>
<li><p>idhar credentials mey dalko → id aakey dockerHubCred→ description mey b → dockerHubCred ae id hey hey ismey andar mera username and password mey hey → ae cheez mai mrery pipeline mey use karunga</p>
</li>
<li><p>push to docker hub mey .</p>
<ul>
<li><p>ab mai mere docker hub mey images hey - abhi compose file build barey baar hora instead of that mera image lena</p>
</li>
<li><p>aur githubwebhook b dekhenge - aap chahthey ho github mey change hua automatic lena hey - vo karangey webhook - ek webhook trigger hojaye - github jenkins url ko hit karega agar kuch update hua toh thab jenkins lekey automatically run karega</p>
</li>
<li><p>jenkins ka url lelo jo b jenkins chalra hey →go to settings → repo settings - webhook → add webhook → payload url mey jenkins url /github-webhook/application/x select→ → no ssl - send me everything → add webhook</p>
</li>
<li><p>mera webhook configure kiye -jenkins mey githubwebhook hook trigger enable rakhna hey</p>
</li>
<li><p>mai docker compose mey image rakhunga instead of build. → this is called continous deployment.</p>
</li>
</ul>
</li>
</ul>
<h1 id="heading-shared-libraries">Shared Libraries:</h1>
<ul>
<li><p>aapne jo likha na stages, code , build , push to dockerhub → mujheko kalko aur piepline likhana hogi mujheko puri mehnat vapas likhunga</p>
<ul>
<li><p>mujhey kal ko kuch deploy karna ae mehnat phir sey likhunga</p>
</li>
<li><p>shared library kya hotha hey jenkins mey - ek repo rehthi hey - jiskey andar groovy ka code hotha hey us code ko aap reuse kar sakthey hey apni pipeline mey</p>
</li>
<li><p>Repo → groovy code → reuse(in pipeline)</p>
</li>
<li><p>ae jo pipeline iwth credentials aapko ae reuse karna hey - shared library create kardo</p>
</li>
<li><p>ek new repo create kardo - name rakho - jenkins-shared-libraries → ek small snippets reuse kar sakthey hey</p>
</li>
<li><p>usmey ek file add karni hye - ab shared libraries hothi hey vars - vars name ka folder banado</p>
</li>
<li><p>mai chahtha hun shared library file like heloo,groovy</p>
<pre><code class="lang-bash">  def <span class="hljs-function"><span class="hljs-title">call</span></span>(){
      <span class="hljs-built_in">echo</span> <span class="hljs-string">" HELOO DOSTO"</span>
  }

  <span class="hljs-built_in">clone</span>:

  def callString url , String branch {

         git url: <span class="hljs-string">"<span class="hljs-variable">${url}</span> , branch:"</span><span class="hljs-variable">${branch}</span><span class="hljs-string">"
              echo "</span> This is cloning the code<span class="hljs-string">"
              }

  def call(String ProjectName , String ImageTag , String DockerhubUser){

              sh "</span> docker build -t <span class="hljs-variable">${DockerHubUser/${ProjectName}</span>:<span class="hljs-variable">${ImageTag}</span> .<span class="hljs-string">"    

               {

  def call(String Project, String ImageTag, String dockerhubuser){
    withCredentials([usernamePassword(credentialsId: 'dockerhubCred', passwordVariable: 'dockerHubPass', usernameVariable: 'dockerHubUser')]) {
        sh "</span>docker login -u <span class="hljs-variable">${dockerHubUser}</span> -p <span class="hljs-variable">${dockerHubPass}</span><span class="hljs-string">"
    }
    sh "</span>docker push <span class="hljs-variable">${dockerHubUser}</span>/<span class="hljs-variable">${Project}</span>:<span class="hljs-variable">${ImageTag}</span><span class="hljs-string">"
  }</span>
</code></pre>
<ul>
<li><p>iskey andar mey ek function banaunga def jisko call karunga - parameter open parameter close</p>
</li>
<li><p>ab ae github sey merey jenkins mey kaisa paunchega - ab jenkins - manage jenkins - system — system wide reuse karna hey - niche - shared libraries - global trusted pipeline libraries - add library → name = Shared → default versin -branch la name aajayega → main</p>
</li>
<li><p>ab retrival method→ modern scm - git → repo url → save kardo</p>
</li>
<li><p>shared library ki repo hey jenkins mey add kiya - aap pipelines mey add nahi kiya</p>
</li>
<li><p>pipeline mey upar @Library(“Shared”) _ → mai ek stage(“Helo”) rakhunda mai heloo print nahi karunag call karunga → script key andar -&gt;hello()- ae pipeline logs mey print dekh sakthey hey - ae akaha sey lera shared libraries.</p>
</li>
<li><p>vars mey chalo - add file → clone.groovy</p>
<ul>
<li><p>ab pipeline mey clone stage mey</p>
</li>
<li><p>clone(“git url”, “main”)</p>
</li>
<li><p>docker-build ka groovy -→ add file →docker_build,groovy</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<pre><code class="lang-bash">        @Library(<span class="hljs-string">'Shared'</span>)_
        pipeline{
            agent { label <span class="hljs-string">'dev-server'</span>}

            stages{
                stage(<span class="hljs-string">"Code clone"</span>){
                    steps{
                        sh <span class="hljs-string">"whoami"</span>
                    git url: <span class="hljs-string">"https://github.com/LondheShubham153/django-notes-app.git"</span>,branch:<span class="hljs-string">"main"</span>
                    <span class="hljs-built_in">echo</span> <span class="hljs-string">" This is cloning the code"</span>
                    }
                }
                stage(<span class="hljs-string">"Code Build"</span>){
                    steps{
                    <span class="hljs-built_in">echo</span> <span class="hljs-string">" Building the code"</span>
                    sh <span class="hljs-string">"whoami"</span>
                    docker_build(<span class="hljs-string">"notes-app"</span>,<span class="hljs-string">"lates"</span>,<span class="hljs-string">"trainwithshubham"</span>)
                    }
                }

                stage(<span class="hljs-string">"Push to Docker Hub"</span>){
                    steps{
                        withCredentials([usernamePassword(credentialsId:<span class="hljs-string">"dockerHubCred"</span>,passwordVariable:<span class="hljs-string">"dockerHubPass"</span>,usernameVariable:<span class="hljs-string">"dockerHubUser"</span>)]){
                        sh <span class="hljs-string">"docker tag notes-app:latest <span class="hljs-variable">${env.dockerHubUser}</span>/notes-app:latest"</span>
                        sh <span class="hljs-string">"docker login -u <span class="hljs-variable">${env.dockerHubUser}</span> -p <span class="hljs-variable">${env.dockerHubPass}</span>"</span>
                        sh <span class="hljs-string">"docker push <span class="hljs-variable">${env.dockerHubUser}</span>/notes-app:latest"</span>
                        }
                    }
                stage(<span class="hljs-string">"Deploy"</span>){
                    steps{
                        <span class="hljs-built_in">echo</span> <span class="hljs-string">"Deploying the code"</span>
                        sh <span class="hljs-string">"docker run -d -p 8000:8000 notes-app:latest"</span>
                    }
                }
                    stage(<span class="hljs-string">"Deploy"</span>){
                    steps{
                        <span class="hljs-built_in">echo</span> <span class="hljs-string">"Deploying the code"</span>
                        sh <span class="hljs-string">"docker compose down &amp;&amp; docker compose up -d "</span>
                    }
                }
</code></pre>
<p>        aap barey baar jenkins mey change karneki jaruri ahi - aap Jenkinsfile likhdo → and jenkins mey pipeline form scm - select - give url and Jenkinsfile - just edit and change</p>
<ul>
<li><h1 id="heading-user-management-in-jenkins-role-based">User management in jenkins (Role based)</h1>
</li>
<li><ul>
<li><p>Production level mey na bohot saare users rehthey unko manage karna hotha hey .</p>
<p>    * * dashbode - manage jenkins → user ko add karna hey kaisa - user pery chalo - create karo - vaseem passwd: vaseem → DevOps wale - &gt; email</p>
<p>    * logout karkey login karkey - ae naya recruit hey - usko mainey sign in karadiya → bhai kal ka aaya hua ladka saara acess hey , usko jenkins manage karneka b access hey - ae toh gadbad hey na</p>
<p>    * role based authorixation chahiya - agar vaseem key pass admin permission hey thab hi ae saare cheeze kar saktha hey - agar read and write hey vahi kar saktha hey jo hey</p>
<p>    * jenkins → plugins → available - roll based - install it</p>
<p>    * * manage jenkins - security - role based - authorizations - logged in users can do anything - &gt; select role based strategy</p>
<p>    * new tool miljayega - manage and assign roles - roles to add - &gt; viewer → job - read , discover , view: read , metrics: view -→ save the role → assign role - make vaseem as viewer or authenticated_users</p>
<p>    * mera user role based access control hora hey - overall read kardo and refresh</p>
</li>
</ul>
</li>
</ul>
<h1 id="heading-cicd-project-three-tiwe-with-k8s-argocd-prometheus-devsecops-sonarqube-trivy-owasp-and-email-notification-on-pipeline-pass-fail">CI/CD project three tiwe with k8s , argocd , prometheus ,devsecops: sonarqube , trivy , owasp and email notification on pipeline pass/ fail.</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748635422441/20f6de68-4cac-458f-84a8-8119ad143ede.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>ek developer github mey puch kartah hey jenins mey pull kartha hey - us code ka ci and cd - ae devsecops key practices hotah hey jaha pey - dependency check kiy ajatha hey , code quality gate ko check kiay ajatha hey , image ko scan ho hotah hey aur docker hub pey =push kareneg - ae baar image push hogayi - phor vaha sey jenkins khud ek job trigger karega jo ki cd rahega continuos delivery vo cheez jabbi aapki code change hoga uska image ko change karkey github pey dalega , aur gitops sey argocd us code ko pull karega aur ek eks cluster pey deploy karaga , ek baar ae app deploy hojayi - us key badh us app ka monitoring logging sab cheezey hogi , agar aap ka app fail hojai email jayeg a sucess hua toh b email jayega</p>
</li>
<li><p>is application ka argocd - eks - monitoring - through gashboards we can check</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748640793060/2e3fee76-e863-4f79-9617-f96e6483ac88.png" alt class="image--center mx-auto" /></p>
<p>Ae sab cheeze karni hey</p>
<ul>
<li><p>go to github - wanderlast - sabsey pehle toh samajthey hey application kya ey - ae three tier application hey - ae frontend tier - react hey , backend hey nodejs- data base hey mongodb ka hey - database mey transactiona karange input output - isliye cacheing rehthi hey - &gt; agar aap server ko baar baar ek hi cheezonko aek cache mey store kardo - reddi sis the key value pair storage service that allows you to get document data whatever you want based on a key .</p>
</li>
<li><p>next hamey ek machine lagegi jissey sachi cheeze drive karegey - is master machine ec2 hogs jo ki kuch security groups , iams , security groups key sath configured hoga - kaisa banayenge - ek tarika hey terraform ec2.tf - ae jo terrafrom ka instance banega or ispey jenkins chalana hey node chahiye toh node baankey run karo yah - isi pey run karo → t2.medium - &gt; ismey trivy , docke r, jenkins , sonar , owasp sab rahega</p>
</li>
<li><p>ek baar master hogaya jenkins ko configure karna hey devsecops key liye -ismey trivy , docke r, jenkins , sonar , owasp sab rahega</p>
</li>
<li><p>phir hum log set-up karenge eks -cluster →is cluster ko particular region sertup karenge</p>
</li>
<li><p>isi cluster mey hamey argocd setup karna hey jo argocd isi cluster ko update karega - jo b yaml files kubernates per deploy hojaye isliye argocd use karthey hey</p>
</li>
</ul>
<p>Argocd: argo cd ek continuos delivery tool hey specially k8s key liye design kiya gaya hey , jaha pey kubernates key services jo b hey sync and deploy kar saktheyey - jihney apps chahiye uthna apps bana sakthey ho - app settings mey jakey aapkey repo sey connect kar sakthey hey directly manifest file aayengi aur deployment karegi</p>
<ol start="6">
<li><p>monitoring - yaha hey hum helm use karenge - kithne logon ko patha hey helm kya hotha hey - aapkey jo kubernates manifest file hothi hey - uskey package ko manage kartah ehy</p>
<ul>
<li><p>us package manager through hum monitor and grafana prometeus dono single click install single click deploy karne valae hey</p>
</li>
<li><p>clone the project in the vm - with the help of terraform create a master vm</p>
<ul>
<li><p>aws - iam - create one user aur - terraform - and i will make it admin acess and i will create access and secret keys and i will configure aws configure</p>
</li>
<li><p>create ssh-keygen → tera-key → teraform plan</p>
<p>  ec2.tf</p>
<pre><code class="lang-bash">  resource <span class="hljs-string">"aws_key_pair"</span> <span class="hljs-string">"deployer"</span> {
    key_name   = <span class="hljs-string">"terra-automate-key"</span>
    public_key = file(<span class="hljs-string">"/Users/shubham/Documents/work/TrainWithShubham/terra-practice/terra-key.pub"</span>)
  }

  resource <span class="hljs-string">"aws_default_vpc"</span> <span class="hljs-string">"default"</span> {

  }

  resource <span class="hljs-string">"aws_security_group"</span> <span class="hljs-string">"allow_user_to_connect"</span> {
    name        = <span class="hljs-string">"allow TLS"</span>
    description = <span class="hljs-string">"Allow user to connect"</span>
    vpc_id      = aws_default_vpc.default.id
    ingress {
      description = <span class="hljs-string">"port 22 allow"</span>
      from_port   = 22
      to_port     = 22
      protocol    = <span class="hljs-string">"tcp"</span>
      cidr_blocks = [<span class="hljs-string">"0.0.0.0/0"</span>]
    }

    egress {
      description = <span class="hljs-string">" allow all outgoing traffic "</span>
      from_port   = 0
      to_port     = 0
      protocol    = <span class="hljs-string">"-1"</span>
      cidr_blocks = [<span class="hljs-string">"0.0.0.0/0"</span>]
    }

    ingress {
      description = <span class="hljs-string">"port 80 allow"</span>
      from_port   = 80
      to_port     = 80
      protocol    = <span class="hljs-string">"tcp"</span>
      cidr_blocks = [<span class="hljs-string">"0.0.0.0/0"</span>]
    }

    ingress {
      description = <span class="hljs-string">"port 443 allow"</span>
      from_port   = 443
      to_port     = 443
      protocol    = <span class="hljs-string">"tcp"</span>
      cidr_blocks = [<span class="hljs-string">"0.0.0.0/0"</span>]
    }

    tags = {
      Name = <span class="hljs-string">"mysecurity"</span>
    }
  }

  resource <span class="hljs-string">"aws_instance"</span> <span class="hljs-string">"testinstance"</span> {
    ami             = var.ami_id
    instance_type   = var.instance_type
    key_name        = aws_key_pair.deployer.key_name
    security_groups = [aws_security_group.allow_user_to_connect.name]
    tags = {
      Name = <span class="hljs-string">"Automate"</span>
    }
    root_block_device {
      volume_size = 30 
      volume_type = <span class="hljs-string">"gp3"</span>
    }
  }
</code></pre>
<p>  terraform.tf</p>
</li>
</ul>
</li>
<li><pre><code class="lang-bash">    terraform {
      required_providers {
        aws = {
          <span class="hljs-built_in">source</span>  = <span class="hljs-string">"hashicorp/aws"</span>
          version = <span class="hljs-string">"5.65.0"</span>
        }
      }
    }

    provider <span class="hljs-string">"aws"</span> {
      region = var.aws_region
    }
</code></pre>
<p>  variable.tf</p>
</li>
</ul>
</li>
</ol>
<pre><code class="lang-bash">    variable <span class="hljs-string">"aws_region"</span> {
      description = <span class="hljs-string">"AWS region where resources will be provisioned"</span>
      default     = <span class="hljs-string">"us-east-2"</span>
    }

    variable <span class="hljs-string">"ami_id"</span> {
      description = <span class="hljs-string">"AMI ID for the EC2 instance"</span>
      default     = <span class="hljs-string">"ami-085f9c64a9b75eed5"</span>
    }

    variable <span class="hljs-string">"instance_type"</span> {
      description = <span class="hljs-string">"Instance type for the EC2 instance"</span>
      default     = <span class="hljs-string">"t2.large"</span>
    }
</code></pre>
<p>    vim ec2.tf - change the keyfile location - iam making a master machine</p>
<ul>
<li><p>You can do from terraform or also manually</p>
</li>
<li><p>terraform init</p>
</li>
<li><p>terraform plan → once its created - connect to the instance.</p>
</li>
<li><p>ae master machine mey kya kya cheeze karna hey</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748680794765/9abbd08f-ab7f-4c09-a099-8b06f553fd71.png" alt class="image--center mx-auto" /></p>
</li>
</ul>
<ul>
<li><p>sudo apt-get update -y</p>
<ul>
<li><p>One by one i should setup now</p>
</li>
<li><p>sudo apt-get install docker.io docker-compose up -d</p>
</li>
<li><p>sudo chmod 777 /var/run/docker.sock - alternate - sudo usermod -aG docker ubuntu &amp;&amp; newgrp docker - refresh the group</p>
</li>
</ul>
</li>
</ul>
<h1 id="heading-wanderlust-mega-project-end-to-end-implementation"><strong>Wanderlust Mega Project End to End Implementation</strong></h1>
<h3 id="heading-in-this-demo-we-will-see-how-to-deploy-an-end-to-end-three-tier-mern-stack-application-on-eks-cluster"><strong>In this demo, we will see how to deploy an end to end three tier MERN stack application on EKS cluster.</strong></h3>
<h3 id="heading-project-deployment-flow"><strong><mark>Project Deployment Flow:</mark></strong></h3>
<p><a target="_blank" href="https://github.com/DevMadhup/Wanderlust-Mega-Project/blob/main/Assets/DevSecOps%2BGitOps.gif"><img src="https://github.com/DevMadhup/Wanderlust-Mega-Project/raw/main/Assets/DevSecOps%2BGitOps.gif" alt /></a></p>
<h2 id="heading-tech-stack-used-in-this-project"><strong>Tech stack used in this project:</strong></h2>
<ul>
<li><p>GitHub (Code)</p>
</li>
<li><p>Docker (Containerization)</p>
</li>
<li><p>Jenkins (CI)</p>
</li>
<li><p>OWASP (Dependency check)</p>
</li>
<li><p>SonarQube (Quality)</p>
</li>
<li><p>Trivy (Filesystem Scan)</p>
</li>
<li><p>ArgoCD (CD)</p>
</li>
<li><p>Redis (Caching)</p>
</li>
<li><p>AWS EKS (Kubernetes)</p>
</li>
<li><p>Helm (Monitoring using grafana and prometheus)</p>
</li>
</ul>
<h3 id="heading-how-pipeline-will-look-after-deployment"><strong>How pipeline will look after deployment:</strong></h3>
<ul>
<li><p><strong>CI pipeline to build and push</strong></p>
</li>
<li><p><strong>CD pipeline to update application version</strong></p>
</li>
<li><p><strong>ArgoCD application for deployment on EKS</strong></p>
</li>
</ul>
<p><strong>Important</strong></p>
<p>Below table helps you to navigate to the particular tool installation section fast.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Tech stack</strong></td><td><strong>Installation</strong></td></tr>
</thead>
<tbody>
<tr>
<td>Jenkins Master</td><td><a target="_blank" href="https://github.com/LondheShubham153/Wanderlust-Mega-Project#Jenkins">Install and configure Jenkins</a></td></tr>
<tr>
<td>eksctl</td><td><a target="_blank" href="https://github.com/LondheShubham153/Wanderlust-Mega-Project#EKS">Install eksctl</a></td></tr>
<tr>
<td>Argocd</td><td><a target="_blank" href="https://github.com/LondheShubham153/Wanderlust-Mega-Project#Argo">Install and configure ArgoCD</a></td></tr>
<tr>
<td>Jenkins-Worker Setup</td><td><a target="_blank" href="https://github.com/LondheShubham153/Wanderlust-Mega-Project#Jenkins-worker">Install and configure Jenkins Worker Node</a></td></tr>
<tr>
<td>OWASP setup</td><td><a target="_blank" href="https://github.com/LondheShubham153/Wanderlust-Mega-Project#Owasp">Install and configure OWASP</a></td></tr>
<tr>
<td>SonarQube</td><td><a target="_blank" href="https://github.com/LondheShubham153/Wanderlust-Mega-Project#Sonar">Install and configure SonarQube</a></td></tr>
<tr>
<td>Email Notification Setup</td><td><a target="_blank" href="https://github.com/LondheShubham153/Wanderlust-Mega-Project#Mail">Email notification setup</a></td></tr>
<tr>
<td>Monitoring</td><td><a target="_blank" href="https://github.com/LondheShubham153/Wanderlust-Mega-Project#Monitor">Prometheus and grafana setup using helm charts</a></td></tr>
<tr>
<td>Clean Up</td><td><a target="_blank" href="https://github.com/LondheShubham153/Wanderlust-Mega-Project#Clean">Clean up</a></td></tr>
</tbody>
</table>
</div><h3 id="heading-pre-requisites-to-implement-this-project"><strong>Pre-requisites to implement this project:</strong></h3>
<p><strong>Note</strong></p>
<p>This project will be implemented on North California region (us-west-1).</p>
<ul>
<li><p><strong>Create 1 Master machine on AWS with 2CPU, 8GB of RAM (t2.large) and 29 GB of storage and install Docker on it.</strong></p>
</li>
<li><p><strong>Open the below ports in security group of master machine and also attach same security group to Jenkins worker node (We will create worker node shortly)</strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/361331879-4e5ecd37-fe2e-4e4b-a6ba-14c7b62715a3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzYxMzMxODc5LTRlNWVjZDM3LWZlMmUtNGU0Yi1hNmJhLTE0YzdiNjI3MTVhMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03M2JlZGI1YTNkNWE4ZTQyZmUyNGU5MDYxN2Q0MTI5NmFkNTY5OGQ1MDY2NWJlZjQ4YmMxYTRhY2JiNDA1ZmJhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.ZZf4J9KsU4SioAIQXZWuwlWsLyqZNscfEHS0d5PnKOY" alt="image" /></p>
</li>
</ul>
<p><strong>Note</strong></p>
<p>We are creating this master machine because we will configure Jenkins master, eksctl, EKS cluster creation from here.</p>
<p>Install &amp; Configure Docker by using below command, "NewGrp docker" will refresh the group config hence no need to restart the EC2 machine.</p>
<pre><code class="lang-bash">sudo apt-get update
</code></pre>
<pre><code class="lang-bash">sudo apt-get install docker.io -y
sudo usermod -aG docker ubuntu &amp;&amp; newgrp docker
</code></pre>
<ul>
<li><strong>Install and configure Jenkins (Master machine)</strong></li>
</ul>
<pre><code class="lang-bash">sudo apt update -y
sudo apt install fontconfig openjdk-17-jre -y

sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key

<span class="hljs-built_in">echo</span> <span class="hljs-string">"deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]"</span> \
  https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list &gt; /dev/null

sudo apt-get update -y
sudo apt-get install jenkins -y
</code></pre>
<ul>
<li><p><strong>Now, access Jenkins Master on the browser on port 8080 and configure it</strong>.</p>
</li>
<li><p>i will setup now jenkins - install suggested plugins - &gt; create a user - admin → passwd → vaseem akram &gt; email address</p>
</li>
<li><p>apney ko master machine sey cluster banani hey eks bananey ley liye iam user with access and secret key chahiye</p>
</li>
<li><p>ab secret key and access key ab mai yaha pey keys laganey key liya aws cli chahiye</p>
</li>
<li><p><strong>Create EKS Cluster on AWS (Master machine)</strong></p>
<ul>
<li><p>IAM user with <strong>access keys and secret access keys</strong></p>
</li>
<li><p>AWSCLI should be configured (<a target="_blank" href="https://github.com/DevMadhup/DevOps-Tools-Installations/blob/main/AWSCLI/AWSCLI.sh">Setup AWSCLI</a>)</p>
</li>
</ul>
</li>
</ul>
<pre><code class="lang-bash">    curl <span class="hljs-string">"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"</span> -o <span class="hljs-string">"awscliv2.zip"</span>
    sudo apt install unzip
    unzip awscliv2.zip
    sudo ./aws/install
    aws configure
</code></pre>
<ul>
<li><p>aws configure a karkey access key and secret key dedo</p>
</li>
<li><p>aws s3 ls</p>
</li>
<li><p>abhi mai eks ctl ko install karna start kardunga ekstctl key liye mujhey kubectl chahiye , kiunki eksctl ko manage kartha hey director kartha hey kubectl</p>
</li>
<li><p>Install <strong>kubectl</strong> (Master machine)(<a target="_blank" href="https://github.com/DevMadhup/DevOps-Tools-Installations/blob/main/Kubectl/Kubectl.sh">Setup kubectl</a> )</p>
</li>
</ul>
<pre><code class="lang-bash">    curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.19.6/2021-01-05/bin/linux/amd64/kubectl
    chmod +x ./kubectl
    sudo mv ./kubectl /usr/<span class="hljs-built_in">local</span>/bin
    kubectl version --short --client
</code></pre>
<ul>
<li><p>kubectl got installed , simillarly humko eksctl b install kardenege</p>
</li>
<li><p>Install <strong>eksctl</strong> (Master machine) (<a target="_blank" href="https://github.com/DevMadhup/DevOps-Tools-Installations/blob/main/eksctl%20/eksctl.sh">Setup eksctl</a>)</p>
</li>
</ul>
<pre><code class="lang-bash">    curl --silent --location <span class="hljs-string">"https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_<span class="hljs-subst">$(uname -s)</span>_amd64.tar.gz"</span> | tar xz -C /tmp
    sudo mv /tmp/eksctl /usr/<span class="hljs-built_in">local</span>/bin
    eksctl version
</code></pre>
<ul>
<li><p>ab mai eks banaunga apney master machine mey</p>
</li>
<li><p>ussey pehley cloud formation ka us name sey kuch hey kya karkey check karni hey</p>
</li>
</ul>
<ul>
<li><strong>Create EKS Cluster (Master machine)</strong></li>
</ul>
<pre><code class="lang-bash">    eksctl create cluster --name=wanderlust \
                        --region=us-east-2 \
                        --version=1.30 \
                        --without-nodegroup
</code></pre>
<ul>
<li>ae 20 min time liyega jab thak jenkins mey configure mey karenge</li>
</ul>
<h1 id="heading-setting-up-jenkins-worker-node"><strong>Setting up jenkins worker node</strong></h1>
<ul>
<li>Create a new EC2 instance (Jenkins Worker) with 2CPU, 8GB of RAM (t2.large) and 29 GB of storage and install java on it</li>
</ul>
<pre><code class="lang-bash">    sudo apt update -y
    sudo apt install fontconfig openjdk-17-jre -y
</code></pre>
<ul>
<li><p>Create an IAM role with <mark>administrator access</mark> attach it to the jenkins worker node <mark>Select Jenkins worker node EC2 instance --&gt; Actions --&gt; Security --&gt; Modify IAM role</mark></p>
</li>
<li><p>Configure AWSCLI (<a target="_blank" href="https://github.com/DevMadhup/DevOps-Tools-Installations/blob/main/AWSCLI/AWSCLI.sh">Setup AWSCLI</a>)</p>
</li>
</ul>
<pre><code class="lang-bash">    sudo su
</code></pre>
<pre><code class="lang-bash">    curl <span class="hljs-string">"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"</span> -o <span class="hljs-string">"awscliv2.zip"</span>
    sudo apt install unzip
    unzip awscliv2.zip
    sudo ./aws/install
    aws configure
</code></pre>
<ul>
<li><strong>generate ssh keys (Master machine) to setup jenkins master-slave</strong></li>
</ul>
<pre><code class="lang-bash">ssh-keygen
</code></pre>
<p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/357394805-0c8ecb74-1bc5-46f9-ad55-1e22e8092198.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU3Mzk0ODA1LTBjOGVjYjc0LTFiYzUtNDZmOS1hZDU1LTFlMjJlODA5MjE5OC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yZDg4MzZlMDkwNTA5OWQzZDA0NzFlYTQ0NTY0NzZlODJkMmI0Yzc1MzU2MTllYzQxMzUxZWI1NjI1Mjc4MTRkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.HIU0bwMhyOsodjS1ZoS5laqlu46D0LEKZ3RVaCenD1A"><img src="https://private-user-images.githubusercontent.com/121779953/357394805-0c8ecb74-1bc5-46f9-ad55-1e22e8092198.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU3Mzk0ODA1LTBjOGVjYjc0LTFiYzUtNDZmOS1hZDU1LTFlMjJlODA5MjE5OC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yZDg4MzZlMDkwNTA5OWQzZDA0NzFlYTQ0NTY0NzZlODJkMmI0Yzc1MzU2MTllYzQxMzUxZWI1NjI1Mjc4MTRkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.HIU0bwMhyOsodjS1ZoS5laqlu46D0LEKZ3RVaCenD1A" alt="image" /></a></p>
<ul>
<li><strong>Now move to directory where your ssh keys are generated and copy the content of public key and paste to authorized_keys file of the Jenkins worker node.</strong></li>
</ul>
<ul>
<li><p><strong>Now, go to the jenkins master and navigate to <mark>Manage jenkins --&gt; Nodes</mark>, and click on Add node</strong></p>
<ul>
<li><p><strong>name:</strong> Node</p>
</li>
<li><p><strong>type:</strong> permanent agent</p>
</li>
<li><p><strong>Number of executors:</strong> 2</p>
</li>
<li><p>Remote root directory</p>
</li>
<li><p><strong>Labels:</strong> Node</p>
</li>
<li><p><strong>Usage:</strong> Only build jobs with label expressions matching this node</p>
</li>
<li><p><strong>Launch method:</strong> Via ssh</p>
</li>
<li><p><strong>Host:</strong> &lt;public-ip-worker-jenkins&gt;</p>
</li>
<li><p><strong>Credentials:</strong> <mark>Add --&gt; Kind: ssh username with private key --&gt; ID: Worker --&gt; Description: Worker --&gt; Username: root --&gt; Private key: Enter directly --&gt; Add Private key</mark></p>
</li>
<li><p><strong>Host Key Verification Strategy:</strong> Non verifying Verification Strategy</p>
</li>
<li><p><strong>Availability:</strong> Keep this agent online as much as possible</p>
</li>
</ul>
</li>
<li><p>And your jenkins worker node is added</p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/357403596-cab93696-a4e2-4501-b164-8287d7077eef.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU3NDAzNTk2LWNhYjkzNjk2LWE0ZTItNDUwMS1iMTY0LTgyODdkNzA3N2VlZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kNmRhZmMxZTQ3YjFiMWEwZjc2OTQ1MDBjZmZmZDNmZmUxOTRiNzYzMThhNTZmZGUwZGY5MTI3ZDFkYTg5Y2YyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.9U0xQPwv681N4KVG9dGFcY5PsRhAQ1w-TjgUEPehUgI" alt="image" /></p>
</li>
<li><p><strong>Install docker (Jenkins Worker)</strong></p>
</li>
</ul>
<pre><code class="lang-bash">sudo apt install docker.io -y
sudo usermod -aG docker ubuntu &amp;&amp; newgrp docker
</code></pre>
<ul>
<li><p><strong>Install and configure SonarQube (Master machine)</strong></p>
</li>
<li><p>hum sonarqube install karenge</p>
</li>
</ul>
<pre><code class="lang-bash">docker run -itd --name SonarQube-Server -p 9000:9000 sonarqube:lts-community
</code></pre>
<ul>
<li><p>trivy install karlenge abb - toh issey aapki file system scan karlenge</p>
</li>
<li><p>user , password dedeo - default admin , admin hoga</p>
</li>
<li><p>abhi cluster create nahi hua jab thak email ka configure karenge - jenkins mey</p>
</li>
</ul>
<ul>
<li><strong>Install Trivy (Jenkins Worker)</strong></li>
</ul>
<pre><code class="lang-bash">sudo apt-get install wget apt-transport-https gnupg lsb-release -y
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
<span class="hljs-built_in">echo</span> deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update -y
sudo apt-get install trivy -y
</code></pre>
<h2 id="heading-steps-to-add-email-notification"><strong>Steps to add email notification</strong></h2>
<ul>
<li><p>→ jaisey gmail open karliya - usmey manage google account - go to security - and make sure 2 step verification is on or not - make it on</p>
<ul>
<li><p>and search app - &gt; app password - agar aapko gmail as a an application chalana hey → mujhey yaha pey ek app banana hey → jenkins - create - you will get one password - store it somewhere → now go to jenkins → manage jenkins → credentials - &gt; gmail ka app password tha idhar dena iskey vajhasey hum gmail bhej sakthey hey → username : aap ka email , password: app-password - desrcip: gmail-password</p>
</li>
<li><p>system → email -notification - extended email notification - idhar smt ka email likhna -=&gt; smtp.gmail.com -→ port generally 25 agar app per chalana hey 465 use akrna —&gt; add password -→ select ssl</p>
</li>
</ul>
</li>
</ul>
<ul>
<li><p>aur ab → last mey email notofication test - smtp.gmail.com → default user - advance - use authenticate → dqvaseem@gmail.com , password - and 465 → test configuration →kisi aur ka email dedo</p>
</li>
<li><p>ab clusters chalu hogey toh nodes add kardenge</p>
</li>
</ul>
<ul>
<li><p><strong>Go to your Jenkins Master EC2 instance and allow 465 port number for SMTPS</strong></p>
</li>
<li><p><strong>Now, we need to generate an application password from our gmail account to authenticate with jenkins</strong></p>
<ul>
<li><strong>Open gmail and go to <mark>Manage your Google Account --&gt; Security</mark></strong></li>
</ul>
</li>
</ul>
<p><strong>Important</strong></p>
<p>Make sure 2 step verification must be on</p>
<p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/358509211-5ab9dc9d-dcce-4f9d-9908-01095f1253cb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NTA5MjExLTVhYjlkYzlkLWRjY2UtNGY5ZC05OTA4LTAxMDk1ZjEyNTNjYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yOWNkNDg0ZjM1NGIxZjVmNmIzMGM5ZDI5NjM4NzgyY2Y4OWRkZWVmNjhjZjExZGM1YTVlODk2NGM0OTc3YWYxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.oaDCq3hQzAc_BnhbIwrFOqR5BHqxxNzL979TBmGHUfM"><img src="https://private-user-images.githubusercontent.com/121779953/358509211-5ab9dc9d-dcce-4f9d-9908-01095f1253cb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NTA5MjExLTVhYjlkYzlkLWRjY2UtNGY5ZC05OTA4LTAxMDk1ZjEyNTNjYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yOWNkNDg0ZjM1NGIxZjVmNmIzMGM5ZDI5NjM4NzgyY2Y4OWRkZWVmNjhjZjExZGM1YTVlODk2NGM0OTc3YWYxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.oaDCq3hQzAc_BnhbIwrFOqR5BHqxxNzL979TBmGHUfM" alt="image" /></a></p>
<ul>
<li><p><strong>Search for <mark>App password</mark> and create a app password for jenkins</strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358509568-701752da-7703-4685-8f06-fe1f65dd1b9c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NTA5NTY4LTcwMTc1MmRhLTc3MDMtNDY4NS04ZjA2LWZlMWY2NWRkMWI5Yy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kNjlkY2Q4MzRlNzEzZTU4YTc2M2QxOTVjMDA3YzNhZGI0OWM3ZjZmMDJlOGQzYTcyNzk1MWM4YmM5MjlhN2FjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.zt7e00PAOvw1iTN14uO3NTE8QNsDtr1oWUBy6FjsoKg" alt="image" /></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358510105-adc8d8c0-8be4-4319-9042-4115abb5c6fc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NTEwMTA1LWFkYzhkOGMwLThiZTQtNDMxOS05MDQyLTQxMTVhYmI1YzZmYy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00NjgxZTc1Mjk2MTRhMjkwMTA5M2MwZDE1YTBmNjgyMDEzZGNiNzBkYjdiODI3NTI2MTZmNTVlMWNmOWI5N2RmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.bZ8ea4DTNvhL-OjA5n53010WvwZTZVNjNhmkLlHJJQo" alt="image" /></p>
</li>
<li><p><strong>Once, app password is create and go back to jenkins <mark>Manage Jenkins --&gt; Credentials</mark> to add username and password for email notification</strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358511061-2a42ec62-87c8-43c8-a034-7be0beb8824e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NTExMDYxLTJhNDJlYzYyLTg3YzgtNDNjOC1hMDM0LTdiZTBiZWI4ODI0ZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zOTExODFjMjViNWZiYjI0MDQxYTA4ZWU5MzY2NmNhNWVlYzdkMGM0NzZhY2RmOTBlYzc5YzNlMzNjZDJmODY3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.oTotAelMgGmu-BvcvfymBd2CgW6X98U21rVSmzsbxjg" alt="image" /></p>
</li>
<li><p><strong>Go back to <mark>Manage Jenkins --&gt; System</mark> and search for <mark>Extended E-mail Notification</mark></strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358512263-bac81e24-bb07-4659-a251-955966feded8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NTEyMjYzLWJhYzgxZTI0LWJiMDctNDY1OS1hMjUxLTk1NTk2NmZlZGVkOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iODM0NzNiYTYzNTBhOTMxNzQzNTIzZGFlMzMzZDRkZTkxYWQ1MjY5ZTQ0OWY1N2JkNDY0OWMxNmYyOWI5YjcxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.i9FHbFdiDec7KkQpgtkgQwuknM9OFqlTCJwoBFOo-Y4" alt="image" /></p>
</li>
<li><p><strong>Scroll down and search for <mark>E-mail Notification</mark> and setup email notification</strong></p>
</li>
</ul>
<p><strong>Important</strong></p>
<p>Enter your gmail password which we copied recently in password field <mark>E-mail Notification --&gt; Advance</mark></p>
<p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/358513004-14e254fc-1400-457e-b3f4-046404b66950.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NTEzMDA0LTE0ZTI1NGZjLTE0MDAtNDU3ZS1iM2Y0LTA0NjQwNGI2Njk1MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01YmNlZTczNDZlOTg2ZWMzZjE4YThiYWQ1NWUxZjViNjI5ZjNmYzk2NDM1MDI1M2Q1NWE3YzU1N2VmM2YwNmRiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.JFjCxV08u3tvTGJ1myIaScnlZEbrxK6IaNvCQqqJUj4"><img src="https://private-user-images.githubusercontent.com/121779953/358513004-14e254fc-1400-457e-b3f4-046404b66950.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NTEzMDA0LTE0ZTI1NGZjLTE0MDAtNDU3ZS1iM2Y0LTA0NjQwNGI2Njk1MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01YmNlZTczNDZlOTg2ZWMzZjE4YThiYWQ1NWUxZjViNjI5ZjNmYzk2NDM1MDI1M2Q1NWE3YzU1N2VmM2YwNmRiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.JFjCxV08u3tvTGJ1myIaScnlZEbrxK6IaNvCQqqJUj4" alt="image" /></a></p>
<h1 id="heading-nodes-creation">Nodes Creation:</h1>
<ul>
<li>apney ko node groups add karni hey - ussey pehley oidc rehtha hey → oepn id connect - jissey ki aapka aws account iss cluster seh bath kar paye.</li>
</ul>
<ul>
<li><strong>Associate IAM OIDC Provider (Master machine)</strong></li>
</ul>
<pre><code class="lang-bash">eksctl utils associate-iam-oidc-provider \
  --region us-east-2 \
  --cluster wanderlust \
  --approve
</code></pre>
<ul>
<li><p><strong>Create Nodegroup (Master machine)</strong></p>
</li>
<li><ul>
<li>aapko yaha pey - aapko ek ssh public key rehni hey eks-nodegroup-key → key pair mey jakey create kardo eks-nodegroup-key</li>
</ul>
</li>
</ul>
<pre><code class="lang-bash">eksctl create nodegroup --cluster=wanderlust \
                     --region=us-east-2 \
                     --name=wanderlust \
                     --node-type=t2.large \
                     --nodes=2 \
                     --nodes-min=2 \
                     --nodes-max=2 \
                     --node-volume-size=29 \
                     --ssh-access \
                     --ssh-public-key=eks-nodegroup-key
</code></pre>
<p><strong>Note</strong></p>
<p>Make sure the ssh-public-key "eks-nodegroup-key is available in your aws account"</p>
<p>- phir sey 20 min lega , jab thak owasp dekehnge</p>
<h2 id="heading-steps-to-implement-the-project"><strong>Steps to implement the project:</strong></h2>
<ul>
<li><p>owasp implement karney key liye owasp ka plugin chahiye - go to dadhboard -→ plugins -→ available Plugins .</p>
</li>
<li><p>4 plugins install kana hey - blue ocean → install → restart jenkins</p>
</li>
<li><p>ab cluster bangaya - node bangaya - &gt; now if i give kubectl get nodes - ab humney cluster bana diye</p>
</li>
</ul>
<ul>
<li><p><strong>Go to Jenkins Master and click on <mark>Manage Jenkins --&gt; Plugins --&gt; Available plugins</mark> install the below plugins:</strong></p>
<ul>
<li><p>OWASP</p>
</li>
<li><p>SonarQube Scanner</p>
</li>
<li><p>Docker</p>
</li>
<li><p>Pipeline: Stage View</p>
</li>
</ul>
</li>
<li><p><strong>Configure OWASP, move to <mark>Manage Jenkins --&gt; Plugins --&gt; Available plugins</mark> (Jenkins Worker)</strong></p>
</li>
<li><p><strong>After OWASP plugin is installed, Now move to <mark>Manage jenkins --&gt; Tools</mark> (Jenkins Worker)</strong></p>
</li>
</ul>
<p>- dependency check dhundo - &gt; add dependency - name → OWASP - &gt; insall automatically kardo - install from github.com → version - 10.0.3 → owasp kuch files download karega jisko 20 min lag sakthey hey , jab aap pipeline chalavoge thab</p>
<ul>
<li>ab save karlo</li>
</ul>
<ul>
<li><h2 id="heading-ab-mujhey-jenkins-ko-aur-sonar-ko-integrate-karana-hey">ab mujhey jenkins ko aur sonar ko integrate karana hey</h2>
<p>  - toh sonar idhar hey - mujhey isko jenkins ko intgerate karana hey , humney jenkins ko github ko kaisa intgerate kiske basis pey intgerate kara ya tha - through tokens</p>
</li>
</ul>
<ul>
<li><p><strong>Login to SonarQube server and create the credentials for jenkins to integrate with SonarQube</strong></p>
<ul>
<li><p>Navigate to <mark>Administration --&gt; Security --&gt; Users --&gt; Token</mark></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358118740-86ad8284-5da6-4048-91fe-ac20c8e4514a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4MTE4NzQwLTg2YWQ4Mjg0LTVkYTYtNDA0OC05MWZlLWFjMjBjOGU0NTE0YS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mMjAzY2M0OGYwODgyNWFlODYxMjdmYWJkMzA2MWYxM2U1MzcyNDFhNzQ1ZjE3MThkZDljZDVkOTI0N2IzMDEwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.nerpBq7nLK0VAyKPEipK5NC6O9hbx57n5uXC9Cfa_kg" alt="image" /></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358118837-6bc671a5-c122-45c0-b1f0-f29999bbf751.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4MTE4ODM3LTZiYzY3MWE1LWMxMjItNDVjMC1iMWYwLWYyOTk5OWJiZjc1MS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jYWQwMmMyOTA2NzMzYzM5OTlhM2NlYWNhNGI3YzNmMTgzMGRkNzAzZThmYWM3YjIzYWEyYTlmYTNkYjVkZmE0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.8-XWgn2OoWlLhpgccbWjl7giVaGHldIfI_7NRg98rW4" alt="image" /></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358118903-e748643a-e037-4d4c-a9be-944995979c60.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4MTE4OTAzLWU3NDg2NDNhLWUwMzctNGQ0Yy1hOWJlLTk0NDk5NTk3OWM2MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yNzRiNmVhYzc1MWQyZDY3ZDJiZjllZGU4NzAwNjYwZjg2Nzg3NzM1M2JlNjAyYWM0MDEyZDAzNmUzNzhjZWZmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.fmxAR1uRc5IjCSoaCGulZXo8NfMW_9nywB_2hA07Jqk" alt="image" /></p>
</li>
</ul>
</li>
<li><p><strong>Now, go to <mark>Manage Jenkins --&gt; credentials</mark> and add Sonarqube credentials:</strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358121052-0688e105-2170-4c3f-87a3-128c1a05a0b8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4MTIxMDUyLTA2ODhlMTA1LTIxNzAtNGMzZi04N2EzLTEyOGMxYTA1YTBiOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03YjUxZjI1ZTY0MThlNzM3NGMxYTk1YWYzNGFkNmVjMmM5YTkyMDBmNWM1ODY1MTU5ZGI1ZjMxZDNkYWY3N2U3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.7g6JA8QlJ-kEE2Zk5EnSf28blmXXaxvNZ1E6NYBdWMc" alt="image" /></p>
</li>
<li><p>ab sonar key token sey jenkins ko integrate kar denge - go to tools - sonar scannner - add sonar scanner</p>
</li>
<li><p><strong>Go to <mark>Manage Jenkins --&gt; Tools</mark> and search for SonarQube Scanner installations:</strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358121304-2fdc1e56-f78c-43d2-914a-104ec2c8ea86.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4MTIxMzA0LTJmZGMxZTU2LWY3OGMtNDNkMi05MTRhLTEwNGVjMmM4ZWE4Ni5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lMWJjNzEwY2FiODMyZjFjNTIxYmIzOGRiZjViYmIxNjdhYzViM2Q3YWJiMzgwOGNjNTg0NzZjYWMzNTBmZTA0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.Uq0U740GR7qpqB-JLSQ2zWSRnjovw-Nq2liEZYuh94k" alt="image" /></p>
</li>
</ul>
<ul>
<li><p><strong>Go to <mark>Manage Jenkins --&gt; credentials</mark> and add Github credentials to push updated code from the pipeline:</strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358480677-4d0c1a47-621e-4aa2-a0b1-71927fcdaef4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDgwNjc3LTRkMGMxYTQ3LTYyMWUtNGFhMi1hMGIxLTcxOTI3ZmNkYWVmNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zNjMxMzdjYTY0MWNkMDI3MzBiOTQ0ZjZlMTdkZTZhYmNmYWE1ODQxZmY2YTZlOTZlMGYxNDE4OWQ3MGNjYjBiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.HAG9jpMje3XD8SNjuuFrw2GUWuoHDiT21d5QJ5vPN7M" alt="image" /></p>
</li>
</ul>
<p><strong>Note</strong></p>
<p>While adding github credentials add Personal Access Token in the password field.</p>
<ul>
<li>ab mujhey sonarqube ko integrate karana hey -</li>
</ul>
<ul>
<li><p><strong>Go to <mark>Manage Jenkins --&gt; System</mark> and search for SonarQube installations:</strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358121531-ae866185-cb2b-4e83-825b-a125ec97243a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4MTIxNTMxLWFlODY2MTg1LWNiMmItNGU4My04MjViLWExMjVlYzk3MjQzYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02ZGM2NTFjMDhiMjg5ZDc1Y2YyYWQzZDUzMjFmYmYwZWIyYTdhMWNiMWI2Y2UzNWI5ZmJhYWUwZmRiYmEzNGY2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.5gt2v9RmiUv0wQmFBnScogF2LtqH82NmVy_E295Q7HU" alt="image" /></p>
</li>
<li><p>jab jenkins sonarqube pey hit karega usko ek webhook chahiye hit karekey liye</p>
</li>
<li><p>agar mujhey jenkins sey sonar ko kuch bhejna hey toh mujhey wehbook chahiye hotha hey</p>
</li>
</ul>
<p><strong>Login to SonarQube server, go to <mark>Administration --&gt; Webhook</mark> and click on create</strong></p>
<p><img src="https://private-user-images.githubusercontent.com/121779953/358122026-16527e72-6691-4fdf-a8d2-83dd27a085cb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4MTIyMDI2LTE2NTI3ZTcyLTY2OTEtNGZkZi1hOGQyLTgzZGQyN2EwODVjYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00MjI2ODUxYjNiMmExNzc1NDI2ZDY4MDVlNDYzZTUzNTBhMTFkYjA0YWVjMGMzM2I4MWQ2MzllMzk0YjcyMDhmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.Fk2qeteqn9-i5r2Rrp5-4S36RVuWx3eYO-1bkbOnu-M" alt="image" /></p>
<p><img src="https://private-user-images.githubusercontent.com/121779953/358122186-a8b45948-766a-49a4-b779-91ac3ce0443c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4MTIyMTg2LWE4YjQ1OTQ4LTc2NmEtNDlhNC1iNzc5LTkxYWMzY2UwNDQzYy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xMjg0MGNiODY1MGYwNThmMmQyMjUyNzU5Y2ZmMWY4ZTJiZTM3OWI1ZDc2NjI5ZDY0YzhhNzlkMTVmM2RmZWQ5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.7-tchoCfYEiTI3yXQ3EHZRKKYe1z6EIWj8xf1HF7v8M" alt="image" /></p>
<h1 id="heading-argo-cd">argo cd :</h1>
<ul>
<li><p>Ab hum log argocd ko setup karlenge - go to the repository - installations</p>
</li>
<li><p>Argocd ek cd tool - &gt; ho kubernates specific deployments key liye kaam kartha hey</p>
</li>
<li><p>mai kaha install karunga - mai eks cluster pey karunga uska jo b kaam hey master mey rahega</p>
</li>
<li><p>- <strong>Install and Configure ArgoCD (Master Machine</strong></p>
<ul>
<li><strong>Create argocd namespace</strong></li>
</ul>
</li>
</ul>
<pre><code class="lang-bash">    kubectl create namespace argocd
</code></pre>
<ul>
<li><strong>Apply argocd manifest</strong></li>
</ul>
<pre><code class="lang-bash">    kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
</code></pre>
<ul>
<li><strong>Make sure all pods are running in argocd namespace</strong></li>
</ul>
<pre><code class="lang-bash">    watch kubectl get pods -n argocd
</code></pre>
<ul>
<li><p><strong>Install argocd CLI</strong></p>
</li>
<li><p>ae jo mera argo cd hey - ae toh ui application agar same cheez cli po karni hey cli install karlethey</p>
</li>
</ul>
<pre><code class="lang-bash">    sudo curl --silent --location -o /usr/<span class="hljs-built_in">local</span>/bin/argocd https://github.com/argoproj/argo-cd/releases/download/v2.4.7/argocd-linux-amd64
</code></pre>
<ul>
<li><strong>Provide executable permission</strong></li>
</ul>
<pre><code class="lang-bash">    sudo chmod +x /usr/<span class="hljs-built_in">local</span>/bin/argocd
</code></pre>
<ul>
<li><strong>Check argocd services</strong></li>
</ul>
<pre><code class="lang-bash">    kubectl get svc -n argocd
</code></pre>
<ul>
<li><strong>Change argocd server's service from ClusterIP to NodePort</strong></li>
</ul>
<pre><code class="lang-bash">    kubectl patch svc argocd-server -n argocd -p <span class="hljs-string">'{"spec": {"type": "NodePort"}}'</span>
</code></pre>
<ul>
<li><strong>Confirm service is patched or not</strong></li>
</ul>
<pre><code class="lang-bash">    kubectl get svc -n argocd
</code></pre>
<ul>
<li><p><strong>Check the port where ArgoCD server is running and expose it on security groups of a worker node</strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/357419258-a2932e03-ebc7-42a6-9132-82638152197f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU3NDE5MjU4LWEyOTMyZTAzLWViYzctNDJhNi05MTMyLTgyNjM4MTUyMTk3Zi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04ZWFmZGJiMmUyNzBhZWY1Nzk4NTkxYTcwYjk0ZDFlZTZmM2U1MjE2Y2Q2M2E4N2NlZDY5ZDI2OWIyNzNkZmI1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.mZf858Pt4GvliEheC4eDws6d58Vrzr1lrl0PwDQJer4" alt="image" /></p>
</li>
<li><p><strong>Access it on browser, click on advance and proceed with</strong></p>
</li>
</ul>
<pre><code class="lang-bash">    &lt;public-ip-worker&gt;:&lt;port&gt;
</code></pre>
<p>    <img src="https://private-user-images.githubusercontent.com/121779953/357420638-29d9cdbd-5b7c-44b3-bb9b-1d091d042ce3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU3NDIwNjM4LTI5ZDljZGJkLTViN2MtNDRiMy1iYjliLTFkMDkxZDA0MmNlMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iMDc0N2MwMDI2NDk5NzQxNTgwMWQwMmIwMDUzNDZkYzdmZjIyOWY2YTY4MzBmMjFlZjFiMjk1Y2RjZWRhNGVlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.ZcvZ-23ewBgERrHsm3ivPZzGAODljpdtNkzC8cFzKb8" alt="image" /></p>
<p>    <img src="https://private-user-images.githubusercontent.com/121779953/357420865-08f4e047-e21c-4241-ba68-f9b719a4a39a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU3NDIwODY1LTA4ZjRlMDQ3LWUyMWMtNDI0MS1iYTY4LWY5YjcxOWE0YTM5YS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yNzdkYmM4OTA4YjQ2MDEyNThiZmYzMjFlY2Q0OWQzZTAxZTgxMDU5ZWMzOTc3MGZkYjJmMWFkNWJhMGRkNDEzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.xG8CJqgP-ScIstmMrP9T7-A5zno-q_TjqouGXU0z5Po" alt="image" /></p>
<p>    <img src="https://private-user-images.githubusercontent.com/121779953/357421043-1ffa85c3-9055-49b4-aab0-0947b95f0dd2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU3NDIxMDQzLTFmZmE4NWMzLTkwNTUtNDliNC1hYWIwLTA5NDdiOTVmMGRkMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02YTcwODdkZTc5MWI1MjA4ODU3ZWViNWU0ZDU5YmRjODY3MDlmNjA3OWM1MmUxZjZhOWEwYTE2MmM2N2UyNjBjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.PpWET-BDPvB-gs24LTcl0o0o8XXEM-ny2l0fKVz552I" alt="image" /></p>
<ul>
<li><strong>agar Fetch the initial password of argocd server</strong></li>
</ul>
<pre><code class="lang-bash">    kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath=<span class="hljs-string">"{.data.password}"</span> | base64 -d; <span class="hljs-built_in">echo</span>
</code></pre>
<ul>
<li><p><strong>Username: admin</strong></p>
</li>
<li><p><strong>Now, go to <mark>User Info</mark> and update your argocd password</strong></p>
</li>
<li><p>sign in karlo abhi → go to user info - update password .</p>
</li>
<li><p>abhi apney ko argocd ko b setup karna hey → settings - repositories</p>
</li>
<li><p>argocd aek delivery tool hey github hey sey kubernates manifest file lekey aatha hey - aur cluster pey update kar detha hey</p>
</li>
<li><p>toh mujhey ek repository chahiye hogi aur cluster chahiye hoga - &gt; connect repo → https - &gt; project name -default -→ clone url give here -→ conect</p>
</li>
<li><p>aisa samjo dockerhub credentails do jagah pey docker push karma hey - is valey stage pey mere wala account pey karna next stag emey dusri vala stage pey karna hey -- &gt; toh mai shared libraries use karlunga as a function vo function mai call karletha hun</p>
</li>
<li><p>same code ko multiple pipelines mey share kar sakthey ho</p>
</li>
</ul>
<ul>
<li><p><strong>Now again, Go to <mark>Manage Jenkins --&gt; System</mark> and search for Global Trusted Pipeline Libraries:&lt;/b</strong></p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748690653898/3dbbad03-6bf0-4f97-88eb-55eaacee0b26.png" alt class="image--center mx-auto" /></p>
</li>
<li><p><a target="_blank" href="https://github.com/DevMadhup/Jenkins_SharedLib.git">https://github.com/DevMadhup/Jenkins_SharedLib.git</a></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358121707-874b2e03-49b9-4c26-9b0f-bd07ce70c0f1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4MTIxNzA3LTg3NGIyZTAzLTQ5YjktNGMyNi05YjBmLWJkMDdjZTcwYzBmMS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kZTEwOTU4MmY2ZGI4NWQ5NmQwNTIyMzdiZTU2Y2U2OWE2ZjJmY2U5YTBjNTk3ZDVhMzIxY2I3MDdmYTA0NzRmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.kluSBZmnFl7bdWG2SU_hOGUD9IJWiC3f82Bycf922uo" alt="image" /></p>
<ul>
<li><p>agar ae mai kisi aur node pey chalana hey toh mai label diunga</p>
</li>
<li><p>environment - sonar_home : sonar kiun diye → kiunki agar aap apney manage jenkins - tools pey javige - sonarqube tool ko sonar name sey diye hey</p>
</li>
<li><p>hamara jo project hey - ismey ae frontend - ae backend hey</p>
<ul>
<li><p>toh backend ki image and front end ki image change huegi kabhi na kabhi - isi liye ae humlog parameters liyenge -</p>
</li>
<li><p>lets say version 4.7 chahiye ,mai yaha pey tags dal saktha hun toh vo vala build hojayega parameters through</p>
</li>
<li><p>usko imagetag</p>
</li>
<li><p>phir trivy , owasp , sonar analysis , sonar quality gate everything taken fron shared library</p>
</li>
<li><p>Ecporting env variables : aisa samjo ki ae jo project hey - backend - mai aapko docker compose through samjatha hun</p>
</li>
<li><p>is project mey kithni services hey - 4 services - &gt; mongodb : container namee → image ka name: mongo → volume</p>
</li>
<li><p>aur ek - backend container - name → image: build./backend → env_file: is ka env file hey backedn file mey env file hey usmey ip port number is key environmnrt specific address hey kuch variables hey</p>
</li>
<li><p>vo file mey → ip alag hey mera ip alag hey isliye ek directory hey automations</p>
</li>
<li><p>push to docker hub shared libraries - docker push karneey liye we need credentials - docker hub pey javo - go to my account settings - aur yaha pey personal access token - generate -new-token - read write access deno generate kardo - paste the token in jenkins - managejenkins - credentials</p>
</li>
</ul>
</li>
<li><p>Argo cd ka kya kaam hey - github sey manifest lekey cluster mey deploy kartha hey</p>
</li>
<li><p>how to ensure ki github pey hamari our manifest files updated hey .</p>
</li>
<li><p>deployment depends on the manifest file , if we do the continuos delivery cd - of manifest files and argocd us manifest files ko lekey deploy kardega</p>
</li>
<li><p>jo b docker image version deyegey hum us image tag sey ci ney docker image ko scan build , sonarqube aur push karega docker hub , ab cd pipeline u docker image ko kubernates manifest file mey update karega</p>
</li>
<li><p>iskey badh argocd ney us yaml files ko deploy kar dega eks-cluster mey</p>
</li>
</ul>
</li>
<li><p>argocd ka kaam simple hey - manifest lena aur deploy karna</p>
</li>
<li><p>GitOps - -→ Gitops is a practice in which the code is basically pulled from github repo through that repo there are tools like argocd directly rely on git code not any pipeline .</p>
<pre><code class="lang-bash">  @Library(<span class="hljs-string">'Shared'</span>) _
  pipeline {
      agent {label <span class="hljs-string">'Node'</span>}

      environment{
          SONAR_HOME = tool <span class="hljs-string">"Sonar"</span>
      }

      parameters {
          string(name: <span class="hljs-string">'FRONTEND_DOCKER_TAG'</span>, defaultValue: <span class="hljs-string">''</span>, description: <span class="hljs-string">'Setting docker image for latest push'</span>)
          string(name: <span class="hljs-string">'BACKEND_DOCKER_TAG'</span>, defaultValue: <span class="hljs-string">''</span>, description: <span class="hljs-string">'Setting docker image for latest push'</span>)
      }

      stages {
          stage(<span class="hljs-string">"Validate Parameters"</span>) {
              steps {
                  script {
                      <span class="hljs-keyword">if</span> (params.FRONTEND_DOCKER_TAG == <span class="hljs-string">''</span> || params.BACKEND_DOCKER_TAG == <span class="hljs-string">''</span>) {
                          error(<span class="hljs-string">"FRONTEND_DOCKER_TAG and BACKEND_DOCKER_TAG must be provided."</span>)
                      }
                  }
              }
          }
          stage(<span class="hljs-string">"Workspace cleanup"</span>){
              steps{
                  script{
                      cleanWs()
                  }
              }
          }

          stage(<span class="hljs-string">'Git: Code Checkout'</span>) {
              steps {
                  script{
                      code_checkout(<span class="hljs-string">"https://github.com/LondheShubham153/Wanderlust-Mega-Project.git"</span>,<span class="hljs-string">"main"</span>)
                  }
              }
          }

          stage(<span class="hljs-string">"Trivy: Filesystem scan"</span>){
              steps{
                  script{
                      trivy_scan()
                  }
              }
          }

          stage(<span class="hljs-string">"OWASP: Dependency check"</span>){
              steps{
                  script{
                      owasp_dependency()
                  }
              }
          }

          stage(<span class="hljs-string">"SonarQube: Code Analysis"</span>){
              steps{
                  script{
                      sonarqube_analysis(<span class="hljs-string">"Sonar
  "</span>,<span class="hljs-string">"wanderlust"</span>,<span class="hljs-string">"wanderlust"</span>)
                  }
              }
          }

          stage(<span class="hljs-string">"SonarQube: Code Quality Gates"</span>){
              steps{
                  script{
                      sonarqube_code_quality()
                  }
              }
          }

          stage(<span class="hljs-string">'Exporting environment variables'</span>) {
              parallel{
                  stage(<span class="hljs-string">"Backend env setup"</span>){
                      steps {
                          script{
                              dir(<span class="hljs-string">"Automations"</span>){
                                  sh <span class="hljs-string">"bash updatebackendnew.sh"</span>
                              }
                          }
                      }
                  }

                  stage(<span class="hljs-string">"Frontend env setup"</span>){
                      steps {
                          script{
                              dir(<span class="hljs-string">"Automations"</span>){
                                  sh <span class="hljs-string">"bash updatefrontendnew.sh"</span>
                              }
                          }
                      }
                  }
              }
          }

          stage(<span class="hljs-string">"Docker: Build Images"</span>){
              steps{
                  script{
                          dir(<span class="hljs-string">'backend'</span>){
                              docker_build(<span class="hljs-string">"wanderlust-backend-beta"</span>,<span class="hljs-string">"<span class="hljs-variable">${params.BACKEND_DOCKER_TAG}</span>"</span>,<span class="hljs-string">"trainwithshubham"</span>)
                          }

                          dir(<span class="hljs-string">'frontend'</span>){
                              docker_build(<span class="hljs-string">"wanderlust-frontend-beta"</span>,<span class="hljs-string">"<span class="hljs-variable">${params.FRONTEND_DOCKER_TAG}</span>"</span>,<span class="hljs-string">"trainwithshubham"</span>)
                          }
                  }
              }
          }

          stage(<span class="hljs-string">"Docker: Push to DockerHub"</span>){
              steps{
                  script{
                      docker_push(<span class="hljs-string">"wanderlust-backend-beta"</span>,<span class="hljs-string">"<span class="hljs-variable">${params.BACKEND_DOCKER_TAG}</span>"</span>,<span class="hljs-string">"trainwithshubham"</span>) 
                      docker_push(<span class="hljs-string">"wanderlust-frontend-beta"</span>,<span class="hljs-string">"<span class="hljs-variable">${params.FRONTEND_DOCKER_TAG}</span>"</span>,<span class="hljs-string">"trainwithshubham"</span>)
                  }
              }
          }
      }
      post{
          success{
              archiveArtifacts artifacts: <span class="hljs-string">'*.xml'</span>, followSymlinks: <span class="hljs-literal">false</span>
              build job: <span class="hljs-string">"Wanderlust-CD"</span>, parameters: [
                  string(name: <span class="hljs-string">'FRONTEND_DOCKER_TAG'</span>, value: <span class="hljs-string">"<span class="hljs-variable">${params.FRONTEND_DOCKER_TAG}</span>"</span>),
                  string(name: <span class="hljs-string">'BACKEND_DOCKER_TAG'</span>, value: <span class="hljs-string">"<span class="hljs-variable">${params.BACKEND_DOCKER_TAG}</span>"</span>)
              ]
          }
      }
  }
</code></pre>
<pre><code class="lang-bash">  version: <span class="hljs-string">"3.8"</span>
  services:
    mongodb:
      container_name: mongo-service
      image: mongo:latest
      volumes:
        - ./backend/data:/data
      ports:
        - <span class="hljs-string">"27017:27017"</span>

    backend:
      container_name: backend
      build: ./backend
      env_file:
        - ./backend/.env.docker
      ports:
        - <span class="hljs-string">"31100:8080"</span>
      depends_on:
        - mongodb

    frontend:
      container_name: frontend
      build: ./frontend
      env_file:
        - ./frontend/.env.docker
      ports:
        - <span class="hljs-string">"5173:5173"</span>

    redis:
      container_name: redis-service
      restart: unless-stopped
      image: redis:7.0.5-alpine 
      expose:
          - 6379
      depends_on:
        - mongodb

  volumes:
    data:

  -------------------------------------
  updatedbackendenv.sh

  <span class="hljs-comment">#!/bin/bash</span>

  <span class="hljs-comment"># Set the Instance ID and path to the .env file</span>
  INSTANCE_ID=<span class="hljs-string">"i-030da7d31a1dbbffc"</span>

  <span class="hljs-comment"># Retrieve the public IP address of the specified EC2 instance</span>
  ipv4_address=$(aws ec2 describe-instances --instance-ids <span class="hljs-variable">$INSTANCE_ID</span> --query <span class="hljs-string">'Reservations[0].Instances[0].PublicIpAddress'</span> --output text)

  <span class="hljs-comment"># Path to the .env file</span>
  file_to_find=<span class="hljs-string">"../backend/.env.docker"</span>

  <span class="hljs-comment"># Check the current FRONTEND_URL in the .env file</span>
  current_url=$(sed -n <span class="hljs-string">"4p"</span> <span class="hljs-variable">$file_to_find</span>)

  <span class="hljs-comment"># Update the .env file if the IP address has changed</span>
  <span class="hljs-keyword">if</span> [[ <span class="hljs-string">"<span class="hljs-variable">$current_url</span>"</span> != <span class="hljs-string">"FRONTEND_URL=\"http://<span class="hljs-variable">${ipv4_address}</span>:5173\""</span> ]]; <span class="hljs-keyword">then</span>
      <span class="hljs-keyword">if</span> [ -f <span class="hljs-variable">$file_to_find</span> ]; <span class="hljs-keyword">then</span>
          sed -i -e <span class="hljs-string">"s|FRONTEND_URL.*|FRONTEND_URL=\"http://<span class="hljs-variable">${ipv4_address}</span>:5173\"|g"</span> <span class="hljs-variable">$file_to_find</span>
      <span class="hljs-keyword">else</span>
          <span class="hljs-built_in">echo</span> <span class="hljs-string">"ERROR: File not found."</span>
      <span class="hljs-keyword">fi</span>
  <span class="hljs-keyword">fi</span>

  -------
  --------------
  updatefrontendenv.sh

  <span class="hljs-comment">#!/bin/bash</span>

  <span class="hljs-comment"># Set the Instance ID and path to the .env file</span>
  INSTANCE_ID=<span class="hljs-string">"i-030da7d31a1dbbffc"</span>

  <span class="hljs-comment"># Retrieve the public IP address of the specified EC2 instance</span>
  ipv4_address=$(aws ec2 describe-instances --instance-ids <span class="hljs-variable">$INSTANCE_ID</span> --query <span class="hljs-string">'Reservations[0].Instances[0].PublicIpAddress'</span> --output text)

  <span class="hljs-comment"># Path to the .env file</span>
  file_to_find=<span class="hljs-string">"../frontend/.env.docker"</span>

  <span class="hljs-comment"># Check the current VITE_API_PATH in the .env file</span>
  current_url=$(cat <span class="hljs-variable">$file_to_find</span>)

  <span class="hljs-comment"># Update the .env file if the IP address has changed</span>
  <span class="hljs-keyword">if</span> [[ <span class="hljs-string">"<span class="hljs-variable">$current_url</span>"</span> != <span class="hljs-string">"VITE_API_PATH=\"http://<span class="hljs-variable">${ipv4_address}</span>:31100\""</span> ]]; <span class="hljs-keyword">then</span>
      <span class="hljs-keyword">if</span> [ -f <span class="hljs-variable">$file_to_find</span> ]; <span class="hljs-keyword">then</span>
          sed -i -e <span class="hljs-string">"s|VITE_API_PATH.*|VITE_API_PATH=\"http://<span class="hljs-variable">${ipv4_address}</span>:31100\"|g"</span> <span class="hljs-variable">$file_to_find</span>
      <span class="hljs-keyword">else</span>
          <span class="hljs-built_in">echo</span> <span class="hljs-string">"ERROR: File not found."</span>
      <span class="hljs-keyword">fi</span>
  <span class="hljs-keyword">fi</span>
</code></pre>
<p>  ```bash
  @Library('Shared') _
  pipeline {
      agent {label 'Node'}</p>
<p>      parameters {
          string(name: 'FRONTEND_DOCKER_TAG', defaultValue: '', description: 'Frontend Docker tag of the image built by the CI job')
          string(name: 'BACKEND_DOCKER_TAG', defaultValue: '', description: 'Backend Docker tag of the image built by the CI job')
      }</p>
<p>      stages {
          stage("Workspace cleanup"){
              steps{
                  script{
                      cleanWs()
                  }
              }
          }</p>
<p>          stage('Git: Code Checkout') {
              steps {
                  script{
                      code_checkout("https://github.com/LondheShubham153/Wanderlust-Mega-Project.git","main")
                  }
              }
          }</p>
<p>          stage('Verify: Docker Image Tags') {
              steps {
                  script{
                      echo "FRONTEND_DOCKER_TAG: ${params.FRONTEND_DOCKER_TAG}"
                      echo "BACKEND_DOCKER_TAG: ${params.BACKEND_DOCKER_TAG}"
                  }
              }
          }</p>
</li>
</ul>
<p>            stage("Update: Kubernetes manifests"){
                steps{
                    script{
                        dir('kubernetes'){
                            sh """
                                sed -i -e s/wanderlust-backend-beta.*
    /wanderlust-backend-beta:${params.BACKEND_DOCKER_TAG}/g backend.yaml
                            """
                        }</p>
<p>                        dir('kubernetes'){
                            sh """
                                sed -i -e s/wanderlust-frontend-beta.*/wanderlust-frontend-beta:${params.FRONTEND_DOCKER_TAG}/g frontend.yaml
                            """
                        }</p>
<p>                    }
                }
            }</p>
<p>            stage("Git: Code update and push to GitHub"){
                steps{
                    script{
                        withCredentials([gitUsernamePassword(credentialsId: 'Github-cred', gitToolName: 'Default')]) {
                            sh '''
                            echo "Checking repository status: "
                            git status</p>
<p>                            echo "Adding changes to git: "
                            git add .</p>
<p>                            echo "Commiting changes: "
                            git commit -m "Updated environment variables"</p>
<p>                            echo "Pushing changes to github: "
                            git push https://github.com/LondheShubham153/Wanderlust-Mega-Project.git main
                        '''
                        }
                    }
                }
            }
        }
      post {
            success {
                script {
                    emailext attachLog: true,
                    from: 'trainwithshubham@gmail.com',
                    subject: "Wanderlust Application has been updated and deployed - '${currentBuild.result}'",
                    body: """
                        
                        
                            <div>
                                <p>Project: ${env.JOB_NAME}</p>
                            </div>
                            <div>
                                <p>Build Number: ${env.BUILD_NUMBER}</p>
                            </div>
                            <div>
                                <p>URL: ${env.BUILD_URL}</p>
                            </div>
                        
                        
                """,
                to: 'trainwithshubham@gmail.com',
                mimeType: 'text/html'
                }
            }
          failure {
                script {
                    emailext attachLog: true,
                    from: 'trainwithshubham@gmail.com',
                    subject: "Wanderlust Application build failed - '${currentBuild.result}'",
                    body: """
                        
                        
                            <div>
                                <p>Project: ${env.JOB_NAME}</p>
                            </div>
                            <div>
                                <p>Build Number: ${env.BUILD_NUMBER}</p>
                            </div>
                        
                        
                """,
                to: 'trainwithshubham@gmail.com',
                mimeType: 'text/html'
                }
            }
        }
    }</p>
<pre><code>
* ---

    ---

    \-

* **Now, go to github repository and under &lt;mark&gt;Automations&lt;<span class="hljs-regexp">/mark&gt; directory update the &lt;mark&gt;instance-id&lt;/m</span>ark&gt; field on both the &lt;mark&gt;updatefrontendnew.sh updatebackendnew.sh&lt;/mark&gt; <span class="hljs-keyword">with</span> the k8s worker<span class="hljs-string">'s instance id**

    ![image](https://private-user-images.githubusercontent.com/121779953/358123023-3cb044b4-df88-4d68-bf7c-775cf78d5bf2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4MTIzMDIzLTNjYjA0NGI0LWRmODgtNGQ2OC1iZjdjLTc3NWNmNzhkNWJmMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yZDk3NzQ4NTIzMjkxOTk1MWU2OGQwNzZiNGExZjdkOGI4N2M1NjZmNGY3MWY3YzFhYzAxNTJmYzRiY2QxNDZmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.JhLdvfvLd_4RMG5mgJaqvrPDQ7fwMh2AROgFtnLUZ6g align="left")

* **Navigate to &lt;mark&gt;Manage Jenkins --&amp;gt; credentials&lt;/mark&gt; and add credentials for docker login to push docker image:**

    ![image](https://private-user-images.githubusercontent.com/121779953/358123993-1a8287fc-b205-4156-8342-3f660f15e8fa.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4MTIzOTkzLTFhODI4N2ZjLWIyMDUtNDE1Ni04MzQyLTNmNjYwZjE1ZThmYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01ZDVmMmQwMDAxYWZlMmQwNGMzMzgyNmQ3NDRhNzBmMTI2NWU4ZTlkYjJjMjA5NmNlYWY0YWYzOTIwMjQwMzIwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.HRF65YDSGNiE-NBxKHqp_9QK8R9OP8DblRK3VwxNztM align="left")

* ae sirf CI hey ae success hua then only CD karo - samja

    * Now create a pipeline

* **Create a &lt;mark&gt;Wanderlust-CI&lt;/mark&gt; pipeline**

    ![image](https://private-user-images.githubusercontent.com/121779953/358123234-55c7b611-3c20-445f-a49c-7d779894e232.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4MTIzMjM0LTU1YzdiNjExLTNjMjAtNDQ1Zi1hNDljLTdkNzc5ODk0ZTIzMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yZTBmY2M5ZWUzYTZhOTg1NGJkNmZkZDNmYjZjYzE5MTFiZDI4YTFlYzBhZDBlMzkxZjlmMGYzYTRmYmQ4ODhhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.fLszV77WOTj7WjSrRHkGio7XwDap_QO0vKEdmkkjXLY align="left")

* **Create one more pipeline &lt;mark&gt;Wanderlust-CD&lt;/mark&gt;**

    ![image](https://private-user-images.githubusercontent.com/121779953/358482252-23f84a93-901b-45e3-b4e8-a12cbed13986.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDgyMjUyLTIzZjg0YTkzLTkwMWItNDVlMy1iNGU4LWExMmNiZWQxMzk4Ni5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05NGEyZjVlODBkZjYxMmZhMzE3ODIwZGUyYTY5ZWM5NTc2ZGVjN2YzOTlmZGZjYTgyODU5OWQ2NmE1MGI5MmRhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.SBmoMO60Jg85BG124Hvt5GPrWc6v1k4ywl9atJUhGwU align="left")

    ![image](https://private-user-images.githubusercontent.com/121779953/358482407-ac79f7e6-c02c-4431-bb3b-5c7489a93a63.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDgyNDA3LWFjNzlmN2U2LWMwMmMtNDQzMS1iYjNiLTVjNzQ4OWE5M2E2My5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lYTkzODU2OTU3Y2IzNWQxOGNmNGNjNDcwZGM2YjQyNmQzZjJkOWNjZmIzOTFiNjc0YjVkMzJkOGEwNzhhMTM2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9._qWTqR5JeGvhCEXB6njWMOyHmlwhP0ZJ6Pf9sqhwn9k align="left")

    ![image](https://private-user-images.githubusercontent.com/121779953/358482633-46a5937f-e06e-4265-ac0f-42543576a5cd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDgyNjMzLTQ2YTU5MzdmLWUwNmUtNDI2NS1hYzBmLTQyNTQzNTc2YTVjZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jZjhhMDk3OTYzMDUxMzY0MzljNTA0YTFmOGNjZTQ1NGYxMWY3N2Y1YWM4YmMyYzIwOWZhNmU4YWNiNzJiOTlmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.i36twuR057dizohtoGK-DxGZY8TK8cWIRKNJt-lGpxQ align="left")

* deploy kaisa karega- argocd - aapka ae jo cluster hey us cluster ko argocd key sath connect karna padtha hey

* sabsey pehley

* argocd login url —usernamme admin → y → password

* argocd cluster list


* **Provide permission to docker socket so that docker build and push command do not fail (Jenkins Worker)**


```bash
chmod 777 /var/run/docker.sock</span>
</code></pre><p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/358484969-e231c62a-7adb-4335-b67e-480758713dbf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDg0OTY5LWUyMzFjNjJhLTdhZGItNDMzNS1iNjdlLTQ4MDc1ODcxM2RiZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04OGExMDNjMGE1YWEzNTIzNDk3NTljM2IxMTJhYTI2ZWI3Y2ZiZjc2OWZlNTZmZTVmYzhmMjI2ZjJkZmJlN2QzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.VPlj5kL-v6vudsnMXrlq_tLgWsEDxpjPPP70QqWNBPQ"><img src="https://private-user-images.githubusercontent.com/121779953/358484969-e231c62a-7adb-4335-b67e-480758713dbf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDg0OTY5LWUyMzFjNjJhLTdhZGItNDMzNS1iNjdlLTQ4MDc1ODcxM2RiZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04OGExMDNjMGE1YWEzNTIzNDk3NTljM2IxMTJhYTI2ZWI3Y2ZiZjc2OWZlNTZmZTVmYzhmMjI2ZjJkZmJlN2QzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.VPlj5kL-v6vudsnMXrlq_tLgWsEDxpjPPP70QqWNBPQ" alt="image" /></a></p>
<ul>
<li><p><strong>Go to Master Machine and add our own eks cluster to argocd for application deployment using cli</strong></p>
<ul>
<li><strong>Login to argoCD from CLI</strong></li>
</ul>
</li>
</ul>
<pre><code class="lang-bash">     argocd login 52.53.156.187:32738 --username admin
</code></pre>
<p><strong>Tip</strong></p>
<p>52.53.156.187:32738 --&gt; This should be your argocd url</p>
<p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/358488344-7d05e5ca-1a16-4054-a321-b99270ca0bf9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDg4MzQ0LTdkMDVlNWNhLTFhMTYtNDA1NC1hMzIxLWI5OTI3MGNhMGJmOS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wM2QwMjNkYTRlMzYyNzg3YmVmODYwMzMzN2IwZWM5ODcxNzQ4YTY5YmVjZTY5MGY2ZDBiZmM5MzRkZGZkOWM3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.gMmog8PZCOxINHYJWAUKJ1dhzLJneb5xl48TU6oERv0"><img src="https://private-user-images.githubusercontent.com/121779953/358488344-7d05e5ca-1a16-4054-a321-b99270ca0bf9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDg4MzQ0LTdkMDVlNWNhLTFhMTYtNDA1NC1hMzIxLWI5OTI3MGNhMGJmOS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wM2QwMjNkYTRlMzYyNzg3YmVmODYwMzMzN2IwZWM5ODcxNzQ4YTY5YmVjZTY5MGY2ZDBiZmM5MzRkZGZkOWM3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.gMmog8PZCOxINHYJWAUKJ1dhzLJneb5xl48TU6oERv0" alt="image" /></a></p>
<ul>
<li><strong>Check how many clusters are available in argocd</strong></li>
</ul>
<pre><code class="lang-bash">argocd cluster list
</code></pre>
<p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/358492051-76fe7a45-e05c-422d-9652-bdaee02d630f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDkyMDUxLTc2ZmU3YTQ1LWUwNWMtNDIyZC05NjUyLWJkYWVlMDJkNjMwZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02YTFhNzUwMWFkNzA1ODcxYTE5ZGY4ZDJhMDE5ZDExZWU1YTAwMjdlMzgzMzRiZDQ5ZDI1ZjZiNjNhYTkwMTkzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.kn9qN78ZAXGaVbekTCdcI1bgr-YL_hzxvAka_QmZp-8"><img src="https://private-user-images.githubusercontent.com/121779953/358492051-76fe7a45-e05c-422d-9652-bdaee02d630f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDkyMDUxLTc2ZmU3YTQ1LWUwNWMtNDIyZC05NjUyLWJkYWVlMDJkNjMwZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02YTFhNzUwMWFkNzA1ODcxYTE5ZGY4ZDJhMDE5ZDExZWU1YTAwMjdlMzgzMzRiZDQ5ZDI1ZjZiNjNhYTkwMTkzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.kn9qN78ZAXGaVbekTCdcI1bgr-YL_hzxvAka_QmZp-8" alt="image" /></a></p>
<ul>
<li><strong>Get your cluster name</strong></li>
</ul>
<pre><code class="lang-bash">kubectl config get-contexts
</code></pre>
<p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/358492383-4cab99aa-cef3-45f6-9150-05004c2f09f8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDkyMzgzLTRjYWI5OWFhLWNlZjMtNDVmNi05MTUwLTA1MDA0YzJmMDlmOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zNDE3MTczMzJmNWI3YWEyYTQ5NzdlNWFiMjNkYjliM2VkOTg4NjAzZDU2MTdhNjM0M2E0NTQyZTgzN2Q0OGQ2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.UxnuOQ2eA-LSNeOaiqXV9Q4k-GEqjuGduLhTjLJqQhI"><img src="https://private-user-images.githubusercontent.com/121779953/358492383-4cab99aa-cef3-45f6-9150-05004c2f09f8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDkyMzgzLTRjYWI5OWFhLWNlZjMtNDVmNi05MTUwLTA1MDA0YzJmMDlmOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zNDE3MTczMzJmNWI3YWEyYTQ5NzdlNWFiMjNkYjliM2VkOTg4NjAzZDU2MTdhNjM0M2E0NTQyZTgzN2Q0OGQ2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.UxnuOQ2eA-LSNeOaiqXV9Q4k-GEqjuGduLhTjLJqQhI" alt="image" /></a></p>
<ul>
<li><strong>Add your cluster to argocd</strong></li>
</ul>
<pre><code class="lang-bash">argocd cluster add Wanderlust@wanderlust.us-west-1.eksctl.io --name wanderlust-eks-cluster
</code></pre>
<p><strong>Tip</strong></p>
<p><a target="_blank" href="mailto:Wanderlust@wanderlust.us-west-1.eksctl.io">Wanderlust@wanderlust.us-west-1.eksctl.io</a> --&gt; This should be your EKS Cluster Name.</p>
<p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/358492765-0f36aafd-bab9-4ef8-ba5d-3eb56d850604.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDkyNzY1LTBmMzZhYWZkLWJhYjktNGVmOC1iYTVkLTNlYjU2ZDg1MDYwNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00MjQzMmY1ZGEwNDRmNzE4YzRlMTk0MTI0NWM3YTZmOTNkYThmOGFhYTk0NmUzNmRjNTEwZGM0OTcwMDA5ZDUwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.hq6nCj3bzUlW_uKxD1lAI7OF-cw3_afu19iTyXFgYRs"><img src="https://private-user-images.githubusercontent.com/121779953/358492765-0f36aafd-bab9-4ef8-ba5d-3eb56d850604.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDkyNzY1LTBmMzZhYWZkLWJhYjktNGVmOC1iYTVkLTNlYjU2ZDg1MDYwNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00MjQzMmY1ZGEwNDRmNzE4YzRlMTk0MTI0NWM3YTZmOTNkYThmOGFhYTk0NmUzNmRjNTEwZGM0OTcwMDA5ZDUwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.hq6nCj3bzUlW_uKxD1lAI7OF-cw3_afu19iTyXFgYRs" alt="image" /></a></p>
<ul>
<li><p><strong>Once your cluster is added to argocd, go to argocd console <mark>Settings --&gt; Clusters</mark> and verify it</strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358496259-4490b632-19fd-4499-a341-fabf8488d13c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDk2MjU5LTQ0OTBiNjMyLTE5ZmQtNDQ5OS1hMzQxLWZhYmY4NDg4ZDEzYy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yM2Y1MmFlOWI1NDJiMWM2MTgzMzQzMGExNjU5ODUzYmNlOGQ0ZmZjNmYzMDcwMmUyNDM4Mzg5YzQzZjNmNzI5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.PTYlBUA0mTYdsl-hcr9DWdbAE3dWiWZEV5MOLgjX4Ag" alt="image" /></p>
</li>
<li><p><strong>Go to <mark>Settings --&gt; Repositories</mark> and click on <mark>Connect repo</mark></strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358486795-cc8728e5-546b-4c46-bd4c-538f4cd6a63d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDg2Nzk1LWNjODcyOGU1LTU0NmItNGM0Ni1iZDRjLTUzOGY0Y2Q2YTYzZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kMGEyMjBkZDc1ZThlYzRkM2JkYmQ0Y2VlMzFlMzBiZWQzOWYzZGNjZjU3MzJhYjFjYzIyODNiMWRiNzcwNmQ1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.i6AXiJPmTgN0AfQ4ZnlDKUbMPIwlD-C6QWjvOjvo0Vg" alt="image" /></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358493734-eb3646e2-db84-4439-a11a-d4168080d9cc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDkzNzM0LWViMzY0NmUyLWRiODQtNDQzOS1hMTFhLWQ0MTY4MDgwZDljYy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05YzMyZDY5ZDYyN2JkMGE2YjgyMjE1ZmI3MTEyYzc3ZmYzMDFmMmNhYzE2YTUwMTdhMGI4NGIwOTlhYjAxYmZhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.Q2KweK-jA8P0vwg_o-Dvka4vUOWYJp4JAIKYo6g8j90" alt="image" /></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358493880-a07f8703-5ef3-4524-aaa7-39a139335eb7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDkzODgwLWEwN2Y4NzAzLTVlZjMtNDUyNC1hYWE3LTM5YTEzOTMzNWViNy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wNTdiZTdhYmFhM2ExOGY1MGRmNWEyMTljOTYwYzE0ZDk0NzM4NmJkZGRhMzMzYWM2NmQ3ZDA2Y2Q3ZTVkNDVhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.ASuMUkbHh3RvnDGAKjzsBSU0cy7cZUgBCTLXayjJpsc" alt="image" /></p>
</li>
</ul>
<p><strong>Note</strong></p>
<p>Connection should be successful</p>
<ul>
<li><strong>Now, go to <mark>Applications</mark> and click on <mark>New App</mark></strong></li>
</ul>
<p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/358495870-ec2d7a51-d78f-4947-a90b-258944ad59a2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDk1ODcwLWVjMmQ3YTUxLWQ3OGYtNDk0Ny1hOTBiLTI1ODk0NGFkNTlhMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01ZjI4OGUzMWVjMTEzMzcyNTgxYTY2MmJhZGU3NWUxM2RhMGYzYjU1ZGNjOTc0ZjQ5OGE3NTcwZTFjOGY5MDgxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.-s2-M3a-ceAAfMDerkTd1vIIKW5eqhBoILRPO6av_Dc"><img src="https://private-user-images.githubusercontent.com/121779953/358495870-ec2d7a51-d78f-4947-a90b-258944ad59a2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDk1ODcwLWVjMmQ3YTUxLWQ3OGYtNDk0Ny1hOTBiLTI1ODk0NGFkNTlhMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01ZjI4OGUzMWVjMTEzMzcyNTgxYTY2MmJhZGU3NWUxM2RhMGYzYjU1ZGNjOTc0ZjQ5OGE3NTcwZTFjOGY5MDgxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.-s2-M3a-ceAAfMDerkTd1vIIKW5eqhBoILRPO6av_Dc" alt="image" /></a></p>
<p><strong>Important</strong></p>
<p>Make sure to click on the <mark>Auto-Create Namespace</mark> option while creating argocd application</p>
<p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/358494979-55dcd3c2-5424-4efb-9bee-1c12bbf7f158.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDk0OTc5LTU1ZGNkM2MyLTU0MjQtNGVmYi05YmVlLTFjMTJiYmY3ZjE1OC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00YWVhNjEyOTViYzc4NzQ4MmZlYTMxYTNlODZlMTJjOTg2YTk4ZGI1NDkyOTE3MDY0M2Q1ZGYzODNhZWJmNzVhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.1zxw0zHeq_xPMowxU-8gDvFKATTymo3zyM71NgQ2EbI"><img src="https://private-user-images.githubusercontent.com/121779953/358494979-55dcd3c2-5424-4efb-9bee-1c12bbf7f158.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDk0OTc5LTU1ZGNkM2MyLTU0MjQtNGVmYi05YmVlLTFjMTJiYmY3ZjE1OC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00YWVhNjEyOTViYzc4NzQ4MmZlYTMxYTNlODZlMTJjOTg2YTk4ZGI1NDkyOTE3MDY0M2Q1ZGYzODNhZWJmNzVhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.1zxw0zHeq_xPMowxU-8gDvFKATTymo3zyM71NgQ2EbI" alt="image" /></a></p>
<ul>
<li><p>Destination select - cluster url and select namespace</p>
</li>
<li><p><strong>Congratulations, your application is deployed on AWS EKS Cluster</strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358496521-bc2d9680-fe00-49f9-81bf-93c5595c20cc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDk2NTIxLWJjMmQ5NjgwLWZlMDAtNDlmOS04MWJmLTkzYzU1OTVjMjBjYy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zNTkxMjk0Y2Q2ZWU3Zjg3MzBlODJiMjIyZThhMDk2YjhiYTBhNzg4MDg0YmNmYWU0YmVmY2RjNTNiMGZhNjliJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.KmvvTrLwlzRBoOhKgBovdxd4R7B5U4lOGLOVXwc3KRU" alt="image" /></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358497007-1ea9d486-656e-40f1-804d-2651efb54cf6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDk3MDA3LTFlYTlkNDg2LTY1NmUtNDBmMS04MDRkLTI2NTFlZmI1NGNmNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02ZGUyYjJiZmQ1NTE0NjZlZjhmNmNiOTUwMzIxZTE3NjZhYmIzZjcyYTRiY2MzMGU3MGY3YzMxODE0NjcwOGI5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.bMymLT8vGXYbdXw_-imryjgoZlA6GthgIwz1D4DpKr0" alt="image" /></p>
</li>
<li><p><strong>Open port 31000 and 31100 on worker node and Access it on browser</strong></p>
</li>
</ul>
<pre><code class="lang-bash">&lt;worker-public-ip&gt;:31000
</code></pre>
<p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/358497382-a4b2a4b4-e1aa-4b22-ac6b-f40003d0723a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDk3MzgyLWE0YjJhNGI0LWUxYWEtNGIyMi1hYzZiLWY0MDAwM2QwNzIzYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mZGU1MWI1MjEyNDZjZDM4ZDYzYzQzYjU5MGJlYzBlYzJiYzNmMmMzNzlhYWQ5ZjZhMjYwMTE0MWQ4MmFhZjU1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.dVzrGEFx_P4yIeLizryKdTz9fcXj_-eAPrIWyVInN24"><img src="https://private-user-images.githubusercontent.com/121779953/358497382-a4b2a4b4-e1aa-4b22-ac6b-f40003d0723a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NDk3MzgyLWE0YjJhNGI0LWUxYWEtNGIyMi1hYzZiLWY0MDAwM2QwNzIzYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mZGU1MWI1MjEyNDZjZDM4ZDYzYzQzYjU5MGJlYzBlYzJiYzNmMmMzNzlhYWQ5ZjZhMjYwMTE0MWQ4MmFhZjU1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.dVzrGEFx_P4yIeLizryKdTz9fcXj_-eAPrIWyVInN24" alt="image" /></a></p>
<ul>
<li><p><strong>Email Notification</strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/358525165-0ab1ef47-f939-4618-8651-6aa9274721f4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzU4NTI1MTY1LTBhYjFlZjQ3LWY5MzktNDYxOC04NjUxLTZhYTkyNzQ3MjFmNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02N2Y0MzY5OGFkNGNhYmEyMzU4Y2FkNTEzOWViZDZiOTU3NDMxMTI4YzQ3NDBlOWE1MzQwOTZjNzhlZWZjMDdlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.GH9LWhdFq6tsUqEAF8jsFhJuzT_m8TZoHnxx-vziOhQ" alt="image" /></p>
</li>
</ul>
<p># Meanwhile we will setup prometheus and grafana</p>
<ul>
<li><p>sab sey pehle ae samjo helm kya hotha hey - helm ek package manager</p>
<ul>
<li><p>agar mujhey patha hey eks kya hey - eks is a kubernates service by aws webservice - uskey andar jo jo components humko patha hey</p>
</li>
<li><p>jo humko pata hey toh baar baar kiun edit karey - kya mai promethus .yaml mey ae saare configurations daldunga</p>
</li>
<li><p>helm mey ae saari configuration mey already dali hui hey , eks key components already helm mey hey</p>
</li>
<li><p>aapko helm install karna hey agar ./get-helm.sh run karenge na toh install hojatha hey helm</p>
</li>
</ul>
</li>
<li><ul>
<li>once pipeline deployment is done</li>
</ul>
</li>
<li><ul>
<li><p>jenkins mey ek iam role banana bhulge - iam - create a role - aws service - ec2→ specific role - admin access → ec2-wanderlust-role</p>
<ul>
<li><p>is role ko master node pey attach karne wala - actions - security - modify iam role - select the iam role - and attach it .</p>
</li>
<li><p>now i will run v1.1.</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>kya aap grafana through dashnoards mey - merey k8s key namespaces key pods hey uska dashboard dikha sakthey ho</p>
<h2 id="heading-how-to-monitor-eks-cluster-kubernetes-components-and-workloads-using-prometheus-and-grafana-via-helm-on-master-machine"><strong>How to monitor EKS cluster, kubernetes components and workloads using prometheus and grafana via HELM (On Master machine)</strong></h2>
<ul>
<li><strong>Install Helm Chart</strong></li>
</ul>
<pre><code class="lang-bash">curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
</code></pre>
<pre><code class="lang-bash">chmod 700 get_helm.sh
</code></pre>
<pre><code class="lang-bash">./get_helm.sh
</code></pre>
<ul>
<li><strong>Add Helm Stable Charts for Your Local Client</strong></li>
</ul>
<pre><code class="lang-bash">helm repo add stable https://charts.helm.sh/stable
</code></pre>
<ul>
<li><strong>Add Prometheus Helm Repository</strong></li>
</ul>
<pre><code class="lang-bash">helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
</code></pre>
<ul>
<li><strong>Create Prometheus Namespace</strong></li>
</ul>
<pre><code class="lang-bash">kubectl create namespace prometheus
</code></pre>
<pre><code class="lang-bash">kubectl get ns
</code></pre>
<ul>
<li><strong>Install Prometheus using Helm</strong></li>
</ul>
<pre><code class="lang-bash">helm install stable prometheus-community/kube-prometheus-stack -n prometheus
</code></pre>
<ul>
<li><strong>Verify prometheus installation</strong></li>
</ul>
<pre><code class="lang-bash">kubectl get pods -n prometheus
</code></pre>
<ul>
<li><strong>Check the services file (svc) of the Prometheus</strong></li>
</ul>
<pre><code class="lang-bash">kubectl get svc -n prometheus
</code></pre>
<ul>
<li><strong>Expose Prometheus and Grafana to the external world through Node Port</strong></li>
</ul>
<p><strong>Important</strong></p>
<p>change it from Cluster IP to NodePort after changing make sure you save the file and open the assigned nodeport to the service.</p>
<pre><code class="lang-bash">kubectl edit svc stable-kube-prometheus-sta-prometheus -n prometheus
</code></pre>
<p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/361246828-90f5dc11-23de-457d-bbcb-944da350152e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzYxMjQ2ODI4LTkwZjVkYzExLTIzZGUtNDU3ZC1iYmNiLTk0NGRhMzUwMTUyZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04MDVhMDE4NzkzNjhjZDhmMDkxMTEyODNmZmVlYzc4MGUwZWM2MmI5YWM3NzI1ZGRiZWUyZjMxMDE1MDUyOWY0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.blu4U0_ZdKQ6uQWc0Y6UBrOJIpU3xslnqtQfiETK4n0"><img src="https://private-user-images.githubusercontent.com/121779953/361246828-90f5dc11-23de-457d-bbcb-944da350152e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzYxMjQ2ODI4LTkwZjVkYzExLTIzZGUtNDU3ZC1iYmNiLTk0NGRhMzUwMTUyZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04MDVhMDE4NzkzNjhjZDhmMDkxMTEyODNmZmVlYzc4MGUwZWM2MmI5YWM3NzI1ZGRiZWUyZjMxMDE1MDUyOWY0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.blu4U0_ZdKQ6uQWc0Y6UBrOJIpU3xslnqtQfiETK4n0" alt="image" /></a></p>
<ul>
<li><strong>Verify service</strong></li>
</ul>
<pre><code class="lang-bash">kubectl get svc -n prometheus
</code></pre>
<ul>
<li><strong>Now,let’s change the SVC file of the Grafana and expose it to the outer world</strong></li>
</ul>
<pre><code class="lang-bash">kubectl edit svc stable-grafana -n prometheus
</code></pre>
<p><a target="_blank" href="https://private-user-images.githubusercontent.com/121779953/361246947-4a2afc1f-deba-48da-831e-49a63e1a8fb6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzYxMjQ2OTQ3LTRhMmFmYzFmLWRlYmEtNDhkYS04MzFlLTQ5YTYzZTFhOGZiNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mMmEzY2QzYmY1MTM0Y2M1MDMyODQwY2ExOGU3Mjk2OTIzOTdlZDdlNmJhYmYwYTliMTNjNDdhYTIyNTE2Y2M1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.ZnKwiL3vFVN82AOiGgLMVlRKw3TEtmyNSkc4XS7zzF0"><img src="https://private-user-images.githubusercontent.com/121779953/361246947-4a2afc1f-deba-48da-831e-49a63e1a8fb6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzYxMjQ2OTQ3LTRhMmFmYzFmLWRlYmEtNDhkYS04MzFlLTQ5YTYzZTFhOGZiNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mMmEzY2QzYmY1MTM0Y2M1MDMyODQwY2ExOGU3Mjk2OTIzOTdlZDdlNmJhYmYwYTliMTNjNDdhYTIyNTE2Y2M1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.ZnKwiL3vFVN82AOiGgLMVlRKw3TEtmyNSkc4XS7zzF0" alt="image" /></a></p>
<ul>
<li><strong>Check grafana service</strong></li>
</ul>
<pre><code class="lang-bash">kubectl get svc -n prometheus
</code></pre>
<ul>
<li><strong>Get a password for grafana</strong></li>
</ul>
<pre><code class="lang-bash">kubectl get secret --namespace prometheus stable-grafana -o jsonpath=<span class="hljs-string">"{.data.admin-password}"</span> | base64 --decode ; <span class="hljs-built_in">echo</span>
</code></pre>
<p><strong>Note</strong></p>
<p>Username: admin</p>
<ul>
<li><p><strong>Now, view the Dashboard in Grafana</strong></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/361247153-d2e7ff2f-059d-48c4-92bb-9711943819c4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzYxMjQ3MTUzLWQyZTdmZjJmLTA1OWQtNDhjNC05MmJiLTk3MTE5NDM4MTljNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yYTgwOThkYWNlZWM4NjdjZGViZmJlYTUzY2NhZTRkYWRiYzYyZTM1MDhhNDNlZWVkMzAwMmU5MzVjNDllNzlmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.ZWmu8weiPPiscFK20bqPblsDfrXIn_4BO3cbIsB84qU" alt="image" /></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/361247192-3d6652d0-7795-4fe9-8919-f33eac88db73.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzYxMjQ3MTkyLTNkNjY1MmQwLTc3OTUtNGZlOS04OTE5LWYzM2VhYzg4ZGI3My5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yMWJhMWZlYWYwZmQ5MDU3NDRkZDRkMmE0MzMzM2NlNjcxNzZjYjcxZmVlNzc2MDVjZDk3NDZlNjdhMjdiZDdlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.ntB-2wepdK6I7gXOr7z0lmuO6S5IR14wle779zadnwg" alt="image" /></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/361247261-13321ee5-5d7b-4976-b409-25d3b865a42a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzYxMjQ3MjYxLTEzMzIxZWU1LTVkN2ItNDk3Ni1iNDA5LTI1ZDNiODY1YTQyYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iMjVmMDA4ZTY0ODFmYTc5ZTY0MmVlMzY3Njc1NTM1NjViNTQ4YjM4MDJiOTQ3NWQ2ZWE3NjBmODY1MGU5NTVmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.hO1eB2AfPk6gJ9TqIG8tjahfgrvK2iltPnxMIurAdbk" alt="image" /></p>
<p>  <img src="https://private-user-images.githubusercontent.com/121779953/361247331-75a22e4b-ae81-4cad-9c92-21dd90d126a8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDg2ODEzODMsIm5iZiI6MTc0ODY4MTA4MywicGF0aCI6Ii8xMjE3Nzk5NTMvMzYxMjQ3MzMxLTc1YTIyZTRiLWFlODEtNGNhZC05YzkyLTIxZGQ5MGQxMjZhOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNTMxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDUzMVQwODQ0NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hMDJiNTZlNTFlNTE3MDc2NmE0ZTE4MmIzZjhlZTZkNTdhYjU5Mjk2NzE5MDI5OGZlMTIxMjIzMzUxZjdmNGY5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.ubIoIZvSIftgV-6BVZ94jVHcy7bOB7PFuokJc6tG6A8" alt="image" /></p>
</li>
</ul>
<h2 id="heading-clean-up"><strong>Clean Up</strong></h2>
<ul>
<li><strong>Delete eks cluster</strong></li>
</ul>
<pre><code class="lang-bash">eksctl delete cluster --name=wanderlust --region=us-west-1
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748716924874/0fb1cdf2-9679-4ff2-a6df-d166427d70ad.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Docker in One Shot]]></title><description><![CDATA[Agenda:

intoduction to Docker

Docker hotha kya hey , jabbi samajlo jabbi aapko ek cient hey , client key pass laptop hey uskey server pey deploy karna hey , mainey devolop kiya mera own machine machine its working me , but in client location its no...]]></description><link>https://devopsblog1.hashnode.dev/docker-in-one-shot</link><guid isPermaLink="true">https://devopsblog1.hashnode.dev/docker-in-one-shot</guid><dc:creator><![CDATA[Vaseem Shaik]]></dc:creator><pubDate>Thu, 29 May 2025 16:30:04 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-agenda">Agenda:</h1>
<ol>
<li>intoduction to Docker</li>
</ol>
<p>Docker hotha kya hey , jabbi samajlo jabbi aapko ek cient hey , client key pass laptop hey uskey server pey deploy karna hey , mainey devolop kiya mera own machine machine its working me , but in client location its not working</p>
<p>docker sek template banakey image create karkey run kartha hey application on containers - jo b requirements , libraries sab ek image mey rakhey ship karthey hey is image ko kisi b computer mey chala sakthey hey</p>
<p>Docker ek open source tool hey</p>
<ul>
<li><p>Docker aaya .cloud key company thi ae problem ai , inhoney is cheez ko containarised kardiya aur open source kar diya , docker ka janam idhar hua</p>
</li>
<li><p>2013 , publisher hey pycon , 2017 mey CNCF vaha pey ae pauchee , vaha sey bohot log use karrey</p>
</li>
</ul>
<p>Why we use dokcer : kabhi kabhi aapkey computer mey chalri , isliye ki , kuch libarires , versions ,kuch tools isliye vo cheez chalri hey ,dusre computer mey ae cheez nahi ho isliye aapko container or vitua environment banana padtha hey , aur usi virtual environment key vajhasey dusrey computers mey b ae chez chalthi hey</p>
<ul>
<li><p>kya ae docker vm jaisa rehtha hey</p>
</li>
<li><p>vm vs docker -</p>
<ul>
<li><p>irtualization hotha hey usmey virtual machines hothey hey</p>
</li>
<li><p>containerization mey docker , container d , podman containers ho sakthey hey</p>
</li>
<li><p>jo vm hothey hey na , ae ek cheez use karthey hey hypersior , hypervisor aapkey o.s sey jagah resources allocate karletha hey uskey uppar o.s chalatha hey</p>
</li>
<li><p>vm mey khudka operating system hotha hey , vitualizatinon hotha hey bohot load hotha hey multi o.s</p>
</li>
<li><p>containerization ek tool use kartha hey docker engine - ae khud ka o.s use nahi rakhtha vo host key o.s ko use karletha hey</p>
</li>
<li><p>jo apna container bantha hey light weight bantha hey</p>
</li>
</ul>
</li>
</ul>
<h2 id="heading-daigramatically">Daigramatically :</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748455680226/f24764e8-1124-4c06-a00a-ecbe058a78ea.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-docker-architecture-kya-hey">Docker Architecture kya hey :</h2>
<p>Docker kaisa kaam kartha hey → docker mey three important cheez hey</p>
<ul>
<li><p>docker engine : dokcer application container engine iskey uppar containers chalre</p>
</li>
<li><p>docker daemon : docker d or docker daemon - ae containers ko manage karthi hey is docker d key ander aur ek cheez rehtah hey container d - ae ek tool hey</p>
</li>
<li><p>ae containers kaisa banange , kaisa instructions denge -ae docker cli key through chalthey hey vo commands docker daemon ko paunchthey hey , jo ki background process hothi hey ae cotainer dki bolthi hey bhai ae chalado ae karado akrkey</p>
</li>
<li><p>docker client: jaha key docker key jithney b cheeze heyna dekh sakthey hey , toh docker client connect kartah hey api → ko toh aisey cheexe hothey hey backend sey communicate kar sakaey , aur jo b hey dikhadega</p>
</li>
</ul>
<p>iskey backgroup mey docker daemon and cli khel chalare hothey hey</p>
<p># install docker :</p>
<ul>
<li><p>sudo apt-get update -y</p>
</li>
<li><p>sudo apt-get install docker.io - docker enginer , dokcer daemon , docker cli , docker client , containerd , sab miljayega</p>
</li>
<li><p>sudo systemctl status docker</p>
</li>
<li><p>whoami - docker ps - &gt; sudo usermod -aG docker ubuntu</p>
</li>
<li><p>newgrp docker # is command sey aapka group refresh hojayega</p>
</li>
<li><p>docker ps - # docker cli sey docker d ko command bheja containers list dikhavo karkey</p>
</li>
<li><h1 id="heading-docker-images">docker images:</h1>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748457149739/38738e55-0e04-4854-84eb-b44f6216d56e.png" alt class="image--center mx-auto" /></p>
<p>  - docker images kya hotha hey</p>
<p>  - aap kabhi school yah colleg emey kabhi chitte banayethey kya - ek paper mey chotey chotey likhey huey rehthey hey - us chethey sey apni answer script banathey ho - ithna sa chitt apass laratha hey</p>
<p>  - ae hi chitta apkey dost ko dedo vo bhi pass hojayega</p>
<p>  - ae jo chitta hey vo ek image hey - is image chittey sey banathey hey vo aisa samajlo containers</p>
</li>
<li><p>toh us image ko aap kahi pey b daldo - us cheez ka container bana sakthey hey right</p>
</li>
<li><p>vo image bani or likhi jathi ey dockerfile sey , bhaiyya dockerfile sey image - image sey container ban jathi hey lekin image kya hey</p>
</li>
<li><ul>
<li><p>image aek aisa blueprint hey jismey saare steps likhey huey hey , kya aap ek application ko run karnekey liye kya kya chahiye , kaisa environment chahiye , kya kya hona chahiye us image ko directly banakey run kar sakey - its like blueprint</p>
<ul>
<li>docker file mey ek instsructions likhey honge , us instructions key basis pey image banthi hey , us image ko replicate kar sakthey hey kithne b containers bana saktehy hey</li>
</ul>
</li>
</ul>
</li>
<li><p>lets say mai hun, mainey bohot badiya sa notes banaya , us notes sey docker in one short sey ek video or ek image bangayi , aap dekhoge ho sakeytho aap key doston ko bhejogey ae conatiner hothi hey</p>
</li>
<li><p>Agar nutshell b bataun - dockerfile mey ek instructions hothey hey aplications ko jo b required cheeze - is docker file sey image banaega - docker image sey bantha hey docker container</p>
<ul>
<li><p>pre-build images ko b la sakthey hey</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748457306239/bfb5f03f-7233-44db-ac3e-567eaf619eae.png" alt class="image--center mx-auto" /></p>
</li>
</ul>
</li>
</ul>
<p>docker login karlo - docker login sey aapko docker hub mey login karna padtha hey</p>
<ul>
<li><p>account settings → PAT → Generate a new token → read write access</p>
</li>
<li><p>Login suceeded - docker hub aek aisi jagah hey - docker key public saarey images idhar rakhi hothi hey</p>
</li>
<li><p>#mujhey docker image pull karni hey kaisey oull karunag -</p>
<ul>
<li><p>docker pull hello-world</p>
</li>
<li><p>docker images - list of all docker images</p>
</li>
<li><p>is image ko kya karna hey , is image sey bantha hey container</p>
</li>
<li><p>docker run hello-world</p>
</li>
<li><p>docker pull mysql # mysql ko run karneykey liye jo image bani hogi vo bhi download kardega</p>
</li>
<li><p>mysql ek server hotha hey login honekey liye usernname pasword dena padtha hey</p>
</li>
<li><p>docker run -e MYSQ_ROOT_PASSWORD=root mysql</p>
</li>
<li><p>docker ps - mysql ka container chalra hoga 0 is container ka b lifecycle hotah hey → chalrahey , chalrahoga , rukh jayega , phir wapas sey restart , phir kill hojayega .</p>
</li>
<li><p>docker stop conatinet_id → vo container ko rok dega</p>
</li>
<li><p>agar mujhey background mey chalana hey toh -d = detached mode mey use karo</p>
</li>
<li><p>Mainey jo b pull kiya vo publically available image ley , lets say merey pass ek java ka project hey</p>
</li>
<li><p>us java ka projetc ka conatiner mujhey banana hey iskey liye mujhey dockerfile likhni hogi - chala dockerfile banathey ho</p>
</li>
<li><ul>
<li><p><code>shubham loundhe - simple-java</code> -clone it - as a devops engineer aapko pata chalna hey ki is java ko run karnekey liye dockerfile likhni aani chahiye</p>
<ul>
<li><p>vim Dockerfile</p>
<pre><code class="lang-dockerfile">  <span class="hljs-comment"># pulla  abase images whcih gives all required tools and libraries</span>
  <span class="hljs-keyword">FROM</span> openjdk:<span class="hljs-number">17</span>-jdk-alphine

  <span class="hljs-comment"># create a folder where the app code will be stored</span>
  <span class="hljs-keyword">WORKDIR</span><span class="bash"> /app</span>
  <span class="hljs-comment"># copy the source code form your host machine to conatiner</span>
  <span class="hljs-keyword">COPY</span><span class="bash"> . . </span>
  <span class="hljs-keyword">COPY</span><span class="bash"> src/Main.java /app/Main.java</span>
  <span class="hljs-comment"># Compine the application code </span>
  <span class="hljs-keyword">RUN</span><span class="bash"> javac src/Main.java</span>
  <span class="hljs-comment"># Run the application code </span>
  <span class="hljs-keyword">CMD</span><span class="bash"> [<span class="hljs-string">"java"</span> , <span class="hljs-string">"Main"</span>]</span>
</code></pre>
<p>  Docker file hotha kya hey , aisa samajlo kuch instructions hothey hey us instricions key vajaheysey aapka applicaton run hoga</p>
</li>
<li><p>instrictions kya hotah hey us key andar - application code , libraries , jo o.s use akrni hey uskey bharemey , frmework , tools , packages ae sab rehni chahiye</p>
</li>
<li><p>ae box ko bananey key liye dockerfile mey istructions dena hey</p>
</li>
<li><p>kabhi maggie banaye - maggie banaye instructions rehthey hey right</p>
</li>
<li><p>step1. kadai , step2. pani step3. masala, step4.maggie step5. gas - to build recipe for maggir , agar tum ae recipe dedi vo us recipe sey maggie banayega</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p>ae java application run karna hey , java , mujhey first ek environment hona hey aur uskey andar java honi hey</p>
</li>
<li><p>Base image: FROM openjdk:- &gt; image tag kya hotha hey - image ka version hotha hey</p>
</li>
<li><p>issey ek environment miljatha hey</p>
</li>
<li><p>mujhey ab working directory banana hey , workdir container mey folder bantha hey uskey andar merey application code copy karunag</p>
</li>
<li><p>RUN javac main.java #mujhey agar koi file or command run karni hey mai RUN command use kartha hun</p>
</li>
<li><p>Jabbi aap ek line likhthey hey - jabb ek image banthi hey har ek line ek layer hothi hey jissey vo image hori hey</p>
</li>
<li><p>ae jo intermeditae container ko liye lines hothey hey</p>
</li>
<li><p>jo cmd hotha hey ek special command hotha hey aapka conatiner bun aye us container ko run karnekey liye - CMD use karthey hey</p>
</li>
<li><p>pani oiney straw chahiye right - vaisa hi cmd - command container run karne use akrthey hey</p>
</li>
<li><p>so ae command nahi likhog tabhi container banega , agar container likhre ho container banneykey badh execute hojayega</p>
</li>
<li><p>is comamnd ko overwride kar sakthey ho - while running the octainer</p>
</li>
<li><p>is ka b bada bhai hey - ENTRYPOINT - entry point overwride nahi ho saktha - ae aisey command hey intermediate container bananey nahi hotha - container mey command inject hoyega</p>
</li>
</ul>
</li>
<li><p>docker build -t java-app . location - steps are layers - ab aapki java name ki image ban gayi</p>
</li>
<li><p>docker run java-app</p>
</li>
<li><p>clone python project - flask-app-ecs → app.py file kuch toh code hey api’s detha hey</p>
</li>
<li><pre><code class="lang-dockerfile">    git clone url 
    vim Dockerfile

    <span class="hljs-keyword">FROM</span> Python:<span class="hljs-number">3.7</span>

    <span class="hljs-keyword">WORKDIR</span><span class="bash"> /app</span>

    <span class="hljs-keyword">COPY</span><span class="bash"> . . </span>

    <span class="hljs-keyword">RUN</span><span class="bash"> pip install -r requirements.txt</span>

    <span class="hljs-keyword">ENTRYPOINT</span><span class="bash"> <span class="hljs-string">"python"</span>,<span class="hljs-string">"run.py"</span></span>
</code></pre>
<p>  - docker build -t flask-app .</p>
</li>
<li><p>docker run -p 80:80 flask-app</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748461881511/bfb3ac84-fb05-40c2-b54f-396de7f36b3c.png" alt class="image--center mx-auto" /></p>
<p>jaisa mainey aapko baytaya ae aapka o.s (host) hey iskey pass resources hothey hey jo docker engine share karletha hey aur containers ko chalaletha hey jo container key andar app chalra hey port number 80 sey chalra hey aur appka 0.s ka port dono ko bind karana padtha hey</p>
<ul>
<li><p>us cheez key liye publish kara na pastha hey -p host:container port</p>
</li>
<li><p>is aapko background mey chalana hey background mey run kardo -d</p>
</li>
<li><p>docker run -d -p 80:80 flask-app</p>
</li>
<li><p>docker ps - karkey dekhunga mera app chalra hey yah nahi</p>
</li>
<li><p>port enable karni chahiye dekhnekey liye - publically open karna padtha hey</p>
</li>
<li><p>agar aapko lagra hey aapka app time lera hey toh logs check kar sakthey hey docker key andar kya chalra hey - <code>docker logs container_id</code></p>
</li>
<li><p>har bar loga vala command chalana padra - aisa kuch hey kya ki aapka container atatch hojaye is screen per ki ssarey logs realtime dekh pau - <code>docker attach cont_id</code></p>
</li>
<li><p>aap cont stop kar sakthey hey - <code>docker stop cont_id</code></p>
</li>
<li><p>jaisa aapne stop kiya vaisa hi start kar sakthey hey - <code>docker start cont_id</code></p>
</li>
<li><p>aapka mysql b chalra , kya mysql ka data base hey uskey andar ghuskey access kar saktah hun ? - &gt; yes → <code>docker exec -it cont_id bash</code></p>
<ul>
<li><p><code>mysql -u root -p root</code></p>
</li>
<li><p><code>show databases;</code></p>
</li>
<li><p><code>create database devops;</code></p>
</li>
<li><p><code>exit</code></p>
</li>
</ul>
</li>
</ul>
<p>docker ps - running containers dikhthey hey</p>
<p>docker images - aapkey pass jithney b images vo dikhthey hey</p>
<p>mujhey ubuntu chalana hey - aisa container chalana hey hamesha running mey ho mac mey ubuntu chalana hey</p>
<p><code>docker run -itd ubuntu</code></p>
<h1 id="heading-docker-networking">Docker Networking :</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748462802841/8824f18d-6567-42da-a9ef-f288aa906a32.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>Docker ki networling kya hotha hey</p>
</li>
<li><p>lets say aapka aek computer hey is computer mey ek docker ka conatiner chalra hey , aapkey pass aur ek docker container chalra ek flask app aur mysql ka container hey - ae flask app ka container hey ek isolated , aur vo b isolated - ae flask mysql sey bath nai kar saktha , mysql flask sey bath nahi kar saktha</p>
<ul>
<li><p>agar aapko in dono key beechmey communication karwwani hey toh aapko ek network chahiye hoga</p>
</li>
<li><p>isliye aathey hey concept aapka docker networks</p>
</li>
</ul>
</li>
<li><p>docker networks 7 prakar key hothey hey</p>
<ol>
<li><p>Host network - ki aapki docker ocnt netwrok hey aur aapkey host machine ki network hey vo same rahega</p>
<ul>
<li>toh aapka port number 80 host mey chalra hey aur aapne docker network mey host dala hua hey docker cont ka b port number 80 chalega</li>
</ul>
</li>
<li><p>default bridge : jaisey aapka ae cont hey aapka ae host hey - , is host sey is cont pey network bananey key liye aapko ek pull bandna padthey hey - by default dethey hey</p>
</li>
<li><p>user defined brige (custom_bridge): khudna network create kar sakthey hye</p>
</li>
<li><p>None: matlab is docker conainer mey koi netwrok nahi , na ussey koi bath kar skathey hey , na vo kisi sey bath kar skatha hey , completely isolated , na inetrnet chahiye container ko ae netwrok ded-</p>
</li>
<li><p>macvlan : macvlan basically mac address , 2 mac address pey communicate kar saktha hey - jab docker swarm cluster rehtah hey thab use kar sakthey</p>
</li>
<li><p>ipvlan</p>
</li>
<li><p>overlay</p>
<ul>
<li>ae jo b 7 hey isko drivers bolthey hey</li>
</ul>
</li>
</ol>
</li>
<li><p>ae jo last three ja docker swarm cluster rehtah hey thab use karthey hey</p>
</li>
<li><p>docker swarm kya hotah hey , abhi is laptop pey docker cont banaye - agar 50 las mey docker ocntainer pey banavo aur uso sabko ek sath chalav</p>
<ul>
<li><p>cluste boltheyhey , aajkal kubernates use karthey hey uskey liye ae last three use karthey hey</p>
</li>
<li><p>frst 4 humko important hey</p>
</li>
</ul>
</li>
<li><p>kaisey padthey hey docker network - docker network ls</p>
</li>
<li><p>abhi three network aapkey samney hey</p>
</li>
<li><ul>
<li>docker network create mynetwork -d bridge</li>
</ul>
</li>
</ul>
<p>iska use hoga ek project mey- jab hum two tier ka project karenge thab - samjo ek flask aap and mysql conatienr chlara - ae jo flask app hey ae ek docker cont hey aur mysql b - ab dono jo docker conatiner independently chalre mujhey koi problem nahi aari - agar merko is dono ko communicate karani hey toh use karthey hey docker networks</p>
<p>#connection of two tier application</p>
<ul>
<li><p>go to github - clone two tier flasp app- clone it</p>
</li>
<li><p>ab is app mey app.py , kya ae application kissi data base ko connect kartha hey - &gt; ismey likha hua configure my sql from environment variables - jo envi ronment variales hey pass karna padtha hey ae application run karwanekey liye</p>
</li>
<li><p>docker run -e → issey environment pass karthey hey</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748464680452/a9f7f24c-3084-41d2-9e95-107695151408.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>vim Dockerfrile</p>
<pre><code class="lang-dockerfile">  <span class="hljs-keyword">FROM</span> python:<span class="hljs-number">3.9</span>-slim

  <span class="hljs-keyword">WORKDIR</span><span class="bash"> /app</span>
  <span class="hljs-keyword">RUN</span><span class="bash"> apt-get update\
      &amp;&amp; apt-get upgrade -y \
      &amp;&amp; apt-get install -y gcc default-libmysqlclient-dev pkg-conf</span>

  <span class="hljs-keyword">COPY</span><span class="bash"> requiremnets.txt</span>

  <span class="hljs-keyword">RUN</span><span class="bash"> pip install mysqlclient</span>
  <span class="hljs-keyword">RUN</span><span class="bash"> pip install --no-cache-dir -r requirements.txt</span>

  <span class="hljs-keyword">COPY</span><span class="bash"> . .</span>

  <span class="hljs-keyword">CMD</span><span class="bash"> [<span class="hljs-string">"python"</span>,<span class="hljs-string">"app.py"</span>]</span>
</code></pre>
<ul>
<li><p>docker build -t two-tier-backend .</p>
</li>
<li><p>jo mysql hey already usiko hi utilise karlunga</p>
</li>
<li><p>kya kya variable pass karna app.py mey dekhlunga</p>
</li>
<li><p><code>docker run -d -e MYSQL_HOST=mysql -e MYSQL_USER=root -e MYSQL_PASSWORD=root -e MYSQL_DB=devops -p 5000:5000 two-tier-backend:latest</code></p>
</li>
<li><p><code>docker ps -a</code> - simple nahi dikhara matlab exit hogaya karkey</p>
</li>
<li><p><code>docker logs cont_id</code> - logs check karey</p>
</li>
<li><ul>
<li><p>kiun chalra nahi matlab - is flask network mey mysql ka cont hi mil hi nahi raha</p>
<ul>
<li><p><code>docker stop mysql_id &amp; docker rm cont_id</code></p>
</li>
<li><p>mai ab ek mysql cont banaunga ussey pehle ek network create karlunga - two-tier drive hey bridge</p>
<ul>
<li><p>ae network dono containers ko dedunga</p>
</li>
<li><p><code>docker run -d --name mysql --network two-tier -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=devops mysql</code></p>
</li>
</ul>
</li>
<li><p><code>docker run -d --network two-tier -e MYSQL_HOST=mysql -e MYSQL_USER=root -e MYSQL_PASSWORD=root -e MYSQL_DB=devops -p 5000:5000 two-tier-backend:latest</code></p>
</li>
</ul>
</li>
</ul>
</li>
<li><p>docker ps - two-tier-backend flask , mysql both are running if i check logs = &gt; docker logs cont_id</p>
</li>
<li><p>docker network ls - ae jo create kiys → docker network inspect cont_id - dono ekhi network toh dono bath kar skathey hey ek sey ek</p>
</li>
<li><p>ab enable kardo 5000 port public to access</p>
</li>
</ul>
</li>
<li><p>docker exec -it mysql_contid bash</p>
</li>
<li><p>mysql -u root -p root</p>
</li>
<li><p>shwo databases;</p>
</li>
<li><p>use devops;</p>
</li>
<li><p>select * from messages;</p>
</li>
</ul>
<h1 id="heading-docker-volume-and-storage">Docker volume and storage:</h1>
<ul>
<li><p>ae jo hum log dekha data base mey data stored hey ae aara application sey - agar aap mey data dalenge toh db mey reflect hora</p>
</li>
<li><p>agar mainey database valey container ko mysql cont ko restrt kardiya kya hoga</p>
</li>
<li><p>docker restart mysql-contid</p>
<ul>
<li><p>docker stop and start refresh hoga - agar mai jakey sql cont mai ab jakey dekhunga toh jo data previously tha vo hey abhi bhi</p>
</li>
<li><p>agar mai restart ki jagah container ko delete kardun toh - docker stop cont_id &amp; docker rm cont-id</p>
</li>
<li><p>docker ka same container vapas run kartha hun - jab mai isko refresh kartha hun saara data ja chuka hoga delete ho chuka hoga</p>
</li>
<li><p>ab ae ek problem hey , ae docker volume and storage -→ae kya hotah hey ae aek tariqa hotah hey docker key through jithey b containers hey uska data persist kara saktha hun</p>
<ul>
<li><p>jissey ki galthi sey delete hojai , restrt , stop and start karey mera data persist rahey</p>
</li>
<li><p>to for ex - ae aapka mysql is ae jo cont iskey andar ssara data hey , agar cont delete hoga toh cont delete hoga</p>
<ul>
<li><p>iska jo data hey usko bind karlethey hey apney host key sath ,apney host hotah hey filesystem hotha hey , usmey ek path folder banalethey hey cont key data key sath , vo jo hotha hey concept bolthey hey volume</p>
</li>
<li><ul>
<li><p>aur is cheez ka command hothah eyy -v or docker volume</p>
<ul>
<li><p>docker volume ls → karunana jo b volumes hey dikh jathi hey</p>
</li>
<li><p>mai khudki volume kaisa create karunga - aap docker volume create mysql-data</p>
</li>
<li><p>ab ae jo volume hey ae kounsey jagah pey rahegi - docker inspect myvolname - ae /var/kib/docker/volumes/mysql-data/_data</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><p>ab mujhey apney container ko is path key sath bind karna hey - &gt; mysql cont abhi key liye delete kardunga &amp; docker rm cont_id</p>
</li>
<li><p>ae jo mysql -vol dithi mai mysql-cont sey bind kardunga</p>
<ul>
<li><p><code>docker run -d --name mysql --v mysql-data:/var/lib/mysql -network two-tier -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=devops mysql</code></p>
</li>
<li><p>mysql ka data stored in /var/lib/mysql</p>
</li>
<li><p>jo b data mai flaskapp sey banauga vo data delete nahi hoga</p>
</li>
<li><p>docker stop cont_id docker rm cont_id -→ ab mai isko delete kardunga toh ky mera mysql ka data b udega</p>
</li>
<li><p>docker volume inspect myvol</p>
</li>
<li><p>sudo su —&gt; cd path = ist ther emy saara data secured hey ,- mai same volume say sam container create karunga</p>
</li>
<li><p>dokcer restart flask_app_id —&gt; as it is stored .</p>
</li>
</ul>
</li>
<li><p># data persist ka aur ek tarika hey kya -→ aap kya karko bahar aajav - ek volume name ka folder banado - cd volumes→ mysql —&gt; ab aap aap key two-tier flask app mey jakey - docker container ka rehtha ha mysql vala - docker stop mysql &amp; docker rm mysql</p>
<p>  #VOLUMES 2 TYPES KEY HOTHEY HEY</p>
</li>
<li><p>1. named based volume:</p>
<ol start="2">
<li>path volume</li>
</ol>
</li>
<li><p>mysql</p>
</li>
<li><p>cd volumes →mysql → saara data backup</p>
</li>
</ul>
<p>agar mai dokcer run mey -v rakhey jo b folder create kiya agar vo folder path dedunga toh b container chalega - isko bolthey path based volume</p>
<ul>
<li>you can save your data with docker volumes.</li>
</ul>
<h1 id="heading-docker-compose">Docker Compose:</h1>
<ul>
<li><p>abhi mainey bohot saara manuall kaam karra hun like , mai baar baar ek two tier flask app mey jatha hun , docker ps kartha hun , agar docker conatiner ko delete karna hey , docker stop or docker rm - &gt; manually karra hun</p>
<ul>
<li>as a devops engineer manually nahi karna , automate karna hey</li>
</ul>
</li>
<li><p>docker compose automate karnemey bohot help kartah hey</p>
<ul>
<li><p>docker compose mey ek configuration file rehtha hey vo aapko bohot madad kar sakthi hey</p>
</li>
<li><p>yet another markup language - &gt; jaha pey key:value pey cheezey pass kardethey -</p>
</li>
<li><p>ab docker compose naame kiun diya , ek aur ek sey zyada containers create karney mey help kartha hey</p>
</li>
<li><p>jo b hum log ney abhi thak kiya docker build ,docker run , docker network , docker volume ae sab aek hi sath mey file sey kar deta hey</p>
</li>
<li><p>docker compose mey multiple docker containers bana sakthey ho, simple ka funda , bananey ka tarika hey combination of build , run , network volumes</p>
</li>
<li><p>docker compose ka version “3.8” - ae syntax ka version hey</p>
</li>
<li><p>aur aap services daloget - i mean kithney containers karkey bata sakthey hey</p>
</li>
<li><p>iskey badh docker build use karthey hey na image lekey -idhar direct image lethey hey - image:→phir environmnet kuch dena hey idhar dey sakthey hey</p>
</li>
<li><p>phir volumes - mysql-data:/var/lib/mysql</p>
</li>
<li><p>networks karrethey - two-tier</p>
</li>
<li><p>port - “3306”:”3306</p>
</li>
</ul>
</li>
</ul>
<ul>
<li><p>abhi flask na image sey nahi hotha , build sey hotha hey - aur iskey liye context lagtha hey - context hey docker file kaha rakhi hui</p>
</li>
<li><p>phir container_name:, ports: “5000”:”5000” , ab environments use kartha hey jo flask environments mey jo chahiye vo , phir networks, vo</p>
</li>
</ul>
<ul>
<li>volumes : jo create kiye uskey name daldo , networks: iska network ka name b daldo</li>
</ul>
<pre><code class="lang-dockerfile"> version: <span class="hljs-string">"3.8"</span>

services:
  mysql:
    <span class="hljs-keyword">user</span>: <span class="hljs-string">"${UID}:${GID}"</span> 
    image: mysql:<span class="hljs-number">5.7</span>
    container_name: mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: devops
      MYSQL_USER: root
      MYSQL_PASSWORD: root
    volumes:
      - ./mysql-data:/var/lib/mysql
      - ./message.sql:/docker-<span class="hljs-keyword">entrypoint</span><span class="bash">-initdb.d/message.sql  </span>
    networks:
      - two-tier
    restart: always
    <span class="hljs-keyword">healthcheck</span><span class="bash">:</span>
      test: [<span class="hljs-string">"CMD"</span>, <span class="hljs-string">"mysqladmin"</span>, <span class="hljs-string">"ping"</span>, <span class="hljs-string">"-h"</span>, <span class="hljs-string">"localhost"</span>, <span class="hljs-string">"-uroot"</span>, <span class="hljs-string">"-proot"</span>]
      interval: <span class="hljs-number">10</span>s
      timeout: <span class="hljs-number">5</span>s
      retries: <span class="hljs-number">5</span>
      start_period: <span class="hljs-number">60</span>s

  flask:
    build:   
        context: .

    container_name: flask-app
    ports:
      - <span class="hljs-string">"5000:5000"</span>
    environment:
      MYSQL_HOST: mysql
      MYSQL_USER: root
      MYSQL_PASSWORD: root
      MYSQL_DB: devops
    depends_on:
      - mysql
    networks:
      - two-tier
    restart: always
    <span class="hljs-keyword">healthcheck</span><span class="bash">:</span>
      test: [<span class="hljs-string">"CMD-SHELL"</span>, <span class="hljs-string">"curl -f http://localhost:5000/health || exit 1"</span>]
      interval: <span class="hljs-number">10</span>s
      timeout: <span class="hljs-number">5</span>s
      retries: <span class="hljs-number">5</span>
      start_period: <span class="hljs-number">30</span>s


volumes:
    mysql-data
networks:
  two-tier:
</code></pre>
<p>is tarah sey aapney badiyasa - docker file banaya → aapko is system mey docker compose ko install karna padega</p>
<ul>
<li><p>sudo apt-get install docker-compose-v2</p>
</li>
<li><p>docker compose up</p>
</li>
<li><p>idhar mey dekho , yaha pey problem , mysql abhi thak bana nahi hey , two-tier flask container mysql sey pehley hi bangaya hey ae toh gadbad hey , ctrl c gracefully stop kardo</p>
</li>
<li><p>ab mai vim docker-compose.yml → ae jo mera flask vala container hey → depends-on : -mysql , jab thak mysql banjatha jab thak mera flask vala banna nahi chahiye .</p>
</li>
<li><p>docker compose up - kehra hey , abhi bhi khera , usney mysql ka container pehley hi bana diya , start kardiya ,entry point bandiya jaisi bangaya usney two tier ko start kar diya , problem kaha aathi hey pata hey , mysql ka pehley ban jatha hey , uskey two-tier flask bantha hey but mysql ka container accept kartha na ready for connections vo badh mey kartha hey , matab jab thak mysql sahi tarikey sey ready nahi hojatha thab tha usko pura ready nahi bol sakthey</p>
</li>
<li><p>isliye aapko ek cheez lagthi hey usko bolthey hey health check , docker compose mey mysql container key sath healthchecks: dalna padthey hey - ismey test key commands dal sakthey hey</p>
</li>
<li><p>ki fro ex: gara mysql mey mai ping kartha hun localhost ko apney passwords key sath , jab thak local host ka ping nahi hotha , thab thak vo retray kartah rahey 5s and 10s once</p>
</li>
<li><p>vaisa hi flaskapp mey b health checks dal sakthey hey</p>
</li>
<li><p>agar aapka health check pass nahi huye restart:kardo always</p>
</li>
</ul>
<p>har baar restart karo jab thak test checks pass nahi hojathey , aur health check baar baar 10s interval mey 5 baar retry karthey raho - ab isko run karthey hey .</p>
<p>just a single command container up hojayega , ab mai detached mode mey run karunga - docker ps</p>
<p>This is how docker compose works.</p>
<h1 id="heading-docker-registry">Docker Registry :</h1>
<ul>
<li><p>Aisa samjo ae jo docker images hey - tow-tier flask or saare images local pey hye , isko kisi server or kisi repository or registry mey store karna hey jaisa ki docker hub , is image ko properly tag karna padega push karna padega ,</p>
</li>
<li><p><code>docker system prune:</code> jithne b aapkey system unsed volumes , betworks , containers , dangling images sab delete kar detha hey</p>
</li>
<li><p><code>docker images - docker rmi -f image_id</code></p>
</li>
<li><ul>
<li><p>multiple images and containers hey toh mai - -&gt; docker images -aq → docker rmi -f $(docker images -aq)</p>
<ul>
<li>docker compose down - containers delete stop kar detha hey aur remove kar detha hey</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>docker registry - jaisey mainey bataya - two-tier flask image hey local mey , merko is image ko repo mey paunchau -jo ki dokcer hub ki repo - docker login -u -p passwor</p>
<ul>
<li><p>ab humko image ko tag karna hey , image tag ka matlab - jo purani latest image hey usko rename kar sakthey hey - agar aapko local pey image store karna hey normal name kaafi hey</p>
</li>
<li><p>agar aapko docker hub pey image rakhni ,, aapka jo b username hey vo us imge name key pehle aani chhaiye</p>
</li>
<li><p>docker image tag two-tier-flask:latest vasee143/two-tier-flask:latest</p>
</li>
<li><p>docker push vasee143/two-tier-flask:latest → ae local sey docker mey mera image pus karra hey</p>
</li>
</ul>
<h1 id="heading-mulsti-stage-docker-builds">mulsti-stage Docker builds</h1>
<ul>
<li><p>docker images - karkey dekho ae jo image hey - jo humney banaya tha</p>
<p>  flask app -ecs ka us image jab b humne build kiya python 3.7 base image utata hey - vo bohot badi image hothi hey , jo mera final image bantha hey na - vo b badi image bankey aatah hey</p>
</li>
<li><p>jab b mera application bohot bada hojayega 0 jab image ka size bada hojayega ae concern hey , problem hey</p>
</li>
</ul>
<p>dokcer images - ae 1.1GB ki hey - ae multi stage docker kya karega aapki image ko stages mey distribute kar detha</p>
<p>aapki image banthi hey - dockerfile sey - uskaimage 1gb - uski ocntainer b bada hotha hey</p>
<p>ek baar aapkey dockerfile mey kya kya cheeze rehthey dekhthey hey</p>
<p>mujhey is size ki reduce karna hey toh merey dokcerfile mey base image hi badi hothi hey toh mai isko reduce kar saktha hun</p>
<p>kabhi kabhi full base images , libraries install karnekey liye jaroori hothi hey</p>
<p>sirf libraries key liye jaroori hothi hey run karnekey liye nahi</p>
<pre><code class="lang-dockerfile"><span class="hljs-comment"># stage1 base image 994mb </span>
<span class="hljs-keyword">FROM</span> python:<span class="hljs-number">3.7</span> AS builder
<span class="hljs-keyword">WORKDIR</span><span class="bash"> /app</span>
<span class="hljs-keyword">COPY</span><span class="bash"> requirements.txt .</span>
<span class="hljs-keyword">RUN</span><span class="bash"> pip install -r requirements.txt</span>
<span class="hljs-comment">#----</span>
<span class="hljs-comment">#stage 2 base image 400mb</span>
<span class="hljs-keyword">FROM</span> python:<span class="hljs-number">3.7</span>-slim
<span class="hljs-keyword">WORKDIR</span><span class="bash"> /app</span>
<span class="hljs-keyword">COPY</span><span class="bash"> --from=builder  /usr/<span class="hljs-built_in">local</span>//lib/python3.7/site-packages/ /usr/<span class="hljs-built_in">local</span>/</span>
  /lib/python3.<span class="hljs-number">7</span>
<span class="hljs-keyword">COPY</span><span class="bash"> . . </span>
<span class="hljs-keyword">ENTRYPOINT</span><span class="bash"> [<span class="hljs-string">"python"</span>,<span class="hljs-string">"run.py"</span>]</span>
</code></pre>
<ul>
<li><p>ae jo base image hey - isko aek alias name dey detha hun → ae sir libraries and packeges build hogi is stage sey - mai nayi stage banaunga uska base image - vo chothi base image use karunga</p>
</li>
<li><p>slim vali jiski size kam rehthi hey sirf run karney key liye</p>
</li>
<li><p>aur wrokdir create karo stage 2 ka - aur packages ko copy karlo from stage 1 then copy karlo code phir run kardo</p>
</li>
<li><p><code>docker build -t flask-app-mini .</code></p>
</li>
<li><p>Humney multi stage build sey 1.gb sey 140 mb thak compress kardiye - that is the power of caching and multistage build hey.</p>
</li>
</ul>
<h1 id="heading-monitoring-and-logging-in-docker">Monitoring and logging in docker</h1>
<ul>
<li><p>toh jaisey apney kiya docker ps - lets sey aapka container chalana hey toh jo humney mini appp banya na usko hi run karkey dekhthey hey</p>
</li>
<li><p>docker run -d -p 80:80 flask-app-mini</p>
</li>
<li><p>ip:80 - this should run - lets say isko debug karna hey</p>
</li>
<li><p>docker logs cont_id - logs dikhege idhar , aap chaho aur ek cheez kar sakthey hey ,</p>
</li>
<li><p>jithney b logs hey ek file mey redirect kar sakthey hey - nohup - kisi b commands ko background mey run arkey file mey store kar detha hey</p>
</li>
<li><p>nohup docker attach cont_id &amp;</p>
</li>
<li><p>ls</p>
<ul>
<li><p>cat nohup.out - aap loga collect kar paarey ho</p>
</li>
<li><p>mai jo b karunga ip:80/thanos - ae servers key logs and monitors kar sakthey hey</p>
</li>
</ul>
</li>
</ul>
<p>Jis tarah sey docker containers mey maza aatha hey kubernatest mey b aatah hey</p>
<h1 id="heading-orchestrating-docker-with-kubernates-introduction">Orchestrating docker with kubernates (Introduction)</h1>
<p>Toh sabsey pehley samjo k8s kya hotha hey - aap docker padthey padhey aapko patah chala ae conecpts hey karkey</p>
<ul>
<li><p>docker hum log directly production mey use nahi karthey - kiunki jaisey abhi mainey kiya docker ps - simple sey mai docker stop kardunga na downtime hojayega - agar docker rm kardunga uska data application delete hojayega</p>
</li>
<li><p>docker containers crash honekey chances zyada hotha hey - production mey isiliye hum conts ko individually nahi chalathey production mey</p>
</li>
<li><p>isliye containers ko orchestrate karthey hey</p>
</li>
</ul>
<p>-Kubernates aek orchetsration tool hey jo docker cont ko manage kartah ehy</p>
<ul>
<li><p>ek docker cont kill hogaya , crash hogaya toh dusra container up hojaye</p>
</li>
<li><p>agar ek docker cont bohot storage and ram zyada lera hey , us storage and ram ko allocate kardo memory jissey ki kuch limits mey hi container chale</p>
</li>
<li><p>jab amazon use karrey hey - jab big billion saley hotah hey - thab bohot zyada load hotah hey - agar crash hojatah ehy thab auto jheal kar detha hey - agar load zyada load aatah hey k8s scale kar detha hey based on criteria , background mey containers hi chalre hothey hey , bus is tarah sey chalre hotey hi uskey pass auto scaling aur auto healing capaticy sey chalre hothey hey</p>
</li>
<li><p>Kubernates mey kuch cheeze hothey hey like</p>
<ul>
<li><p>pods: pods aisa hothey hey ek unit hey iskey andar containers run hothey honge , ek aur multiple pods b run hothey hondey</p>
</li>
<li><p>agar merko der saare pods chahiye (collection of pods(replicas chahiye) humko deployment chahiye - ae jo deployment rehthi hey frontend , backend , data base ki alag banathey hey - un deployments ko ek dusre sey bath karnekey liye network jo chahiye hotha hey aap service sey dethey ho - (connect the deployments to the users)-</p>
</li>
<li><p>ingress - usmey b routing karni hey ingressuse karna padtha hey</p>
</li>
</ul>
</li>
</ul>
<h1 id="heading-projects">Projects:</h1>
<ul>
<li><p>project1: 3 Tier Application with Docker Compose</p>
</li>
<li><p>project2: Deploying a web application with Nginx and mysql</p>
</li>
</ul>
<p>PROJECT2:</p>
<ul>
<li><p>Dosto agar project ki bath karey nginx with mysql - nginx ae industry standard reverse proxy tool hey</p>
</li>
<li><p>now we are gonna pair up nginx and mysql</p>
</li>
</ul>
<h2 id="heading-project-hey-web-app-hey-django-mey-likhey-hey-vo-nginx-ser-server-hoga-djnango-ka-backend-hey-vo-data-base-sey-connect-hoga-mysql-ka">project hey - web app hey (django mey likhey hey ) vo nginx ser server hoga - djnango ka backend hey - vo data base sey connect hoga mysql ka</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748519698731/e2b8dd16-cadf-44a5-b4b6-e7cb5de9bcf8.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>aapko anana hoga -django , django ka application , vo connetc hoga mysql database sey ae pure application sever hoga nginx sey</p>
</li>
<li><p>ae b kind of three conatiners use karney vala hey</p>
</li>
<li><ol>
<li><p>nginx cont , django cont , aur mysql cont</p>
<ol start="2">
<li><p>ae mysql cont hey ae djnago cont though bat karega ismey b network lagana padtah hey</p>
</li>
<li><p>nginx hotahhey , django or web applications hothey hey vo port pey chlathey hey , ab 800 key andar aur b andar routing chalri ho , vo routing internally route hojai externally port number dena na padey isliye ek reverse proxy server hota hey</p>
<ul>
<li><p>proxy matlab aap unko ek proxy pass dedo agar aaka url localhost:8000 aaya , agar aapka url localhost/app or localhost/home aaya tohi internally yaha redirect kardo</p>
</li>
<li><p>mainey apney website mey dala - ip/ daldiya nginx sever key routing mey aisa likha hoga agar / hey django pey redirect kardey agar /db hey mysql ko redirect kardey</p>
</li>
<li><p>go to github - django-notes-app - ae jo aap hey - is appko hum end to end build karenge</p>
</li>
<li><ul>
<li><p>clone karlo - ismey kya kya cheeze hey samajthey hey</p>
<ul>
<li><p>ismey my notes hey ae frontend hey - frontend hey ae already build bani hui files hey - iska jo important hey backend hey (notesapp( backend hey jo django mey likha hua hey</p>
</li>
<li><p>settings.py ae jo file rehthi hey sab configuration rehthi hey</p>
<p>  templates key andar mynotes/build - ae frontend key html css import karleha hey</p>
<p>  aur database connectivity environmrnts diyi hui hey</p>
<p>  humko .env file b banani padthi hey , jaha sey database ko connect karnekey liye jo jo env chahiye vo idhar dey rakhey hey</p>
</li>
<li><p>directly pass kar sakthey hey yah env file mey b rakh sakthey hey</p>
</li>
<li><p>samaj mey aagaya na mynotes - fronend , notesapp -backend , nginx name ka folder jaha pey nginx conf rakhi hui hey  </p>
<pre><code class="lang-dockerfile">  upstream django{
      server django_app:<span class="hljs-number">8000</span>;
  }

  server {
      listen <span class="hljs-number">80</span>;

      server_name localhost;

      location / {
          proxy_pass http://django_cont:<span class="hljs-number">8000</span>;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Forwarded-Proto $scheme;
      }
  }
</code></pre>
<p>  ki agar is server pey port number 80 pey kahi pey http django container uska port 8000 url aathi hey vo / ko redirect kardega</p>
</li>
<li><p>agar mai instance ki ip:/ lagadun then ae redirct karega internal django product mey</p>
</li>
<li><p>clone hogaya - iski docker file dekhlenge</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
</ol>
</li>
</ul>
<pre><code class="lang-dockerfile"><span class="hljs-keyword">FROM</span> python:<span class="hljs-number">3.9</span>

<span class="hljs-keyword">WORKDIR</span><span class="bash"> /app/backend</span>

<span class="hljs-keyword">COPY</span><span class="bash"> requirements.txt /app/backend</span>
<span class="hljs-keyword">RUN</span><span class="bash"> apt-get update \
    &amp;&amp; apt-get upgrade -y \
    &amp;&amp; apt-get install -y gcc default-libmysqlclient-dev pkg-config \
    &amp;&amp; rm -rf /var/lib/apt/lists/*</span>


<span class="hljs-comment"># Install app dependencies</span>
<span class="hljs-keyword">RUN</span><span class="bash"> pip install mysqlclient</span>
<span class="hljs-keyword">RUN</span><span class="bash"> pip install --no-cache-dir -r requirements.txt</span>

<span class="hljs-keyword">COPY</span><span class="bash"> . /app/backend</span>

<span class="hljs-keyword">EXPOSE</span> <span class="hljs-number">8000</span>
<span class="hljs-comment">#RUN python manage.py migrate</span>
<span class="hljs-comment">#RUN python manage.py makemigrations</span>
</code></pre>
<p>docker build -t noted-app .</p>
<p>mujhey three container banana hey -</p>
<ul>
<li>vim docker-compose.yml</li>
</ul>
<pre><code class="lang-dockerfile">version: <span class="hljs-string">"3.8"</span> 
services:
    nginx:
        build:
            context: ./nginx
        container_name: nginx
        ports:
            - <span class="hljs-string">"80:80"</span>
        networks:
            - notes-app
        restart: always 
        depends_on:
            - django 





    db: 
        name: mysql
        image: mysql
        ports: 
            -p <span class="hljs-string">"3306:3306"</span>
        environments:
            MYSQL_ROOT_PASSWORD: root
            MYSQL_DATABASE: test_db
        volumes:
            ./mysql-data:/var/lib/mysql 
        networks:
            notes-app
        restart: always

         <span class="hljs-keyword">healthcheck</span><span class="bash">:</span>
            test: [<span class="hljs-string">"CMD"</span>, <span class="hljs-string">"mysqladmin"</span>,<span class="hljs-string">"ping"</span>,<span class="hljs-string">"-h"</span>,<span class="hljs-string">"localhost"</span>,<span class="hljs-string">"-uroot"</span>,<span class="hljs-string">"-proot"</span>]
            interval: <span class="hljs-number">10</span>s
            timeout: <span class="hljs-number">5</span>s
            retries: <span class="hljs-number">5</span>
            start_period: <span class="hljs-number">60</span>s


    django:
         build:
            context: .
         container_name: django_cont
         command: sh -c <span class="hljs-string">" python manage.py migrate --no-input &amp;&amp; gunicorn  notes.wsgi --bind 0.0.0.0:8000"</span>

         ports:
            -p <span class="hljs-string">"8000:8000"</span>

         env_file:
            - <span class="hljs-string">".env"</span>
         restart: always
         depends_on: 
            - db

          <span class="hljs-keyword">healthcheck</span><span class="bash">:</span>
            test: [<span class="hljs-string">"CMD-SHELL"</span>,<span class="hljs-string">"curl -f http://localhost:8000/admin || exit 1"</span>]
            interval: <span class="hljs-number">10</span>s
            timeout: <span class="hljs-number">5</span>s
            retries: <span class="hljs-number">5</span>
            start_period: <span class="hljs-number">60</span>s



volumes:
    mysql-data
networks:
    notes-app
</code></pre>
<p>cd nginx/ cat Dockerfile , default file hey isko kaisey likhthey hey →go to google → nginx default config file - begginers guide - here you see the document</p>
<p>ab - dockerfile mey dekho</p>
<p>FROM nginx:1.23-alpine</p>
<p>COPY ./default.conf /etc/nginx/conf.d/default.conf</p>
<ul>
<li><p>ab docker compose mey nginx ka likhdo , ab django mysql pey depend kartha hey toh pehle mysql likhdo</p>
</li>
<li><p>idhar django ka cont_name important kiunki cont_name humne default.conf mey mention ki hui hey</p>
</li>
<li><p>gunicorn ae aisa ek tool hotha hey jo aapkey aaplication ko server kartha hey production mey , toh gunicorn ek wsgi ek file rethi hey jo apney application ko server kartha hey</p>
</li>
<li><p>djangi k application hotha hey na , jab b vo mysql sey connect hoha hey na migrate karna padtha hey isliye command rehtha hey</p>
</li>
<li><p>ab docker compose up<br />  ab sab issues fix kiya i hope it will work now - docker compose up —build -ae kiun pata hey by default ae cache ko letha hey isliye phir sey build karney key liye —build detheyhey ae like —no-cache</p>
</li>
</ul>
<p>— ja thak mysql container dhang sey chalega thab thak django nahi chalega</p>
<ul>
<li><p>jo health check mainey mysql key liye kiya vahi health check django key liye karun</p>
</li>
<li><p>docker compose up —build → docker ps -a</p>
</li>
<li><p>docker network create notes-app -d bridge</p>
</li>
<li><p>docker compose up —build</p>
</li>
</ul>
<h1 id="heading-three-tier-application-with-docker-compose-java-app">Three tier application with docker compose java app</h1>
<p>→ GO TO Expense tracker → pehley ae project key bharemey dekhenge</p>
<p>ab samjo three tier application ka matlab kya hotah hey , ek hotha hey frontend -jo thyme leaf name ki framework hey - thymeleaf name ki ek frontend hey uspey aapka ui banahua hey</p>
<ul>
<li><p>jo aapka bckend hey springboot hey ek java ka framework backend</p>
</li>
<li><p>jo data base hey mysql - pey data base hey</p>
</li>
<li><p>backend hey ae build hotha hey maven sey - maven ek build tool hey apache foundation banaya hey</p>
</li>
<li><p>apey ko docker compose chahiye ismey ae three containers banare honge</p>
</li>
<li><p>thymeleaf &amp; springboot - ki ae do b ek application mey combine kar sakthey hey</p>
</li>
<li><p>jo maven key through build hojayega - base image rahega maven ka - phir maven ki base image mey soringbook java build karenge</p>
</li>
<li><p>aek mysql db lenge connect karneka khoshish karenge</p>
</li>
</ul>
<p>ab thodasa dekhenge is project key bhareme →</p>
<ul>
<li><p>src → developer ka kaam - yaha pey kuch test cases hey , main mey resources hey → assets - jo landing pages , css</p>
</li>
<li><p>application.properties ae important part hey</p>
</li>
<li><p>application ka name: expensesapp, spring.database: jdbc:mysql://mysql:3306/expenses_tracker , username= , password=  </p>
<p>  ae vo configurations hey ajo aapkey springboot app mey hey , springboot configuration hey vo kuch kuch variables aur uski corresponding values ko mangthi hey - vahi values mysql pey makesure karna hey ki aap derey ho</p>
</li>
<li><p>ab humko pom.xml important hey - aapkey application hey kounsey kounsey dependencies use kartha hey</p>
</li>
</ul>
<p>Clone the code from shubham - &gt; <a target="_blank" href="https://github.com/LondheShubham153/Expenses-Tracker-WebApp.git">https://github.com/LondheShubham153/Expenses-Tracker-WebApp.git</a></p>
<p>pehley dockerfile and docker-compose.yml ko remove karo scratch sey banayenge</p>
<pre><code class="lang-dockerfile"><span class="hljs-comment"># stage 1 - Build the jar (Java application Runtime)</span>
<span class="hljs-keyword">FROM</span> maven:<span class="hljs-number">3.8</span>.<span class="hljs-number">3</span>-openjdk-<span class="hljs-number">17</span> AS builder
<span class="hljs-comment"># Working directory </span>
<span class="hljs-keyword">WORKDIR</span><span class="bash"> /app</span>
<span class="hljs-keyword">COPY</span><span class="bash"> . .</span>
<span class="hljs-keyword">RUN</span><span class="bash"> mvn clean install  -DskipTests=<span class="hljs-literal">true</span></span>

<span class="hljs-comment">#Stage 2 - execute the Jar File from the above stage</span>

<span class="hljs-keyword">FROM</span> openjdk:<span class="hljs-number">17</span>-alpine

<span class="hljs-keyword">COPY</span><span class="bash"> --from=builder /app/target/*.jar /app/target/expenseapp.jar</span>

<span class="hljs-keyword">CMD</span><span class="bash"> [<span class="hljs-string">"java"</span>,<span class="hljs-string">"-jar"</span>.<span class="hljs-string">"/app/target/expenseapp.jar"</span>]</span>
</code></pre>
<ul>
<li><p>docker build -t expenseapp .</p>
</li>
<li><p>vim dokcer-compose.yml</p>
<ul>
<li><p>```dockerfile
  version: "3.8"</p>
<p>  services:
      java-app:
          build:
              context: .
           container_name: "expensesapp"
           networks:</p>
<ul>
<li>expenses-app-nw
ports:</li>
<li><p>"8080:8080"</p>
<p>environment:
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_URL: "jdbc:mysql://mysql:3306/expenses_tracker?allowPublicKeyRetrieval=true&amp;useSSL=false"
SPRING_DATASOURCE_PASSWORD: Test@123
depends_on:</p>
</li>
<li>mysql_db
restart: always
healthcheck:
test ["CMD-SHELL" , "curl -f http://localhost:8080 || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period:60s</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>            mysql_db:
                image: mysql
                container_name: "mysql"
                networks:</p>
<ul>
<li>expenses-app-nw
environment:
MYSQL_ROOT_PASSWORD: Test@123
MYSQL_DATABASE: "expenses_tracker"
restart: always
ports:</li>
<li>"3306:3306"
healthcheck:
test ["CMD" , "mysqladmin","ping","-h","localhost","-uroot","-pTest@123"]
interval: 10s
timeout: 5s
retries: 5
start_period:60s
volumes:</li>
<li>./mysql-data:/var/lib/mysql
nginx:
build:
context: ./nginx
container_name: nginx_cont
ports:</li>
<li>"80:80"
networks:</li>
<li>expenses-app-nw
restart: always 
depends_on:</li>
<li><p>java-appand </p>
<p>networks:
expenses-app-nw:</p>
<p>```</p>
<p>- docker compose up</p>
<ul>
<li><p>networks mey mapping agar deyaga toh - nahi rehna chahiye ; colon rehna hey</p>
</li>
<li><p>docker compose up —build</p>
</li>
<li><p>enable the port number in aws 8080</p>
</li>
</ul>
</li>
</ul>
<ul>
<li><p>cp -r ../django-notes-app/nginx .</p>
</li>
<li><p>vim /nginx/default.conf -→ replace container name here and port number 8080</p>
</li>
<li><p>upstream server expensesapp 8080</p>
</li>
</ul>
<p>copy nginx code from django naotes</p>
<ul>
<li><p>and paste it here and docker compose up —build</p>
</li>
<li><p>why permission denied ari mysql-data ki → aapka jo volume hey created nahi hey</p>
</li>
<li><p>docker volume create java-app-data → ab apna docker compose.yml file mey replace kardo java-app-data</p>
</li>
</ul>
<p>SSL B BATADO - take your ip address and go to go-daddy .com - create one profile and purchase one domain.</p>
<p>phir jakey us domain ka na dns mapping hotha hey -→ ab mai dns mapping mey ae ip address ispey ma kardo karkey -→ manage dns mey - aek record banado - add new record - docker name - option mey A record , Arecord subdomain hotha hey - &gt; docker.trainwithshubham.com → value mey ip daldo aur ttl - custom seconds 600 and save it</p>
<ul>
<li><p>ae domain name nginx → default.conf mey daldo → phir A record delete karkey phirsey create kardo aur</p>
<ul>
<li>docker compose up —build and now check it will be working.</li>
</ul>
</li>
</ul>
<h1 id="heading-docker-scout">Docker scout</h1>
<ul>
<li><p>jabbi aap docker ki images banahey ho - lets say aap docker ki image banali - aap ney two-tier flask ki image banali</p>
<ul>
<li><p>ae image aek bse image sey bani - ae python ki or kisi ki b ho sakthi hey right , aisa b ho saktha hey ae base image mey kuch security related threats , security related issues , vulnerabilities ho , isiliye image ko humne security key liye scan karthey hey</p>
</li>
<li><p>bhaiyya ae scan trivy b kartah hey , trivy ka kaam image , scanning , file system scanning k a</p>
</li>
<li><p>similarly usi prakar sey docker ney khud ka b image scanning tool banaya hey docker scout</p>
</li>
<li><p>aapko bohot aasan sey dockerdesktop mey hotha hey</p>
</li>
<li><p>desktop mey jakey - aapkey pass jithney b images hey docker scout scan kar saktha hey - dekh saktha hey ki kahi uski base image sey yah complete images ser kahi threat vulnerabilities hey kya karkey</p>
</li>
<li><p>ae issues kya hey kaisa pata chalega</p>
</li>
<li><p>terminal mey javo uskey liye - docker images</p>
</li>
<li><p><code>docker scout quickview imagename</code> - ae pehley dockerhub sey authentic karega aur scan karkey diyega</p>
</li>
<li><p>aur depth mey janna hey - <code>docker scout dves imagename</code></p>
</li>
</ul>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748534388571/6bdc5c1b-24a2-43bf-95c1-f80b4885ca38.png" alt class="image--center mx-auto" /></p>
</li>
</ul>
<h1 id="heading-docker-init">Docker init:</h1>
<ul>
<li><p>AE sa samajlo ki aapko dockerfile banani hey - dockecompose banai hey k readme banai hey kithna time lagtha hey</p>
</li>
<li><p>docker file mey kya kya likhtey hey</p>
</li>
<li><ul>
<li>from , workdir , copy , run , cmd , author , label , maintainer</li>
</ul>
</li>
<li><p>but ae jo kaam manually karna padtha hey</p>
</li>
</ul>
<p>docker init kya kartha hey aapko ek ready made template bana detha ehy</p>
<p>mujhey just docker init karna hey - aur select karna hey aur click akrna hey</p>
<ul>
<li><p>docker ignore bana detha hey , dockerfile , composefile , readme b bana detha hey - project select karlo</p>
</li>
<li><p>use version also - enter - relative directory of main landing package → .</p>
</li>
<li><p>port - 8080 ,</p>
</li>
<li><p>within few seconds - dockerfile , docker compose and sab files banayega .</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Git and Github For DevOps]]></title><description><![CDATA[Agenda:

Git and GitHub Basics

Basic Commands of git

pull request, merging, branching strategies for DevOps

Hooks (Pre-commit Hooks)

Repo setup End to end & us repo ko (Github Actions key through CI/CD kaisa karenge)



Pehle samjengey kya hotha ...]]></description><link>https://devopsblog1.hashnode.dev/git-and-github-for-devops</link><guid isPermaLink="true">https://devopsblog1.hashnode.dev/git-and-github-for-devops</guid><dc:creator><![CDATA[Vaseem Shaik]]></dc:creator><pubDate>Wed, 28 May 2025 17:50:04 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-agenda">Agenda:</h1>
<ol>
<li><p>Git and GitHub Basics</p>
</li>
<li><p>Basic Commands of git</p>
</li>
<li><p>pull request, merging, branching strategies for DevOps</p>
</li>
<li><p>Hooks (Pre-commit Hooks)</p>
</li>
<li><p>Repo setup End to end &amp; us repo ko (Github Actions key through CI/CD kaisa karenge)</p>
</li>
</ol>
<ul>
<li>Pehle samjengey kya hotha hey git and github</li>
</ul>
<p>Git is a Version Control System - ae kya hotha hey - aap aisa samjo, ae aap ho, ae aapka dost hey, aur ek dost hey, mai aur babban achey vale dost hey - sochey sath mey boo likhenge - in book mey bohot chapters rehthey hey - mai chapter 1 karlunga, chapter 2 babban, chapter 3 gabban</p>
<ul>
<li><p>phir mainey kithna kaam kiya, kithne time kiya, chapter 1 karnaa author kon tha, kya proof hey ae chapter mainey hi likhey aek commitment hothi hey —→ ae saari ceezey record hni chahiye agar aap group project kar raheho</p>
</li>
<li><p>Vara aisey hi log hothey hey pura assignment mila hey assignment mila hey, saara project mainey kiya lekin babban ney likha my contribution in the assignment.</p>
</li>
<li><p>Ae sab record honi chahiye - or let’s say mainey aapney book key chapter mey kuch jadbad kardi, main usko edit kar pau, or jabbi chahu purani version mey jau pau</p>
</li>
<li><p>aap versions pey ja sakthey ho, aap kisi aur key changes ko record kar sakthey ho - aap aek version control system mey kaam karreyho</p>
</li>
</ul>
<p>Git b ek vcs hey jaha pey aap aur aapkey team mates ek repository mey aapkey contributions dal sakthey ho, aap apney code ko maintain kar sakthey hey</p>
<ul>
<li><p>kithney bajey likha , kya proof hey , kya data hey , koun likha sab track kr saktha hey</p>
</li>
<li><p>Linus Torvalds has created git , how can we download the git , just install the git download software on windows.</p>
</li>
<li><p><code>git —version</code> - to check the git version</p>
</li>
</ul>
<p>Github kya hey : Github is a platform jiskey background mey git vcs ka fundamentals sari cheezey include hey , like apna code manage kar sakthey hey , collabration kar sakthey hey , llike gui dey detha hey .</p>
<p>github / gitlab kya difference - both are same = isko bolthey hey source code management tools .</p>
<p>Git is a vcs tool hey ae power kartha hey github, gitlab and bitbucket ko.</p>
<ul>
<li>Go to GitHub.com and signup and create your account.</li>
</ul>
<p><em><mark>Basics Commands:</mark></em></p>
<ul>
<li><p>i will create a folder and file ismey mera code rahega - through git files ko manage karunga → phir github mey push karune valey hey , later on , pree hooks laganey valey hey aur github actions key through , pull request through , project skey through ci cd karenge</p>
</li>
<li><p>→folder→ filer→git→girhub→pre hooks→githubaction→pr→project→CI</p>
</li>
</ul>
<p>let’s get started - i will create a new window in vs code i will create a fodler - click on open -go to document folder - create a folder githubfordevops→ open this folder</p>
<p>testing.py - print(“Heloo dosto , kya haal chaal , kaisey hey sab”)</p>
<ul>
<li><p>ab is cheez ko , mera code hey , mainey likha hey , main is file ko run karunga</p>
</li>
<li><p>ab ae file kisney likhi , kab likhi , kya proof hey kisney likhi , agar ae file delete hogai kya ae file retrive hui</p>
</li>
<li><p>aapko git boltha hey mai aapko ek vcs detha hun ki jo is file likhne valae author nbata sakthe hey , data bata saktha hey , proof commit bata saktha hey , agar delete ho gayi kya mai v1 puraney version pey ja saktha hun no , git ja saktha hey</p>
</li>
</ul>
<p>rm testing.py - kya ae retrive kar saktehy no</p>
<p>file system mey you cannot recover deleted stuff , in vcs you have retrive option and also roll back to the previous version</p>
<ul>
<li><p>Mujhey abhi is cheez ko vcs banana hey is folder mey aapko karna padega <code>git init</code></p>
</li>
<li><p><code>Git init</code> : to initialize a empty git vcs repository local repo</p>
</li>
<li><p>aap is directory ko file sytem sey vcs ko git init</p>
</li>
<li><p>ek baar initialize hogai aapki git directory -</p>
</li>
<li><p>git status - to check the</p>
</li>
<li><ul>
<li><p>create a file testing.py file - ab mujhey git status karkey dekhna</p>
<ul>
<li><p>ab humko aayega untrakked files - hum jab local repo create karthey hey</p>
</li>
<li><p>ae 2 logical areas create kartha hey untracked , stage and tracked</p>
</li>
<li><p>ab jab b aapki file system mey hothi hey untracked hothi hey git vcs ko</p>
</li>
<li><p>agar aapko us file ko git vcs key andar dalna hey vo cheez tracked hojayegi</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748383025977/bc240b19-ad95-4d31-9a8b-0957dfd80e03.png" alt class="image--center mx-auto" /></p>
<p>  is file ko stage mey lekey aaunag aur track mey dalunga</p>
</li>
<li><p>ae ship mey jana hey yah nahi vaisa sochlo</p>
</li>
<li><p>untracked sey stage mey lana hey - <code>git add file name</code></p>
</li>
<li><p>vapas untracked mey lana hey - <code>git rm —cached file name</code></p>
</li>
<li><p>ab stage sey track karani hey - <code>git commit -m “message”</code></p>
</li>
<li><ul>
<li><p>git status - vo abhi tracked hey , agar mai testing.py ko delete kardunga - toh isko mai vapas restre kar saktha hun</p>
<ul>
<li><code>git restore python.py</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><p>ab thak humney sikha - git init , git status , git add , git commit , git rm -cached , git restore</p>
</li>
</ul>
<p>Ab nayi file banathey hey git-commands.txt - history commands ko copy karlo aur paster kardo</p>
<ul>
<li><p>Hum abhi ae sare changes ko local sey remote github ko push karenge</p>
</li>
<li><ul>
<li><p>Github pey jakey ek new repo create kardo - name - github-for-devops-workshop</p>
<ul>
<li><p>aap ka jo local hey vo aapka personal hey , github hey world wide web pey hey - kahi sey b access kar sakthey hey , agar aapko aapkey local code hey vaha sey github ko pahunchani hey <code>git push</code> command sey paunchavogey</p>
</li>
<li><p>github mey username password lagtha hey na</p>
</li>
<li><ul>
<li>mai use kartha hun , mai local ko personal access token de detah hun thaki vo merey github mey push kar detha</li>
</ul>
</li>
<li><p>copy which are here push an existing repo - git remote add origin url</p>
</li>
<li><p>hey github , local ko batara hun remote dhoor mey rakhi hui ek url usko add kardo</p>
</li>
<li><p><code>git remote -v</code> → remote add hui yah nahi idhar check karthey</p>
</li>
<li><p>git push origin main - jab enter karunga - username and token mangega</p>
</li>
<li><p>aap github settings pey jakey - personal access token -create karo - token ko repo ka access dedo</p>
</li>
<li><p><code>git remote set-url origin https://PAT@github.com/username/repo.git</code></p>
</li>
<li><p><code>git push origin master</code> - push hogaya</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>Github mey rakhi hui repository , iskey sath ky akya kar sakthey hey , aap clone kar sakthey ho yah fork kar sakthey hey</p>
<p>fork - github - github hotha hey - fork karlo</p>
<p>clone - github to local clone hotha hey clone karlo</p>
<ul>
<li>mainey commands jo b naye they remote add ka vo commands.md mey likha - <code>git status</code> kiya - <code>git add</code> kiya - <code>git commit</code> kar detha hun</li>
</ul>
<p>bina token sey connect - settings mey jakey - ssh mey - apka system ka ssh-key copy karna hey thab vo allow karega</p>
<ul>
<li><p>mai direct remote mey edit kartha hun - commit kardiya github key through</p>
</li>
<li><p>jo new sey change kiya kya vo merey local mey hey ? toh ek command use karunga - <code>git pull origin master</code></p>
</li>
</ul>
<p>Branches:</p>
<p>what is branches</p>
<p>-ae jo main master kya tha - ae branches key name hothey hey</p>
<p>branches kya hothey hey - tree pata hey , jaisey tree key roots rehthey hey - tree key seed lagathey hey pehley us seed sey rrrroots - roots sey - tree - trees - branches hothey hey</p>
<p>seed mathlab , jab git repo initally commit kiya create kiye na vo seed tha vo tha master pey - jab local mey repo banathey hey master pey rehtah hey</p>
<p>agar github mey create arangey na main ey rehtha hey</p>
<ul>
<li><p>git branch branchname - create the branch</p>
</li>
<li><p>git checkout -b brnachname - create branch and also switch</p>
</li>
<li><p>git switch dev copy of the same desired state of code</p>
</li>
<li><p>dev mey jakey mainey create kiya ek file - add kardunga , commit kardunga</p>
</li>
</ul>
<p>master ko paat nai dev mey kya chalra hey , dev ko pastha nahi master mey kya chalra hey</p>
<p>every branch in git maintains its own copy - faida - isolate , copy banalethey hey -</p>
<p>Branchin ki strategies rehthey hey</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748388301691/c4cbc1db-f455-4a97-8c93-7fd9c1eddae1.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>ek code rakha rehtha hey master pey</p>
</li>
<li><p>aur ek code rehtah hey stage - staging mey ky ahotha hey jo master ka code hey uat , users test kar paye</p>
</li>
<li><p>dev mey dev code rakha jatah hey sirf sur sirf development hothi hey</p>
</li>
</ul>
<p>feauture1 , feautre2, feauture3 → dev → test (ua) → master</p>
<p>dev mey naya developer kuch enhancements key liye use karthey</p>
<ul>
<li><p>agar aap chahthey ho ki kaha pey rakha hua hey production mey dalna hey yah nah dalna hey usey stagging mey rakha jatha hey</p>
</li>
<li><p>aur sahi vala hey , sahi sey chalra hey usko checihi math isliye vo code - master pey rehthi hey</p>
</li>
<li><p>bohot log kaam karthey right feauture pey so ek ek person vo khud branches create karlega feauture key uppar</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748388552219/7c2c6c62-c828-451c-80c7-6196633a2b50.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>mujhey dev key changes master mey merge karna hey toh make sure your on master - and then <code>git merge dev</code></p>
</li>
</ul>
<p>git hub key though compare and save</p>
<p>#if you go git tech fetch , jithney b branches remote me hey local mey aajathey</p>
<p>GIT HOOKS:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748417075677/c74eda86-ac71-462f-ae4c-8a41e7af23ff.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>Yeh aapki branch hey master , ae daigram dekkey kya yadh aatha hey - ki untraced , stage aur tracked yadh aara , aisa samajlo ki mainey ek untracked file thi</p>
<ul>
<li><p>lets say demo.py - usko mainey stage karnekey liye git add kiya , bohot saare files thi git add . kiya git commit kiya , kya vo track hojayegi</p>
</li>
<li><p>mujhko ae batao , demo.file mey mujhey galthi api-key reh gayi , kahi code mey kuch galath tha kya vo commit hogayi</p>
</li>
<li><p>galthi sey galath code b ho saktha hey , it is humar error</p>
</li>
<li><p>iska solution kya hotah hey - commit karnesey pehle badh , push karnesey pehley yah badh - kuch internal checks laga sakthey ho</p>
</li>
<li><p>aur ae jo add aur commit key beechmey aek check ho saktha hey - ae automatically check hona hey toh hooks sey hoga - pre commit hook ser agar aapkey files mey dikath hey , aur aap commit karney jathey ho - syntax wrong hey toh ae commit nahi kar detha</p>
</li>
<li><p>ab mai apney rep mey jaunga , ls -a , aur .git valey folder key andar jav - cd .git - gaye bohot dhyaan sey dekhna - ls kiya idhar hooks name ka folder dikhega</p>
</li>
<li><p>ls - pre commit , prepare-commit dikhege - bohot saare samples hey , apko actually ae name ki file banana hey →</p>
</li>
<li><p>```plaintext
  vim pre-commit   </p>
<ul>
<li><p>vs code mey jakey - search mey user.exclude - idhar .git lo delete karni hey kiun ki mujhey visible hojaye</p>
<h1 id="heading-mainey-ek-file-banayi-jiska-name-demopy-jiskey-andar-ek-mainey-function-banaliya">mainey ek file banayi jiska name demo.py - jiskey andar ek mainey function banaliya</h1>
<p>demo.py</p>
<p>def my_function():
  a=5
  b=6
c=6
test()
  return d 
my_function()</p>
<h1 id="heading-ae-wrong-code-hey-agar-mai-git-status-karun-git-add-and-commit-kardun-ideally">ae wrong code hey agar mai git status karun , git add and commit kardun , ideally</h1>
<p>commit hojayega -&gt; git ko thodi hi patah hey ae wrong code karkey </p>
<h1 id="heading-this-file-is-now-addes-thabki-ae-file-galath-file-hey">this file is now addes , thabki ae file galath file hey</h1>
<h1 id="heading-mai-isko-pre-commit-hooks-sey-theek-kar-detha-hun">mai isko pre commit hooks sey theek kar detha hun</h1>
<p>toh python ka jo code rehtah hey usko check karnekey liye -&gt; flake8 hotha hey code ka quality check kar saktheyy hey </p>
<h1 id="heading-pip-install-flake8">pip install flake8</h1>
<p>flake8 demo.y </p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h1 id="heading-is-tool-sey-code-ka-quality-check-karliya-ae-code-quality-test-kartha-hey">is tool sey code ka quality check karliya , ae code quality test kartha hey</h1>
<h1 id="heading-kya-mai-as-a-devops-engineer-ae-tool-ko-apney-git-key-process-mey-daldun">kya mai as a devops engineer , ae tool ko apney git key process mey daldun</h1>
<h1 id="heading-commit-honesey-pehley-ae-tool-chal-jaye">commit honesey pehley ae tool chal jaye</h1>
<ul>
<li><p>mai kya chahtha hun , hooks mey jaunga ek file banaunga - pre-commit file </p>
<h1 id="heading-ab-mai-aapni-sarey-files-ko-lekey-aajaunga">ab mai aapni sarey files ko lekey aajaunga</h1>
<p>files=$(diff --cached --name-only --diff-filter=ACM | grep '.py$'
flake8 $files</p>
<p>if git grep - q    "password|secret_key|API_KEY' $(git diff --cached --name-only); then
   echo " Kiun apni job risk"
 exit 1
fi</p>
</li>
</ul>
<h1 id="heading-ab-mai-pre-commit-file-ko-executable-banadunga">ab mai pre-commit file ko executable banadunga</h1>
<ul>
<li><p>chmod u+x pre-commit </p>
<h1 id="heading-ab-mai-git-status-git-add-git-commit-m-commit-galath-file-mai-commit">ab mai git status , git add . - git commit -m "commit" galath file mai commit</h1>
<p>karney try karra hun lekin pre-commit hook commit nahi karney dega </p>
</li>
</ul>
<pre><code>
        \- ky aap aapney office mey puri ki puri pre commits hits lagagkey purei ki puri teams ki jo bugs , they problems they ek hi minute mey solve kar sakthey , jo wrong code dalenge hi nahi toh problems ayeney hi nahi


* agar mai galthi sey password , yah api-keys hey toh mai commit nahi karney dena .


* mai demo.py mey password daldiya , ab git add . and git commit khoshish karunga toh error aajayega


# Github Actions:

* Github actions key sath aek portfolio deploy karna chahthey ho


\- ab aisa samajlo ae aapki github repo hey , jiskey andar aapkey files hey , ab ismey ek branche hey master , uskey andar kuch kuch commands hey application hey

is application ko deploy karthey ho ,isko aap build ,test , phir deploy b karthey ho right , is cheez karnekey liye jenkins use karthey hey right

ci cd pipelines banathey ho right - &amp;gt; ab ae jo pipelines hey jo jenkins mey banri vo aap github mey b bana sakthey ho , jisko bolthey hey github actions , github actions aek inbuilt tool hey jo aapko aapkey code ko build test deploy , scan , sonarqube , sab cheez karney detha hey

* <span class="hljs-string">`aapko jana hey aapkey repo mey jana hey - lets say isko scan karna hey - actions mey javo - pylint - configure - khud hi likh diya python code test key liye pylint - yaml mey rehtha hey`</span>


aapkey repo mey .github folder rehtah hey usmey aap workflows likh sakhey hey ki - onpush , ontest, ondeploy

commit karney key badh- github workflows key bajuk small dot rehtah hey - vo actions run horey hongey

testing.py mey thoda code likhdo

/ def heloo():

“““ <span class="hljs-built_in">this</span> is ehloo <span class="hljs-function"><span class="hljs-keyword">function</span> “““

<span class="hljs-title">return</span> “<span class="hljs-title">heloo</span> <span class="hljs-title">dosto</span>”

<span class="hljs-title">heloo</span>(<span class="hljs-params"></span>)

<span class="hljs-title">tum</span> <span class="hljs-title">commit</span> <span class="hljs-title">karkey</span> <span class="hljs-title">push</span> <span class="hljs-title">karenge</span> <span class="hljs-title">automatically</span> <span class="hljs-title">aapkey</span> <span class="hljs-title">actions</span> <span class="hljs-title">start</span> <span class="hljs-title">honge</span> <span class="hljs-title">run</span> <span class="hljs-title">karna</span>

* <span class="hljs-title">jo</span> <span class="hljs-title">b</span> <span class="hljs-title">error</span> <span class="hljs-title">aaya</span> <span class="hljs-title">hey</span> <span class="hljs-title">as</span> <span class="hljs-title">a</span> <span class="hljs-title">python</span> <span class="hljs-title">epert</span> <span class="hljs-title">karkey</span> <span class="hljs-title">aapka</span> <span class="hljs-title">file</span> <span class="hljs-title">ka</span> <span class="hljs-title">code</span> <span class="hljs-title">and</span> <span class="hljs-title">error</span> <span class="hljs-title">dekey</span> <span class="hljs-title">fix</span> <span class="hljs-title">akrdo</span> <span class="hljs-title">karkey</span> <span class="hljs-title">batao</span> <span class="hljs-title">aajayega</span> <span class="hljs-title">aur</span> <span class="hljs-title">copy</span> <span class="hljs-title">karkey</span> <span class="hljs-title">add</span> <span class="hljs-title">and</span> <span class="hljs-title">commit</span> <span class="hljs-title">push</span> <span class="hljs-title">kardo</span>.


<span class="hljs-title">Go</span> <span class="hljs-title">to</span> <span class="hljs-title">aws</span> <span class="hljs-title">account</span> : - <span class="hljs-title">s3</span> → <span class="hljs-title">mai</span> <span class="hljs-title">ek</span> <span class="hljs-title">bucket</span> <span class="hljs-title">banaunga</span> - <span class="hljs-title">tws</span>-<span class="hljs-title">portfolio</span> - <span class="hljs-title">url</span> <span class="hljs-title">aisa</span> <span class="hljs-title">aek</span> <span class="hljs-title">portfolio</span> <span class="hljs-title">banaunga</span> —&amp;<span class="hljs-title">gt</span>; <span class="hljs-title">through</span> <span class="hljs-title">github</span> <span class="hljs-title">actions</span>

<span class="hljs-title">Github</span> <span class="hljs-title">pey</span> <span class="hljs-title">aapka</span> <span class="hljs-title">code</span> <span class="hljs-title">rakha</span> <span class="hljs-title">jayega</span> <span class="hljs-title">code</span> <span class="hljs-title">hoga</span> <span class="hljs-title">html</span> , <span class="hljs-title">java</span> <span class="hljs-title">script</span> <span class="hljs-title">aur</span> <span class="hljs-title">css</span> , <span class="hljs-title">java</span> <span class="hljs-title">script</span> → <span class="hljs-title">is</span> <span class="hljs-title">code</span> <span class="hljs-title">ko</span> <span class="hljs-title">s3</span> <span class="hljs-title">bucket</span> <span class="hljs-title">mey</span> <span class="hljs-title">oaunchana</span> <span class="hljs-title">hey</span> - <span class="hljs-title">is</span> <span class="hljs-title">bucket</span> <span class="hljs-title">ko</span> <span class="hljs-title">public</span> <span class="hljs-title">access</span> <span class="hljs-title">dekhey</span> - <span class="hljs-title">public</span> <span class="hljs-title">thak</span> <span class="hljs-title">paunchana</span> <span class="hljs-title">hey</span> - <span class="hljs-title">ae</span> <span class="hljs-title">sab</span> <span class="hljs-title">ho</span> <span class="hljs-title">automated</span> <span class="hljs-title">github</span> <span class="hljs-title">actions</span>

<span class="hljs-title">s3</span> <span class="hljs-title">ko</span> <span class="hljs-title">access</span> <span class="hljs-title">karnekey</span> <span class="hljs-title">liye</span> - <span class="hljs-title">iam</span> - <span class="hljs-title">security</span> <span class="hljs-title">creds</span> <span class="hljs-title">hothi</span> <span class="hljs-title">hey</span> , <span class="hljs-title">create</span> <span class="hljs-title">kardo</span> <span class="hljs-title">acess</span> <span class="hljs-title">key</span> <span class="hljs-title">and</span> <span class="hljs-title">security</span> <span class="hljs-title">key</span>

* <span class="hljs-title">tws</span>-<span class="hljs-title">portfolio</span> <span class="hljs-title">fork</span> <span class="hljs-title">karkey</span> → <span class="hljs-title">uskey</span> <span class="hljs-title">andar</span> <span class="hljs-title">html</span> <span class="hljs-title">css</span> <span class="hljs-title">aur</span> <span class="hljs-title">java</span> <span class="hljs-title">script</span> <span class="hljs-title">ka</span> <span class="hljs-title">code</span> <span class="hljs-title">hye</span>

* <span class="hljs-title">mai</span> <span class="hljs-title">ek</span> <span class="hljs-title">file</span> <span class="hljs-title">create</span> <span class="hljs-title">karunga</span> .<span class="hljs-title">github</span>/<span class="hljs-title">workflows</span>/<span class="hljs-title">main</span>.<span class="hljs-title">yml</span>

* * <span class="hljs-title">name</span>: <span class="hljs-title">portfolio</span>


```<span class="hljs-title">plaintext</span>
<span class="hljs-title">name</span>: <span class="hljs-title">portfolio</span> 
<span class="hljs-title">on</span> 
    <span class="hljs-title">push</span>
        <span class="hljs-title">branches</span>
            - <span class="hljs-title">main</span>

<span class="hljs-title">jobs</span>:
    <span class="hljs-title">build</span>-<span class="hljs-title">and</span>-<span class="hljs-title">deploy</span>
        <span class="hljs-title">runs</span>-<span class="hljs-title">on</span>-<span class="hljs-title">ubuntu</span>-<span class="hljs-title">latest</span>
        <span class="hljs-title">steps</span>:
            - <span class="hljs-title">NAME</span>:     <span class="hljs-title">checkout</span>
        <span class="hljs-title">uses</span>: <span class="hljs-title">actions</span>/<span class="hljs-title">checkout</span>@<span class="hljs-title">v1</span>

        - <span class="hljs-title">name</span>: <span class="hljs-title">configure</span> <span class="hljs-title">aws</span> <span class="hljs-title">cred</span>
           <span class="hljs-title">uses</span>: <span class="hljs-title">aws</span>-<span class="hljs-title">actions</span>/<span class="hljs-title">configure</span>-<span class="hljs-title">aws</span>-<span class="hljs-title">credential</span>@<span class="hljs-title">v1</span> # <span class="hljs-title">humko</span> <span class="hljs-title">is</span> <span class="hljs-title">repo</span> <span class="hljs-title">key</span> <span class="hljs-title">settings</span> <span class="hljs-title">mey</span> <span class="hljs-title">secrets</span> <span class="hljs-title">and</span> <span class="hljs-title">variables</span> <span class="hljs-title">mey</span> <span class="hljs-title">actions</span> <span class="hljs-title">mey</span> <span class="hljs-title">secret</span> <span class="hljs-title">and</span> <span class="hljs-title">access</span> <span class="hljs-title">key</span> <span class="hljs-title">banado</span>

        <span class="hljs-title">with</span>:
        <span class="hljs-title">aws</span>-<span class="hljs-title">access</span>-<span class="hljs-title">key</span>-<span class="hljs-title">id</span>: <span class="hljs-title">$</span></span>{{ secrets.aws_access_key_id}}




            -
</code></pre><p>-s3 -mey jakey cukedt create karkey - s3 hosting mey index .html create karo</p>
<p>aur bucket policy mey jakey - gnerator policy - s3 bucket policy mey allow - bucket policy copy kareleye - bucket policy create kardo replacing with your bucket id</p>
]]></content:encoded></item><item><title><![CDATA[Linux End To End]]></title><description><![CDATA[How Internet works

Internet works through optical fibers cables indise the water they keep cables and attach with the data centers

data transfer through cables , this cables are located in the sea.

between user and cables -data center, a ISP will ...]]></description><link>https://devopsblog1.hashnode.dev/linux-end-to-end</link><guid isPermaLink="true">https://devopsblog1.hashnode.dev/linux-end-to-end</guid><dc:creator><![CDATA[Vaseem Shaik]]></dc:creator><pubDate>Tue, 27 May 2025 19:29:31 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-how-internet-works">How Internet works</h1>
<ul>
<li><p>Internet works through optical fibers cables indise the water they keep cables and attach with the data centers</p>
</li>
<li><p>data transfer through cables , this cables are located in the sea.</p>
</li>
<li><p>between user and cables -data center, a ISP will be there ,</p>
</li>
</ul>
<p>what is server :</p>
<ul>
<li><p>a server hey uska kaam kya hey -kisi info ko server karna , server is just basically a computer to server client</p>
</li>
<li><p>the server is to server the info</p>
</li>
<li><p>client ka kaam hey request info to the server</p>
</li>
<li><p>youtube.com ae aek domain hey , iskey against ek application server i mean application ka domain</p>
</li>
<li><p>ek application server hoga jaha pey youtube chalra -is server ka kuch ip address hogi → aek domain aur ip address ko link karnekey liye ek DNS server rehtha hey</p>
</li>
<li><p>facebook.com kultha hey - isp internet ka acess detha hey , oprical fiber data ko flow karathi hey - aur data center mey jo application chalra co aapkey mobile mey stream hotha rehtha hey</p>
</li>
</ul>
<p>diff between web server and application server</p>
<ul>
<li><p>web server is nothing but jo b static code deploy kiye rehthey toh vo web servers , static data serve kartha hey</p>
</li>
<li><p>application server bussiness logic data ko server kartha hey</p>
</li>
<li><p>Types of applications</p>
<ul>
<li><p>standalone apps - usko internet ki jaroorat nahi hothi —&gt; koi db ki jaroorat nahi rehthi - aap kabhi airport mey , how was your feedback , click kar diya chaldiya - usko bakhi cheez ka jaroorat nahi hey</p>
</li>
<li><p>if you have web application like instagram or youtube , youtube mey video streaming hora hey , Notifications jarey ae thab hotha hey aap standalone nahi aap ek group of applications chalare hey - iskey supporting mey app severs, db servers, email server</p>
</li>
</ul>
</li>
<li><p>isiliye ek devops engineer ko pata rehna hey ki vo kis cheez pey kaam karra</p>
</li>
<li><p>agar stahndalone pey kaam karra hey usko db , ki bakhi connections ki jaruru nahi padegi</p>
</li>
<li><p>agar ae web applications pey kaam karra hey isko db connction , frontend connection , backend connection , cloud ae sab dekhna</p>
</li>
</ul>
<p>what is application support and maintainance</p>
<ul>
<li><p>ki jo hamare phone mey laptop mey application horey hey ae ssaarey applications kahi ek o.s mey chalre hothey hey</p>
</li>
<li><p>vo applications sahi sey cha;re hey nahi , creash toh nahi horey , us appliocations ko support ki jaruri hey yah nahi dekhthey hey</p>
</li>
<li><p>application chalra hey kabhi bhi connection issue aa ra hogey as a devops or linux admin kounsey server mey dikkath hey</p>
</li>
</ul>
<p>ae applications linux pey chalthey hey , linux ae ky ahey cheez</p>
<ul>
<li><p>90 percent key log windows chalathey hey 90 percent applications linux mey chalthey hey</p>
</li>
<li><p>linux opensource hey , linux ko linus torvalds ney 1991 mey banaya tha , jissey jo basically koi antivirus ki jaruri nahi hey , security top notch hey , community hey , multi tasking hey , updates ki jaruri nahi ,</p>
</li>
<li><p>linux use karthey hey majority companies linux pey hi chalrehey</p>
</li>
</ul>
<p>ae jo unix and linux kya hey - unix basically ek o.s hey vo ek commercialised hey - unix ka prime example hey mac o.s</p>
<ul>
<li><p>same as liunux kaam sab linux hi hey .</p>
</li>
<li><p>unix ka hi free version linux</p>
</li>
<li><p>\linux ko install kaisa karey - pehle tarika hey</p>
<p>  1. wsl for linux</p>
<ol start="2">
<li><p>virtual box</p>
</li>
<li><p>azure / aws/gcp koi b cloud pey koi vm banakey use kar sakthey hey</p>
</li>
<li><p>vagrant b hey - hashicorp ki company hey ussey aao linux use kar sakthey hey</p>
</li>
</ol>
</li>
</ul>
<p>Difference between linux and windows</p>
<ul>
<li><p>windows is a licence one</p>
</li>
<li><p>linux is a gpl general public license</p>
</li>
<li><p>linux mainly focus on development , networking , tyerminal , programming , scripting \</p>
</li>
<li><p>windows mey antivirus use karna , linux mey nahi</p>
</li>
<li><p>widnows mey update pusthey hey , linu smey update ki jaruri nahi - ubuntu vala saal mey 2 baar update martha hey</p>
</li>
</ul>
<p>softeare remote location server tools</p>
<ul>
<li><p>agar ae mey hu aur yaha mey mai ek dhoor rakhey huey server or vm ko connect karna chahtha hun</p>
</li>
<li><ul>
<li><ol>
<li><p>remote desktop protocol</p>
<p>     2. ssh - secure shell</p>
<p>     3. anydesk</p>
<p>     4. ultraviewer</p>
</li>
</ol>
</li>
</ul>
</li>
<li><p>what is kernal , bootloader , shell</p>
</li>
</ul>
<p>ki linux kya hotha hey , linux ek o.s hotha hey - har ek o.s ka dil rehtha hey - ud dil ko bolthey hey kernal ]</p>
<p>kernal basically purey o.s ko chalaney liye jo coding files , processors , program required hothi hey vo kernal key pass hothey hey</p>
<p>kernal ka founder linux - ab is kernal ka kuch kaam hotha hey processes chalana ae hotha hey</p>
<ul>
<li><p>ae c program mey likha hua kernal hey , humko c nahi aathi , hum kaisa chalaye , hum ko aek program chahiye is kernal ko bath karey thab aajatha hey shell</p>
</li>
<li><ul>
<li><p>shell basically ek programm terminal hotah hhey jaha sey kernal ko bath kar pathey</p>
<p>    * shell key commands rehthey hey , un commands ko use karkey shell commands sey hum bath karthey hey</p>
<p>    * shell ek gateway hey aapko aur kernal key beech mey rehtha hey</p>
<p>    * bootloader ky ahotha hey - aisa samajlo aap ka computer start hotha hey</p>
<p>    boot loader ek aesi proceesor hey jo o.s mey files rehthi hey kerma; mey rakhey huey process ko jagah detha hey - gnu - grub - - it helps to boot your entire system</p>
<p>    * grand unified boot loader (grub)</p>
</li>
</ul>
</li>
</ul>
<p>aapkey center mey rehtah hey kernal - kernal key uppar shell - shell key uppar application utilities rehthey hey</p>
<p>shell kernal sey kernal - hardware sey bath kartha hey = kernal change karega hadrware ko</p>
<p>df -h - command jo b disk ka infro hey dikh jayega</p>
<ul>
<li><p>free -h = system memory usage ., ram usage check kartha hey</p>
</li>
<li><p>cpu ka usage - Top command sey dekh sakthey hey</p>
</li>
</ul>
<p>Linux file system kya hotah hey</p>
<ul>
<li>in lunux everything in system treated as files , everything starts from / - isko bolthey hey / root folder - iskey andar bohot saare folders rehthey hey</li>
</ul>
<p>cd - change directory - ek directiory sey dueri directoey ko jana hey toh cd use kartha hun</p>
<p>cd / - ismey aapko bohot saarey folders dikhthey hey</p>
<p>linux harrek cheez ko segregate kartha hey - agar merey logs aaaye toh linux var mey store kartha hey</p>
<p>agar jithey mey b linux users hey - usr mey store kartha hey</p>
<p>toh linux mey harrek cheez file system sey based hey</p>
<p>#state of proceeses in linux : agar aapko cpu mey kya chalra hey ytoh top - aap dekh sakthey ehy kithey processes het , kithne chalre hey kithey sokey hey dekh sakthey hey</p>
<p>actually ae background mey process id sey run hothey hey</p>
<h1 id="heading-linux-commands">linux commands ":</h1>
<ul>
<li><p>date : date is used to see teh current time and date</p>
</li>
<li><p>ls - list of files it shows cin current directory</p>
</li>
<li><p>mkdir devops - it creates the directory</p>
</li>
<li><p>ls -l - its hows the detaills of file or folders - permissions , owner of thr filr or dir , sixe, date and time and file/folder name - first character denotes teh file or dir</p>
</li>
<li><p>pwd - is used to see hwere we are currently</p>
</li>
<li><p>touch - is used to create a new file</p>
</li>
<li><p>clear - it cl;ears the terminal</p>
</li>
<li><p>cd - change directory - cuurent directory sey kisi aur directory ko jana hey</p>
</li>
<li><p>cd .. - one directory back</p>
</li>
<li><p>rmdir - deletes the empty directory</p>
</li>
<li><p>rm - delete the files</p>
</li>
<li><p>rm -rf folder - if folder has any files or subdirectories - recursively deleted</p>
</li>
<li><p>cat - file ko dekhna hey toh cat use kartha hey</p>
<ul>
<li><p>agar file mey kuch print karna hey “ echo “ hello world” &gt; demofile.txt</p>
</li>
<li><p>redirect karne | echo "“how are u “ » demofile.txt</p>
</li>
</ul>
</li>
</ul>
<p>zcat : agar aapki koi zip file hey compressed file hey vo compressed file ko dekhna hey contents ko dekhney zcat use karthey</p>
<p>head : first 10 lines dekhna hey file key head use karthey hey</p>
<p>tail - nichey key 10 liens dekhne use karthey hey</p>
<p>tail -n number filename</p>
<p>more and less aisa samaj lo aapkey pass badi file hey , agar file ka content ek page ,dusa page , i mean page by page screen dikhayega</p>
<p>it shows in pagenated way</p>
<p>cp : mujey ek file or folder ko kahi aur pey copy karna hey mujhey cp command use karna</p>
<ul>
<li><p>cp oldfilename newfile name - backupfile hojatha</p>
</li>
<li><p>cp -r cloud/ devops/ - cloud folder ko devops name key folder mey copy kar diya</p>
</li>
</ul>
<p>mv : mujhey copy nahi move karni hey file i will use mv command</p>
<ul>
<li><p>rename karni hey thabbi mv use karthey hey</p>
</li>
<li><ul>
<li>mv oldname newname</li>
</ul>
</li>
</ul>
<p>wc: agar muhey ae file.txt mey kithey words , lines , characters / kithni storage ki hey bytes hey toh mai wc command use kar saktha hun</p>
<p>hardlink : dekho jab windows mey aapko game khelna hotah hey c mey rehtha tha aap hamesh thodi hi c mey jakey khelthey usko shortcut banathey hey dekstop mey</p>
<ul>
<li><p>links are shortcuts - hardllink ae aisa shortcut rehtha hey jaha pey agar aapka jo main vali file delete hogi bhi shortcut hey zinda rehtha hey</p>
</li>
<li><p>softlink aisa hey agar main file dleet hogayi shortcut b delete hojathi</p>
</li>
<li><ul>
<li><p>echo “hi “ &gt; devops.txt</p>
<p>    * ln /home/ubuntu/cloud?devops/devops.txt hardlink-file</p>
<p>    * ln -s /home/ubuntu/cloud/devops/devops.txt softlinkfile</p>
<p>    * ls -ltr , toh agar orinal location mey content change hua toh softlink mey bhi change hojatha</p>
</li>
</ul>
</li>
</ul>
<p>cut = cut kya kartha hey jo file mey content hey like “ this is my file” - aisey 4 words hey lets say ek word 2 bytes ka hey</p>
<ul>
<li><p>cut -b 1 myfile.txt → cut -b 1-4 myfile.txt</p>
</li>
<li><p>file mey sey chotasa portion chahiye cut karkey dey detha</p>
</li>
</ul>
<p>tee - echo “ heloo” | tee - toh vo cheex screen pey b dikhayegi aur aapko file mey dalni hey vo file mey b dal dethi hey</p>
<ul>
<li><p>echo “heloo” | tee heloo.txt</p>
</li>
<li><p>to take input and display the output on screen and also in file i have to send</p>
</li>
</ul>
<p>sort : it allows to sort the order in alphabbetically</p>
<p>clear - clar the terminal</p>
<p>diff - mujhe do files mey kya diff hey dekhna hey</p>
<ul>
<li>diff demo.file hardlink.file</li>
</ul>
<p>vim : vim ek editor jaisa hey edit karne key liye</p>
<p>ssh : merey pass ae linux instance hey ae kahi dhoor pey rakha hua instance hey agar muhey udhar thak paunchna hey through ssh sey</p>
<ul>
<li><p>remote server ko secure shell sey connect karna hey toh ssh use kar sakthey hey ssh ko kuch ports use karthey hey 22 ae enable rehna hey</p>
</li>
<li><p>aap rahul aap anjali sey bath karreho , ab anjali aapsey thabhi bath karegi anjali ka numer aapkey pass hoga - anjalaki ka number private hey - anjali rahulko degi , rahul public name hey na toh rahul anjali ko pata hona like public key agar anjali key pass public key hoga toh ki connect hoga</p>
</li>
<li><p>ssh -i pemfile username<a class="user-mention" href="https://hashnode.com/@ipaddress">ipaddress</a></p>
</li>
<li><p>aur putty b use kar sakthey hey , mobaxterm use kar sakthey hey</p>
</li>
</ul>
<p>df : tumara system hey usmey kithna storage use hua kithna bacha hua hey dekhme key liye dekh sakthey hey</p>
<ul>
<li><p>ismey itney blocks hey ithney used hey ithney available hey</p>
</li>
<li><p>storage key bharame dikhatha hey</p>
</li>
</ul>
<p>du : disk utility - kisi particular folder or file ka sixe kithna use kiye dekhnekey liye use karthey hey</p>
<p>ps: processor ps batata hey ki particular command bash hey vo counsi processor pey chalra</p>
<p>top : total saare processor live mey batata hey</p>
<p>fuser : fuser vo ek particular file key liye ,</p>
<p>kill - kisi process ko kill karna hey kill use karthey hey</p>
<p>free : merey pass ithna ram ithna used , ithna available hey regarding ram dikhayega</p>
<p>nohup: generally applications mey use karthey hey - aek application mey loga aarey hey us loga ko kisi file mey store karna hey</p>
<ul>
<li><p>nohub free -h - ek file banadega nohup,out usmey iska output daldega</p>
</li>
<li><p>agar mai chala unga nohub df -h</p>
</li>
<li><p>pehla vala output aisa hi rahega aur dusra vala b aatha hi collect hotha hi hoga</p>
</li>
</ul>
<p>vmstat - jo virtual memory rehthi hey aapki vo dikhadetha</p>
<ul>
<li>vmstat -a virtual memory mey ithna free hey ithna active inactive ram key bharame bata detha hey</li>
</ul>
<h1 id="heading-system-level-commands">system level commands :</h1>
<p>jabbi ek devops engineeer apna sysem open kartha hey usko system key bhaaremey jankari reha hey , kounlogged in kiya kkounsey user sey logged in hey , kounsa o.s hey kithne der sey chalra , last logged in kab hey</p>
<ol>
<li><p>uname: aap kounsey platform mey linux chalare ho jaisey ubuntu - mujhey pata chaltah hey kounsa platform chalara hun pata chaltha hey</p>
</li>
<li><p>uptimr: aapka system kithni der sey chalra hey - last 10:41 up 9 min sey , load average - 1 user active hey</p>
</li>
<li><p>date : current date na dtime</p>
</li>
<li><p>who , whoami key dif</p>
<ul>
<li><p>who - kounsey user ney loginkab login kiya tha , kithney users ae system ko logged in kiye hey</p>
</li>
<li><p>whoami - system meu current user logged in user hey uska user name dekhna hey whoami</p>
</li>
<li><p>agar uskey sab activities dekhna hey who likhdunga</p>
</li>
</ul>
</li>
<li><p>which : ae devops ko - let say merey pass bash installed hey kounsa bash installed hey</p>
<ul>
<li><p>which bash - vo batadega us batch ki location</p>
</li>
<li><p>which cp : insatlled ka location batadega</p>
</li>
</ul>
</li>
<li><p>id : ae bada hi important cheez hotha hey - jis user sey logged in hua uska id kya hey , uska group id kya hey</p>
<ul>
<li>id - ubuntu ka id , ubuntu gid ae sab details batadega</li>
</ul>
</li>
<li><p>sudo - aap aur ek user banaya same gharoe rehre aap kithna package kamathey hey ae sab farak nahi padtha gharpe sudo papa root ki chalegi</p>
<ul>
<li><p>agar aapka ghar linux ka machine hey jithna b users add chalalo papa si toh koi bada nahi rehtha root user key pass saari permissions rehthi hey</p>
</li>
<li><p>super user - ubuntu jethalal ki file delete karna hey iskey pass permissions nahi rehtha thab sudo ka permission letha hey</p>
</li>
<li><p>agar aapko kisi cheez ki permissions nahi mil pari toh sudo use karlethey</p>
</li>
<li><p>cat /etc/groups</p>
<ul>
<li>mujhey agar sudo use karunga yag sudo group mey add karunga</li>
</ul>
</li>
</ul>
</li>
<li><p>shutdown: aapkey systemko shutdown karni hey papa ki permission lekey shutdow karo</p>
</li>
<li><p>reboot: system ko restart karne key liye use karthey hey</p>
</li>
<li><p>apt , yum , dnf , pacman</p>
<ul>
<li><p>apt - application package manger ubuntu package install karnekey liye use karthey hey</p>
</li>
<li><p>sudo apt install docker - docker ko isi system mey dhundra hey , heyi nahi toh internet sey lekey aaunag</p>
</li>
<li><p>sudo apt-get docker.io - internet sey lekey aakey download karrahun</p>
</li>
<li><p>sudo apt remove docker.io - uninstall hojayega</p>
</li>
<li><p>YUM , DNF , PACMAN - AE b package managers hey alag alag distributions ka</p>
</li>
<li><p>centos- yum , dnf - fedora ka , pacman - arch , redhat - rpm</p>
</li>
</ul>
</li>
<li><p>which docker - kaha pey install hua hey dikhayega</p>
</li>
</ol>
<h1 id="heading-users-and-files">users and files :</h1>
<p>linux famous hua because multi user feauture hey</p>
<ol>
<li><p>user kaisa create karthey hey - useradd -m ajay - permission denied - without sudo you cannot create</p>
<ul>
<li><p>sudo sueradd -m vaseem - creates user wih home directory</p>
</li>
<li><p>passwd vaseem - creates the password</p>
</li>
</ul>
</li>
<li><p>su vaseem - switch user - agar merko user switch karni hey su use kar saktha hun</p>
<ul>
<li><p>whoami</p>
</li>
<li><p>pwd</p>
</li>
</ul>
</li>
<li><p>userdel : user ko delete karna hey - &gt; sudo userdel ajay</p>
</li>
<li><p>grouppadd : ap as a devops engineer ek company mey add hothey hey , humdevops engineer hey , bohot saare users add huey company mey , 3 log testers , 2 log devops key</p>
<ul>
<li><p>in devops logon key roles and permissions honge , as a devops engineer in sab ko kaisa add karenge aur roles and permissions denge</p>
</li>
<li><p>toh mai group banaunag tester and devops us group mey test employee ko tester group mey add , aur devops valaey ko devops group mey</p>
</li>
</ul>
</li>
</ol>
<p>    #sudo useradd 1, 2, 3,4</p>
<p>    #groupadd devops test</p>
<p>    #cat /etc/passwd</p>
<p>    #cat /etc/group</p>
<ol start="5">
<li><p>gpasswd: group mey members ko add karna hey</p>
<ul>
<li><p>sudo gpasswd -a ajay devops</p>
</li>
<li><p>sudo gpasswd -a devops devops</p>
</li>
<li><p>sudo passwd -a rohit tester</p>
</li>
<li><p>sudo gpasswd -M kohli,rahul,dhawan tetser</p>
</li>
</ul>
</li>
<li><p>groupdel : sudo groupdel tester ; agar group delete karni hey th ae command use karthey hey</p>
</li>
</ol>
<h1 id="heading-file-permission-commands">file permission commands</h1>
<p>ae groups and users ko kiun create kiya - ae isloye kiyatha un users ko in files and folder ks paoper access miley</p>
<p>file ko permission ki kya zaroorath hey</p>
<ul>
<li><p>agar ls -l kiun toh iska info aaga</p>
</li>
<li><p>first charcter - defines either file , folder or link than next permissions - user , group other</p>
</li>
<li><p>r= read =4 ; write =2 =w ; x=execute=1</p>
</li>
</ul>
<ol>
<li><p>chmod : agar merko file ka permission change karni hey mai chnagemod - chmod use kartah hun</p>
<ul>
<li>chmod 777 filename / folder name</li>
</ul>
</li>
<li><p>umask : umask 0002 - ki jabbi koi file create karthey ho by default permisions kya honi chhaiye iskey liye umask rehtha hey</p>
</li>
<li><p>chown : used to change owner</p>
</li>
<li><p>chgrp used to chnage group</p>
</li>
</ol>
<h1 id="heading-compression-command">compression command :</h1>
<ol>
<li><p>zip , gunzip ,and gzip : agar merey pass bohot saarey files anf folders hey toh isko mai zip compress karna hey ae commands use karunag</p>
<ul>
<li><p>zip -r backup.zip folder</p>
</li>
<li><p>unzip backup.zip</p>
</li>
</ul>
</li>
</ol>
<p>    1.1 : tar : tar -cvf file.tar cloud/</p>
<ol start="2">
<li><p>tar , untar</p>
</li>
<li><p>scp : secure copy agar merko local sey remote , remote sey local ko files copy karni hey toh scp use karthey hey</p>
<ul>
<li><p>scp -i pem filename username<a class="user-mention" href="https://hashnode.com/@ipaddress">ipaddress</a>.</p>
</li>
<li><p>scp -i pem username@ip:remotefile loacl path</p>
</li>
</ul>
</li>
<li><p>rsync : same as scp but here it works as a remote sync</p>
<ul>
<li>rsync -e “ssh -i pemfile” -avz linux.file ubuntu@domainorip:/home/ubuntu/</li>
</ul>
</li>
</ol>
<h1 id="heading-networking-commands">Networking commands:</h1>
<ul>
<li><p>aap ho ek devops engineer - day to day life mey kartha kya hey - unka kaam zyada applications systems pey deploy karna</p>
</li>
<li><p>pehle devops kya karega agar application kaam nahi karra - us application ko ping karega</p>
</li>
</ul>
<ol>
<li>ping : ping ek command rehthi hey jo aapko batathi hey ae particular cheez po data recieve hori hey , data pahunchpara yah nahi</li>
</ol>
<ul>
<li><p>ping sigmasoftinfotech.com — main pahunch para yah nahi yah mere thak data pahunchra hey yah nahi</p>
</li>
<li><p>aapka internet b chalra aur revice b hora</p>
</li>
<li><p>ping internet bhejtha hey aur recieve b kartha hey</p>
</li>
</ul>
<ol start="2">
<li><p>netstat - netstat ae rehtha hey matlab network statistics - network key related jithney b cheeze b hey bvo batata hey</p>
<ul>
<li><p>bohot imp command - netstat ney kya kiya - top pey active internet connections - matlab aapkey system pey active internet connections ko dikha detha hey</p>
</li>
<li><p>kissi server pey active connections and protocals kounsey kounsey hey</p>
</li>
<li><p>jab tum ec2 use karthey hey bohot saarey sockets use hothey hey , sockerts matlab aisa samajloki one system sey dusri system sey yah type key interface sey connect karna hey sockets use hothey hey</p>
</li>
</ul>
</li>
<li><p>net-tools key andar - netstat ,,traceroot , telnet , ns-lookup ae sab particular tool kit key andar aatha hey isko use karnekey liye net tools install karni hey</p>
</li>
<li><p>ifconfig : bhaiyay ifconfig kya hey ; interface</p>
<ul>
<li><p>dockero , eth0 , i0 aatha hey - jithney b network interfaces hey idhar dikhata hey</p>
</li>
<li><p>ethernet cable eth0 - docker ek interface chalatha hey jab install karneke badh , ae ethernet kis cheez key connect hua rehtha (NIC) network interface card ae network ko jodneykey liye kaam aatha hey</p>
</li>
<li><p>l0 matlab loop back - matlab aapka jo system hey - lets sey nic kuch b connect nahi hua - local server ko loop back server bolthey internally chalega hamare server mey</p>
</li>
</ul>
</li>
<li><p>traceroute kya hey tracepath kya hey</p>
<ul>
<li><p>ae duniya mey hamko aek jhoot batadiya - server kaisa work hotha hey ae same concept - is cheez ko bolthey hey route is route ko trace karnekey liye trace route command use karthey hey</p>
</li>
<li><p>traceroute youtube.com-</p>
<ul>
<li><p>sabse pehle traceroute kya kartha hey - pehle kaha gaya phi ekounsey ip pey gaya trace karthey hey kaha kaha pey hops huey dekhney key liye</p>
</li>
<li><p>ipaddress finder open karkey check karo</p>
</li>
</ul>
</li>
<li><p>tracepath sigmasoftinfotech.com</p>
<ul>
<li>sabsey pehle local host - sey kaha kaha hops hora karkey</li>
</ul>
</li>
<li><p>mtr = ping+tracepath ping b karega , path b batayega</p>
<ul>
<li>mtr sigmasoftinfotech.com , idhar 9 baar hops kartha hey , traceroute mey 30 baar route hos kartah hey</li>
</ul>
</li>
<li><p>nslookup : nslookup sigmasoft.com - koi domain dhang sey chalra active hey yah nahi aur uska ip address '- active ey yah nahi dikhatha hey</p>
</li>
<li><p>telnet : telnet b same kartah hey particular website domain and port per connect karnemey help kartha hey</p>
</li>
</ul>
</li>
<li><p>hostname: batadega ki is system ka hostaname kya hey</p>
<ul>
<li><p>agar merko hostaname ka name chane karna hey sudo hostname sigamblr.com</p>
</li>
<li><p>cat /etc/hosts - idhar b chane kar sakthey hey</p>
</li>
</ul>
</li>
<li><p>ip : apne computer ka adress dikhana hey - ip address show</p>
</li>
<li><p>iwconfig - jithney b wireless connections hothey hey — mujhey ab thak - ip , if , iw mila</p>
<ul>
<li><p>aapko wireless cheeze karni hey wireless-tools install karna padtha hey</p>
</li>
<li><ul>
<li>iwconfig - agar koi wifi -wireless hoga toh dikhadega</li>
</ul>
</li>
</ul>
</li>
<li><p>ss - ky hotha hey jaisa netstat hey na same ss detha hey</p>
</li>
<li><p>dig : agar aapko kisi b domainname ka info nikalna hey</p>
<ul>
<li><p>kaha pey host kiya hey</p>
</li>
<li><p>whois - kaha sey kharida hey domainanme - kaha sey registry hui hey toh whois use karo</p>
</li>
</ul>
</li>
<li><p>nc:</p>
</li>
<li><p>arp: address resolution , aapka device ka ddress rehtahey host ek router sey mac address mangatha hey vo router mac affress detha hey vo janneyka command arp.</p>
</li>
<li><p>ifplugstatus: batata hey aapkey interfacces chalre hey yah nahi</p>
</li>
</ol>
<p>ae comands jo b ab padthey hey ae use karthey hi karthey hey</p>
<ol>
<li><p>curl vs wget : curl jo hotha hey na , ae jo curl ae command aapki end points ko call karne key liye</p>
<ul>
<li><p>api kya hotah hey ae aap ho aur vo aapka server - aap directly sevrer sey bath nahi karthey usi tarikhey sey ae aapho aur ae aek restaurant hey mcdonals aap directly kichen pey nahi ghusthey - waiter ko bolthey hey waiter na api hey</p>
</li>
<li><p>user will ask api to get something from server then server give the respone .</p>
</li>
<li><ul>
<li>curl -X GET apiendpoint | jq - agar tum ko is reponse ka data ko sundar sey dikhana hey jq likhdo</li>
</ul>
</li>
</ul>
</li>
<li><p>wget : aisa samajlo internet se kisi cheez ko download karni hey wget use karthey hey</p>
<ul>
<li>wget url</li>
</ul>
</li>
<li><p>iptables : pura ek jaisey , vpc peering mey route tables rehthey hey - ip : rote table sab dikhatha hye</p>
<ul>
<li>sudo iptables —list-rules</li>
</ul>
</li>
<li><p>watch - jo command hey ae agar aapko koi b chalani hey uski output har ek 22 seconds pey dekhni baar baar dekhni hey</p>
<ul>
<li>watch -n 5 top , watch top</li>
</ul>
</li>
<li><p>nmap : bacially network map rehtha hey - pura network map - kind of route tables - ae ip kidar jatha hey , kya kya port sopen mey hey dekh saktheyhey</p>
<ul>
<li>nmap -v sigmasoftinfotech.com</li>
</ul>
</li>
<li><p>route : agar aapko aapne routes change karni hey - gatewya dikhatha hey - route table , inetrenet kaha sey route hori hey , subnets kaha sey route horey dikhatha heyy</p>
</li>
</ol>
<h1 id="heading-pro-linux-command-s">pro linux command s:</h1>
<ul>
<li><p>awk</p>
</li>
<li><p>sed</p>
</li>
<li><p>grep</p>
</li>
<li><p>shellscript nahi likhni commands se hi khelna hey</p>
</li>
</ul>
<p>toh awk hey ek command hey khub hi programming hey awk command : aek file hey us file mey , kuch range sof line slikalni hey , count dikahan hey kuch log files hey us log files mey key kuch data extract karna hey ae saari cheezon ko kaisa help karthi hey</p>
<ul>
<li><p>download one log file ,</p>
</li>
<li><p>head -n 2 app.log</p>
</li>
<li><p>mujhey data time chahiye</p>
</li>
<li><p>awk ‘ {print}‘ app.log -→ awk ‘ {print $1,$2}’ app.log -→</p>
<ul>
<li><p>mujhey sirf info lines chahiye -→ awk ‘/INFO/ {print $1,$2,$3,$4}’ app.log &gt; info.log</p>
</li>
<li><p>kithni baar info aaya hey -→ awk ‘/INFO/ {count++} END {print count}’ app.log</p>
<ul>
<li><p>awk ‘/ipaddress/ {count++} END {print count}’ app.log</p>
</li>
<li><p>ae logs hey 8:40 pm start huey aur 8:53 mey khatam huey mujhye 8:53 key hi logs chahiye</p>
<p>  ae time kounsey column pey aaya hey</p>
</li>
<li><p>aws ‘ $2 &gt;= “08:53:00” &amp;&amp; $2 &lt;= “08:53:59” {print $2,$3,$4}’ app.log</p>
</li>
<li><p>awk ‘NR &gt;==2 &amp;&amp; NR &lt;=10 {print NR}‘ app.log</p>
</li>
</ul>
</li>
<li><ul>
<li>awk mey jo data chahiye na aek format data chahiye , , formated data , csv , tsv - format data hey awk chaltha hey</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>SED: sed hi awk jaisa tool hey stream editor - jo b aapka streaming data aara - vo real time mey edit b kar sakthey hey</p>
<ul>
<li><p>sed -n ‘ /INFO/p‘ app.log # yaha apko expressions dena padthi hey exact match karneke liye -n dena padtha hey , pattern match ko p dalna hey</p>
</li>
<li><p>sed , line by line kaam kartha hey , jaha jaha pey i ibfo likha mujhey INFO hey usko replace kardo LOGS sey jo is cheez ko karthey globally kardo</p>
</li>
<li><ul>
<li><p>sed ‘s/INFO/LOG/g ‘ app.log - info kounsi line pery aay ahey</p>
<ul>
<li>sed '-n -e ‘s/INFO/'=’ app.log → = showing line number , row also print karani hey → ed '-n -e ‘/INFO/'=’ -e ‘/INFO/p’ app.log</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>        <code>-sed ‘1,15 s/INFO/LOG/g;1,10p; 11q ’ app.log</code> #; this symbol is pause the command</p>
<hr />
<h1 id="heading-linux">Linux :</h1>
<h3 id="heading-1-how-the-internet-works"><strong>1. How the Internet Works</strong></h3>
<p>The internet is a global network of computers that communicate with each other to share information. Let’s break it down step by step:</p>
<ul>
<li><p><strong>Optical Fiber Cables</strong>:</p>
<ul>
<li><p>The internet uses optical fiber cables, which are thin cables made of glass or plastic that carry data as light signals.</p>
</li>
<li><p>These cables are laid under the sea (submarine cables) to connect continents and countries. They transfer data at very high speeds.</p>
</li>
<li><p>Example: If you’re in India and accessing a website in the USA, your data travels through these undersea cables.</p>
</li>
</ul>
</li>
<li><p><strong>Data Centers</strong>:</p>
<ul>
<li><p>Data centers are large buildings filled with powerful computers called servers. These servers store and process data for websites, apps, and services like YouTube or Facebook.</p>
</li>
<li><p>The optical fiber cables connect to these data centers to send and receive data.</p>
</li>
</ul>
</li>
<li><p><strong>ISP (Internet Service Provider)</strong>:</p>
<ul>
<li><p>The ISP is like a middleman that connects your device (phone, laptop) to the internet.</p>
</li>
<li><p>Example: Companies like Jio, Airtel, or Comcast provide internet access to your home. They connect your device to the optical fiber cables and data centers.</p>
</li>
</ul>
</li>
<li><p><strong>How Data Flows</strong>:</p>
<ul>
<li><p>When you open YouTube on your phone, your request goes through your ISP, travels via optical fiber cables to a data center, and the server in the data center sends the video back to you.</p>
</li>
<li><p>This happens very fast, so you see the video streaming on your phone almost instantly.</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-2-what-is-a-server"><strong>2. What is a Server?</strong></h3>
<p>A server is just a powerful computer that provides (or “serves”) information or services to other devices, called clients.</p>
<ul>
<li><p><strong>Server’s Job</strong>:</p>
<ul>
<li><p>A server’s main job is to respond to requests from clients. For example, when you visit a website, your browser (the client) asks the server for the website’s data, and the server sends it back.</p>
</li>
<li><p>Example: You type “<a target="_blank" href="http://youtube.com">youtube.com</a>” in your browser. The YouTube server sends the video or webpage to your device.</p>
</li>
</ul>
</li>
<li><p><strong>Client’s Job</strong>:</p>
<ul>
<li><p>A client is your device (phone, laptop, etc.) that requests information from a server.</p>
</li>
<li><p>Example: Your phone (client) asks the YouTube server for a video, and the server delivers it.</p>
</li>
</ul>
</li>
<li><p><strong>Domain and DNS</strong>:</p>
<ul>
<li><p>A domain is a human-readable name like “<a target="_blank" href="http://youtube.com">youtube.com</a>” or “<a target="_blank" href="http://facebook.com">facebook.com</a>” that points to a server.</p>
</li>
<li><p>Every server has an IP address (like 192.168.1.1), which is like its unique address on the internet.</p>
</li>
<li><p>A <strong>DNS server</strong> (Domain Name System) connects the domain name (<a target="_blank" href="http://youtube.com">youtube.com</a>) to the correct IP address of the server.</p>
</li>
<li><p>Example: When you type “<a target="_blank" href="http://youtube.com">youtube.com</a>,” the DNS server finds the IP address of YouTube’s server and connects you to it.</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-3-difference-between-web-server-and-application-server"><strong>3. Difference Between Web Server and Application Server</strong></h3>
<ul>
<li><p><strong>Web Server</strong>:</p>
<ul>
<li><p>A web server delivers static content, like HTML pages, images, or CSS files, to your browser.</p>
</li>
<li><p>Example: If you visit a simple webpage with text and images, the web server sends those files to your browser.</p>
</li>
<li><p>Common web servers: Apache, Nginx.</p>
</li>
</ul>
</li>
<li><p><strong>Application Server</strong>:</p>
<ul>
<li><p>An application server handles dynamic content and business logic. This means it processes data, runs calculations, or interacts with databases to create content on the fly.</p>
</li>
<li><p>Example: When you log in to Instagram, the application server checks your password, fetches your posts, and sends them to your phone.</p>
</li>
<li><p>Common application servers: Tomcat, JBoss.</p>
</li>
</ul>
</li>
<li><p><strong>Key Difference</strong>:</p>
<ul>
<li><p>Web servers are for static content (pre-made files like images or HTML).</p>
</li>
<li><p>Application servers handle dynamic tasks (like processing login requests or generating personalized content).</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-4-types-of-applications"><strong>4. Types of Applications</strong></h3>
<p>Applications can be divided into two main types:</p>
<ul>
<li><p><strong>Standalone Applications</strong>:</p>
<ul>
<li><p>These apps don’t need the internet or a database to work.</p>
</li>
<li><p>Example: A feedback app at an airport where you click “Good” or “Bad” and it works offline without needing a server or database.</p>
</li>
<li><p>They are self-contained and run on your device alone.</p>
</li>
</ul>
</li>
<li><p><strong>Web Applications</strong>:</p>
<ul>
<li><p>These apps need the internet and often rely on multiple servers (application server, database server, email server, etc.).</p>
</li>
<li><p>Example: YouTube or Instagram. These apps stream videos, send notifications, and store data in databases, requiring a group of servers to work together.</p>
</li>
<li><p>They need a frontend (what you see), backend (business logic), and database (to store data like posts or videos).</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-5-application-support-and-maintenance"><strong>5. Application Support and Maintenance</strong></h3>
<ul>
<li><p><strong>What It Means</strong>:</p>
<ul>
<li><p>Applications (like apps on your phone or software on your laptop) run on an operating system (like Linux or Windows).</p>
</li>
<li><p>Support and maintenance mean ensuring these applications run smoothly without crashing and fixing issues if they arise.</p>
</li>
</ul>
</li>
<li><p><strong>DevOps or Linux Admin’s Role</strong>:</p>
<ul>
<li><p>A DevOps engineer or Linux admin checks if the application is running properly, if there are connection issues, or if a server is causing problems.</p>
</li>
<li><p>Example: If YouTube stops streaming, they check which server (web server, application server, or database) is having an issue.</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-6-what-is-linux"><strong>6. What is Linux?</strong></h3>
<ul>
<li><p><strong>Linux Basics</strong>:</p>
<ul>
<li><p>Linux is an open-source operating system, meaning anyone can use or modify it for free.</p>
</li>
<li><p>It was created by Linus Torvalds in 1991.</p>
</li>
<li><p>Most servers (90%) run on Linux because it’s secure, doesn’t need antivirus, supports multitasking, and gets community updates.</p>
</li>
</ul>
</li>
<li><p><strong>Why Companies Use Linux</strong>:</p>
<ul>
<li><p>It’s free, secure, and highly customizable.</p>
</li>
<li><p>Most web applications (like YouTube, Instagram) run on Linux servers.</p>
</li>
</ul>
</li>
<li><p><strong>Linux vs. Unix</strong>:</p>
<ul>
<li><p>Unix is a commercial operating system (like macOS).</p>
</li>
<li><p>Linux is a free, open-source version inspired by Unix.</p>
</li>
<li><p>Example: macOS is Unix-based, while Ubuntu is a Linux distribution.</p>
</li>
</ul>
</li>
<li><p><strong>How to Install Linux</strong>:</p>
<ol>
<li><p><strong>WSL (Windows Subsystem for Linux)</strong>: Run Linux inside Windows without a separate machine.</p>
</li>
<li><p><strong>VirtualBox</strong>: Install Linux on a virtual machine on your computer.</p>
</li>
<li><p><strong>Cloud</strong>: Use cloud platforms like AWS, Azure, or GCP to create a Linux virtual machine.</p>
</li>
<li><p><strong>Vagrant</strong>: A tool by HashiCorp to easily set up Linux environments.</p>
</li>
</ol>
</li>
</ul>
<hr />
<h3 id="heading-7-linux-vs-windows"><strong>7. Linux vs. Windows</strong></h3>
<ul>
<li><p><strong>Windows</strong>:</p>
<ul>
<li><p>Requires a license (you pay for it).</p>
</li>
<li><p>Needs antivirus software.</p>
</li>
<li><p>Regular updates are mandatory.</p>
</li>
<li><p>Focused on user-friendly interfaces for general use (like gaming or office work).</p>
</li>
</ul>
</li>
<li><p><strong>Linux</strong>:</p>
<ul>
<li><p>Free under the General Public License (GPL).</p>
</li>
<li><p>No need for antivirus due to strong security.</p>
</li>
<li><p>Updates are optional (e.g., Ubuntu releases updates twice a year).</p>
</li>
<li><p>Focused on development, networking, programming, and scripting.</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-8-remote-server-connection-tools"><strong>8. Remote Server Connection Tools</strong></h3>
<p>To connect to a remote server (a computer far away), you can use these tools:</p>
<ol>
<li><p><strong>RDP (Remote Desktop Protocol)</strong>: Connect to a server’s desktop remotely, like seeing its screen.</p>
</li>
<li><p><strong>SSH (Secure Shell)</strong>: Connect to a server’s command line securely using a terminal. Uses port 22.</p>
</li>
<li><p><strong>AnyDesk</strong>: A remote desktop tool for graphical access.</p>
</li>
<li><p><strong>UltraViewer</strong>: Similar to AnyDesk, for remote desktop access.</p>
</li>
</ol>
<hr />
<h3 id="heading-9-kernel-bootloader-and-shell"><strong>9. Kernel, Bootloader, and Shell</strong></h3>
<ul>
<li><p><strong>Kernel</strong>:</p>
<ul>
<li><p>The kernel is the core of the operating system. It’s like the heart of Linux.</p>
</li>
<li><p>It manages hardware, processes, and files. It’s written in the C programming language.</p>
</li>
<li><p>Example: The kernel controls how your CPU runs programs or how your hard drive stores data.</p>
</li>
</ul>
</li>
<li><p><strong>Shell</strong>:</p>
<ul>
<li><p>A shell is a program that lets you talk to the kernel using commands.</p>
</li>
<li><p>It’s like a bridge between you and the kernel.</p>
</li>
<li><p>Example: When you type a command like ls, the shell sends it to the kernel, which lists the files.</p>
</li>
</ul>
</li>
<li><p><strong>Bootloader</strong>:</p>
<ul>
<li><p>The bootloader is a program that starts your operating system when you turn on your computer.</p>
</li>
<li><p>Example: GRUB (Grand Unified Bootloader) loads Linux by finding and starting the kernel and other necessary files.</p>
</li>
</ul>
</li>
<li><p><strong>How They Work Together</strong>:</p>
<ul>
<li><p>The bootloader starts the kernel.</p>
</li>
<li><p>The kernel runs the operating system and hardware.</p>
</li>
<li><p>The shell lets you interact with the kernel by typing commands.</p>
</li>
<li><p>Example: You type df -h in the shell to check disk space, the shell tells the kernel, and the kernel gets the data from the hardware.</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-10-linux-file-system"><strong>10. Linux File System</strong></h3>
<ul>
<li><p>In Linux, everything is treated as a file (even folders, devices, or processes).</p>
</li>
<li><p>The file system starts with the root folder, written as /.</p>
</li>
<li><p><strong>Key Directories</strong>:</p>
<ul>
<li><p>/: The root folder, the top of the file system.</p>
</li>
<li><p>/var: Stores logs (e.g., system or application logs).</p>
</li>
<li><p>/usr: Stores user-related data and programs.</p>
</li>
<li><p>/home: Stores user files (like your documents or downloads).</p>
</li>
</ul>
</li>
<li><p><strong>Navigating the File System</strong>:</p>
<ul>
<li><p>Use cd to change directories (e.g., cd /var to go to the var folder).</p>
</li>
<li><p>Use cd .. to go back one directory.</p>
</li>
<li><p>Use pwd to see your current directory.</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-11-linux-commands"><strong>11. Linux Commands</strong></h3>
<p>Here’s a breakdown of the Linux commands you mentioned, explained simply:</p>
<ol>
<li><p><strong>date</strong>: Shows the current date and time.</p>
<ul>
<li>Example: date → Output: Tue May 27 03:00:00 IST 2025</li>
</ul>
</li>
<li><p><strong>ls</strong>: Lists files and folders in the current directory.</p>
<ul>
<li>Example: ls → Output: file1.txt folder1</li>
</ul>
</li>
<li><p><strong>ls -l</strong>: Lists files/folders with details (permissions, owner, size, date).</p>
<ul>
<li>Example: ls -l → Output: -rw-r--r-- 1 user group 1024 May 27 file1.txt</li>
</ul>
</li>
<li><p><strong>mkdir devops</strong>: Creates a folder named “devops”.</p>
<ul>
<li>Example: mkdir devops → Creates a folder called devops.</li>
</ul>
</li>
<li><p><strong>pwd</strong>: Shows the current directory you’re in.</p>
<ul>
<li>Example: pwd → Output: /home/user/devops</li>
</ul>
</li>
<li><p><strong>touch file.txt</strong>: Creates an empty file named file.txt.</p>
<ul>
<li>Example: touch file.txt → Creates file.txt.</li>
</ul>
</li>
<li><p><strong>clear</strong>: Clears the terminal screen.</p>
</li>
<li><p><strong>cd foldername</strong>: Changes to the folder named “foldername”.</p>
<ul>
<li>Example: cd devops → Moves to the devops folder.</li>
</ul>
</li>
<li><p><strong>cd ..</strong>: Goes back one directory.</p>
<ul>
<li>Example: If you’re in /home/user/devops, cd .. takes you to /home/user.</li>
</ul>
</li>
<li><p><strong>rmdir foldername</strong>: Deletes an empty folder.</p>
<ul>
<li>Example: rmdir devops → Deletes the empty devops folder.</li>
</ul>
</li>
<li><p><strong>rm file.txt</strong>: Deletes a file.</p>
<ul>
<li>Example: rm file.txt → Deletes file.txt.</li>
</ul>
</li>
<li><p><strong>rm -rf foldername</strong>: Deletes a folder and all its contents (files and subfolders).</p>
<ul>
<li>Example: rm -rf devops → Deletes the devops folder and everything inside it.</li>
</ul>
</li>
<li><p><strong>cat file.txt</strong>: Displays the contents of a file.</p>
<ul>
<li>Example: cat file.txt → Output: hello world (if file.txt contains “hello world”).</li>
</ul>
</li>
<li><p><strong>echo "hello world" &gt; file.txt</strong>: Writes “hello world” to file.txt, overwriting it.</p>
<ul>
<li>Example: echo "hello world" &gt; file.txt → file.txt now contains “hello world”.</li>
</ul>
</li>
<li><p><strong>echo "how are u" &gt;&gt; file.txt</strong>: Appends “how are u” to file.txt without overwriting.</p>
<ul>
<li>Example: echo "how are u" &gt;&gt; file.txt → Adds “how are u” to the end of file.txt.</li>
</ul>
</li>
<li><p><strong>zcat file.gz</strong>: Displays the contents of a compressed (zipped) file without unzipping it.</p>
<ul>
<li>Example: zcat file.gz → Shows the contents of file.gz.</li>
</ul>
</li>
<li><p><strong>head file.txt</strong>: Shows the first 10 lines of a file.</p>
<ul>
<li>Example: head file.txt → Displays the first 10 lines of file.txt.</li>
</ul>
</li>
<li><p><strong>tail file.txt</strong>: Shows the last 10 lines of a file.</p>
<ul>
<li>Example: tail file.txt → Displays the last 10 lines of file.txt.</li>
</ul>
</li>
<li><p><strong>tail -n 5 file.txt</strong>: Shows the last 5 lines of a file.</p>
<ul>
<li>Example: tail -n 5 file.txt → Displays the last 5 lines.</li>
</ul>
</li>
<li><p><strong>more file.txt</strong>: Shows a file page by page (press space to see the next page).</p>
<ul>
<li>Example: more file.txt → Displays file.txt one screen at a time.</li>
</ul>
</li>
<li><p><strong>less file.txt</strong>: Similar to more, but you can scroll up and down.</p>
<ul>
<li>Example: less file.txt → Opens file.txt for scrolling.</li>
</ul>
</li>
<li><p><strong>cp file1.txt file2.txt</strong>: Copies file1.txt to file2.txt.</p>
<ul>
<li>Example: cp file1.txt file2.txt → Creates a copy of file1.txt named file2.txt.</li>
</ul>
</li>
<li><p><strong>cp -r folder1 folder2</strong>: Copies a folder and its contents.</p>
<ul>
<li>Example: cp -r cloud devops → Copies the cloud folder to a new folder named devops.</li>
</ul>
</li>
<li><p><strong>mv file1.txt file2.txt</strong>: Moves or renames a file.</p>
<ul>
<li>Example: mv file1.txt file2.txt → Renames file1.txt to file2.txt.</li>
</ul>
</li>
<li><p><strong>wc file.txt</strong>: Counts words, lines, and bytes (size) in a file.</p>
<ul>
<li>Example: wc file.txt → Output: 10 50 300 file.txt (10 lines, 50 words, 300 characters).</li>
</ul>
</li>
<li><p><strong>ln file.txt hardlink-file</strong>: Creates a hard link to a file (a shortcut that stays even if the original file is deleted).</p>
<ul>
<li>Example: ln file.txt hardlink-file → Creates a hard link to file.txt.</li>
</ul>
</li>
<li><p><strong>ln -s file.txt softlink-file</strong>: Creates a soft link (a shortcut that breaks if the original file is deleted).</p>
<ul>
<li>Example: ln -s file.txt softlink-file → Creates a soft link to file.txt.</li>
</ul>
</li>
<li><p><strong>cut -b 1-4 file.txt</strong>: Extracts a portion of text (bytes 1 to 4) from each line of a file.</p>
<ul>
<li>Example: cut -b 1-4 file.txt → Output: “this” (if file.txt contains “this is my file”).</li>
</ul>
</li>
<li><p><strong>tee file.txt</strong>: Writes output to both the screen and a file.</p>
<ul>
<li>Example: echo "hello" | tee file.txt → Shows “hello” on the screen and writes it to file.txt.</li>
</ul>
</li>
<li><p><strong>sort file.txt</strong>: Sorts the lines of a file alphabetically.</p>
<ul>
<li>Example: sort file.txt → Sorts the lines in file.txt.</li>
</ul>
</li>
<li><p><strong>diff file1.txt file2.txt</strong>: Shows differences between two files.</p>
<ul>
<li>Example: diff file1.txt file2.txt → Lists differences between file1.txt and file2.txt.</li>
</ul>
</li>
<li><p><strong>vim file.txt</strong>: Opens a file in the Vim editor for editing.</p>
<ul>
<li>Example: vim file.txt → Opens file.txt for editing.</li>
</ul>
</li>
<li><p><strong>ssh user@ipaddress</strong>: Connects to a remote server securely using SSH.</p>
<ul>
<li>Example: ssh -i key.pem ubuntu@192.168.1.1 → Connects to a server with IP 192.168.1.1 as the user “ubuntu” using a key file.</li>
</ul>
</li>
<li><p><strong>df -h</strong>: Shows disk space usage in a human-readable format.</p>
<ul>
<li>Example: df -h → Output: Shows used and available disk space.</li>
</ul>
</li>
<li><p><strong>du -h foldername</strong>: Shows the size of a folder or file.</p>
<ul>
<li>Example: du -h devops → Output: Shows the size of the devops folder.</li>
</ul>
</li>
<li><p><strong>ps</strong>: Shows running processes for the current session.</p>
<ul>
<li>Example: ps → Lists processes running in your terminal.</li>
</ul>
</li>
<li><p><strong>top</strong>: Shows live system resource usage (CPU, RAM, processes).</p>
<ul>
<li>Example: top → Displays a live view of running processes and system usage.</li>
</ul>
</li>
<li><p><strong>fuser file.txt</strong>: Shows which process is using a file.</p>
<ul>
<li>Example: fuser file.txt → Lists the process ID using file.txt.</li>
</ul>
</li>
<li><p><strong>kill 1234</strong>: Stops a process with the given process ID (e.g., 1234).</p>
<ul>
<li>Example: kill 1234 → Terminates process ID 1234.</li>
</ul>
</li>
<li><p><strong>free -h</strong>: Shows memory (RAM) usage in a human-readable format.</p>
<ul>
<li>Example: free -h → Output: Shows used and free RAM.</li>
</ul>
</li>
<li><p><strong>nohup command</strong>: Runs a command that keeps running even if you close the terminal.</p>
<ul>
<li>Example: nohup free -h &amp; → Runs free -h in the background and saves output to nohup.out.</li>
</ul>
</li>
<li><p><strong>vmstat</strong>: Shows virtual memory statistics.</p>
<ul>
<li>Example: vmstat -a → Shows active and inactive memory.</li>
</ul>
</li>
</ol>
<hr />
<h3 id="heading-12-system-level-commands"><strong>12. System-Level Commands</strong></h3>
<p>These commands give information about the system:</p>
<ol>
<li><p><strong>uname</strong>: Shows the operating system name (e.g., Linux, Ubuntu).</p>
<ul>
<li>Example: uname → Output: Linux</li>
</ul>
</li>
<li><p><strong>uptime</strong>: Shows how long the system has been running and the load average.</p>
<ul>
<li>Example: uptime → Output: 03:00:00 up 9 min, 1 user, load average: 0.01</li>
</ul>
</li>
<li><p><strong>who</strong>: Lists all users currently logged into the system.</p>
<ul>
<li>Example: who → Output: Lists usernames and login times.</li>
</ul>
</li>
<li><p><strong>whoami</strong>: Shows the current logged-in user.</p>
<ul>
<li>Example: whoami → Output: ubuntu</li>
</ul>
</li>
<li><p><strong>which command</strong>: Shows the location of a command.</p>
<ul>
<li>Example: which bash → Output: /bin/bash</li>
</ul>
</li>
<li><p><strong>id</strong>: Shows the user ID and group ID of the current user.</p>
<ul>
<li>Example: id → Output: uid=1000(ubuntu) gid=1000(ubuntu)</li>
</ul>
</li>
<li><p><strong>sudo</strong>: Runs a command with superuser (admin) privileges.</p>
<ul>
<li>Example: sudo apt install docker → Installs Docker with admin rights.</li>
</ul>
</li>
<li><p><strong>cat /etc/group</strong>: Shows the groups on the system.</p>
<ul>
<li>Example: cat /etc/group → Lists all groups and their members.</li>
</ul>
</li>
<li><p><strong>shutdown</strong>: Shuts down the system.</p>
<ul>
<li>Example: sudo shutdown now → Shuts down immediately.</li>
</ul>
</li>
<li><p><strong>reboot</strong>: Restarts the system.</p>
<ul>
<li>Example: sudo reboot → Restarts the system.</li>
</ul>
</li>
</ol>
<hr />
<h3 id="heading-13-package-managers"><strong>13. Package Managers</strong></h3>
<p>Package managers install, update, or remove software on Linux.</p>
<ol>
<li><p><strong>apt</strong>: Used on Ubuntu/Debian to manage packages.</p>
<ul>
<li><p>Example: sudo apt install docker → Installs Docker.</p>
</li>
<li><p>Example: sudo apt remove docker → Uninstalls Docker.</p>
</li>
</ul>
</li>
<li><p><strong>yum, dnf, pacman</strong>:</p>
<ul>
<li><p><strong>yum</strong>: Used on CentOS for package management.</p>
</li>
<li><p><strong>dnf</strong>: Used on Fedora, an improved version of yum.</p>
</li>
<li><p><strong>pacman</strong>: Used on Arch Linux.</p>
</li>
<li><p>Example: sudo yum install docker → Installs Docker on CentOS.</p>
</li>
</ul>
</li>
</ol>
<hr />
<h3 id="heading-14-users-and-groups"><strong>14. Users and Groups</strong></h3>
<p>Linux is a multi-user system, meaning many users can use it at once with different permissions.</p>
<ol>
<li><p><strong>useradd</strong>: Creates a new user.</p>
<ul>
<li>Example: sudo useradd -m vaseem → Creates a user “vaseem” with a home directory.</li>
</ul>
</li>
<li><p><strong>passwd</strong>: Sets a password for a user.</p>
<ul>
<li>Example: sudo passwd vaseem → Sets a password for user “vaseem”.</li>
</ul>
</li>
<li><p><strong>su</strong>: Switches to another user.</p>
<ul>
<li>Example: su vaseem → Switches to the user “vaseem”.</li>
</ul>
</li>
<li><p><strong>userdel</strong>: Deletes a user.</p>
<ul>
<li>Example: sudo userdel vaseem → Deletes the user “vaseem”.</li>
</ul>
</li>
<li><p><strong>groupadd</strong>: Creates a new group.</p>
<ul>
<li>Example: sudo groupadd devops → Creates a group named “devops”.</li>
</ul>
</li>
<li><p><strong>gpasswd</strong>: Adds users to a group.</p>
<ul>
<li>Example: sudo gpasswd -a ajay devops → Adds user “ajay” to the devops group.</li>
</ul>
</li>
<li><p><strong>groupdel</strong>: Deletes a group.</p>
<ul>
<li>Example: sudo groupdel devops → Deletes the devops group.</li>
</ul>
</li>
</ol>
<hr />
<h3 id="heading-15-file-permissions"><strong>15. File Permissions</strong></h3>
<p>Linux files and folders have permissions for the owner, group, and others.</p>
<ul>
<li><p><strong>Permissions</strong>:</p>
<ul>
<li><p><strong>r</strong> (read) = 4: Allows reading a file or listing a folder.</p>
</li>
<li><p><strong>w</strong> (write) = 2: Allows modifying a file or folder.</p>
</li>
<li><p><strong>x</strong> (execute) = 1: Allows running a file (like a script) or entering a folder.</p>
</li>
</ul>
</li>
<li><p><strong>chmod</strong>: Changes file or folder permissions.</p>
<ul>
<li>Example: chmod 777 file.txt → Gives full permissions (read, write, execute) to everyone.</li>
</ul>
</li>
<li><p><strong>umask</strong>: Sets default permissions for new files.</p>
<ul>
<li>Example: umask 0002 → New files will have permissions like 664 (rw-rw-r--).</li>
</ul>
</li>
<li><p><strong>chown</strong>: Changes the owner of a file or folder.</p>
<ul>
<li>Example: sudo chown ajay file.txt → Makes “ajay” the owner of file.txt.</li>
</ul>
</li>
<li><p><strong>chgrp</strong>: Changes the group of a file or folder.</p>
<ul>
<li>Example: sudo chgrp devops file.txt → Sets the group of file.txt to “devops”.</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-16-compression-commands"><strong>16. Compression Commands</strong></h3>
<p>These commands compress or decompress files and folders.</p>
<ol>
<li><p><strong>zip</strong>: Compresses files/folders into a .zip file.</p>
<ul>
<li>Example: zip -r <a target="_blank" href="http://backup.zip">backup.zip</a> folder → Compresses the folder into <a target="_blank" href="http://backup.zip">backup.zip</a>.</li>
</ul>
</li>
<li><p><strong>unzip</strong>: Extracts a .zip file.</p>
<ul>
<li>Example: unzip <a target="_blank" href="http://backup.zip">backup.zip</a> → Extracts the contents of <a target="_blank" href="http://backup.zip">backup.zip</a>.</li>
</ul>
</li>
<li><p><strong>tar</strong>: Creates or extracts .tar archives.</p>
<ul>
<li><p>Example: tar -cvf file.tar folder → Creates a file.tar archive from the folder.</p>
</li>
<li><p>Example: tar -xvf file.tar → Extracts the contents of file.tar.</p>
</li>
</ul>
</li>
<li><p><strong>gzip/gunzip</strong>: Compresses or decompresses files.</p>
<ul>
<li><p>Example: gzip file.txt → Compresses file.txt to file.txt.gz.</p>
</li>
<li><p>Example: gunzip file.txt.gz → Decompresses file.txt.gz.</p>
</li>
</ul>
</li>
</ol>
<hr />
<h3 id="heading-17-file-transfer-commands"><strong>17. File Transfer Commands</strong></h3>
<p>These commands transfer files between local and remote systems.</p>
<ol>
<li><p><strong>scp</strong>: Securely copies files between local and remote systems.</p>
<ul>
<li>Example: scp -i key.pem file.txt ubuntu@192.168.1.1:/home/ubuntu → Copies file.txt to a remote server.</li>
</ul>
</li>
<li><p><strong>rsync</strong>: Synchronizes files between local and remote systems, only transferring changes.</p>
<ul>
<li>Example: rsync -e "ssh -i key.pem" -avz file.txt ubuntu@192.168.1.1:/home/ubuntu → Syncs file.txt to a remote server.</li>
</ul>
</li>
</ol>
<hr />
<h3 id="heading-18-networking-commands"><strong>18. Networking Commands</strong></h3>
<p>These commands help manage and troubleshoot networks.</p>
<ol>
<li><p><strong>ping</strong>: Checks if a server or website is reachable.</p>
<ul>
<li>Example: ping <a target="_blank" href="http://youtube.com">youtube.com</a> → Shows if <a target="_blank" href="http://youtube.com">youtube.com</a> responds.</li>
</ul>
</li>
<li><p><strong>netstat</strong>: Shows network connections and statistics.</p>
<ul>
<li>Example: netstat → Lists active connections and ports.</li>
</ul>
</li>
<li><p><strong>ifconfig</strong>: Shows network interface details (like Ethernet or Wi-Fi).</p>
<ul>
<li>Example: ifconfig → Lists interfaces like eth0 (Ethernet) or lo (loopback).</li>
</ul>
</li>
<li><p><strong>traceroute</strong>: Shows the path data takes to reach a server.</p>
<ul>
<li>Example: traceroute <a target="_blank" href="http://youtube.com">youtube.com</a> → Lists all hops (routers) between you and <a target="_blank" href="http://youtube.com">youtube.com</a>.</li>
</ul>
</li>
<li><p><strong>tracepath</strong>: Similar to traceroute but simpler.</p>
<ul>
<li>Example: tracepath <a target="_blank" href="http://sigmasoftinfotech.com">sigmasoftinfotech.com</a> → Shows the path to <a target="_blank" href="http://sigmasoftinfotech.com">sigmasoftinfotech.com</a>.</li>
</ul>
</li>
<li><p><strong>mtr</strong>: Combines ping and traceroute.</p>
<ul>
<li>Example: mtr <a target="_blank" href="http://sigmasoftinfotech.com">sigmasoftinfotech.com</a> → Shows live ping and path data.</li>
</ul>
</li>
<li><p><strong>nslookup</strong>: Finds the IP address of a domain.</p>
<ul>
<li>Example: nslookup <a target="_blank" href="http://sigmasoftinfotech.com">sigmasoftinfotech.com</a> → Shows the IP address and server details.</li>
</ul>
</li>
<li><p><strong>telnet</strong>: Tests if a server is reachable on a specific port.</p>
<ul>
<li>Example: telnet <a target="_blank" href="http://sigmasoftinfotech.com">sigmasoftinfotech.com</a> 80 → Checks if port 80 is open.</li>
</ul>
</li>
<li><p><strong>hostname</strong>: Shows or sets the system’s hostname.</p>
<ul>
<li><p>Example: hostname → Output: mycomputer</p>
</li>
<li><p>Example: sudo hostname newname → Changes the hostname to “newname”.</p>
</li>
</ul>
</li>
<li><p><strong>ip</strong>: Shows IP address and network details.</p>
<ul>
<li>Example: ip address show → Lists all network interfaces and their IP addresses.</li>
</ul>
</li>
<li><p><strong>iwconfig</strong>: Shows wireless network details.</p>
<ul>
<li>Example: iwconfig → Lists Wi-Fi interfaces and details (if installed).</li>
</ul>
</li>
<li><p><strong>ss</strong>: Shows socket statistics (similar to netstat).</p>
<ul>
<li>Example: ss → Lists active network connections.</li>
</ul>
</li>
<li><p><strong>dig</strong>: Gets detailed DNS information for a domain.</p>
<ul>
<li>Example: dig <a target="_blank" href="http://sigmasoftinfotech.com">sigmasoftinfotech.com</a> → Shows DNS records.</li>
</ul>
</li>
<li><p><strong>whois</strong>: Shows who owns a domain and its registration details.</p>
<ul>
<li>Example: whois <a target="_blank" href="http://sigmasoftinfotech.com">sigmasoftinfotech.com</a> → Shows domain owner and registrar.</li>
</ul>
</li>
<li><p><strong>arp</strong>: Shows the Address Resolution Protocol table (maps IP addresses to MAC addresses).</p>
<ul>
<li>Example: arp → Lists devices on the network.</li>
</ul>
</li>
<li><p><strong>ifplugstatus</strong>: Checks if network interfaces are connected.</p>
<ul>
<li>Example: ifplugstatus → Shows if eth0 is plugged in.</li>
</ul>
</li>
<li><p><strong>curl</strong>: Makes requests to APIs or downloads data from a URL.</p>
<ul>
<li>Example: curl -X GET <a target="_blank" href="https://api.example.com">https://api.example.com</a> → Fetches data from an API.</li>
</ul>
</li>
<li><p><strong>wget</strong>: Downloads files from the internet.</p>
<ul>
<li>Example: wget <a target="_blank" href="https://example.com/file.txt">https://example.com/file.txt</a> → Downloads file.txt.</li>
</ul>
</li>
<li><p><strong>iptables</strong>: Manages firewall rules.</p>
<ul>
<li>Example: sudo iptables --list-rules → Shows current firewall rules.</li>
</ul>
</li>
<li><p><strong>watch</strong>: Runs a command repeatedly and shows its output.</p>
<ul>
<li>Example: watch -n 5 top → Runs top every 5 seconds.</li>
</ul>
</li>
<li><p><strong>nmap</strong>: Scans a network for open ports and devices.</p>
<ul>
<li>Example: nmap <a target="_blank" href="http://sigmasoftinfotech.com">sigmasoftinfotech.com</a> → Shows open ports on <a target="_blank" href="http://sigmasoftinfotech.com">sigmasoftinfotech.com</a>.</li>
</ul>
</li>
<li><p><strong>route</strong>: Shows or modifies the routing table.</p>
<ul>
<li>Example: route → Lists routing information.</li>
</ul>
</li>
</ol>
<hr />
<h3 id="heading-19-pro-linux-commands-awk-sed-grep"><strong>19. Pro Linux Commands (awk, sed, grep)</strong></h3>
<p>These are advanced commands for processing text and logs.</p>
<ol>
<li><p><strong>awk</strong>:</p>
<ul>
<li><p>A powerful tool to process and extract data from files.</p>
</li>
<li><p>Example: awk '{print $1,$2}' app.log → Prints the first two columns (e.g., date and time) from app.log.</p>
</li>
<li><p>Example: awk '/INFO/ {print}' app.log → Prints lines containing “INFO”.</p>
</li>
<li><p>Example: awk '/INFO/ {count++} END {print count}' app.log → Counts how many times “INFO” appears.</p>
</li>
<li><p>Example: awk '$2 &gt;= "08:53:00" &amp;&amp; $2 &lt;= "08:53:59" {print}' app.log → Prints logs between 8:53:00 and 8:53:59.</p>
</li>
</ul>
</li>
<li><p><strong>sed</strong>:</p>
<ul>
<li><p>A stream editor to edit text in real-time.</p>
</li>
<li><p>Example: sed -n '/INFO/p' app.log → Prints lines containing “INFO”.</p>
</li>
<li><p>Example: sed 's/INFO/LOG/g' app.log → Replaces “INFO” with “LOG” in app.log.</p>
</li>
<li><p>Example: sed -n -e '/INFO/=' app.log → Shows line numbers where “INFO” appears.</p>
</li>
<li><p>Example: sed '1,15 s/INFO/LOG/g;1,10p;11q' app.log → Replaces “INFO” with “LOG” in lines 1-15, prints lines 1-10, and stops at line 11.</p>
</li>
</ul>
</li>
<li><p><strong>grep</strong>:</p>
<ul>
<li><p>Searches for text patterns in files.</p>
</li>
<li><p>Example: grep "INFO" app.log → Shows lines containing “INFO”.</p>
</li>
</ul>
</li>
</ol>
<h3 id="heading-20-role-of-a-devops-engineer"><strong>20. Role of a DevOps Engineer</strong></h3>
<ul>
<li><p>A DevOps engineer deploys and maintains applications on servers.</p>
</li>
<li><p>They ensure applications run smoothly, troubleshoot issues, and manage servers (often Linux).</p>
</li>
<li><p>Example: If an application like YouTube stops working, they:</p>
<ul>
<li><p>Check if the server is reachable (ping).</p>
</li>
<li><p>Check logs for errors (cat, grep, awk).</p>
</li>
<li><p>Restart the server or service if needed (systemctl or kill).</p>
</li>
<li><p>Ensure proper permissions (chmod, chown) and network settings (iptables, netstat).</p>
</li>
</ul>
</li>
</ul>
]]></content:encoded></item></channel></rss>