<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[DevOps and SRE Learning - Medium]]></title>
        <description><![CDATA[This is a group for all those interested in DevOps, DevSecOps, NetDevOps, NetOps, NetSecOps, CICD. I think you’ll find the discussions in the group interesting, stimulating, and challenging in the DevOps and SRE world which is moving continuously in the CI/CD workflow. - Medium]]></description>
        <link>https://medium.com/devops-and-sre-learning?source=rss----248569d59069---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>DevOps and SRE Learning - Medium</title>
            <link>https://medium.com/devops-and-sre-learning?source=rss----248569d59069---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 18 May 2026 11:46:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/devops-and-sre-learning" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Simplified Steps to Create your own QR Code]]></title>
            <link>https://medium.com/devops-and-sre-learning/simplified-steps-to-create-your-own-qr-code-4d9028c3d940?source=rss----248569d59069---4</link>
            <guid isPermaLink="false">https://medium.com/p/4d9028c3d940</guid>
            <category><![CDATA[qr-code]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[linkedin]]></category>
            <category><![CDATA[articles]]></category>
            <dc:creator><![CDATA[Hemant Jain]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 14:42:30 GMT</pubDate>
            <atom:updated>2022-08-11T14:42:11.533Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*XvLakIoMp-_F1uDP" /><figcaption>Source: Unsplash.com</figcaption></figure><p>Nowadays, there are very few places where you’ll not find QR codes. In fact, QR codes have become so ubiquitous that in 2021, <a href="https://www.statista.com/statistics/320655/qr-codes-usage/">45 percent of customers utilized marketing-related QR codes</a>.</p><p>There’s no doubting the QR code’s popularity and use. But what is it, exactly?</p><p>The abbreviation QR stands for “quick response code.” It’s a black-and-white sign in the shape of a square that may be scanned with a smartphone or laser to discover more about a product or service. Content, links, discounts, event details, and other information that consumers desire to see can be stored in these encrypted squares. You can even look at the different<a href="https://www.dynamsoft.com/barcode-reader/barcode-types/qr-code/"> types of QR codes</a> and choose the one that best suits your business and purpose.</p><p>QR codes are widely used in a variety of businesses. They even helped in the fight against the Covid-19 outbreak by automating operations to limit physical touch. All you need is a smartphone with a QR code reader or an online QR code scanner to use QR codes. Another advantage of QR codes is that they are simple to make with just a few basic steps. So, if you’re interested in producing a QR code, here is how you can do it,</p><p>1. Look for a QR code generator on the internet. QR code generators abound on the internet. Examine their ratings and reviews and choose one to begin with. The best part is that the majority of them are free.</p><p>2. What kind of material are you looking to promote? Do you want to provide a link to a website or any unique information? Before moving on to the next level, you must make these decisions.</p><p>3. Fill out the information in the form that pops up on your screen. It will ask you to add the content you want to encode in your QR code. It can be a landing page, payment gateway, or any information related to your product such as PDFs and videos.</p><p>4. Once you have filled in all the information, a QR code will be generated on the screen, You’ll need to download that QR code</p><p>5. After downloading the QR code. Select a reliable QR code reader for the next step, which is to test the QR code you’ve made. There are a variety of options accessible. Your phone may also feature a QR code reader, however, it may not be able to scan QR codes that are severely broken or crumpled. As a result, choose one that works in a variety of demanding situations. You can use an <a href="https://demo.dynamsoft.com/barcode-reader/">online QR code scanner</a> with versatile functionality. Try the <a href="https://demo.dynamsoft.com/barcode-reader/">demo here</a>.</p><p>6. If your QR code is working properly, it’s time to share it with your audience. You can add the QR code to your collaterals such as pamphlets, menus, storefronts, product packaging, or website.</p><h3>Bonus Suggestion</h3><p>You can keep track of the performance of your QR code by doing an analysis that will help you in the future. For this, you must create a UTM tracking URL before encoding it with your QR code. Creating UTM URLs will help you in analyzing the performance with your analytics tool.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d9028c3d940" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devops-and-sre-learning/simplified-steps-to-create-your-own-qr-code-4d9028c3d940">Simplified Steps to Create your own QR Code</a> was originally published in <a href="https://medium.com/devops-and-sre-learning">DevOps and SRE Learning</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SRE vs. DevOps — a False Distinction?]]></title>
            <link>https://medium.com/devops-and-sre-learning/sre-vs-devops-a-false-distinction-64ba685ee74c?source=rss----248569d59069---4</link>
            <guid isPermaLink="false">https://medium.com/p/64ba685ee74c</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Hemant Jain]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 06:22:32 GMT</pubDate>
            <atom:updated>2022-08-11T06:22:25.092Z</atom:updated>
            <content:encoded><![CDATA[<h3>SRE vs. DevOps — a False Distinction?</h3><p>Just a few days before he died at the beginning of the 1990s, a wise man taught us that “the show must go on.” Freddie Mercury’s parting words have long provided the guiding light for many, if not all, ops teams.</p><p>In their eyes, the production environment should be exposed to minimum risk, even at the expense of new features and problem resolution.</p><p>About 10 years ago, Google decided to change its approach to production management. It took the company only a few years to realize that while R&amp;D focused on creating new features and pushing them to production, the Operations group was trying to keep production as stable as possible — the two teams were pulling in opposite directions. This tension arose due to the groups’ different backgrounds, skill sets, incentives and metrics by which they were measured.</p><p>Trying to bridge this gap between the two groups, one of Google’s ops leaders, Ben Treynor, thought of an innovative solution. Instead of having an Ops team built solely from system administrators, software engineers — with an R&amp;D background and mentality — could enrich the way the team worked with the development group, change its goals and help with automating solutions.</p><h3>Site Reliability Engineering, or SRE</h3><p>And so, the Site Reliability Engineering position was created. According to Google, SRE engineers are responsible for the stability of the production environment, but at the same time are committed to new features and operational improvement. Google decided its SRE teams <a href="https://landing.google.com/sre/interview/ben-treynor.html">should be composed of 50 percent software engineers and 50 percent system administrators</a>. The engineers were driven to use software as a way of solving problems and perfecting what had historically been solved by hand. They integrated easily with the development team, and encouraged code quality improvements and automation testing.</p><p>Understanding the value of SRE, several organizations of various sizes decided to embrace its principles. Some, such as Dropbox, Netflix and Github, are well-known for being at the forefront of technology leadership.</p><h3>Wait, Isn’t That DevOps?</h3><p>DevOps is a more recent movement, designed to help organizations’ IT department move in agile and performant ways. It builds a healthy working relationship between the Operations staff and Dev team, allowing each to see how their work influences and affects the other. By combining knowledge and effort, DevOps should produce a more robust, reliable, agile product.</p><p>Both SRE and DevOps are methodologies addressing organizations’ needs for production operation management. But the differences between the two doctrines are quite significant: While DevOps raise problems and dispatch them to Dev to solve, the SRE approach is to find problems and solve some of them themselves.</p><p>While DevOps teams would usually choose the more conservative approach, leaving the production environment untouched unless absolutely necessary, SREs are more confident in their ability to maintain a stable production environment and push for rapid changes and software updates. Not unlike the DevOps team, SREs also thrive on a stable production environment, but one of the SRE team’s goals is to improve performance and operational efficiency.</p><p>Google tried a few approaches to implementing the SRE process before finding the one that suited them best. One of these approaches attempted to tie the number of permitted releases to the product’s stability. The principle underlying this process is that new releases are green-lighted based on current product performance.</p><p>For each service, the SRE team sets a service-level agreement (SLA) that defines how reliable the system needs to be to end users. If the team agrees on a 99.9 percent SLA, that gives them an error budget of 0.1 percent. An error budget is exactly what the name suggests: the maximum allowable threshold for errors and outages. Here’s the interesting thing: the development team can “spend” this error budget in any way they like.</p><p>If the product is currently running flawlessly, with few or no errors, they can launch whatever they want, whenever they want. Conversely, if they have met or exceeded the error budget, and are operating at or below the defined SLA, all new releases are frozen until they reduce the number of errors to a level that allows the launch to proceed. This process ensures that both the SREs and developers have a strong incentive to minimize the number of errors in production.</p><p>Another interesting approach recommended by Treynor, which is more related to SRE professionalism and efficiency, is allowing SREs to move between projects. Moreover, he suggests allowing SRE engineers to move to development, and even the other way around.</p><p>As the work done by both teams is similar, these transitions help the Ops team gain better and deeper knowledge of the product and code, and bring the Dev teams into the production space to help them understand its challenges. This strongly promotes a team atmosphere, rather than one in which an individual feels that “I’m on the SRE team for this product.”</p><p>As part of this approach, Treynor had Dev teams handle 5 percent of the operations workload. This, according to many organizations, adds to the SRE team’s motivation and effectiveness.</p><h3>Riddles in the Dark</h3><p>Well, SRE seems perfect. As already stated, several large-scale organizations have chosen to move some of their production operations from old Ops to SRE. However, there are still a few questions that need to be asked:</p><p><strong>Is the position of SysAdmin (production/ops) no longer relevant for SysAdmins?</strong></p><p>Historically, almost all system administrators have come into their roles through tech support and similar work, or even just running Linux on their desktops and then transitioning into server work. It should be pretty clear that the same path is not available into SRE.</p><p>To retain their positions, SysAdmins should now be more code-oriented, have better technological knowledge and be receptive to new methods of conducting the work they already do.</p><p><strong>Can an SRE team prevent production incidents?</strong></p><p>One of the strengths of a professional site reliability engineer is the ability to handle the growth of production load and traffic in-house. Monitoring and analyzing processes and logs with platforms such as the <a href="https://logz.io/learn/complete-guide-elk-stack/">ELK Stack</a> is part of the day-to-day workload, and the team should be able to identify problems as they occur, and even foresee risks to software stability.</p><p>The power of this position — based on the skill set it requires — lies in developing solutions for these problems and risks. As Ciara, a software engineer in Google’s cloud storage SRE team, described it in a “<a href="https://twitter.com/lifeatgoogle/status/804050374730665984">Life in Google</a>” post, “We solve cooler problems in cooler ways.”</p><p><strong>Are we doing DevOps or are we doing SRE?</strong></p><p>This question is usually asked by people trying to position themselves in the Operations world.</p><p>According to many companies that implemented SRE in a slightly different way than Google, you don’t have to decide.</p><p>At Reddit, <a href="https://boards.greenhouse.io/reddit/jobs/251080#.WQbILFWGNUR">ops engineers work on</a> reducing toil, improving deployment and scaling processes, but they are referred to as “DevOps.”</p><p>At <a href="https://logz.io/">Logz.io</a>, we bridge the gap between developers and production through the use of automated monitoring and performance stress-testing. And we personally refer to it as “<a href="https://logz.io/learn/what-is-devops/">DevOps</a>” rather than “SRE.”</p><h3>So, is it Just a Question of Context?</h3><p>In her <a href="https://charity.wtf/2016/06/30/devops-vs-sre-delayed-coverage-of-the-dumbest-war/">blog</a>, Charity Majors talks about SRE and DevOps being two different operational approaches that any organization can choose to work by, but insists on emphasizing that there is no “correct” approach. Although Google and Dropbox have decided on SRE, this does not mean the rest of the world should do so as well. What fits Google’s needs and organizational philosophy does not necessarily work for other orgs — at any scale.</p><p>Moreover, Charity believes that DevOps, having grown and evolved within a broader variety of software organizations, is the more flexible, collaborative and adaptable approach, and will work better for most software organizations at all stages of development.</p><p>On the other hand, SoundCloud senior engineer, <a href="https://twitter.com/matthiasr">Matthias Rampke</a> issued a series of tweets on how SRE and DevOps were basically the same, with only one difference — high management support.</p><p>Though in contradiction to her blog, Charity lent weight to this opinion during an <a href="http://pages.catchpoint.com/DEVOPS-SRE-AMA-Registration.html">AskMeAnything event </a>that revolved around DevOps and SRE. She shared a story about a friend who was hiring for a startup, which, as an experiment, posted the exact same job description twice, the only difference being that one listing was titled “DevOps engineer,” and the other “SRE.”</p><p>At the time of relating the story, DevOps was winning by 10 percent or 20 percent. However, all this means is that the job title is irrelevant, and naming an SRE team does not magically bestow qualities upon it. Rather than focusing on the title, organizations must focus on the work being done.</p><p>To summarize, we can quote Matt Simmons, a technologist with many insights into this topic, <a href="https://standalone-sysadmin.com/the-difference-between-site-reliability-engineering-system-administration-and-devops-d05031495499">who says</a>, “Not every infrastructure needs an SRE, but every infrastructure could use an administrator who acted more like one.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64ba685ee74c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devops-and-sre-learning/sre-vs-devops-a-false-distinction-64ba685ee74c">SRE vs. DevOps — a False Distinction?</a> was originally published in <a href="https://medium.com/devops-and-sre-learning">DevOps and SRE Learning</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zabbix Monitoring Configuration Installation on AWS EC2]]></title>
            <link>https://medium.com/devops-and-sre-learning/zabbix-monitoring-configuration-installation-on-aws-ec2-934c7680dc22?source=rss----248569d59069---4</link>
            <guid isPermaLink="false">https://medium.com/p/934c7680dc22</guid>
            <dc:creator><![CDATA[Hemant Jain]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 06:07:14 GMT</pubDate>
            <atom:updated>2021-01-22T15:49:59.354Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I will take you through the steps required to follow in setting up a performance monitoring tool Zabbix on Amazon Cloud Service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*tGiS_8ICPPsKpzEyr_f0eA.jpeg" /><figcaption>Zabbix Image</figcaption></figure><h3>What is Zabbix?</h3><p><strong>Zabbix</strong> is an open-source monitoring software tool for diverse IT components, including networks,servers, virtual machines(VMs) and cloud services.</p><p>Zabbix provides <strong><em>monitoring metrics</em></strong>, among others network utilization, CPU load and disk space consumption. Zabbix <strong><em>monitoring configuration</em></strong> can be done using XML based templates which contain elements to monitor.</p><p>Zabbix can use MySQL, MariaDB, PostgreSQL, SQLite, Oracle or IBM DB2 to store data. Its backend is written in C and the web frontend is written in PHP.</p><h3>Various Zabbix Monitoring Options</h3><h4><strong>Three Major Components of Zabbix</strong></h4><ul><li><strong>Zabbix Server</strong></li><li><strong>Zabbix Agent</strong> and</li><li><strong>Zabbix Web Interface</strong></li></ul><p><strong>Zabbix server</strong> is the one which collects all the relevant data from the server you want to monitor.</p><p>The servers you want to monitor are called <strong>Agents</strong>.</p><p>You can have the server monitoring without the <strong>Zabbix web part.</strong> But I would suggest using it as it makes the experience better.</p><p>Let’s run through the installation steps for the Zabbix on AWS EC2 Instance:</p><h3>Zabbix Installation Steps:</h3><p>Initially you would be needed to spin a basic <strong>t2.micro</strong> instance on AWS EC2.</p><p>Let’s connect to the EC2 Instance using the SSH terminal on MobaXterm platform which delivers much better visualization frontend towards the Ubuntu Linux machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JkkEOUiD_aXwGyRLPsqyHw.png" /><figcaption>SSHing into the AWS EC2 Instance using private key</figcaption></figure><p>An SSH connection will be started with your Ubuntu virtual machine.</p><p>Use the following command to become the root user on the Ubuntu virtual machine.</p><pre>sudo su -</pre><p>You have successfully created an Ubuntu virtual Machine on Amazon AWS.</p><p>Install the MySQl database service.</p><pre>apt-get update<br>apt-get install mysql-server mysql-client</pre><p>Access the MySQL service command-line.</p><pre>mysql -u root -p</pre><p>Create a database named zabbix.</p><pre>CREATE DATABASE zabbix CHARACTER SET UTF8 COLLATE UTF8_BIN;</pre><p>Create a database user named zabbix.</p><pre>CREATE USER ‘zabbix’@’%’ IDENTIFIED BY ‘admin@123’;</pre><p>In our example, the password <strong>admin@123</strong> was set to the user named <strong>zabbix</strong>.</p><p>Give the MySQL user named <strong>zabbix</strong> permission over the database named <strong>zabbix</strong>.</p><pre>GRANT ALL PRIVILEGES ON zabbix.* TO ‘zabbix’@’%’;<br>FLUSH PRIVILEGES;<br>quit;</pre><p>Download the Zabbix 4.4 installation package.</p><pre>mkdir /downloads<br>cd /downloads<br>wget <a href="https://ufpr.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.0/zabbix-4.4.0.tar.gz">https://ufpr.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.0/zabbix-4.4.0.tar.gz</a></pre><p>Import Zabbix database template inside MySQL.</p><pre>tar -zxvf zabbix-4.4.0.tar.gz<br>cd zabbix-4.4.0/database/mysql/<br>mysql -u zabbix -p zabbix &lt; schema.sql<br>mysql -u zabbix -p zabbix &lt; images.sql<br>mysql -u zabbix -p zabbix &lt; data.sql</pre><p>You have finished the Zabbix database installation.</p><h4>Installing Zabbix 4.4 Web Interface</h4><p>Install the Apache web server and all the required packages.</p><pre>apt-get install apache2 php libapache2-mod-php php-cli php-mysql php-mbstring php-gd php-xml php-bcmath php-ldap</pre><p>Find the location of the php.ini file on your system.<br>Edit the php.ini file.</p><pre>updatedb<br>locate php.ini<br>vi /etc/php/7.2/apache2/php.ini</pre><p>Keep in mind that your PHP version and the location of the file may not be the same of mine.</p><p>Set the following items on the php.ini file:</p><pre>max_execution_time = 300<br>memory_limit = 256M<br>post_max_size = 32M<br>max_input_time = 300<br>date.timezone = America/New_York</pre><p>Set the correct timezone to your location.</p><p><strong>Restart</strong> the apache service.</p><pre>service apache2 restart</pre><p>You have finished the Apache web server installation with PHP support.</p><h4>Zabbix Server 4.4 Installation on Ubuntu</h4><p>Download and install the <strong>GOLANG</strong> package.</p><pre>mkdir /downloads/go -p<br>cd /downloads/go<br>wget <a href="https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz">https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz</a><br>tar -C /usr/local -zxvf go1.13.1.linux-amd64.tar.gz</pre><p>The <strong>GOLANG</strong> software was installed under the /usr/local folder.</p><p>In order to work properly, the GO software expect the system to have a set of environment variables.</p><p>Let’s create a file to automate the required environment variables configuration.</p><pre>vi /etc/profile.d/go.sh</pre><p>Here is the <strong><em>go.sh</em></strong> file content:</p><pre>#/bin/bash<br>export GOROOT=/usr/local/go<br>export GOPATH=$GOROOT/work<br>export PATH=$PATH:$GOROOT/bin:$GOPATH/bin</pre><p><strong>Reboot</strong> your computer.</p><pre>reboot</pre><p>Verify if the required environment variables were created automatically.</p><pre>env | grep -E “(ROOT|GOPATH)”</pre><p>Here is the correct output:</p><pre>GOROOT=/usr/local/go<br>GOPATH=/usr/local/go/work</pre><p>Create a Linux account to the Zabbix user and install the required packages.</p><pre>groupadd zabbix<br>useradd -g zabbix -s /bin/bash zabbix<br>apt-get update<br>apt-get install build-essential libmysqlclient-dev libssl-dev libsnmp-dev libevent-dev<br>apt-get install libopenipmi-dev libcurl4-openssl-dev libxml2-dev libssh2–1-dev libpcre3-dev<br>apt-get install libldap2-dev libiksemel-dev libcurl4-openssl-dev libgnutls28-dev</pre><p>Access the <strong>Zabbix</strong> package folder, compile and install the Zabbix server</p><pre>cd /downloads/zabbix-4.4.0<br> ./configure — enable-server — enable-agent — enable-agent2 — with-mysql — with-openssl — with-net-snmp — with-openipmi — with-libcurl — with-libxml2 — with-ssh2 — with-ldap<br>make<br>make install</pre><p>Find the location of the <strong><em>zabbix_server.conf </em></strong>file.</p><pre>updatedb<br>locate zabbix_server.conf<br>vi /usr/local/etc/zabbix_server.conf</pre><p>Here is the original file, before our configuration.</p><pre>LogFile=/tmp/zabbix_server.log<br>DBName=zabbix<br>DBUser=zabbix<br>Timeout=4<br>LogSlowQueries=3000<br>StatsAllowedIP=127.0.0.1</pre><p>Here is the new file with our configuration.</p><pre>LogFile=/tmp/zabbix_server.log<br>DBHost=localhost<br>DBName=zabbix<br>DBUser=zabbix<br>DBPassword=admin@123<br>Timeout=4<br>LogSlowQueries=3000<br>StatsAllowedIP=127.0.0.1</pre><p><strong>Start</strong> the <strong>Zabbix server</strong>.</p><pre>/usr/local/sbin/zabbix_server</pre><p>Now, you need to choose which version of Zabbix agent you want to use.</p><p>Use the following command to <strong>start</strong> the default <strong>Zabbix Agent</strong>.</p><pre>/usr/local/sbin/zabbix_agentd</pre><p><strong>Or </strong>use the following command to <strong>start </strong>the <strong>new Zabbix Agent2</strong>.</p><pre>/usr/local/sbin/zabbix_agent2 &amp;</pre><p>Zabbix agent 2 appears to run only in the foreground.</p><p><strong>Move</strong> all the Zabbix frontend files to the root directory of your Apache installation.</p><p>Set the <strong>correct file permission </strong>on all moved files</p><pre>cd /downloads/zabbix-4.4.0/frontends<br>mkdir /var/www/html/zabbix<br>mv php/* /var/www/html/zabbix<br>chown www-data.www-data /var/www/html/zabbix/* -R</pre><p><strong>Restart</strong> the Apache service.</p><pre>service apache2 restart</pre><h4>Zabbix 4.4 Web Installer</h4><p>Open your browser and enter the IP address of your web server plus /zabbix.</p><p>Make sure the security group for the EC2 instance allows the traffic on the default port for the Zabbix server, else just modify the <strong>SecurityGroup</strong> for the EC2 instance by adding the<strong><em> Inbound rules </em></strong>as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UpmmA2XK88g1HK0nP_zidQ.png" /></figure><p>In our example, the following URL was entered in the Browser:</p><pre><a href="http://54.203.0.220/zabbix/overview.php?ddreset=1">http://54.203.0.220/zabbix</a></pre><p>The <strong>Zabbix</strong> <strong>web</strong> <strong>installation</strong> <strong>interface</strong> should be presented.</p><p>Click on the <strong>Next</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*KSJt94Lo7lpfRNd7xG-kIw.png" /></figure><p>On the next screen, you will have to check if all the requirements were achieved.</p><p>Click on the <strong>Next</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*0vfoBI2zA7fnJW_F5reyHg.png" /></figure><p>Enter the Database information required to connect to the Zabbix database.</p><pre>Host: localhost</pre><pre>Database Username: zabbix</pre><pre>Database Password: admin@123</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*nMP7VCHQLrDkACAeJokNgw.png" /></figure><p>On the next screen, you just have to click on the <strong>Next</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*5r1Yhpu0yiRXuT9rv7MtwQ.png" /></figure><p>Now, take a look on the configuration summary.</p><p>Click on the <strong>Next</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*sDrJqxyZK3GhTRVajLIH8Q.png" /></figure><p>On the next screen, you will have to click on the <strong>Finish</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*a00Wlio5Vy0HJTq4xW4-SQ.png" /></figure><p>Finally, you will be presented with the Zabbix login screen.</p><pre>Zabbix default username: <strong>Admin</strong></pre><pre>Zabbix default Password: <strong>zabbix</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o786zjooZAwtOuFllFtBIg.png" /></figure><p>After a successful login, you will be sent to the new <strong>Zabbix</strong> <strong>Dashboard</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1elvPo7XLZw78VE08WgtGA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z2mzd42uGG-_9br8QQ4Y4g.png" /></figure><h3>Voila !!</h3><p>You have successfully installed the Zabbix Server Configuration and Monitoring tool, an open-source monitoring software tool for diverse IT components, including networks,servers, virtual machines(VMs) and cloud services.</p><p>It can be used for <strong><em>monitoring metrics</em></strong>, among others network utilization, CPU load and disk space consumption.</p><h3>References:</h3><ul><li><a href="https://www.zabbix.com/">Zabbix: The enterprise-class open source observability solution</a></li><li><a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-zabbix-to-securely-monitor-remote-servers-on-ubuntu-16-04">How To Install and Configure Zabbix to Securely Monitor Remote Servers on Ubuntu 16.04 | DigitalOcean</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=934c7680dc22" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devops-and-sre-learning/zabbix-monitoring-configuration-installation-on-aws-ec2-934c7680dc22">Zabbix Monitoring Configuration Installation on AWS EC2</a> was originally published in <a href="https://medium.com/devops-and-sre-learning">DevOps and SRE Learning</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dockerizing ELK stack into containers using Docker]]></title>
            <link>https://medium.com/devops-and-sre-learning/dockerizing-elk-stack-into-containers-using-docker-a9d33bf9c58?source=rss----248569d59069---4</link>
            <guid isPermaLink="false">https://medium.com/p/a9d33bf9c58</guid>
            <dc:creator><![CDATA[Hemant Jain]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 06:06:25 GMT</pubDate>
            <atom:updated>2021-01-14T16:10:18.148Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aOdKZ47_-rV-ntgOeOva3Q.png" /><figcaption>Docker Image</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qQGjPAbEuZJj-Bix9L0aoA.png" /><figcaption>ELK Stack Overview Image</figcaption></figure><h3>Introduction</h3><h3>Docker Overview:</h3><h4>What is Docker?</h4><p>Docker is a tool which is used by developer and operation teams to create and automate the deployment of applications in lightweight containers so that applications can work efficiently in different environments</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*KgPrOsQcoixL2V-H" /><figcaption>Docker Overview</figcaption></figure><p><strong>Note: </strong>Container is a software package that consists of all the dependencies required to run an application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/0*4sEQRELK5IitITF0" /><figcaption>Special Note</figcaption></figure><h4><strong>How are Docker containers created?</strong></h4><ul><li>Docker File creates a Docker Image using the build command</li><li>A Docker Image contains all the project’s code</li><li>Using Docker Image, any user can run the code in order to create Docker Containers</li><li>Once a Docker Image is built, it’s uploaded in a registry or a Docker Hub</li><li>From the Docker Hub, users can get the Docker Image and build new containers</li></ul><h4><strong>What is Docker Compose?</strong></h4><ul><li>Docker Compose is used for running multiple containers as a single service</li><li>Here, containers run in isolation but can interact with each other</li><li>All Docker Compose files are YAML files</li><li>In Docker Compose, a user can start all the services (containers) using a single command</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*6WZ55ORh58Z9AbRP" /><figcaption>Docker-Compose Command Containers</figcaption></figure><p><strong>For example:</strong></p><p>If you have an application which requires NGINX server and Redis database, you can create a Docker Compose file which can run both the containers as a service without the need to start each one separately</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*4m5IpaKNQrQkZ9Jc" /><figcaption>Docker-Compose Example</figcaption></figure><h3>ELK Stack Overview:</h3><ul><li>Elasticsearch is an open-source, full-text search, and analysis engine, based on the Apache Lucene search engine.</li><li>Logstash is a log aggregator that collects data from various input sources, executes different transformations and enhancements, and then ships the data to various supported output destinations.</li><li>Kibana is a visualization layer that works on top of Elasticsearch, providing users with the ability to analyze and visualize the data.</li><li>And last but not least — Beats are lightweight agents that are installed on edge hosts to collect different types of data for forwarding into the stack.</li></ul><p>Together, these different components are most commonly used for monitoring, troubleshooting, and securing IT environments (though there are many more use cases for the ELK Stack such as business intelligence and web analytics).</p><p>Beats and Logstash take care of data collection and processing, Elasticsearch indexes and stores the data, and Kibana provides a user interface for querying the data and visualizing it.</p><h3>Why is ELK So Popular?</h3><ul><li>The ELK Stack is popular because it fulfills a need in the log management and analytics space.</li><li>Monitoring modern applications and the IT infrastructure they are deployed on requires a log management and analytics solution that enables engineers to overcome the challenge of monitoring what is highly distributed dynamic and noisy environments.</li><li>ELK Stack helps by providing users with a powerful platform that collects and processes data from multiple data sources, stores that data in one centralized data store that can scale as data grows, and that provides a set of tools to analyze the data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KQRSD0AK7a8oIWTX3CwCWA.png" /><figcaption>ELK Stack Overview</figcaption></figure><ul><li>Of course, the ELK Stack is open-source.</li><li>With IT organizations <a href="https://logz.io/blog/is-open-source-overtaking-splunk/">favoring open-source products</a>, this alone could explain the popularity of the stack.</li><li>Using open source means organizations can avoid vendor lock-in and onboard new talent much more easily.</li><li>Everyone knows how to use Kibana, right? Open source also means a vibrant community is constantly driving new features and innovation and helping out in case of need.</li></ul><p>We will use docker-compose to deploy our ELK stack. Docker-compose offers us a solution to deploy multiple containers at the same time.</p><p>Prerequisites:</p><ul><li><a href="https://docs.docker.com/install/">Docker</a></li><li><a href="https://docs.docker.com/compose/install/">Docker-Compose</a></li></ul><p>The full template is available <a href="https://github.com/jainhemant163/ELK-Docker-Containerization">on my GitHub</a>. Clone the repository and start the containers by using Docker-compose.</p><pre>$ git clone <a href="https://github.com/jainhemant163/ELK-Docker-Containerization.git">https://github.com/jainhemant163/ELK-Docker-Containerization.git</a><br>$ cd docker-elk<br>$ docker-compose up -d</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1_AyzSPJVbhi3lb278UERw.png" /><figcaption>Docker Processes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uEEu8-Q7mDSRBPE1RO-13A.png" /><figcaption>Docker Images</figcaption></figure><p>The first resource which is deployed is Elasticsearch. Elasticsearch is a system for quickly analyzing and analyzing different types of data.</p><p>We’re able to use a single instance and disable <a href="https://www.elastic.co/products/stack">xpack</a> (paying feature) using environment variables. It is deployed in the logging-network which is a <a href="https://docs.docker.com/network/bridge/">Docker bridge network</a>.</p><p>Now we will deploy Logstash. Logstash is an open-source, server-side data processing pipeline that simultaneously ingests data from a multitude of sources, transforms it, and then sends it to tools like Elasticsearch.</p><p>Logstash depends on Elasticsearch, which needs to be deployed first. Port 12201 is exposed and mapped on the server. Other Docker containers will send their logs to Logstash by connecting to this UDP port. As volume, we will mount the logstash.conf inside the container.</p><p>We will now expect Gelf input. Gelf is the Graylog Extended Log Format and is a great choice for logging from within applications,which we can then send our logs to our ElasticSearch container. They can communicate with each other using their service name because they are deployed in the same Docker Bridge network.</p><p>The file /usr/share/logstash/config/pipelines.yml contains the available pipelines which Logstash runs. Here we can define specific files (pipelines), but we are using only one pipeline now.</p><p>The default file describes the directory where our logstash.conf is available, so we don’t need to update our pipeline configuration. If you want to run multiple pipelines, you can add additional id’s and point to specific .conf files instead of pointing to a directory like it is now (by default). For more info, take a look <a href="https://www.elastic.co/guide/en/logstash/current/multiple-pipelines.html">here</a>.</p><p>If you configure multiple pipelines, it can be useful to debug your Logstash container. You can use docker exec to debug your Logstash container and check configuration files. This is out of scope for our current basic setup.</p><pre>$ docker exec -it docker-elk_logstash_1 bash<br>bash-4.2$ cat /usr/share/logstash/pipeline/logstash.conf<br>input {<br>  gelf {}<br>}output {<br>  elasticsearch {<br>    hosts =&gt; &quot;elasticsearch:9200&quot;<br>  }<br>}</pre><p>The last ELK stack related service in our template is the setup of Kibana. Kibana lets us visualize our Elasticsearch data.</p><p>Kibana depends on Logstash and will expose and map port 5601. Like all other ELK stack related resources, Logstash is deployed inside the logging-network. This allows the containers to communicate with each other by using service names.</p><p>Now we can test our setup. One Apache (httpd) container is already started by using Docker-compose. Users of Docker Desktop for Mac should edit the gelf-address in the docker-compose.yml to udp://host.docker.internal:12201. Check <a href="https://github.com/lvthillo/docker-elk/issues/1">here</a> for more information. Don’t forget to update your environment by running docker-compose up -d again.</p><p>We will start an additional Nginx container using the Docker CLI.</p><p>Users of Docker Desktop for Mac should update the gelf-address to udp://host.docker.internal:12201. Check <a href="https://github.com/lvthillo/docker-elk/issues/1">here</a> for more information.</p><pre>$ docker run -d -p 8080:80 --log-driver gelf --log-opt gelf-address=udp://localhost:12201 nginx:latest</pre><p>Let’s visit both applications in the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ZM6tVkWQ8vjEA3aVS33Cg.png" /><figcaption>Docker Container Running Nginx</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qLYpXzBb88VDLajALYPe_w.png" /><figcaption>Docker Container Running Formatted httpd server page</figcaption></figure><p>Now Access Kibana on <a href="http://localhost:5601/">http://localhost:5601</a>. Click on the left on ‘Discover’ and on ‘Create Index Pattern’. Create a pattern using ‘*’ and ‘@timestamp’,also create a pattern using ‘.kibana_1’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZZQTcYwlDZ75Fb6QankKaA.png" /><figcaption>ELK Kibana Dashboard Index Creation</figcaption></figure><p>Now click on discover and verify the logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ynt9FcQv5StO2yzj7E84JQ.png" /><figcaption>Kibana Dashboard Visualization for Indexes_1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yy27GyP4ufGdpV-wrhNXtQ.png" /><figcaption>Kibana Dashboard Visualization for Indexes_2</figcaption></figure><h3>Conclusion</h3><p>In this article, I tried to containerize the complete ELK stack using Docker and Docker-Compose, making it easy to Docker containers on Kibana visualization dashboards.</p><p>The main concern of this article was to help the developers in set up the complete Elasticsearch, Logstash, Kibana stack over Docker container in the same network making it easy to communicate with other containers in the same network.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9d33bf9c58" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devops-and-sre-learning/dockerizing-elk-stack-into-containers-using-docker-a9d33bf9c58">Dockerizing ELK stack into containers using Docker</a> was originally published in <a href="https://medium.com/devops-and-sre-learning">DevOps and SRE Learning</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Grafana Installation Steps on AWS EC2 Instance]]></title>
            <link>https://medium.com/devops-and-sre-learning/grafana-installation-steps-on-aws-ec2-instance-9b0a94716ce9?source=rss----248569d59069---4</link>
            <guid isPermaLink="false">https://medium.com/p/9b0a94716ce9</guid>
            <dc:creator><![CDATA[Hemant Jain]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 06:05:58 GMT</pubDate>
            <atom:updated>2021-01-15T02:37:52.723Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>Grafana Installation on Ubuntu EC2 Instance with Security Group Enabled by using shell script.</em></strong></p><p><strong>Grafana</strong> is <a href="https://en.wikipedia.org/wiki/Multi-platform">multi-platform</a> <a href="https://en.wikipedia.org/wiki/Open_source">open source</a> analytics and <a href="https://en.wikipedia.org/wiki/Interactive_visualization">interactive visualization</a> software available since 2014. It provides charts, graphs, and alerts for the web when connected to supported data sources. It is expandable through a <a href="https://en.wikipedia.org/wiki/Plug-in_(computing)">plug-in system</a>. End users can create complex monitoring dashboards using interactive query builders.</p><p>As a visualization tool, Grafana is a popular component in monitoring stacks,often used in combination with <a href="https://en.wikipedia.org/wiki/Time_series_database">time series databases</a> such as <a href="https://en.wikipedia.org/wiki/Prometheus_(software)">Prometheus</a> and <a href="https://en.wikipedia.org/wiki/Graphite_(software)">Graphite</a>.</p><p><strong><em>In this post, you will learn how to install the Grafana, by using shell script AWS EC2 Ubuntu Instance Server.</em></strong></p><p><strong>Step1:</strong> Spin up an EC2 Instance on AWS by logging in your dev/prod account</p><p><strong>Step2:</strong> Once the EC2 Instance is up and running,we would be using the Public DNS (IPv4) or IPv4 Public IP to login into server using credentials, and switch the user to root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CI25q6ctAY2VUZ4CL_P_gw.png" /><figcaption>Mobaxterm SSH Login Screen using IAM Access and Secret Key</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OViSFKJHNBM8nFaLSdWIwA.png" /><figcaption>Mobaxterm EC2 Instance Login Screen</figcaption></figure><p><strong>Step3: O</strong>pen any text editor and create the grafanainstallation.sh shell script file.And paste the below code and save using ESC+wq Command on text editor.</p><blockquote><strong>#!/bin/bash<br>echo ‘deb </strong><a href="https://packages.grafana.com/oss/deb"><strong>https://packages.grafana.com/oss/deb</strong></a><strong> stable main’ &gt;&gt; /etc/apt/sources.list<br>curl </strong><a href="https://packages.grafana.com/gpg.key"><strong>https://packages.grafana.com/gpg.key</strong></a><strong> | sudo apt-key add -<br>sudo apt-get update<br>sudo apt-get -y install grafana<br>systemctl daemon-reload<br>systemctl start grafana-server<br>systemctl enable grafana-server.service</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TAuUt6TPlMPgkdUfaB21wg.png" /></figure><p><strong>Step4</strong>: Change the permission of file by using the command.</p><blockquote><strong>chmod +x grafanainstallation.sh</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FoD1dfx_4U29moHc39pC5g.png" /></figure><p><strong>Step5: </strong>execute the shell script by using command</p><blockquote><strong>./grafanainstallation.sh</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UIvwgH-Y2W19q6GlPM4s2w.png" /></figure><p><strong>Step6: </strong>Verify whether Grafana is running or not by using following command</p><blockquote><strong>service grafana-server status</strong></blockquote><p>If the Grafana Server is not running run the below command to start it.</p><blockquote><strong>service grafana-server start</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rX0CNBQUi-GyNCKeASA3xQ.png" /></figure><p><strong>Step7:</strong> Perfect, our Grafana server is in active state and is up and running for the Metrics and Performance Visualization.</p><p><strong>Step8:</strong> Here, you won’t be able to the grafana dashboard now as the AWS Security Group for the EC2 Instance is not enabled to accept the load for port 3000.Therefore,you must allow the 3000 port in security groups in AWS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CfGAOnqhveuBL62HrM18cQ.png" /></figure><p><strong>Step9:</strong> Take the IP address or DNS of your server and place it on address bar of the any browser along with Grafana port 3000. (we can change the port number)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*63GyDS_mf_D0KE8YN2bpMQ.png" /></figure><p><strong>Step10:</strong> By default, Grafana username and password are admin and admin. From the next screen you can get the option to change your password. that is depend on your choice either you can change or not.</p><p><strong>Step11: </strong>Below is the Grafana Home screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*63GyDS_mf_D0KE8YN2bpMQ.png" /><figcaption>Grafana Visualization Dashboard Home Screen</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b0a94716ce9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devops-and-sre-learning/grafana-installation-steps-on-aws-ec2-instance-9b0a94716ce9">Grafana Installation Steps on AWS EC2 Instance</a> was originally published in <a href="https://medium.com/devops-and-sre-learning">DevOps and SRE Learning</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick Learning Guide for Kubernetes-Part I]]></title>
            <link>https://medium.com/devops-and-sre-learning/quick-learning-guide-for-kubernetes-part-i-ef21b1ab1622?source=rss----248569d59069---4</link>
            <guid isPermaLink="false">https://medium.com/p/ef21b1ab1622</guid>
            <dc:creator><![CDATA[Hemant Jain]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 06:05:54 GMT</pubDate>
            <atom:updated>2020-06-07T20:28:16.103Z</atom:updated>
            <content:encoded><![CDATA[<p>Many of you might be wondering, What is Kubernetes? Why it has become so popular in the DevOps industry? What are the advanced features offering from Kubernetes? How to setup the configuration for Kubernetes platform on my local machine or some cloud platform like AWS, GCP, Azure, etc…</p><p>If this all questions intricates you and you would like to know more about it then this article would be right platform to learn and get aware about Kubernetes, so without wasting time let’s dive deep and understand Kubernetes,its extra-ordinary features and the complete setup on AWS platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*UGd80moMCaCoo0pXt9QGLA.png" /><figcaption>Kubernetes Logo</figcaption></figure><h3><strong>What is Kubernetes?</strong></h3><p><strong>Kubernetes </strong>is an open-source Container Management (<strong>orchestration</strong>) tool which automates container deployment, container (de) scaling &amp; container load balancing.</p><p>It’s container management responsibilities includes:</p><p><strong>1.Scheduling</strong></p><blockquote>Deploy containers across a cluster of servers, using the available resources (data centers, servers, CPU, memory, ports, etc.) as efficiently as possible.</blockquote><p><strong>2.Deployments</strong></p><blockquote>Roll out updates to containers using a variety of deployment strategies, such as rolling deployment, blue-green deployment, and canary deployment, and automatically roll back if there’s an error.</blockquote><p><strong>3.Auto healing</strong></p><blockquote>Monitor the health of your containers and servers and automatically replace unhealthy ones.</blockquote><p><strong>4.Auto scaling</strong></p><blockquote>Scale the number of containers and servers up or down in response to load.</blockquote><p><strong>5.Load balancing</strong></p><blockquote>Make your containers accessible to the outside world and distribute traffic across your containers.</blockquote><p><strong>6.Service discovery</strong></p><blockquote>Allow containers to find and communicate with each other over the network, automatically routing requests to the proper destination.</blockquote><p><strong>7.Configuration and secrets</strong></p><blockquote>Provide containers with environment-specific configuration data and secrets.</blockquote><p><strong><em>NOTE: Kubernetes is not a containerization platform. It is a multi-container management solution.</em></strong></p><h3>Why Kubernetes?</h3><p><strong>Kubernetes</strong> has become the de facto choice for container orchestration. Here’s why:</p><p><strong>Massive feature set</strong></p><blockquote>Kubernetes offers a huge range of functionality for managing containers, including auto scaling, auto healing, rolling deployments, service discovery, secrets management, configuration management, bin packing, storage orchestration, batch execution, access controls, log aggregation, SSH access, batch processing, and much more.</blockquote><p><strong>Massive community</strong></p><blockquote>Kubernetes has the biggest community of any orchestration tool, with more than 50,000 stars and 2,500 contributors on <a href="https://github.com/kubernetes/kubernetes"><strong>GitHub</strong></a>, thousands of blog posts, numerous books, hundreds of meetup groups, several dedicated conferences, and a huge ecosystem of frameworks, tools, plugins, integrations, and service providers.</blockquote><p><strong>Run anywhere</strong></p><blockquote>You can run Kubernetes on-premise, in the cloud (with 1st class support from the cloud provider, e.g.,: AWS offers EKS, Google Cloud offers GKE, Azure offers AKS), and on your own computer (it’s built directly into the Docker desktop app). This reduces lock-in and makes multi-cloud and hybrid-cloud more manageable, as both the containers themselves and the way you manage them are portable.</blockquote><p><strong>Proven technology</strong></p><blockquote>Kubernetes was originally designed by Google, based on years of experience with their internal container management systems (Borg and Omega), and is now maintained by the Cloud Native Computing Foundation. It’s designed for massive scale and resiliency (Google runs billions of containers per week) and with a huge community behind it, it’s continuously getting better.</blockquote><h3>What are the main Kubernetes design principles?</h3><p>The design of a Kubernetes cluster is based on 3 principles, as explained in the <a href="https://kubernetes.io/docs/reference/setup-tools/kubeadm/implementation-details/">Kubernetes implementation details</a>.</p><p>A <strong>Kubernetes </strong>cluster should be:</p><ul><li><strong>Secure.</strong> It should follow the latest security best-practices.</li><li><strong>Easy to use.</strong> It should be operable using a few simple commands.</li><li><strong>Extendable.</strong> It shouldn’t favor one provider and should be customizable from a configuration file.</li></ul><h3><strong>Key Feature Offering from Kubernetes Platform</strong></h3><p><strong>1. Service Discovery &amp; Load Balancing</strong></p><p>With <strong>Kubernetes</strong>, there is no need to worry about networking and communication because Kubernetes will automatically assign IP addresses to containers and a single DNS name for a set of containers, that can load-balance traffic inside the cluster.</p><p><strong>2. Storage Orchestration</strong></p><p>With <strong>Kubernetes</strong>, you can mount the storage system of your choice. You can either opt for local storage, or choose a public cloud provider such as GCP or AWS, or perhaps use a shared network storage system such as NFS, iSCSI, etc.</p><p><strong>3. Self-Healing</strong></p><p>Personally, this is my favorite feature. Kubernetes can automatically restart containers that fail during execution and kills those containers that don’t respond to user-defined health checks. But if nodes itself die, then it replaces and reschedules those failed containers on other available nodes.</p><p><strong>4. Automatic Rollbacks &amp; Rollouts</strong></p><p>Kubernetes progressively rolls out changes and updates to your application or its configuration, by ensuring that not all instances are worked at the same instance. Even if something goes wrong, Kubernetes will rollback the change for you.</p><p><strong>5. Secret &amp; Configuration Management</strong></p><p>Kubernetes can help you deploy and update secrets and application configuration without rebuilding your image and without exposing secrets in your stack configuration.</p><p><strong>6. Automatic Binpacking</strong></p><p>Kubernetes automatically packages your application and schedules the containers based on their requirements and available resources while not sacrificing availability. To ensure complete utilization and save unused resources, Kubernetes balances between critical and best-effort workloads.</p><p><strong>7. Batch Execution</strong></p><p>In addition to managing services, Kubernetes can also manage your batch and CI workloads, thus replacing containers that fail, if desired.</p><p><strong>8. Horizontal Scaling</strong></p><p>Kubernetes needs only 1 command to scale up the containers, or to scale them down when using the CLI. Else, scaling can also be done via the Dashboard (kubernetes UI).</p><p><strong>9. Service Topology</strong></p><p>Kubernetes,based on the cluster topology it has the ability to route the service traffic to various nodes configured.</p><p>Service Topology enables a service to route traffic based upon the Node topology of the cluster. For example, a service can specify that traffic be preferentially routed to endpoints that are on the same Node as the client, or in the same availability zone.</p><p><strong>10. IPv4/IPv6 dual-stack</strong></p><p>IPv4/IPv6 dual-stack enables the allocation of both IPv4 and IPv6 addresses to Pods and Services.</p><p>If you enable IPv4/IPv6 dual-stack networking for your Kubernetes cluster, the cluster will support the simultaneous assignment of both IPv4 and IPv6 addresses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*JcY_KefDl_GmMkkcc6mZWw.png" /><figcaption>Source : <a href="https://www.opcito.com/">https://www.opcito.com/</a></figcaption></figure><p><strong><em>These were some of the notable features of Kubernetes,which makes Kubernetes multi-container management solution with auto-healing,load balancing like features.</em></strong></p><p>In the next article we would be discussing more about the Kubernetes architecture and the Master-Slave (Worker) Configuration for the Load Balancing and Distribution along with various algorithms used behind those methodologies.</p><blockquote><strong>Reference Links to read more about Kubernetes and its Applications:</strong></blockquote><ul><li><a href="https://kubernetes.io/">Production-Grade Container Orchestration</a></li><li><a href="https://aws.amazon.com/kubernetes/">Kubernetes on AWS | Amazon Web Services</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef21b1ab1622" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devops-and-sre-learning/quick-learning-guide-for-kubernetes-part-i-ef21b1ab1622">Quick Learning Guide for Kubernetes-Part I</a> was originally published in <a href="https://medium.com/devops-and-sre-learning">DevOps and SRE Learning</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick Learning Guide for Kubernetes-Part II]]></title>
            <link>https://medium.com/devops-and-sre-learning/quick-learning-guide-for-kubernetes-part-ii-f5336d7993?source=rss----248569d59069---4</link>
            <guid isPermaLink="false">https://medium.com/p/f5336d7993</guid>
            <dc:creator><![CDATA[Hemant Jain]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 06:05:49 GMT</pubDate>
            <atom:updated>2020-06-07T23:22:18.360Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>This article is in continuation of <a href="https://medium.com/@hemantjain/quick-learning-guide-for-kubernetes-part-i-ef21b1ab1622"><strong>Quick Learning Guide for Kubernetes-Part </strong></a><strong>I</strong> where we learnt about <strong>Kubernetes </strong>and answered the basic questions about <strong>Kubernetes</strong> and it’s features making it a multi-container orchestration platform in the <strong>Containerization industry.</strong></blockquote><p>Next, in this article we would be learning more about the <strong>Kubernetes Architecture, Master-Slave (Worker) Node Configuration</strong> with detailed overview about the submodules in each section and many more…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*UGd80moMCaCoo0pXt9QGLA.png" /></figure><h3>Kubernetes Architecture/Kubernetes Components</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*HHRp0HENvfAu2hXT8Gto9g.png" /><figcaption>Source: <a href="https://phoenixnap.com/">https://phoenixnap.com/</a></figcaption></figure><p><strong>Kubernetes </strong>Architecture has the following main components:</p><ul><li>Master nodes</li><li>Worker/Slave nodes</li><li>Distributed key-value store(etcd.)</li></ul><p><strong>What is Master Node in Kubernetes Architecture?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*twkOguno_radLd5vbsMqOw.png" /><figcaption>Source: <a href="https://phoenixnap.com/">https://phoenixnap.com/</a></figcaption></figure><p>The <strong>Kubernetes Master</strong> (Master Node) receives input from a <strong>CLI </strong>(Command-Line Interface) or <strong>UI </strong>(User Interface) via an API. These are the commands you provide to Kubernetes.</p><p>It is the entry point for all administrative tasks which is responsible for managing the Kubernetes cluster. There can be more than one master node in the cluster to check for fault tolerance. More than one master node puts the system in a <strong><em>High Availability </em></strong>mode, in which one of them will be the main node which we perform all the tasks.</p><p>For managing the cluster state, it uses<strong> etcd</strong> in which all the master nodes connect to it.</p><p>Let us discuss the components of a master node. As you can see in the diagram it consists of <strong>4</strong> components:</p><p><strong>1. API Server</strong></p><ul><li>The <strong><em>API Server</em></strong> is the front-end of the control plane and the only component in the control plane that we interact with directly.</li><li>Performs all the administrative tasks through the <strong><em>API server</em></strong> within the master node.</li><li>In this REST commands are sent to the <strong><em>API server</em></strong> which validates and processes the requests.</li><li>After requesting, the resulting state of the cluster is stored in the distributed key-value store.</li></ul><p><strong>2. Scheduler</strong></p><ul><li>A <strong><em>Scheduler</em></strong><em> </em>watches for new requests coming from the API Server and assigns them to healthy nodes.</li><li>The <strong><em>Scheduler </em></strong>schedules the tasks to <strong><em>slave nodes</em></strong>. It stores the resource usage information for each slave node.</li><li>It schedules the work in the form of <strong><em>Pods</em></strong> and <strong><em>Services</em></strong>.</li><li>Before scheduling the task, the <strong><em>scheduler </em></strong>also takes into account the quality of the service requirements, data locality, affinity, anti-affinity, etc.</li></ul><p><strong>3. Controller Manager</strong></p><ul><li>Also known as <strong><em>controllers</em></strong>.</li><li>It is a daemon which regulates the Kubernetes cluster which manages the different non-terminating control loops.</li><li>It also performs lifecycle functions such as namespace creation and lifecycle, event garbage collection, terminated-pod garbage collection, cascading-deletion garbage collection, node garbage collection, etc.</li><li>The role of the <strong><em>Controller</em></strong><em> </em>is to obtain the desired state from the API Server. It checks the current state of the nodes it is tasked to control, and determines if there are any differences, and resolves them, if any.</li></ul><p><strong>4. Key-Value Store (etcd)</strong></p><ul><li>The <strong><em>Key-Value Store</em></strong>, also called <strong><em>etcd</em></strong>, is a database Kubernetes uses to back-up all cluster data.</li><li>It stores the entire configuration and state of the cluster.</li><li>The Master node queries etcd to retrieve parameters for the state of the nodes, pods, and containers.</li><li>It can be part of the Kubernetes Master, or, it can be configured externally.</li><li><strong><em>etcd</em></strong><em> </em>is written in the Go programming language. In Kubernetes, besides storing the cluster state (based on the <a href="https://raft.github.io/"><strong>Raft Consensus Algorithm</strong></a>) it is also used to store configuration details such as subnets, ConfigMaps, Secrets, etc.</li></ul><p>Now you have understood the functioning of Master node. Let’s see what is the Worker/Minions node and its components.</p><p><strong>What is Worker Node in Kubernetes Architecture?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*715PqIW5nFIjcN8Az83rNA.png" /><figcaption>Source: <a href="https://phoenixnap.com/">https://phoenixnap.com/</a></figcaption></figure><h3>Worker Node (formerly minions)</h3><p>It is a physical server or you can say a VM which runs the applications using Pods (<strong>a pod scheduling unit</strong>) which is controlled by the master node. On a physical server (worker/slave node), pods are scheduled. For accessing the applications from the external world, we connect to nodes.</p><p><strong><em>Worker nodes</em></strong> listen to the API Server for new work assignments; they execute the work assignments and then report the results back to the Kubernetes Master node.</p><p>Let’s see what are the following components:</p><p><strong>1. Kubelet</strong></p><ul><li>The <strong><em>kubelet</em></strong><em> </em>runs on every node in the cluster.</li><li>It is the <strong>principal Kubernetes agent.</strong></li><li>By installing <strong><em>kubelet</em></strong>, the node’s CPU, RAM, and storage become part of the broader cluster.</li><li>It watches for tasks sent from the API Server, executes the task, and reports back to the Master.</li><li>It gets the <strong><em>Pod</em></strong> specifications through the API server and executes the containers associated with the Pod and ensures that the containers described in those Pod are running and healthy.</li><li>Based on that information, the Master can then decide how to allocate tasks and resources to reach the desired state.</li></ul><p>2. <strong>Kube-proxy</strong></p><ul><li><strong><em>Kube-proxy</em></strong> runs on each node to deal with individual host sub-netting and ensure that the services are available to external parties.</li><li>The <strong><em>kube-proxy</em> </strong>makes sure that each node gets its IP address, implements local <strong><em>iptables</em></strong> and rules to handle routing and traffic load-balancing.</li><li>It serves as a network proxy and a load balancer for a service on a single worker node and manages the network routing for TCP and UDP packets.</li><li>It is the network proxy which runs on each worker node and listens to the API server for each Service endpoint creation/deletion.</li><li>For each <strong><em>Service</em></strong><em> </em>endpoint, <strong><em>kube-proxy</em></strong> sets up the routes so that it can reach to it.</li></ul><p>3. <strong>Container Runtime</strong></p><ul><li>To run and manage a container’s lifecycle, we need a <strong><em>container runtime</em> </strong>on the worker node.</li><li>The <strong><em>container runtime</em></strong> pulls images from a container image registry and starts and stops containers.</li><li>Sometimes, Docker is also referred to as a <strong><em>container runtime</em></strong>, but to be precise, Docker is a platform which uses <strong>containers </strong>as a <strong><em>container runtime</em></strong>.</li></ul><p>4. <strong>Pod</strong></p><ul><li>A <strong><em>Pod </em></strong>is the smallest element of scheduling in Kubernetes. Without it, a container cannot be part of a cluster. If you need to scale your app, you can only do so by adding or removing pods.</li><li>The <strong><em>Pod </em></strong>serves as a ‘<strong>wrapper</strong>’ for a single container with the application code. A <strong><em>Pod </em></strong>is one or more containers that logically go together.</li><li>Based on the availability of resources, the Master schedules the pod on a specific node and coordinates with the container runtime to launch the container.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*Q4Wg5c9W2XjQIqT5aSakdg.png" /><figcaption>Source: <a href="https://phoenixnap.com/">https://phoenixnap.com/</a></figcaption></figure><ul><li><strong><em>Pods </em></strong>run on nodes. Pods run together as a logical unit. So they have the same shared content.</li><li>They all share the same IP address but can reach other Pods via localhost, as well as shared storage.</li><li><strong><em>Pods </em></strong>don’t need to all run on the same machine as containers can span more than one machine. One node can run multiple pods.</li><li>In instances where pods unexpectedly fail to perform their tasks, Kubernetes does not attempt to fix them. Instead, it creates and starts a new pod in its place.</li><li>This new pod is a replica, except for the DNS and IP address. This feature has had a profound impact on how developers design applications.</li><li>Due to the flexible nature of Kubernetes architecture, applications no longer need to be tied to a particular instance of a pod.</li><li><strong><em>Pods </em></strong>can be connected to persistent storage in order to run stateful applications.</li><li>Instead, applications need to be designed so that an entirely new pod, created anywhere within the cluster, can seamlessly take its place. To assist with this process, Kubernetes uses services.</li></ul><p>To quickly summarize this learning chapter about the Kubernetes architecture the Master Worker Architecture flow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ntIhdT6lQ8vNBju5AtKSZQ.png" /></figure><p><strong><em>Reference Links to read more about Kubernetes and its Applications:</em></strong></p><p><a href="https://kubernetes.io/">Production-Grade Container Orchestration</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5336d7993" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devops-and-sre-learning/quick-learning-guide-for-kubernetes-part-ii-f5336d7993">Quick Learning Guide for Kubernetes-Part II</a> was originally published in <a href="https://medium.com/devops-and-sre-learning">DevOps and SRE Learning</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick Learning Guide for Kubernetes-Part III]]></title>
            <link>https://medium.com/devops-and-sre-learning/quick-learning-guide-for-kubernetes-part-iii-d82491a32b9d?source=rss----248569d59069---4</link>
            <guid isPermaLink="false">https://medium.com/p/d82491a32b9d</guid>
            <dc:creator><![CDATA[Hemant Jain]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 06:05:44 GMT</pubDate>
            <atom:updated>2020-06-08T01:03:20.293Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article is in continuation of </em><a href="https://medium.com/@hemantjain/quick-learning-guide-for-kubernetes-part-ii-f5336d7993"><strong><em>Quick Learning Guide for Kubernetes-Part II </em></strong></a><em>where we learnt about </em><strong><em>Kubernetes </em></strong><em>and discussed about the Kubernetes Architecture and the Master -Worker features and it’s features making it a multi-container orchestration platform in the </em><strong><em>Containerization and DevOps industry.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*UGd80moMCaCoo0pXt9QGLA.png" /></figure><h3>Kubernetes Services</h3><ul><li>Like a pod, a Kubernetes service is a REST object. A service is both an abstraction that defines a logical set of pods and a policy for accessing the pod set.</li><li>Pods are not constant. One of the best features Kubernetes offers is that non-functioning pods get replaced by new ones automatically.</li><li>However, these new pods have a different set of IPs. It can lead to processing issues, and IP churn as the IPs no longer match. If left unattended, this property would make pods highly unreliable.</li><li>Services are introduced to provide reliable networking by bringing stable IP addresses and DNS names to the unstable world of pods.</li><li>By controlling traffic coming and going to the pod, a Kubernetes service provides a stable networking endpoint — a fixed IP, DNS, and port. Through a service, any pod can be added or removed without the fear that basic network information would change in any way.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*03ExGh7GZyghAZzBzuVAYQ.png" /><figcaption>Kubernetes Pod and Node Architecture (Source: <a href="https://kubernetes.io/docs/tutorials/kubernetes-basics/expose/expose-intro/">https://kubernetes.io/docs</a>)</figcaption></figure><p><strong>General Attributes of a Kubernetes service:</strong></p><p><strong>1.</strong> A label selector can find pods that are targeted by a service.</p><ul><li><em>For K8S-native applications, the endpoints API will be updated whenever there are changes to a set of pods in a service.</em></li><li><em>For non-native applications, a virtual-IP-based bridge to services redirects to backend pods.</em></li></ul><p><strong>2. </strong>A service is assigned an IP address (“cluster IP”), which the service proxies use.</p><p><strong>3.</strong> A service can map an incoming port to any targetPort. (The targetPort is set, by default, to the port field’s same value. The targetPort can be defined as a string.)</p><p><strong>4. </strong>The port number assigned to each name can vary in each backend pod.</p><ul><li><em>For example, you can change the port number that pods expose in the next version of your backend software, without breaking clients.</em></li></ul><p><strong>5.</strong> Services support TCP (default), UDP and SCTP for protocols.</p><p><strong>6.</strong> Services can be defined with or without a selector.</p><p><strong>7.</strong> Services support a variety of port definitions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*kXd667gLGhD2r2xNiBPxkw.png" /><figcaption>Kubernetes Label and Label Selector (Source: <a href="https://kubernetes.io/docs/tutorials/kubernetes-basics/expose/expose-intro/">https://kubernetes.io/docs</a>)</figcaption></figure><h3>Types of Kubernetes services</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eo8aoQ7BmiiMuwOsZieecw.png" /><figcaption>Kubernetes Services Type</figcaption></figure><p>There are four types of Kubernetes services:</p><ol><li><strong>ClusterIP.</strong> This default type exposes the service on a cluster-internal IP. You can reach the service only from <em>within</em> the cluster.</li><li><strong>NodePort.</strong> This type of service exposes the service on each node’s IP at a static port. A ClusterIP service is created automatically, and the NodePort service will route to it. From <em>outside</em> the cluster, you can contact the NodePort service by using “&lt;NodeIP&gt;:&lt;NodePort&gt;”.</li><li><strong>LoadBalancer.</strong> This service type exposes the service externally using the load balancer of your cloud provider. The external load balancer routes to your NodePort and ClusterIP services, which are created automatically.</li><li><strong>ExternalName.</strong> This type maps the service to the contents of the externalName field (e.g., foo.bar.example.com). It does this by returning a value for the CNAME record.</li></ol><p>Before moving forward, let’s go over the role of kube-proxy. Kube-proxy implements a form of virtual IP for services for all types other than ExternalName. To achieve this, you can set three possible modes:</p><ul><li><strong>Proxy-mode: userspace.</strong> In this mode, kube-proxy keeps an eye on the Kubernetes master, watching for services and endpoints objects that get added or removed. For each service, the mode opens a random port on your local node. Any connections to this “proxy port” are proxied to a service’s backend pods and reported in the endpoints.</li><li><strong>Proxy-mode: iptables.</strong> When this mode is on, kube-proxy continues to watch the Kubernetes master for added or removed services and endpoint objects.</li></ul><blockquote><em>For each service, unlike in userspace, this mode installs iptables rules in order to capture traffic to the service’s clusterIP (virtual) and port, and then redirects that traffic to a service backend set.</em></blockquote><blockquote><em>For each endpoints object, the mode installs iptables rules to select a random (by default) backend pod.</em></blockquote><ul><li><strong>Proxy-mode: ipvs</strong>. In this mode, kube-proxy watches the services and endpoints and calls netlink interface in order to create appropriate ipvs rules. Then, to ensure ipvs status is consistent with its expectations, the mode periodically syncs ipvs rules with services and endpoints. When a service is accessed, traffic gets redirected to a backend pod.</li></ul><h3>How to discover a Kubernetes service</h3><p>In Kubernetes, there are two ways to discover a service:</p><ol><li><strong>DNS: </strong>In this recommended method, the DNS server is added to the cluster in order to watch the Kubernetes API create DNS record sets for each new service. When DNS is enabled throughout the cluster, all pods should be able to automatically perform name resolution of services.</li><li><strong>ENV Var: </strong>In this discovery method, a pod runs on a node, so the kubelet adds environment variables for each active service.</li></ol><h3>Headless services</h3><p>When you neither need nor want load-balancing and a single service IP, create a headless service by specifying “none” for the cluster IP (.spec.clusterIP). There are two options:</p><ul><li><strong>Headless service with selectors</strong>. With a headless service that defines selectors, the endpoints controller creates endpoint records in the API, modifying the DNS configuration to return A records (addresses) that point to the pods that back the service.</li><li><strong>Headless service without selectors. </strong>Headless services don’t define selectors, so the endpoints controller does not create endpoint records. However, the DNS system configures one of the following:</li></ul><blockquote>For service type ExternalName, CNAME records</blockquote><blockquote>For the other service types, a record for any endpoints that share names with the service</blockquote><h3><strong>How Do Kubernetes Services Work?</strong></h3><ol><li>Pods are associated with services through key-value pairs called labels and selectors. A service automatically discovers a new pod with labels that match the selector.</li><li>This process seamlessly adds new pods to the service, and at the same time, removes terminated pods from the cluster.</li><li>For example, if the desired state includes three replicas of a pod and a node running one replica fails, the current state is reduced to two pods. Kubernetes observers that the desired state is three pods.</li><li>It then schedules one new replica to take the place of the failed pod and assigns it to another node in the cluster.</li><li>The same would apply when updating or scaling the application by adding or removing pods.</li><li>Once we update the desired state, Kubernetes notices the discrepancy and adds or removes pods to match the manifest file.</li><li>The Kubernetes control panel records, implements, and runs background reconciliation loops that continuously check to see if the environment matches user-defined requirements.</li></ol><p>Now we have learnt about what Kubernetes is,what all features it offers, learning about the k8s architecture and now in the above section learning in details about the Kubernetes Services</p><p>Let’s have some practical demo of creating the Kubernetes Services in our Linux/Ubuntu.</p><h3>How to create a service</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4xABgjU9SP7di-uQNDquEg.png" /><figcaption>Services Architecture in Kubernetes (Source: <a href="https://linuxacademy.com/">https://linuxacademy.com</a>)</figcaption></figure><p>Creating a service is better understood when we use a simple example. We’ll run a “Hello World” application and use a deployment kind to create the app. Once deployment is up and running, we can create a service, using type ClusterIP, for our app.</p><p>First, let’s create a deployment running</p><pre>$ kubectl run hello-world <strong>--replicas</strong>=2 <strong>--labels</strong>=load-balancer-example <strong>--image</strong>=gcr.io/google-samples/node-hello:1.0 <strong>--port</strong>=8080</pre><p>Without going into too much detail, this command creates a deployment with two replicas of our application.</p><p>Next, run the below command to see the deployment is running. Now we can check the replicaset and pods that the deployment created.</p><pre>$ kubectl get deployment hello-world<br>NAME          DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE<br>hello-world   2         2         2            2           56s</pre><p>With the applications running, we want to access one. So, let’s create a ClusterIP type of service. We can:</p><ul><li>Create a yaml manifest for the service and apply it, or</li><li>Use the “kubectl expose” command, which is the easier option. This expose command creates a service without creating a yaml file.</li></ul><pre>$ kubectl expose deployment hello-world <strong>--type</strong>=ClusterIP <strong>--name</strong>=example-service<br>service &quot;example-service&quot; exposed</pre><p>Here, we’ll create a service called example-service with type ClusterIP.</p><p>To access our application, run “<strong><em>kubectl get service example-service</em></strong>” to get our port number. Then, run a special command called port-forward. Because our service type is Cluster IP, which can only be accessed from within the cluster, we must access our app by forwarding the port to a local port.</p><p>We can use other types, like “<strong><em>LoadBalancer</em></strong>”, which will create a LB in AWS or GCP, then we can access the app using the DNS address given to the LB with our port number.</p><pre>$ kubectl get service example-service<br>NAME              TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE<br>example-service   ClusterIP   100.20.149.98   &lt;none&gt;        8080/TCP   1h</pre><pre>$ kubectl port-forward service/example-service 8080:8080<br>Forwarding <strong>from</strong> 127.0.0.1:8080 -&gt; 8080</pre><p>Now we can browse <a href="http://localhost:8080">http://localhost:8080</a> from our workstation and we should see:</p><pre>Hello Kubernetes!</pre><ul><li><a href="https://linuxacademy.com/">#1 Learn-by-Doing Online Cloud Training Platform - Linux Academy</a></li><li><a href="https://kubernetes.io/">Production-Grade Container Orchestration</a></li><li><a href="https://docs.bytemark.co.uk/article/kubernetes-terminology-glossary/">Kubernetes Terminology: Glossary - Documentation | Bytemark</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d82491a32b9d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devops-and-sre-learning/quick-learning-guide-for-kubernetes-part-iii-d82491a32b9d">Quick Learning Guide for Kubernetes-Part III</a> was originally published in <a href="https://medium.com/devops-and-sre-learning">DevOps and SRE Learning</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Multi-Cluster Kubernetes on AWS Using the Terraform as IaC]]></title>
            <link>https://medium.com/devops-and-sre-learning/setting-up-multi-cluster-kubernetes-on-aws-using-the-terraform-as-iac-26a30e32c702?source=rss----248569d59069---4</link>
            <guid isPermaLink="false">https://medium.com/p/26a30e32c702</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[multi-cluster]]></category>
            <dc:creator><![CDATA[Hemant Jain]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 06:05:38 GMT</pubDate>
            <atom:updated>2020-06-21T19:11:38.778Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*PGWtgd8RU5vsqQz2xp4X8Q.png" /></figure><p>For starting up with this complete tutorial from scratch you would be needing a Linux Machine to run all the scripts which you can make it easily available from AWS EC2 Instances or running the VMWare Workstation Pro or Oracle Virtualbox with Ubuntu based iso file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NgUP8ry_EpJaAH03B6ly_g.png" /></figure><h3><strong>Introduction</strong></h3><h3>What is Terraform ?</h3><p>Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.</p><p>Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied.</p><p><strong>The key features of Terraform are:</strong></p><p>1. Infrastructure as Code</p><p>Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.</p><p>2. Execution Plans</p><p>Terraform has a “planning” step where it generates an <em>execution plan</em>. The execution plan shows what Terraform will do when you call apply. This lets you avoid any surprises when Terraform manipulates infrastructure.</p><p>3. Resource Graph</p><p>Terraform builds a graph of all your resources, and parallelizes the creation and modification of any non-dependent resources. Because of this, Terraform builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.</p><p>4. Change Automation</p><p>Complex changesets can be applied to your infrastructure with minimal human interaction. With the previously mentioned execution plan and resource graph, you know exactly what Terraform will change and in what order, avoiding many possible human errors.</p><h3>What is Kubernetes?</h3><p>Kubernetes is a powerful open-source system, initially developed by Google, for managing containerized applications in a clustered environment. It aims to provide better ways of managing related, distributed components and services across varied infrastructure.</p><p><strong>Kubernetes</strong>, at its basic level, is a system for running and coordinating containerized applications across a cluster of machines. It is a platform designed to completely manage the life cycle of containerized applications and services using methods that provide predictability, scalability, and high availability.</p><p>As a Kubernetes user, you can define how your applications should run and the ways they should be able to interact with other applications or the outside world. You can scale your services up or down, perform graceful rolling updates, and switch traffic between different versions of your applications to test features or rollback problematic deployments. Kubernetes provides interfaces and composable platform primitives that allow you to define and manage your applications with high degrees of flexibility, power, and reliability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*NRiw8t4xdr_J6jF9xx7OiQ.png" /><figcaption>Kubernetes Architecture (Source : <a href="https://www.linux.com/">https://www.linux.com/</a>)</figcaption></figure><h3>Installing Terraform</h3><p>Terraform is very easy to install. You can download Terraform from the <a href="https://www.terraform.io/downloads.html">Terraform download page</a>. Select the appropriate package for your operating system and architecture, unzip the archive and move the binary to a directory included in your PATH variable.</p><p>First, create ~/bin directory:</p><pre><em>mkdir ~/bin</em></pre><p>On Ubuntu, if you create this directory it will automatically be added to your PATH.</p><p>Next, download the zip archive. Visit the Terraform download page for the latest version to download.</p><pre><em>wget https://releases.hashicorp.com/terraform/0.12.26/terraform_0.12.26_linux_amd64.zip</em></pre><p>Unzip the archive. The archive will extract a single binary called terraform.</p><pre><em>unzip terraform_0.12.26_linux_amd64.zip</em></pre><p>Move the terraform binary to a directory included in your system&#39;s PATH in our case that&#39;s ~/bin directory.</p><pre><em>mv terraform ~/bin</em></pre><p>To check whether Terraform is installed, run:</p><pre><em>terraform version<br># Terraform v0.12.26</em></pre><h3>Install kubectl on Linux</h3><h4>Install kubectl binary with curl on Linux</h4><p>1. Download the latest release with the command:</p><pre>curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl</pre><p>2. Make the kubectl binary executable.</p><pre>chmod +x ./kubectl</pre><p>3. Move the binary in to your PATH.</p><pre>sudo mv ./kubectl /usr/local/bin/kubectl</pre><p>4. Test to ensure the version you installed is up-to-date:</p><pre>kubectl version --client</pre><h3>Configure AWS credentials</h3><p>First of all, you need an <a href="https://aws.amazon.com/">AWS account</a>.</p><p>Since the Terraform kubeadm module will create AWS resources on your behalf, it needs to have access to the <a href="https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys">Access Key ID and Secret Access Key</a> of an <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html">IAM User</a> in your AWS account.</p><p>If you’re already using the <a href="https://aws.amazon.com/cli/">AWS CLI</a> and have an ~/.aws/credentials file on your machine, then you should be good to go.</p><p>In all other cases, you can set the following environment variables:</p><pre>export AWS_ACCESS_KEY_ID=&lt;AccessKeyID&gt;<br>export AWS_SECRET_ACCESS_KEY=&lt;SecretAccessKey&gt;</pre><p>You can find out the Access Key ID and Secret Access Key of all the IAM users in your AWS account in the <a href="https://console.aws.amazon.com/iam/home">AWS IAM Console</a></p><h3>Ensure default OpenSSH keys</h3><p>The Terraform kubeadm module will set up SSH access to the nodes of the cluster by using the default key pair of OpenSSH:</p><ul><li>~/.ssh/id_rsa (private key)</li><li>~/.ssh/id_rsa.pub (public key)</li></ul><p>If you currently don’t have these files on your local machine, you can generate them with the following command:</p><pre><strong>$ ssh-keygen</strong></pre><p><em>You’re now ready to use the Terraform kubeadm module!</em></p><h3>Various Methods for Kubernetes Cluster</h3><p>There are many ways to create Kubernetes cluster s — from simple cluster installation tools like <a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/">kubeadm</a> to full-blown managed Kubernetes services like <a href="https://cloud.google.com/kubernetes-engine">GKE</a>, <a href="https://aws.amazon.com/eks/">EKS</a>, or <a href="https://docs.microsoft.com/azure/aks/">AKS</a>.</p><p>Generally, the available options pose a trade-off between automation and flexibility:</p><ul><li>Managed Kubernetes services make creating a cluster very easy, but they usually apply many default settings that you can’t configure.</li><li>On the other extreme, installing Kubernetes <a href="https://github.com/kelseyhightower/kubernetes-the-hard-way">manually without any scripts and tools</a> allows you to configure every setting you want, but it requires many manual and error-prone steps.</li></ul><p><em>Often, what you want is a middle ground between these two extremes.</em></p><p>Such as creating an un-opinionated cluster in a simple way — preferably with a single command.</p><p>This is especially true if you want to experiment with certain low-level Kubernetes features, such as <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/">CNI plugins</a> — if a given cluster installation method installs a CNI plugin by default, you can’t use it for this purpose, since you need to be in control about which CNI plugin to install and how to configure it.</p><p><em>This article presents an approach that attempts to combine both automation and flexibility.</em></p><p>The created clusters are “minimum viable clusters”, as they are produced by kubeadm, with no CNI plugin installed and no opinionated settings applied.</p><p>The goal of this is to provide a base on which you can run controlled Kubernetes experiments (such as testing CNI plugins or experimenting with other Kubernetes features).</p><h3>Managed Kubernetes services</h3><p>There are two categories for creating a Kubernetes cluster: managed services and installation tools.</p><p>Managed Kubernetes services create and operate a cluster for you and give you access to it.</p><p><em>They allow you to use Kubernetes in a Software as a Service (SaaS) manner.</em></p><p>Managed Kubernetes services provide the highest degree of automation (creation and operation are entirely done for you), but the least amount of flexibility (you can configure only those settings that the service provider exposes through its API).</p><p>The most popular managed Kubernetes services are provided by the major cloud providers:</p><ul><li><a href="https://cloud.google.com/kubernetes-engine">Google Kubernetes Engine (GKE)</a> by GCP</li><li><a href="https://aws.amazon.com/eks/">Amazon Elastic Kubernetes Service (EKS)</a> by AWS</li><li><a href="https://docs.microsoft.com/azure/aks/">Azure Kubernetes Service (AKS)</a> by Azure</li></ul><h3>Kubernetes installation tools</h3><p>Kubernetes installation tools allow you to install and manage Kubernetes on your own (both on-premises or in the cloud).</p><p><em>They allow you to use Kubernetes like a traditional self-managed piece of software.</em></p><p>Installation tools provide varying degrees of automation and flexibility depending on the extent to which the tool wants to “get it right for you”.</p><p>At the time of writing, the most popular (and officially supported) Kubernetes installation tools are:</p><ul><li><a href="https://kops.sigs.k8s.io/"><strong>kops</strong></a></li><li><a href="https://kubespray.io/"><strong>kubespray</strong></a></li><li><a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/"><strong>kubeadm</strong></a></li></ul><p>The flip side of creating a cluster with kubeadm is being not a single-command operation (as it’s the case for kops and kubespray).</p><p>Rather, it requires a whole series of manual steps:</p><ul><li>Provision the infrastructure on which you want to create the cluster</li><li>Log in to every node and install kubeadm and Docker on it</li><li>Run the <a href="https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-init/">kubeadm init</a> command on one of the nodes</li><li>Run the <a href="https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-join/">kubeadm join</a> command on all the other nodes</li></ul><p>Furthermore, these steps depend on each other — for example, the kubeadm join commands must include a token and other identifiers that are generated by the initial kubeadm init command.</p><p>In summary, creating a Kubernetes cluster with kubeadm is a time-consuming tedious process when done manually.</p><p><em>This is where the </em><strong><em>Terraform kubeadm </em></strong><em>module comes in.</em></p><h3>The Terraform kubeadm module</h3><p>The <a href="https://registry.terraform.io/modules/weibeld/kubeadm/aws">Terraform kubeadm module</a> automates the operation of kubeadm with the goal of providing both automation and flexibility.</p><p>However, the module does not only run kubeadm, but it also provisions the infrastructure for the cluster.</p><blockquote><em>Currently, only AWS is supported as an infrastructure provider, but support for GCP and Azure is planned.</em></blockquote><p>That means, with the Terraform kubeadm module, you can go from zero to a running cluster on AWS with a single command in a few minutes.</p><p>This brings you the convenience of kops without having to deal with opinionated features that you might not need.</p><p>With the Terraform kubeadm module, you get the exact same “minimum viable” cluster that you also get when running kubeadm manually.</p><p><strong>More Details can be found at :</strong></p><blockquote><a href="https://registry.terraform.io/modules/weibeld/kubeadm/aws/0.2.0">https://registry.terraform.io/modules/weibeld/kubeadm/aws/0.2.0</a></blockquote><p>The power and versatility of Terraform comes from the <a href="https://www.terraform.io/docs/providers/index.html">Terraform providers</a>.</p><p>Terraform providers are plugin-style components that encapsulate the interaction with the API of a specific service (e.g. AWS, GCP, Cloudflare) and expose the resources that can be managed through this service as <a href="https://www.terraform.io/docs/configuration/resources.html">Terraform resources</a>.</p><p>Terraform resources are the basic building blocks of a Terraform configuration.</p><p>For example, there exists a <a href="https://www.terraform.io/docs/providers/aws/index.html">Terraform provider for AWS</a>, and this provider defines a Terraform resource named <a href="https://www.terraform.io/docs/providers/aws/r/instance.html">aws_instance</a> which corresponds to an <a href="https://aws.amazon.com/ec2/">Amazon EC2 instance</a>.</p><p>When you define an aws_instance Terraform resource in your Terraform configuration, Terraform will create an EC2 instance for you.</p><p>Furthermore, when you change the definition of the aws_instance resource in your configuration, Terraform will apply the corresponding changes to the real EC2 instance in your AWS account.</p><p>A Terraform configuration can be organised as a <a href="https://www.terraform.io/docs/modules/index.html">Terraform module</a>.</p><p>A Terraform module encapsulates a piece of Terraform configuration so that it can be reused and shared.</p><p>The <a href="https://registry.terraform.io/">Terraform Registry</a> is the primary place where Terraform modules are hosted and shared — you can browse hundreds of freely available Terraform modules there.</p><p>The <a href="https://registry.terraform.io/modules/weibeld/kubeadm/aws">Terraform kubeadm module</a> is also freely available on the Terraform Registry, and the following sections explain how to use it.</p><h3>Creating a single cluster</h3><p>In the following, you will create a minimal cluster consisting of a single master node and two worker nodes on AWS.</p><p>Start by creating a new directory:</p><pre><strong>$ mkdir terraform-kubeadm<br>$ cd terraform-kubeadm</strong></pre><p>And in this directory, create a file named main.tf with the following content:</p><pre>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}module &quot;cluster&quot; {<br>  source  = &quot;weibeld/kubeadm/aws&quot;<br>  version = &quot;~&gt; 0.2&quot;<br>}</pre><p>The above is a Terraform configuration that invokes the <a href="https://registry.terraform.io/modules/weibeld/kubeadm/aws">Terraform kubeadm module</a>.</p><p><em>That’s all the code you have to write to create a minimal Kubernetes cluster.</em></p><p>But before you can do so, you have to initialise Terraform in your current working directory as follows:</p><pre><strong>$ terraform init</strong></pre><p>The <a href="https://www.terraform.io/docs/commands/init.html">terraform init</a> downloads both the AWS provider and the Terraform kubeadm module to a subdirectory named .terraform in your current working directory.</p><p>Now you can start the process of turning your configuration into reality:$</p><pre><strong>$ terraform apply</strong></pre><p>The <a href="https://www.terraform.io/docs/commands/apply.html">terraform apply</a> command first shows you a so-called <a href="https://www.terraform.io/docs/commands/plan.html">execution plan</a> which is a summary of resources that Terraform will create, modify, or delete.</p><p>In your case, since you’re starting from zero, there should be only resources to create.</p><p>The command prompts you if you want to proceed, which you can confirm by typing yes.</p><p>Terraform now turns the execution plan into reality by creating the necessary AWS resources in your AWS account.</p><p>You can lean back and wait for Terraform to create your cluster!</p><p><em>It shouldn’t take longer than 3–4 minutes.</em></p><p>When the command completes, your cluster should be up and running!</p><p>In your current working directory, you should now have a file with a random name (such as modern-amoeba) and a .conf extension:</p><pre><strong>$ ls *.conf<br> modern-amoeba.conf</strong></pre><p>This is the <a href="https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/">kubeconfig</a> file for connecting to your newly created cluster.</p><p>You can use it to access your cluster with kubectl as follows:</p><pre><strong>$ kubectl --kubeconfig modern-amoeba.conf get pods --all-namespaces</strong></pre><blockquote><em>Please replace </em><em>modern-amoeba.conf with the name of your kubeconfig file.</em></blockquote><p>You should see the system Pods of your cluster.</p><p><em>Congratulations, you just created your first cluster!</em></p><blockquote><em>You can see the EC2 instances (and other resources) that Terraform created in your AWS account in the </em><a href="https://console.aws.amazon.com/ec2/v2/home"><em>AWS EC2 Console</em></a><em>.</em></blockquote><p><em>So, looks like you have a running cluster now.</em></p><p>However, if you inspect the above output a bit closer, you should see that the coredns Pods are Pending:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v4VeOLdiGUQLN1p5_41dbQ.png" /></figure><p>And if the nodes of the cluster should be NotReady:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0wbM1IWh34jtO7lARIXVA.png" /></figure><p><em>Don’t worry!</em></p><p>This doesn’t mean there’s something wrong — it’s the expected behaviour!</p><p>The reason is that your cluster doesn’t yet have a <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/">CNI plugin</a> installed — this keeps the nodes in the NotReady state and prevents any Pods in the Pod network from being scheduled.</p><blockquote><em>In case you wonder why the other Pods are all </em><em>Running: that&#39;s because these Pods run in the </em><a href="https://github.com/kubernetes/api/blob/master/core/v1/types.go#L2938"><em>host network</em></a><em> (i.e. they have </em><em>.spec.hostNetwork set to </em><em>true) rather than in the Pod network, which doesn&#39;t depend on a CNI plugin.</em></blockquote><p>The reason that your cluster has no CNI plugin installed is that kubeadm doesn’t install a CNI plugin by default — rather it leaves this choice to the user.</p><p>The article will show how to install a CNI plugin in your cluster later.</p><p><em>For now, let’s first explore the cluster a bit more.</em></p><h3>Connecting to a node</h3><p>In the following, you will SSH into one of the nodes of your cluster.</p><p>To do so, you need to know the public IP address of this node.</p><p>You could do so by going to the <a href="https://console.aws.amazon.com/ec2/v2/home">AWS EC2 Console</a> and looking up the public IP address of the EC2 instance that corresponds to the node.</p><p>However, the Terraform kubeadm module provides an easier way to get this information.</p><p>The module features a collection of <a href="https://registry.terraform.io/modules/weibeld/kubeadm/aws?tab=outputs">output values</a> that convey internal information about the cluster to the user.</p><p>One of these outputs is called cluster_nodes and it contains information about the individual nodes of the cluster, including their public IP addresses.</p><p>You can include this output in your Terraform configuration as follows (added lines are highlighted):</p><pre>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}module &quot;cluster&quot; {<br>  source  = &quot;weibeld/kubeadm/aws&quot;<br>  version = &quot;~&gt; 0.2&quot;<br>}<strong>output &quot;nodes&quot; {<br>  value = module.cluster.cluster_nodes<br>}</strong></pre><p>To display this output, you have to run terraform apply again:</p><pre><strong>$ terraform apply --auto-approve</strong></pre><blockquote><em>The </em><em>--auto-approve flag automatically approves the execution plan so that you don&#39;t need to type </em><em>yes.</em></blockquote><p>When the command completes, you should see an output looking something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CdvrqSqUBkY8ynSEXWXweA.png" /></figure><p>As you can see, this contains some information about each node of the cluster, including its public IP address.</p><p>With this information, you can now SSH into any node of the cluster as follows:</p><pre><strong>$ ssh -i ~/.ssh/id_rsa ubuntu@&lt;NODE-PUBLIC-IP&gt;</strong></pre><blockquote><em>Note that </em><em>~/.ssh/id_rsa is the default OpenSSH private key that is used by default by the Terraform kubeadm module to set up SSH access to the cluster nodes. It&#39;s the credential that allows you to connect to all the nodes of the cluster.</em></blockquote><p>You should now be logged into the node, where you can do all kind of interesting things, such as listing the running containers:</p><pre><strong>$ sudo docker ps</strong></pre><p>But for now, just return to your local machine:</p><pre><strong>$ exit</strong></pre><p><em>There’s a way you can improve your cluster infrastructure!</em></p><h3>Using a dedicated VPC instead of default</h3><p>By default, the kubeadm module creates the cluster in the <a href="https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html">default VPC</a> of the specified AWS region.</p><p>That means, the cluster coexists with other AWS resources in this VPC.</p><p>In some cases, this is not a problem, but in general, it’s a good idea to separate unrelated applications into separate VPCs.</p><p>The Terraform kubeadm module allows you to create a dedicated VPC for your cluster on-the-fly.</p><p>To do so, edit your Terraform configuration as follows (added lines are highlighted):</p><pre>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}<br><strong>module &quot;network&quot; {<br>  source  = &quot;weibeld/kubeadm/aws//modules/network&quot;<br>  version = &quot;~&gt; 0.2&quot;<br>}<br></strong>module &quot;cluster&quot; {<br>  source    = &quot;weibeld/kubeadm/aws&quot;<br>  version   = &quot;~&gt; 0.2&quot;<br><strong>  vpc_id    = module.network.vpc_id<br>  subnet_id = module.network.subnet_id</strong><br>}<br>output &quot;nodes&quot; {<br>  value = module.cluster.cluster_nodes<br>}</pre><p>The above configuration adds an invocation of the <a href="https://github.com/weibeld/terraform-aws-kubeadm/tree/master/modules/network">network submodule</a>.</p><p>Since you added a new module invocation, you first need to run terraform init before you can apply the configuration:</p><pre><strong>$ terraform init</strong></pre><p>This downloads the network submodule to your local directory.</p><p>Now you can apply your new configuration:</p><pre><strong>$ terraform apply</strong></pre><p>Terraform now figures out how to get from the current state to the new specification and shows you the execution plan.</p><p>If you pay close attention to the execution plan, you can see that the aws_instance resources get destroyed and recreated — this means that Terraform will effectively destroy the existing cluster and create a new one in the new VPC.</p><p>To confirm the execution plan, type yes.</p><p>When the command completes, you should have both a new VPC and a new cluster running in it.</p><blockquote><em>You can see the VPC that Terraform created in the </em><a href="http://localhost:4000/https.//console.aws.amazon.com/vpc/home"><em>AWS VPC Console</em></a><em>.</em></blockquote><p>Let’s test if you can still access this new cluster:</p><pre><strong>$ kubectl --kubeconfig real-hedgehog.conf get pods --all-namespaces</strong></pre><p><em>Voila…!!</em></p><p>You should see the list of system Pods just like before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8nmkcNw2CGK_vVxxrDBgQ.png" /></figure><p>But now your cluster is running in its own VPC isolated from any other AWS resources!</p><h3>Creating multiple clusters</h3><p>So far, you created only a single cluster, but what if you want multiple ones?</p><p><em>For example, if you wanted to run a series of experiments on multiple clusters in parallel?</em></p><p>In the following, you will extend your fleet of clusters to three clusters in total.</p><p>To do so, edit your configuration as follows (changed lines are highlighted):</p><pre>provider &quot;aws&quot; {<br>  region = &quot;us-east-1&quot;<br>}<br>module &quot;network&quot; {<br>  source  = &quot;weibeld/kubeadm/aws//modules/network&quot;<br>  version = &quot;~&gt; 0.2&quot;<br>}<br>module &quot;cluster&quot; {<br>  source    = &quot;weibeld/kubeadm/aws&quot;<br>  version   = &quot;~&gt; 0.2&quot;<br>  vpc_id    = module.network.vpc_id<br>  subnet_id = module.network.subnet_id<br>}<br><strong>module &quot;cluster_2&quot; {<br>  source    = &quot;weibeld/kubeadm/aws&quot;<br>  version   = &quot;~&gt; 0.2&quot;<br>  vpc_id    = module.network.vpc_id<br>  subnet_id = module.network.subnet_id<br>}<br>module &quot;cluster_3&quot; {<br>  source    = &quot;weibeld/kubeadm/aws&quot;<br>  version   = &quot;~&gt; 0.2&quot;<br>  vpc_id    = module.network.vpc_id<br>  subnet_id = module.network.subnet_id<br>}<br></strong>output &quot;nodes&quot; {<br><strong>  value = {<br>    (module.cluster.cluster_name)   = module.cluster.cluster_nodes<br>    (module.cluster_2.cluster_name) = module.cluster_2.cluster_nodes<br>    (module.cluster_3.cluster_name) = module.cluster_3.cluster_nodes<br>  }</strong><br>}</pre><p>The main change of the above configuration consists in the addition of two invocations of the kubeadm module.</p><p>The configuration now includes three invocations of the kubeadm module, which results in Terraform creating three clusters.</p><p>In the present configuration, all clusters use the same settings, but you could configure each cluster separately by specifying different <a href="https://registry.terraform.io/modules/weibeld/kubeadm/aws?tab=inputs">input variables</a> for the individual invocations of the kubeadm module.</p><blockquote><em>You could also create a dedicated VPC for each cluster by adding additional invocations of the network submodule.</em></blockquote><p>If this configuration works, then, after applying it, you should have three running clusters.</p><p>Since you added additional module invocations, you first need to run terraform init:</p><pre><strong>$ terraform init</strong></pre><p>Now, you can apply the configuration with terraform apply:</p><pre><strong>$ terraform apply</strong></pre><p>If you pay attention to the execution plan that Terraform presents to you, you should see that it includes the creation of the resources belonging to two new clusters.</p><p>This means, that Terraform will create two new clusters while leaving the existing cluster unchanged — that’s because you just added two new cluster specifications in your configuration, but didn’t modify the existing one.</p><p><em>After you confirm the prompt with </em>yes<em> and the command completes, there should now be three running clusters!</em></p><p>You should now also have three kubeconfig files in your current working directory, one for each cluster:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4o0R39p86zJdvqPhgnQnJw.png" /></figure><p>Let’s test if you can access each of the clusters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZgPwHi2wSGJbft8CQM0wYA.png" /></figure><p>All the commands should succeed!</p><p>Which means that all three clusters are running.</p><p><em>Congratulations, you just created a fleet of three Kubernetes clusters!</em></p><h3>Installing CNI plugins</h3><p>You have three clusters now, but something might still slightly bother you about them.</p><p>They have no CNI plugin installed which causes the nodes to be NotReady and prevents any Pods from being scheduled.</p><p><em>Let’s fix that!</em></p><p>Having three freshly bootstrapped clusters is actually a great opportunity to compare different CNI plugins in a controlled environment.</p><p>Three of the most popular CNI plugins are:</p><ul><li><a href="https://www.projectcalico.org/"><strong>Calico</strong></a></li><li><a href="https://www.weave.works/docs/net/latest/overview/"><strong>Weave Net</strong></a></li><li><a href="https://cilium.io/"><strong>Cilium</strong></a></li></ul><p>So let’s install one of them on each cluster.</p><p><a href="https://docs.projectcalico.org/getting-started/kubernetes/quickstart">Install Calico</a> on the first cluster:</p><pre><strong>$ kubectl apply \<br>  -f </strong><a href="https://docs.projectcalico.org/manifests/calico.yaml"><strong>https://docs.projectcalico.org/manifests/calico.yaml</strong></a><strong> \<br>  --kubeconfig careful-thrush.conf</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sjN0L63Y7lwHf7SaVhtAlw.png" /></figure><p><a href="https://www.weave.works/docs/net/latest/kubernetes/kube-addon/">Install Weave Net</a> on the second cluster:</p><pre><em># Identify Kubernetes version<br></em><strong>$ K8S_VERSION=$(kubectl version --kubeconfig large-walleye.conf | base64 | tr -d &#39;\n&#39;)<br></strong><em># Install CNI plugin<br></em><strong>$ kubectl apply \<br>  -f &quot;https://cloud.weave.works/k8s/net?k8s-version=$K8S_VERSION&quot; \<br>  --kubeconfig large-walleye.conf</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sMYL0NBZZ2hGrO85ggnw9g.png" /></figure><p>And <a href="https://docs.cilium.io/en/stable/gettingstarted/k8s-install-default/">install Cilium</a> on the third cluster:</p><pre><strong>$ kubectl apply \<br>  -f </strong><a href="https://raw.githubusercontent.com/cilium/cilium/1.7.0//"><strong>https://raw.githubusercontent.com/cilium/cilium/1.7.0/\</strong></a><strong><br>install/kubernetes/quick-install.yaml \<br>  --kubeconfig modern-amoeba.conf</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*6sB_7UzfVf-MQT9g4_RA-Q.png" /></figure><p><em>Now, give the CNI plugins some time to initialise.</em></p><p>Then query the nodes of your clusters again:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Jf5uKJ4-HsuJMEaTJ_iGA.png" /></figure><p><em>Voila …!!</em></p><p>All the nodes should be Ready now!</p><p>If you list the Pods, they should now also all be Running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UrVsPu7C3Mz54vJ5tE0j_w.png" /></figure><p><em>The CNI plugins indeed completed the setup of your clusters and rendered them fully functional.</em></p><p>At this point, you can launch further Pods in your clusters and do more experiments.</p><h3>Destroying the clusters</h3><p>When you’re done experimenting with the clusters, you should delete them because, unfortunately, running clusters on AWS costs money.</p><p><em>Fortunately, Terraform makes this very easy.</em></p><p>All you have to is to issue the following command:</p><pre><strong>$ terraform destroy</strong></pre><p>The <a href="https://www.terraform.io/docs/commands/destroy.html">terraform destroy</a> deletes all the resources from your configuration that are currently running.</p><p>This means that all the AWS resources corresponding to your clusters will be deleted.</p><p>The command also shows you an execution plan, specifying the exact set of resources that will be deleted, which you can confirm with yes.</p><p>When the command completes, your AWS account will be in exactly the same state as it was before your ran terraform apply for the first time!</p><h3>Conclusion</h3><p>This article presented the <a href="https://registry.terraform.io/modules/weibeld/kubeadm/aws">Terraform kubeadm module</a> which allows to automatically spin-up a Kubernetes multi-clusters on AWS using the kubeadm functionality with terraform simplicity and consistency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3zBE_E-5iwSCZXCmFyPbHg.jpeg" /></figure><p><strong>References:</strong></p><ul><li><a href="https://registry.terraform.io/modules/weibeld/kubeadm/aws/0.2.0">Terraform Registry</a></li><li><a href="https://www.terraform.io/">Terraform | HashiCorp Developer</a></li><li><a href="https://docs.aws.amazon.com/eks/latest/userguide/what-is-eks.html">What is Amazon EKS?</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26a30e32c702" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devops-and-sre-learning/setting-up-multi-cluster-kubernetes-on-aws-using-the-terraform-as-iac-26a30e32c702">Setting up Multi-Cluster Kubernetes on AWS Using the Terraform as IaC</a> was originally published in <a href="https://medium.com/devops-and-sre-learning">DevOps and SRE Learning</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing Access Token/Credentials using HashiCorp Vault]]></title>
            <link>https://medium.com/devops-and-sre-learning/securing-access-token-credentials-using-hashicorp-vault-3f6616a4f462?source=rss----248569d59069---4</link>
            <guid isPermaLink="false">https://medium.com/p/3f6616a4f462</guid>
            <category><![CDATA[hashicorp]]></category>
            <category><![CDATA[hashicorp-vault]]></category>
            <dc:creator><![CDATA[Hemant Jain]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 06:05:25 GMT</pubDate>
            <atom:updated>2020-07-21T21:25:07.145Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*he0fhM1Nfn9XfiXPv8o1Vw.png" /><figcaption>HashiCorp Vault Logo</figcaption></figure><p>We developers often have access tokens and other sensitive information flowing through our applications. Access tokens are needed so that we can consume APIs on behalf of our users, and the tokens have to be stored somewhere.</p><p>With single-page applications, it’s tempting to store access tokens directly in the browser. Doing so is convenient because it makes it easy to intercept API hits and add the token to an Authorization header.</p><p>But here’s the problem: major identity providers explicitly warn against keeping access tokens in the browser, as does OWASP, and the authors of the OAuth 2.0 <a href="https://tools.ietf.org/html/draft-ietf-oauth-browser-based-apps-03">Best Current Practices</a> specification.</p><blockquote>“<strong>It’s recommended not to store any sensitive information in local storage.</strong>” <strong>-OWASP Cheat Sheet</strong></blockquote><blockquote>“<strong>Don’t store tokens in local storage.</strong>” <strong>-Auth0: Where to Store Tokens</strong></blockquote><blockquote>“<strong>You are safe from CSRF, but you have opened yourself up to a much greater attack vector… XSS.</strong>” -<strong>Okta: JWTs Suck</strong></blockquote><h3>What is Vault?</h3><p>Vault is a tool for securely accessing <em>secrets</em>. A secret is anything that you want to tightly control access to, such as API keys, passwords, or certificates. Vault provides a unified interface to any secret, while providing tight access control and recording a detailed audit log.</p><p>A modern system requires access to a multitude of secrets: database credentials, API keys for external services, credentials for service-oriented architecture communication, etc.</p><p>Understanding who is accessing what secrets is already very difficult and platform-specific. Adding on key rolling, secure storage, and detailed audit logs is almost impossible without a custom solution. This is where Vault steps in.</p><h3><strong>Key Features of Vault</strong></h3><p><strong>1. Dynamic Secrets</strong></p><p>Vault can generate secrets on-demand for some systems, such as AWS or SQL databases. For example, when an application needs to access an S3 bucket, it asks Vault for credentials, and Vault will generate an AWS keypair with valid permissions on demand. After creating these dynamic secrets, Vault will also automatically revoke them after the lease is up.</p><p><strong>2. Secure Secret Storage</strong></p><p>Arbitrary key/value secrets can be stored in Vault. Vault encrypts these secrets prior to writing them to persistent storage, so gaining access to the raw storage isn’t enough to access your secrets. Vault can write to disk, <a href="https://www.consul.io/">Consul</a>, and more.</p><p><strong>3. Data Encryption</strong></p><p>Vault can encrypt and decrypt data without storing it. This allows security teams to define encryption parameters and developers to store encrypted data in a location such as SQL without having to design their own encryption methods.</p><p><strong>4. Leasing and Renewal</strong></p><p>All secrets in Vault have a <em>lease</em> associated with them. At the end of the lease, Vault will automatically revoke that secret. Clients are able to renew leases via built-in renew APIs.</p><p><strong>5. Revocation</strong></p><p>Vault has built-in support for secret revocation. Vault can revoke not only single secrets, but a tree of secrets, for example all secrets read by a specific user, or all secrets of a particular type. Revocation assists in key rolling as well as locking down systems in the case of an intrusion.</p><h3><strong>What are the Vault Goals?</strong></h3><ol><li><strong>Single Source of Secrets</strong></li><li><strong>Programmatic Application Access(Automated)</strong></li><li><strong>Operator Access(Manual)</strong></li><li><strong>Practical Security</strong></li><li><strong>Modern Data Center Friendly</strong></li></ol><h3>Installation Steps for HashiCorp Vault</h3><pre>$ wget <a href="https://releases.hashicorp.com/vault/1.0.3/vault_1.0.3_linux_amd64.zip">https://releases.hashicorp.com/vault/1.0.3/vault_1.0.3_linux_amd64.zip</a><br>$ unzip vault_1.0.3_linux_amd64.zip -d .<br>$ sudo cp vault /usr/bin/<br>$ sudo mkdir /etc/vault<br>$ sudo mkdir /opt/vault-data<br>$ sudo mkdir -p /logs/vault/</pre><p>Configuration File for the Vault:</p><pre>$ sudo vi /etc/vault/config.json</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0af8baf545c1180bca9ce4af0328ec3a/href">https://medium.com/media/0af8baf545c1180bca9ce4af0328ec3a/href</a></iframe><p>Configuring the Vault Service on the Virtual Machine</p><pre>$ sudo vi /etc/systemd/system/vault.service</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b91a268f8dab5c7bfcb6549fa4bc9209/href">https://medium.com/media/b91a268f8dab5c7bfcb6549fa4bc9209/href</a></iframe><p>Now,starting the HashiCorp Vault Service on the Private IP Address provided in the Configuration File by running the command shown below:</p><pre>$ sudo systemctl start vault.service<br>$ sudo systemctl status vault.service</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNH1kG59V4gJ5FoqkHjvBg.png" /><figcaption>Vault Service Main Page Screen</figcaption></figure><p>Now, it ask for the Number of Key Share you want to split your Master Key into;and shown below I am inputting 5 value and it is asking how many keys are required to re-create the master key — threshold key (3).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*6KDvK5QPpZuBlbf83bLehQ.png" /></figure><p>Now you would be needing minimum of 3 threshold keys to unseal your master vault.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XTJK4_pPOej_qZ9AthdUFQ.png" /></figure><p>It asks the Root Token or the Root Password to login into Vault to configure the User, Policies, Secrets in Vault Directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BnQ2xOgQeKm05NOiMeW96g.png" /></figure><p>After successfully inputting minimum 3 threshold keys correctly and passing the correct Token Value,we are logged-in inside the Vault Account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zI6K-Qaxa298VYWoEqg16w.png" /></figure><p>In the next article,we will learn how to create users, policies, secret on Vault to store our authentication server credentials for future purpose.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f6616a4f462" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devops-and-sre-learning/securing-access-token-credentials-using-hashicorp-vault-3f6616a4f462">Securing Access Token/Credentials using HashiCorp Vault</a> was originally published in <a href="https://medium.com/devops-and-sre-learning">DevOps and SRE Learning</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>