<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Juan Luis Baptiste on Medium]]></title>
        <description><![CDATA[Stories by Juan Luis Baptiste on Medium]]></description>
        <link>https://medium.com/@juanluisbaptiste?source=rss-8c6edd7c7991------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jwaNyLeiSxptHNrWpOJmSg.png</url>
            <title>Stories by Juan Luis Baptiste on Medium</title>
            <link>https://medium.com/@juanluisbaptiste?source=rss-8c6edd7c7991------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 14:25:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@juanluisbaptiste/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Content Delivery Networks Explained, Part 3]]></title>
            <link>https://medium.com/globant/content-delivery-networks-explained-part-3-32ad1865a9f0?source=rss-8c6edd7c7991------2</link>
            <guid isPermaLink="false">https://medium.com/p/32ad1865a9f0</guid>
            <category><![CDATA[cdn]]></category>
            <category><![CDATA[5g-network]]></category>
            <category><![CDATA[edge-computing]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cloudops]]></category>
            <dc:creator><![CDATA[Juan Luis Baptiste]]></dc:creator>
            <pubDate>Thu, 26 Dec 2024 14:24:33 GMT</pubDate>
            <atom:updated>2024-12-26T14:24:33.601Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*yl7I9zhu9WW9Uv8i" /><figcaption>Photo by<a href="https://unsplash.com/@willianjusten?utm_source=medium&amp;utm_medium=referral"> Willian Justen de Vasconcellos</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Welcome to the third and final chapter of the <em>Content Delivery Networks Explained</em> series. In the <a href="https://medium.com/globant/content-delivery-networks-explained-5a1feaa224c8">first part</a>, we reviewed CDN origins and their underlying mechanisms. The <a href="https://medium.com/globant/content-delivery-networks-explained-part-2-23512ce5dcb1">second part</a> discussed the various types of CDNs and their transformative applications in areas like streaming, web security, and beyond.</p><p>In this concluding chapter, we shift our focus to the present and future of CDNs, examining how cutting-edge technologies such as 5G networks, Artificial Intelligence, Machine Learning, and blockchain drive their evolution. These advancements are reshaping how content is delivered today and setting the stage for the next generation of CDNs. What can we expect from CDNs in the future? Let’s find out!</p><h3>5G Networks: A Game-Changer for Content Delivery Networks</h3><p>The arrival of 5G technology has marked the beginning of a new era of wireless connectivity, with its promise of ultra-high speeds and ultra-low latency, for faster communication, seamless streaming, real-time applications, and the growing demands of IoT devices. This technological advancement significantly impacts CDNs, which is vital for ensuring smooth and efficient content delivery to wireless devices and IoT systems.</p><h3>What are 5G Networks?</h3><p>5G networks represent the fifth generation of cellular mobile communications. They offer significantly faster speeds, lower latency, and greater capacity than previous generations. This technological breakthrough transforms industries by providing the infrastructure to support high-bandwidth, low-latency applications, crucial for content delivery.</p><p>5G networks offer several advantages over previous generations of cellular networks that can significantly enhance CDN performance:</p><ul><li><strong>Higher bandwidth:</strong> 5G networks provide significantly higher bandwidth capabilities, enabling the delivery of high-quality content like 4K and 8K videos. This is crucial for video streaming services and other bandwidth-intensive applications.</li><li><strong>Lower latency:</strong> 5G networks offer ultra-low latency, essential for real-time applications such as online gaming, virtual reality (VR), and augmented reality (AR). A lower latency improves the user experience and opens the possibility for new and innovative applications.</li><li><strong>Increased capacity:</strong> 5G networks can handle many connected devices, making them ideal for IoT applications, industrial automation, and advanced healthcare technologies. For CDNs, this increased capacity means they can handle a much larger volume of traffic, especially during peak usage times.</li></ul><h3>Implementing CDNs in 5G networks</h3><p>CDNs in 5G networks use Software Defined Networks (SDN) and Network Function Virtualization (NFV) technologies to implement the following core components that handle traffic management, resource allocation, and dynamic content delivery:</p><ul><li><strong>Mobile Edge Computing (MEC):</strong> MEC brings computing resources closer to the network edge, reducing latency and improving performance. CDNs can benefit from MEC by deploying virtual caching servers and other services at the network’s edge.</li><li><strong>Virtual CDNs (vCDNs):</strong> vCDNs are software-defined CDNs that can be deployed and scaled quickly. By taking advantage of virtualization and cloud technologies, vCDNs can adapt to the dynamic demands of 5G networks.</li><li><strong>5G network slicing:</strong> vCDNs can create virtualized, isolated network slices tailored to specific content delivery needs, such as high-bandwidth slices for video streaming, low-latency slices for real-time applications like gaming or AR/VR, or secure slices for delivering sensitive or mission-critical content.</li></ul><p>The following diagram represents a CDN built within a 5G network:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CCMAaMzdXqlDAPgE" /><figcaption>A CDN in a 5G network</figcaption></figure><p>Major CDN providers like Akamai, AWS, Google Cloud, and Fastly actively invest in 5G technologies to enhance their offerings. They are building 5G-ready infrastructure, partnering with telecom operators, and developing innovative solutions to capitalize on the opportunities presented by 5G.</p><h3>Artificial Intelligence and Machine Learning</h3><p>Artificial Intelligence (AI) and Machine Learning (ML) are revolutionizing how content is delivered. They make CDNs smarter, more efficient, and more adaptable to evolving user demands and internet conditions. Thanks to these technologies, CDNs are getting a massive upgrade in key areas, from network traffic handling optimizations to enhancing security.</p><p>Some CDN providers have already introduced these technologies into their products and services. For example, Akamai uses ML to <a href="https://www.akamai.com/blog/security/how-akamai-uses-machine-learning-to-detect-shared-ips">detect shared IP addresses</a>, <a href="https://www.akamai.com/newsroom/press-release/-akamai-unveils-machine-learning-that-intelligently-automates-ap">automate threat detection</a>, or perform <a href="https://www.akamai.com/products/web-performance-optimization">dynamic content optimization</a>, among many others. Similarly, Cloudflare uses these technologies for <a href="https://blog.cloudflare.com/cloudflare-bot-management-machine-learning-and-more/">bot detection</a>, <a href="https://blog.cloudflare.com/threat-detection-machine-learning-models/">detecting malicious domains</a>, or <a href="https://blog.cloudflare.com/waf-ml/">enhancing its WAF threat detection engine</a>. But, where AI and ML are taking CDNs?</p><h3>How AI and ML can enhance CDNs</h3><p>Let’s see some of the ways AI and ML could or are enhancing CDNs:</p><ul><li><strong>Real-Time traffic management:</strong> AI can monitor real-time network conditions, such as traffic congestion and server loads, and dynamically adjust routing to ensure optimal delivery paths. This ensures consistent performance and avoids bottlenecks, improving user experience.</li><li><strong>Predictive caching and content placement: </strong>ML models can analyze user behavior, traffic patterns, and regional preferences to predict which content will be requested and where. CDNs can proactively cache popular content at edge locations, reducing user latency and load times.</li><li><strong>Threat detection</strong>: ML models trained on normal traffic patterns can detect anomalies that may indicate security threats, such as DDoS attacks or data breaches. This enables CDNs to mitigate threats in real-time, enhancing security automatically.</li><li><strong>Quality of Experience (QoE) optimization:</strong> AI can monitor metrics like buffering, latency, and resolution drops to improve streaming quality for video and gaming content adaptively. This results in a smoother, more satisfying user experience.</li></ul><p>These strategies improve delivery speed and mitigate potential outages by identifying and resolving potential issues before they impact end users. These AI-powered CDN enhancements will benefit various industries, including e-commerce, media and entertainment, gaming, and finance. AI and ML will likely lead to fully autonomous CDNs capable of self-optimizing, self-healing, and adapting to new technologies like 5G, edge AI, and IoT. These advancements will be crucial as demands for high-speed, low-latency, and secure content delivery continue to grow.</p><h3>Edge Computing: Bringing Computation Closer to the Data</h3><p>Wikipedia defines <a href="https://en.wikipedia.org/wiki/Edge_computing">Edge computing</a> as <em>a distributed computing model that brings computation and data storage closer to the data sources, reducing latency, improving response times, and enabling real-time data processing</em>. CDNs are the precursors of edge computing. By distributing content delivery servers across a vast global network and closer to end users, CDN providers have been effectively implementing edge computing principles for years.</p><p>Today, cloud and CDN providers have made significant strides in implementing edge computing solutions. Major cloud providers like AWS, Azure, and Google Cloud offer a wide range of edge computing services, including serverless functions, and CDNs. These services enable developers to deploy applications and services closer to end-users, reducing latency and improving performance.</p><p>Traditionally focused on content delivery, CDN providers have expanded their offerings to include edge computing capabilities. Some of the first services they implemented on their edge computing infrastructure include real-time video transcoding and dynamic content generation. But now, CDN providers are pushing things even further by placing more computing power on the edge with the help of 5G networks.</p><p>5G’s high-speed, low-latency capabilities enable CDNs to deploy more powerful edge servers, capable of handling complex computations and real-time processing tasks. This allows for innovative applications like augmented reality, virtual reality, AI inference, and multiplayer gaming, which require significant processing power at the edge and low latencies. Take Akamai, for example, with its <a href="https://www.akamai.com/cloud-computing">Connected Cloud</a> and the upcoming <a href="https://www.akamai.com/newsroom/press-release/akamai-takes-cloud-computing-to-the-edge">Gecko</a> project, or AWS <a href="https://aws.amazon.com/wavelength/">Wavelength</a>, and <a href="https://aws.amazon.com/about-aws/global-infrastructure/localzones/">Local Zones</a>, as examples of the continuing expansion of computing power to the edge.</p><p>The following diagram represents a CDN on a 5G network, with computing capacity placed at the edge:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/0*htnQTWsZovUeKWPq" /><figcaption>A MEC host for a virtual CDN node</figcaption></figure><p>The MEC host uses SDN and NFV to provide virtualization infrastructure, so services like Virtual CNDs can be implemented.</p><p>While edge computing is still in its early stages, the rapid advancements in technology and the growing demand for low-latency, high-performance applications are driving its adoption across various industries. Before these advancements, developers had to design lighter applications for the edge, relegating more complex and resource-intensive applications to centralized cloud providers. This limitation often hindered innovation, as the performance capabilities of edge environments constrained developers. Cloud computing is reaching areas where traditional providers have struggled, allowing developers to stop worrying about designing specifically for the cloud or the edge. For example, applications such as real-time video analytics, augmented reality (AR) experiences, and complex machine learning models can now be deployed at the edge, utilizing the expanded computing power provided by CDN providers like Akamai.</p><h3>Blockchain’s Impact on CDNs</h3><p>Blockchain technology is changing industries with its secure, decentralized, and transparent systems. Eliminating intermediaries, protecting data, and building trust with unchangeable records have greatly impacted areas like finance and healthcare. Now, it’s showing great potential for content delivery networks (CDNs), potentially solving problems like centralization, bottlenecks, and security risks. With its peer-to-peer structure, it can strengthen defenses against DDoS attacks and make processes faster and more efficient using smart contracts. Because of the massive size of current CDNs, implementing blockchain-based solutions is a natural step in their evolution.</p><h3>How blockchains could enhance CDNs</h3><p>In traditional CDNs, centralization poses risks like bottlenecks and vulnerabilities because they rely on a single controlling entity to manage and operate the infrastructure. Blockchain decentralization improves resilience, enabling peer-to-peer content distribution to avoid centralization. This can reduce latency and costs by optimizing content delivery paths and using dynamic caching strategies based on real-time demand. Transparency is another key improvement, as blockchain provides immutable records of transactions to guarantee the integrity of the delivered content.</p><p>Blockchain could be integrated with traditional CDNs to create hybrid models that exploit both technology’s strengths. This approach allows for a gradual transition to web blockchain-based solutions, minimizing disruption to existing infrastructure. There is a lot of superficial information out there about how to integrate traditional CDNs with blockchain technology, and the reason is that so far, no traditional CDN provider has done it. Most of the existing projects are geared toward Web3 apps. While some of these projects claim to support Web2 sites, they are focused on supporting blockchain-only applications because their implementation with Web2 websites is complex and without the same benefits as those offered by traditional a CDN provider. To date, they are still figuring out ways to <a href="https://www.akamai.com/newsroom/press-release/akamai-mufg-announce-joint-venture-for-blockchain-based-online-payment-network">integrate both technologies</a> in a useful way.</p><h3>Blockchains and the Internet of the future</h3><p>Blockchain technology is shaping the future of the Internet by powering the next wave of decentralized applications known as Web3. Web3 introduces transformative advantages over traditional websites (or web2) by prioritizing decentralization, giving users more control over their data and digital assets. Unlike the centralized systems of Web2, Web3 relies on distributed networks, enhancing security and reducing risks like single points of failure. Blockchain’s transparency ensures trust, as transactions are immutable and verifiable by all parties. Additionally, Web3 promotes censorship resistance, making platforms less vulnerable to external restrictions or control. Web3 lays the foundation for a more equitable, secure, and innovative Internet by reverting ownership and power to users.</p><p>Within the web3 ecosystem, the main development of CDNs has been happening with new projects in the DePIN field. <a href="https://en.wikipedia.org/wiki/Decentralized_physical_infrastructure_network">DePIN</a> (Decentralized Physical Infrastructure Networks) projects are blockchain-based systems designed to manage and operate physical infrastructure in a decentralized way. DePINs are particularly valuable for projects that require large-scale infrastructure, such as data storage, cloud computing, streaming, or CDNs. Some outstanding DePIN projects in the CDN area are <a href="https://aioz.network/">AIOZ</a>, <a href="https://pipe.network/cdn-users">Pipe</a>, and <a href="https://www.media.network/">Media</a>. These projects provide peer-to-peer distributed CDNs (dCDN) for web3 projects, among the other edge computing service offerings. The following is a comparison between traditional client-server architectures vs. a peer-to-peer model using blockchain with the <a href="https://ipfs.tech/">IPFS</a> network:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6F2Wn8vGw7EzyC3V" /><figcaption>Peer-to-peer based CDN diagram — Source: <a href="http://gate.io/">Gate.io</a></figcaption></figure><p>In the peer-to-peer architecture, nodes in the network rely on any other node for the resources they need, instead of relying on centralized servers.</p><p>How will CDNs evolve under this context? At some point, traditional CDN providers will support Web3 applications, but Web3 is still in its infancy, and there is still a long way to go. Many issues still <a href="https://www.coforge.com/what-we-know/blog/scalability-challenge-of-ethereum-blockchain-platform">need to be solved first</a>, such as transaction speed and energy consumption limitations, before the big players in the CDN arena see web3 as a viable alternative.</p><h3>Conclusion</h3><p>Content Delivery Networks (CDNs) are undergoing transformative advancements fueled by cutting-edge technologies. The deployment of 5G networks has already revolutionized content delivery, offering unparalleled speed, capacity, and low latency to meet the demands of connected devices and real-time applications. Similarly, Artificial Intelligence and Machine Learning are enhancing CDNs, optimizing performance, strengthening security, and personalizing user experiences.</p><p>Edge computing has firmly established itself as a key component of CDN infrastructure, bringing computation closer to end users and enabling innovative applications with reduced latency. And blockchain technology is also reshaping the landscape, introducing decentralized, secure, and transparent frameworks that can complement traditional CDN models.</p><p>CDNs are now leading the future infrastructure, seamlessly integrating with advanced technologies to deliver efficient, secure, and innovative solutions. As these systems continue to evolve, they are well-positioned to meet the changing needs of industries and users, playing a crucial role in shaping the future of content delivery.</p><h3>References</h3><ul><li><a href="https://en.wikipedia.org/wiki/5G">5G Networks: Wikipedia</a></li><li><a href="https://www.zte.com.cn/global/about/magazine/zte-technologies/2021/1-en/special-topic/4.html">5G CDN: New CDN Architecture and Technologies for Video over Gigabit</a></li><li><a href="https://en.wikipedia.org/wiki/Edge_computing">Edge Computing: Wikipedia</a></li><li><a href="https://www.akamai.com/blog/edge/edge-computing-5g-emerging-technology-shaping-future-it">Edge Computing and 5G: Emerging Technology Shaping the Future of IT</a></li><li><a href="https://edgenext.medium.com/ai-driven-cdn-pioneering-dynamic-content-optimization-ca79159d1f2d">AI-Driven CDN: Pioneering Dynamic Content Optimization</a></li><li><a href="https://en.wikipedia.org/wiki/Decentralized_physical_infrastructure_network">DePIN: Wikipedia</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32ad1865a9f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/content-delivery-networks-explained-part-3-32ad1865a9f0">Content Delivery Networks Explained, Part 3</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Content Delivery Networks Explained, Part 2]]></title>
            <link>https://medium.com/globant/content-delivery-networks-explained-part-2-23512ce5dcb1?source=rss-8c6edd7c7991------2</link>
            <guid isPermaLink="false">https://medium.com/p/23512ce5dcb1</guid>
            <category><![CDATA[ddos-protection]]></category>
            <category><![CDATA[cdn-service]]></category>
            <category><![CDATA[streaming-service]]></category>
            <category><![CDATA[waf]]></category>
            <category><![CDATA[cloudops]]></category>
            <dc:creator><![CDATA[Juan Luis Baptiste]]></dc:creator>
            <pubDate>Wed, 27 Dec 2023 22:07:11 GMT</pubDate>
            <atom:updated>2023-12-27T22:07:11.897Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Sjyz5XAt7y-FqetY" /><figcaption>Photo by<a href="https://unsplash.com/@erdaest?utm_source=medium&amp;utm_medium=referral"> Erda Estremera</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is the second part of my series of articles unraveling the inner workings of Content Delivery Networks (CDNs). In <a href="https://medium.com/globant/content-delivery-networks-explained-5a1feaa224c8">the previous article</a>, we started by discussing the origins of the CDNs; their history, and the motives that led to their creation. We then continued to explain the advantages CDNs give their users and discussed in detail how they work.</p><p>Now, in this follow-up, we delve deeper into the evolution of CDNs, exploring specialized markets and the diverse products and services they now offer. From optimizing non-cacheable content to facilitating audio and video streaming, enhancing security, and supporting developers with specialized CDNs, this article provides a comprehensive overview of the multifaceted role that CDNs play in today’s digital landscape.</p><h3>Non-cacheable Content Optimizations</h3><p>In the <a href="https://medium.com/globant/content-delivery-networks-explained-5a1feaa224c8">previous article</a>, we delved into how CDNs handle caching for static content. Now, let’s explore strategies for accelerating non-cacheable content like dynamic content generated on a per-user or per-request basis, POST requests, or content with explicit no-cache directives in HTTP headers:</p><ul><li><em>Route Optimization:</em> Anycast directs requests to the nearest CDN server, minimizing data travel distance. BGP routing optimizations prioritize the most efficient and least congested paths beyond the shortest route.</li><li><em>TCP and SSL Optimization:</em> Transport layer optimizations like connection reuse, Fast Open (TFO), window scaling, and SSL optimizations such as OCSP Stapling enhance data transfer speed for both static and dynamic content.</li><li><em>Content Preloading:</em> CDNs can asynchronously preload resources like images and scripts referenced in an HTML file, even if the pages themselves can’t be cached, reducing overall load time.</li><li><em>Intelligent Caching Policies:</em> While dynamic pages may be non-cacheable, selective caching of constant fragments of a page (e.g., headers, footers, navigation menus) or modifying cache keys to include specific user distinctions, like the user ID or a session token, can be employed.</li><li><em>HTTP/2 and HTTP/3 Support</em><strong>:</strong> CDNs support modern protocols like HTTP/2 and HTTP/3, utilizing features like multiplexing and header compression to enhance data transfer efficiency for dynamic content.</li><li><em>Proprietary Optimization Solutions:</em> Some CDNs offer unique solutions. For example, Akamai’s <a href="https://techdocs.akamai.com/property-mgr/docs/sureroute-beh">SureRoute</a> tests multiple routes between the CDN edge servers and the origin server, identifying the optimal path with the best performance and establishing alternative routes in case of failure. Cloudflare <a href="https://www.cloudflare.com/website-optimization/railgun/">Railgun</a> speeds up non-cacheable content delivery by compressing the connection between Cloudflare’s edge servers and the origin server. It transmits only content differences, minimizing data transfer and boosting dynamic content delivery speed, ideal for websites with frequently changing information.</li></ul><h3>Audio &amp; Video Streaming</h3><p>In simple terms, streaming means transmitting audio or video over the Internet, sending small segments at a time to avoid the need for clients to download the entire file before playback. Streaming includes two main types: <em>On Demand</em> and <em>Live</em>.</p><h3>On-demand streaming</h3><p>Video on Demand (VoD) is a technology for transmitting video over the Internet, as its name says, distributed to users on demand. This means that users can watch the desired content, such as movies or TV shows, whenever they want, unlike traditional television’s fixed broadcast schedules. With VoD, this content can not only be consumed on demand, but from anywhere, such as from a TV, a phone, tablet, or a computer. Its playback is more flexible since it can be stopped, paused, or fast-forwarded whenever the user desires. Some of the best-known platforms that provide Video on Demand are YouTube and Netflix.</p><p>Video on Demand (VoD) delivers video content over the Internet, such as movies or TV shows, to users whenever they want, allowing flexible viewing on various devices like TVs, phones, tablets, or computers. Unlike traditional TV schedules, VoD platforms such as YouTube and Netflix offer the freedom to pause, stop, or fast-forward content at the user’s convenience.</p><p><strong>How does VoD work?</strong></p><p>Content producers upload their material to a VoD platform, where it becomes accessible to users through a feature-rich video player. This player allows viewers to control playback, including pausing, rewinding, and fast-forwarding, as well as enabling closed captions, switching audio tracks, accessing <a href="https://en.wikipedia.org/wiki/Digital_rights_management">DRM-protected</a> content, and downloading for offline viewing. Video transmission employs HTTP-based protocols like <a href="https://en.wikipedia.org/wiki/HTTP_Live_Streaming">HLS</a> or <a href="https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP">DASH</a>, and <a href="https://en.wikipedia.org/wiki/Real-Time_Messaging_Protocol">RTMP</a>, and supports different <a href="https://en.wikipedia.org/wiki/Video_codec">video codecs</a>, like <a href="https://en.wikipedia.org/wiki/Advanced_Video_Coding">H.264</a> and <a href="https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding">H.265</a> that can adapt the stream’s bitrate according to network conditions like speed and latency.</p><p>VoD platforms utilize Content Delivery Networks (CDNs) to scale their capacity to meet user demand. Video files are cached by CDNs, but they are streamed instead of just delivered. CDN providers support the same features as the VoD platform support, so video players can access the video content through the CDN as if they were accessing the platform’s services directly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/0*mMb7kV2hTSbvphSY" /><figcaption>How on-demand video streaming works</figcaption></figure><h3>Live streaming</h3><p>Live streaming contrasts with VoD streaming as it transmits real-time content instead of pre-recorded files. Widely applied in various niche markets like social media (YouTube Live, Facebook Live, Instagram Live), gaming (Twitch), sports (ESPN+), education (edX), virtual fitness (Zwift), etc. Accessing live streams requires a platform-provided player or application, similar to on-demand streaming.</p><p><strong>How does live streaming work?</strong></p><p>The process begins by capturing video or audio using devices like smartphones or cameras. The feed is then sent to an encoder for editing and compression, utilizing codecs like H.264, H.265, or VP9. When streaming from a phone, the streaming application handles the encoding. The encoded feed is sent to a streaming server, which adjusts it into multiple bitrates and resolutions for different devices, implements DRM if needed, splits it into segments of a few seconds, and adds them to a playlist file. The playlist file is used by video players to know which segments are available and in which order and corresponding quality levels for adaptive bitrate streaming.</p><p>The streaming server then sends the pre-packaged stream to a Content Delivery Network (CDN) for distribution to end-users using HLS or DASH protocols. The CDN caches segments on its edge servers for a few seconds or minutes. This sounds counter-intuitive, but caching the segments on the CDN allows users to view the stream with a low latency because the Round Trip Time (RTT) is much shorter to the CDN servers than connecting to the streaming server. Some CDNs offer monetization features like ad insertion or pay-per-view, DVR functionality, and analytics tools.</p><p>The client-side player on the viewer’s device requests the stream playlist from the CDN servers via HLS or DASH, downloads video segments, and assembles them for seamless playback, providing an adaptive streaming experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*W5MnZHTaOPyIvOMd" /><figcaption>How live streaming works</figcaption></figure><p><strong>Why is a CDN crucial for live streaming?</strong></p><p>A CDN is crucial for optimal live streaming for several reasons:</p><ul><li><em>Bandwidth efficiency:</em> Direct connections to the origin server can overload bandwidth. A CDN distributes traffic across several servers, preventing congestion and ensuring a smoother stream.</li><li><em>Latency reduction:</em> Caching on CDN edge servers shortens the Round Trip Time (RTT), resulting in lower latency than a direct connection. This is especially beneficial for distant locations (i.e., a stream originated in NY and played in Tokyo), enhancing the viewing experience.</li><li><em>Resource optimization:</em> Offloading streaming tasks to CDN edge servers alleviates strain on the origin server’s hardware, conserving resources and improving overall efficiency.</li></ul><h3>Audio streaming</h3><p>On-demand audio streaming platforms like Spotify, YouTube Music, Apple Music, or Tidal also use HLS or DASH protocols but use audio codecs such as <a href="https://en.wikipedia.org/wiki/Advanced_Audio_Coding">AAC</a> or <a href="https://en.wikipedia.org/wiki/Opus_(audio_format)">OPUS</a>. Live audio streaming platforms like Clubhouse, Stereo, or X Spaces use real-time transmission protocols like <a href="https://en.wikipedia.org/wiki/WebSocket">WebSocket</a> and <a href="https://en.wikipedia.org/wiki/WebRTC">WebRTC</a> instead of HTTP-based protocols, with audio codecs such as Opus, PCM, or AAC-LL. The usage of a CDN works in the same way for audio streaming, the same CDN services can be used for both audio and video.</p><h3>Software Distribution</h3><p>CDNs have long played a crucial role in delivering software to end users across various industries, such as technology, gaming, healthcare, and finance. By leveraging CDNs, companies can take off the burden of distributing the software to end users by:</p><ul><li>Scaling software distribution by offloading large downloads to the CDN.</li><li>Enhancing redundancy and reliability through multiple copies on edge servers.</li><li>Decreasing bandwidth and infrastructure costs at the origin, boosting cost-effectiveness.</li><li>Improving user satisfaction by reducing load times and latency.</li><li>Using analytics for a more in-depth understanding of user behavior.</li></ul><p>The use of CDNs for software distribution optimizes and strengthens resilience and cost efficiency, improving user experience.</p><h3>Security</h3><p>CDNs play a crucial role in IT security, particularly as dynamic and interactive websites with advanced technologies emerge. The evolution of the Internet has introduced new challenges and vulnerabilities, making sites susceptible to attacks. The widespread availability of high-speed broadband connections has facilitated large-scale coordinated attacks, disrupting entire networks. CDN providers leverage their extensive networks to offer security services that mitigate these threats at the edge, far from the customer’s origin. Now, we will explore the mechanics of these attacks and how CDN security services safeguard websites.</p><h3>Web Application Firewalls</h3><p><a href="https://en.wikipedia.org/wiki/Web_application_firewall">Web application firewalls (WAFs)</a> are specialized firewalls that protect websites from web threats and attacks, addressing vulnerabilities like coding errors or lack of security standards. Operating at the application layer (HTTP/HTTPS), WAFs serve as a barrier between a web application and the internet. They inspect and filter traffic to thwart malicious activities such as SQL injection, cross-site scripting, and others listed in the <a href="https://owasp.org/www-project-top-ten/">OWASP Top 10</a>. CDN providers often integrate WAFs at the edge, distributed across servers, applying customizable security policies like conditional rule configuration, IP-based lists, rate limiting, and geolocation. WAFs also provide robust monitoring with detailed logs, enabling real-time analysis for immediate detection and response to emerging threats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wqppVop7CLhD_7SO" /><figcaption>How a WAF in the CDN stops threats at the edge</figcaption></figure><h3>DDoS attack protection</h3><p>A DDoS attack is a malicious attempt to disrupt the normal functioning of a network, service, or website by flooding it with an excessive amount of traffic. Using several compromised computers, typically part of a botnet, the attack aims to slow down, render unresponsive, or make the target system inaccessible to legitimate users. The goal of a DDoS attack is to disrupt the availability of the targeted online service, making it difficult or impossible for users to access the intended resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/0*2BJs7O3kKzCX6JIv" /><figcaption>Diagram of a DDoS attack</figcaption></figure><p><strong>How a CDN protect against a DDoS attack?</strong></p><p>CDNs defend against DDoS attacks through a global, distributed architecture utilizing Anycast routing to disperse traffic across multiple servers. This prevents a single vulnerable target, enhancing resilience. CDNs employ traffic filtering mechanisms, including rate limiting and blacklisting, to differentiate between legitimate and malicious requests. Integration of Web Application Firewalls (WAFs) adds another layer of protection by inspecting and blocking harmful HTTP traffic. Advanced threat intelligence services keep CDNs updated on evolving attack patterns, while continuous monitoring and analytics enable quick detection and proactive responses to potential DDoS threats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/0*iKh-Lj3b9ogzy0ZG" /><figcaption>How a CDN protects against a DDoS attack</figcaption></figure><p><strong>Traffic scrubbing</strong></p><p>This is a DDoS mitigation technique used by some CDN providers to protect against attacks. It involves continuous monitoring of network traffic, redirecting it to a specialized center for deep packet inspection. Advanced algorithms differentiate between legitimate and malicious traffic, removing harmful elements. Only clean traffic is forwarded to the target infrastructure, preventing overwhelming and ensuring uninterrupted service. In a CDN’s security offering, traffic scrubbing plays a critical role in mitigating DDoS attacks. When an attack is detected, traffic is dynamically rerouted through scrubbing centers to filter out malicious traffic, minimizing the impact of the attack.</p><p>Collectively, these measures establish CDNs as robust defenders against DDoS threats, enhancing the availability and performance of online services.</p><h3>Origin protection</h3><p>This is a crucial CDN service, it is used to shield the origin server from direct exposure to the Internet by acting as an intermediary layer, often referred to as “Origin Shield”. It filters incoming traffic, mitigating threats and DDoS attacks, allowing access only from specified IP addresses associated with the origin protection service. This separation enhances security, ensuring the origin is accessible solely through the controlled environment of the origin shield. Without this protection, attackers could bypass the CDN by knowing the origin server IP address, rendering security measures ineffective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0CFZkgzdBkW3E-n8" /><figcaption>How does the shield service only allow access from the CDN edge servers</figcaption></figure><h3>API protection</h3><p>In the era of microservices, robust API protection is crucial. API protection services have become essential for securing various API types in modern applications, including Web (REST), SOAP, GraphQL, WebSocket, and microservices’ internal APIs. These services offer key measures:</p><ul><li><em>Authentication and authorization:</em> Ensures only authenticated and authorized entities access APIs, preventing unauthorized entry.</li><li><em>Traffic encryption:</em> Implements strong encryption protocols like HTTPS to safeguard data in transit, ensuring confidentiality.</li><li><em>Rate limiting:</em> Guards against abuse and DoS attacks by regulating request volumes, and ensuring API availability and reliability.</li><li><em>Logging and monitoring:</em> Establishes vigilant monitoring for real-time anomaly detection and proactive responses to potential security incidents.</li></ul><p>API protection services from CDN providers, like WAF or anti-DDoS measures, are integral to a company’s security. Placed strategically at the network edge, these services efficiently filter and monitor incoming API traffic, thwarting malicious attempts and ensuring secure data exchange.</p><h3>Bot protection</h3><p>Internet bot protection services safeguard online platforms from malicious automated programs, differentiating between good and bad bots. Good bots serve helpful purposes such as search engine indexing and website monitoring, while bad bots engage in malicious activities such as web scraping, credential stuffing, and distributed denial-of-service (DDoS) attacks. The key aspects of these services include:</p><ul><li><em>Bot detection and classification:</em> Advanced algorithms and machine learning distinguish between legitimate users and malicious bots.</li><li><em>Challenge-response mechanisms:</em> CAPTCHA and other methods verify human interaction, creating obstacles for automated scripts.</li><li><em>Rate limiting and throttling:</em> Control the number of requests to prevent overwhelming systems with excessive bot requests.</li><li><em>IP filtering and reputation scoring:</em> Maintain databases of known malicious IPs, assign reputation scores, and filter out traffic from IPs with a poor reputation.</li><li><em>Real-time monitoring and reporting:</em> Continuous monitoring enables real-time detection and response to bot activity, with detailed reporting on threats.</li></ul><p>As 47% of Internet traffic in 2022 came from bots, these services are crucial for e-commerce, finance, gaming, and online media. CDN providers integrating such services act as frontline defenders, protecting websites and applications from a range of bot-related threats.</p><h3>Developer-Oriented CDNs</h3><p>Developer-oriented CDNs offer specialized services for content delivery, focusing on specific needs like JavaScript, CSS, fonts, or npm packages. Examples include Cdnjs, jsDelivr, Unpkg, jQuery CDN, and JetPack Site Accelerator. These CDNs, often free of charge, enhance the performance of JavaScript-heavy websites, allowing developers to specify library versions for better control and compatibility. Some use a multi-CDN approach for increased resilience. Leveraging these CDNs can reduce latency, improve loading times globally, and benefit individual developers and small projects.</p><h3>Image Processing and Optimization</h3><p>Some CDNs offer image optimization services to enhance image quality based on the device and connection quality to improve web page load times. These services create derivative images by reducing image size without compromising quality through operations like compression, format conversion, resizing, cropping, rotation, color adjustment, and watermarks. When a user accesses a page through the CDN, the optimization service checks for matching rules and delivers cached derivative images if available; if not, it creates and delivers derivative images with the size, quality level, and transformation specifications defined on the specified rules. This transparent process eliminates the need for manual intervention by website developers and users.</p><h3>Analytics Tools and Reporting</h3><p>CDN providers offer robust analytics and reporting tools for valuable insights into web performance and user experience. These tools optimize content delivery, improve website speed, and ensure a seamless user experience by handling key metrics like latency, bandwidth usage, and cache hit ratios. <a href="https://en.wikipedia.org/wiki/Real_user_monitoring">Real User Monitoring (RUM)</a>, a notable component, provides a granular understanding of user interactions by tracking real-time data on page load times, user engagement, and device-specific performance. Leveraging CDN analytics and RUM tools enables organizations to identify bottlenecks, optimize content delivery, and enhance the overall user experience, facilitating informed decisions for superior online performance.</p><h3>Conclusions</h3><p>Our exploration of Content Delivery Networks highlights their vital role in shaping the modern digital landscape. From the intricate strategies employed in optimizing non-cacheable content to the pivotal support CDNs provide in audio and video streaming, software distribution, and cybersecurity, it’s evident that CDNs have evolved far beyond their initial purpose. They have become the backbone of a seamless and secure online experience.</p><p>The significance of CDNs extends beyond content delivery, reaching into the realms of developer support with specialized CDN solutions tailored for specific content types. Furthermore, image processing and optimization services showcase the adaptability of CDNs to meet the diverse needs of today’s digital ecosystem. As we conclude this series, it’s clear that CDNs continue to be dynamic, responding to the ever-changing demands of the internet. They stand as a key pillar in ensuring the efficiency, security, and accessibility of online content for users across the globe. In a world where digital experiences are paramount, the role of CDNs remains central in shaping the future of the internet.</p><h3>References</h3><ul><li><a href="https://techdocs.akamai.com/property-mgr/docs/sureroute-beh">Akamai SureRoute</a>.</li><li><a href="https://techdocs.akamai.com/home">Akamai documentation</a>.</li><li><a href="https://developers.cloudflare.com/">Coudflare documentation</a>.</li><li><a href="https://www.cloudflare.com/website-optimization/railgun/">Cloudflare Railgun</a>.</li><li><a href="https://en.wikipedia.org/wiki/Web_application_firewall">WAD definition . Wikipedia.</a></li><li><a href="https://en.wikipedia.org/wiki/Denial-of-service_attack">DDoS definition — Wikipedia</a>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23512ce5dcb1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/content-delivery-networks-explained-part-2-23512ce5dcb1">Content Delivery Networks Explained, Part 2</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Content Delivery Networks Explained]]></title>
            <link>https://medium.com/globant/content-delivery-networks-explained-5a1feaa224c8?source=rss-8c6edd7c7991------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a1feaa224c8</guid>
            <category><![CDATA[cloudops]]></category>
            <category><![CDATA[cdn-service]]></category>
            <category><![CDATA[cdn-providers]]></category>
            <dc:creator><![CDATA[Juan Luis Baptiste]]></dc:creator>
            <pubDate>Fri, 27 Oct 2023 14:32:58 GMT</pubDate>
            <atom:updated>2023-10-27T17:14:42.240Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*_-oUoFzP0bt-27K5" /><figcaption>Photo by<a href="https://unsplash.com/@kadh?utm_source=medium&amp;utm_medium=referral"> Kira auf der Heide</a> on<a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral"> Unsplash</a></figcaption></figure><p>In today’s digital age, where speed, reliability, and performance are paramount, Content Delivery Networks (CDNs) have played a vital role in transforming the digital landscape, revolutionizing the way web content is delivered to end-users across the globe. CDNs are designed to optimize content caching, storage, and delivery processes of different types of content to ensure a seamless browsing experience, ensuring this content is delivered to website visitors as quickly as possible.</p><p>In this series of articles, we will explore the inner workings of CDNs. We will begin by discussing their origins, how they work, and how they have evolved to the present day. In future articles, we will describe the different types of CDNs that cover areas such as website acceleration, video streaming, image optimization, and security, and we will also peer into the future of CDNs. With the unstoppable march of technology and the rapid evolution of digital media consumption, what lies ahead for CDNs? How new technologies and trends will influence their future? These are some of the questions we will seek to answer by the end of this series of articles. So, fasten your seatbelts as we embark on this enlightening exploration into the past, present, and future of CDNs.</p><h3>First, A Bit of History</h3><p>Content Delivery Networks were born in the mid-1990s as a way to mitigate the first bottlenecks that were starting to appear in the early days of the commercial Internet. The first commercial CDN was <a href="https://www.akamai.com/company/company-history">built by Akamai in 1998</a>, as the result of a challenge posed by World Wide Web inventor <a href="https://www.w3.org/People/Berners-Lee/">Tim Berners-Lee</a>, at MIT University, challenging his colleagues to come up with an inherently new and better approach to deliver Internet content. Future Akamai founders developed <em>mathematical algorithms to Intelligently route and replicate content across an extensive network of distributed servers</em> to solve the issues that were starting to appear with the growth of the Internet around the world.</p><p>During the early 2000s, other CDN providers such as StackPath (formerly MaxCDN), Edgio (formerly Limelight Networks), CacheFly, CDNetworks, and Cloudflare, among many others, emerged to cover the growing demand of this market in different parts of the world, tailoring their offerings to meet every customer need. This influx of providers fostered healthy competition and innovation within the CDN industry, ultimately benefiting businesses and users alike with improved content delivery services.</p><p>If we fast-forward, the Internet has evolved in a myriad of ways, and CDNs have evolved with them, from websites with relatively simple pages that displayed mostly static content in the 90s to the consumption of vast amounts of multimedia content today. Video and audio streaming services, gaming, software downloads, and social networking sites rich in images and video have increased the amount of Internet traffic infinitely, making the usage of a CDN for any website an absolute necessity. Content Delivery Networks have become an integral part of the Internet infrastructure nowadays; it could not survive without them.</p><h3>What is a Content Delivery Network</h3><p>In a sentence, a Content Delivery Network is a network of servers strategically spread across the globe, designed to deliver content to users with high availability, low latency, and fast load times. These goals are achieved by distributing these servers globally close to end users, so content can be delivered the closest to them. But first, let’s review how things work without a CDN. Take a look at this diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CMdzjj_--7rm0xn5" /><figcaption><em>Access to a website without a Content Delivery Network</em></figcaption></figure><p>Without a CDN, Internet users connect directly to a website, and the infrastructure supporting the site must be able to support the load generated by users requesting content and deliver it on time with 100% availability.</p><p>Before cloud providers appeared, companies had to estimate ahead of time the amount of traffic they planned to receive and purchase oversized infrastructure to support this growth and absorb any traffic peak generated by events such as promotions, seasonal purchases, etc. This meant having to invest large sums of money in an infrastructure of which a good part of it was going to be unused most of the time, depreciating until the next infrastructure renewal period. And there was always the risk that the infrastructure would fall short, no matter how detailed the estimates were, for example, due to a DDoS attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*Rrs3VS6JFMOfZcMW" /><figcaption>Capacity planning without a CDN</figcaption></figure><p>With the appearance of cloud providers, although it is no longer necessary to have this oversized infrastructure as it can be dynamically scaled to meet user demand, these escalations continue to generate large costs for companies. Now, let’s look at how a CDN can help with these issues, take a look at this diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*brQnAYogRr4eEo-l" /><figcaption><em>Access to a website with a Content Delivery Network</em></figcaption></figure><p>The servers of a CDN are placed at the “edge” of the Internet (called <em>edge servers</em>), between the website or <em>origin server</em>, and the end users. These edge servers connect to the website’s origin server and request content on behalf of the end users, caching all the static assets of the website (HTML, images, JavaScript scripts, CSS and font files, etc.) and then delivering them to the end users.</p><p>As mentioned before, these edge servers are geographically placed in data centers, commonly known in the CDN world as Points of Presence (PoP). These PoPs are located very close to the end users, sometimes even on their “last mile” connection. This means that some of the content for a website could be delivered to end users from a distance of as little as one or two hops (hops are the network devices through which requests must pass, like routers), instead of traveling to the website’s server that could be in another country and at several hops away. This drastically reduces the latency and delivery times.</p><p>Another advantage of using a CDN is that the resources at the origin can be drastically decreased. When the CDN edge servers deliver the cached content to end users, they end up absorbing a big chunk of the traffic that otherwise would go to the origin server, only accessing it when they need to fetch new content or update their cache.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*IkrZMpVB5Hhhecto" /><figcaption>Capacity planning with a CDN</figcaption></figure><p>As you can see in the previous image, the CDN absorbs the traffic peaks, preventing them from reaching the origin server. Smaller infrastructure is needed at the origin to handle much more traffic than when not using a CDN, saving a ton of money on infrastructure bills.</p><p>We have explained until now the basic concepts of how a CDN works. To sum it up, CDNs can:</p><ul><li>Reduce load times and latency, keeping web users more satisfied.</li><li>Make business, in general, more cost-effective by cutting down costs and increasing revenue.</li><li>Make the Internet less congested.</li></ul><h3>How Do CDNs Work</h3><p>So far, we have explained what a CDN is, giving a general overview of how they work. Now, we are going to delve deeper into their inner workings, how content in a CDN is accessed, and how it ends up being cached.</p><p>The operation of a CDN can be divided into two parts: what happens between <em>the edge servers and the end users</em> and what happens between <em>the origin server and the edge servers</em>. Let’s start with the former, how end users access a website through a CDN.</p><h3>Accessing a website through the CDN</h3><p>Depending on the CDN provider, this process is done in different ways, but there are two methods to accomplish this: <em>Dynamic DNS resolution</em> and <em>Anycast routing</em>. Let’s review them in more detail.</p><p><strong>Dynamic DNS resolution</strong></p><p>With this method, CDN providers use proprietary DNS servers to return an IP address of a CDN server that is the closest to the user, depending on their location. But to better understand how this method works, we need to brush up first some concepts of how DNS lookups work.</p><p>When a computer connected to the Internet needs to translate a hostname into an IP address, it employs a resolver software to execute the query (usually part of the operating system). When the resolver program receives a DNS query, it splits the domain name into its individual parts, from right to left. The first part is the <a href="https://en.wikipedia.org/wiki/Top-level_domain">Top-Level Domain (TLD)</a>. TLDs are the domains at the highest level in the DNS hierarchy after the <a href="https://en.wikipedia.org/wiki/Root_name_server">root name servers</a>. Some known TLD examples are .com, .net, .org, .gov, etc. Root servers are at the top of the DNS hierarchy, and their sole function is to return the authoritative servers for the TLDs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iops4J6YACN8bH9l" /><figcaption>DNS hierarchy — Source: <a href="https://www.cloudflare.com/learning/dns/glossary/dns-root-server/">Cloudflare</a></figcaption></figure><p>The resolver program then queries a root server and asks for an authoritative server for the TLD. The root server returns the authoritative server for the TLD and then asks this server for the authoritative server for the next part in the hostname, and so on, until an IP address is returned. We will explain this later with an example to make it more clear.</p><p>But first, to redirect a website’s traffic to the CDN, the owner needs to point the interested hostnames in his domain to a hostname provided by the CDN provider. For example, the owner of the <em>example.com</em> domain should create a CNAME record on that domain’s authoritative name servers to point <a href="http://www.example.com/"><em>www.example.com</em></a> to a hostname like <a href="http://www.example.com.cdnprovider.com/"><em>www.example.com.cdnprovider.com</em></a>, which the CDN provides.</p><p>Let’s see an example. The following diagram shows the DNS resolution process through a CDN:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/0*whSBE8Rhki0K32Ru" /><figcaption>DNS resolution through a CDN</figcaption></figure><p>This is the process that follows:</p><ol><li>A user tries to access <a href="http://www.example.com/"><em>www.example.com</em></a> on his computer.</li><li>Through the operating system resolver, the user&#39;s browser asks the configured DNS nameserver on the computer for the IP address of <a href="http://www.example.com./"><em>www.example.com</em>.</a></li><li>The client’s DNS nameserver asks a root server for the authoritative server for the <em>.com</em> TLD.</li><li>Now, the client’s DNS nameserver asks the returned TLD server for the authoritative server of the <em>example.com</em> domain.</li><li>The client DNS server asks the returned server if it knows the IP address for <a href="http://www.example.com./"><em>www.example.com</em>.</a> If that server has a matching record for that hostname, it will return it to the resolver; if not, it will return an error code indicating that it does not know the answer for that query.</li><li>The client DNS server returns an answer to the web browser.</li><li>The user’s browser, through the operating system resolver, asks the configured DNS nameserver of the computer for the IP address of <a href="http://www.example.com.cdnprovider.com./"><em>www.example.com.cdnprovider.com</em>.</a></li><li>Now, the client DNS nameserver asks the <em>.com</em> TLD server for the authoritative nameserver of the <em>cdnprovider.com</em> domain.</li><li>The client DNS server asks the returned server if he knows the IP address for <a href="http://www.example.com.cdnprovider.com./"><em>www.example.com.cdnprovider.com</em>.</a> The CDN will select the closest edge server to the user and return their IP address.</li><li>The client DNS server returns the IP address to the web browser.</li><li>The web browser will try to connect to the returned IP address and retrieve the website’s content that has been cached on the CDN.</li></ol><p>Now let’s pay attention from <em>step nine</em> onwards, looking up the IP address of the edge server. How does the DNS server, queried by the web browser, return that specific IP address geographically closest to the end user? Here’s where all the magic happens!</p><p>When the browser asks for the IP address of <a href="http://www.example.com.cdnprovider.com,/">www.<em>example.com.cdnprovider.com</em>,</a> the authoritative server for <em>cdnprovider.com</em>, which belongs to the CDN provider, will return an IP address that is in the same geographical region as the DNS server that initiated the query (the one asked by the user’s web browser). How do the CDN provider DNS servers know this? The CDN uses its proprietary algorithms and <a href="https://en.wikipedia.org/wiki/Internet_geolocation">IP location databases</a> to return the closest CDN server to that specific user. After the web browser has this IP address, it can continue to request the website’s content from the CDN. This method was the first to be used by the first CDN providers like Akamai, and it is used by others like Imperva and requires large sums of investments to create their networks around the world.</p><p><strong>Anycast routing</strong></p><p><a href="https://en.wikipedia.org/wiki/Anycast"><em>Anycast</em></a> is a network addressing method that allows multiple machines to share a common IP address, unlike <a href="https://en.wikipedia.org/wiki/Unicast"><em>unicast</em></a> addressing, where an IP address can only be assigned to a single machine. There are other network addressing strategies, like <a href="https://en.wikipedia.org/wiki/Multicast"><em>multicast</em></a> and <a href="https://en.wikipedia.org/wiki/Broadcasting_(networking)#/"><em>broadcast</em></a>, but they fall out of the scope of this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/0*t8FF3HCvUANKxg3g" /><figcaption>Different network addressing strategies — Source: <a href="https://en.wikipedia.org/wiki/Anycast">Wikipedia</a></figcaption></figure><p>With Anycast, the <a href="https://en.wikipedia.org/wiki/Border_Gateway_Protocol">BGP routing protocol</a> is responsible for directing user requests to the nearest machine within the network, depending on their location. BGP selects the destination machine based on a <em>least-cost analysis</em> that includes evaluating the <em>number of hops</em>, the <em>lowest transit cost</em>, and <em>latency</em>. This method offers several advantages, including reduced latency and enhanced redundancy. Within the realm of CDNs, Anycast primarily steers incoming traffic towards the closest PoP capable of efficiently handling the request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/0*7hOntQGcYN_bn5tz" /><figcaption>Anycast network addressing selecting the closest data center</figcaption></figure><p>In the event of a specific PoP becoming unavailable, having a high volume of traffic, or experiencing a DDoS attack, the BGP routing protocol would intelligently re-route the traffic to the nearest operational data center that hosts a machine with the same Anycast IP address. Anycast has been the implementation choice for many new providers since Internet speeds improved in the last decades. The downside is their implementation complexity compared with the previous model we discussed, it needs to be carefully planned. Anycast routing is used by CDN providers like Cloudflare.</p><h3>How content is placed in the CDN edge servers</h3><p>There are two methods that edge servers use to retrieve the content to store in cache and then deliver it to end users: <em>push</em> and <em>pull</em>.</p><p><strong>Pull method</strong></p><p>In the pull method, the CDN edge servers connect to the website’s origin server, and pull content to store in their caches, according to the caching rules configured for that website. When a user accesses the site, the edge servers check their cache to see if they already have the content stored or if it is new and needs to be cached. If it is the latter, the edge server will connect to the origin server, pull the content, and store it in their cache. If it is the former, the edge server will check if the content has already expired according to the caching rules and needs to be updated with a fresh copy from the origin or can be delivered from the cache to the requesting user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*SLHNIMjvIFBzM_xL" /><figcaption>Content fetching via pull method</figcaption></figure><p>This method has the advantage that the cache of the edge servers is updated automatically as end users access the website and request content. The disadvantage is that when there isn’t any cached content for the website in the CDN or when a full content <em>cache purge</em> is done, many edge servers will connect at the same time to the origin server to retrieve the content to store in their cache, which will cause a momentarily higher resource usage than it should be able to handle. Eventually, this is more convenient than having to manually update the content on the edge servers, as it needs to be done with the push method. A purge is an operation that will mark parts of the cached content or the totality of the cache as expired or invalid, forcing edge servers to pull a fresh copy of the purged content to update their cache.</p><p>It is important to note that not all edge servers will have all the content of a website stored in their cache; servers&#39; caches will be populated as end users access the website from different locations and through different edge servers.</p><p><strong>Push method</strong></p><p>In the push method, the administrator of the website is responsible for uploading the desired content from their server to the CDN, normally when there’s an update or new content is added. This is usually done by uploading the static content to an FTP server, via rsync or other methods, and the CDN then pushes the uploaded content to the edge servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*ASGtd35m4T7BRzDV" /><figcaption>Content distribution via push method</figcaption></figure><p>Compared with the pull method, push has the advantage that the website owner controls when the content will be uploaded, avoiding traffic spikes that could appear as can happen when using the pull method because the content is pushed to the edge servers instead. However, it has the disadvantage that the content upload to the CDN needs to be done manually, unlike the pull method, which populates the CDN edge server cache without any intervention from the website’s administrator. Or, the website administrator could implement a mechanism to automate the content upload, for example, using rsync and cron, but it will never be as transparent as with the pull method.</p><p>There are some “hybrid” options, though. Some CDN providers allow their customers to upload the content to a server, and then edge servers will be updated using the pull method. Some examples are Akamai with <a href="https://www.akamai.com/products/netstorage">NetStorage</a> and AWS CloudFront with <a href="https://aws.amazon.com/s3/">S3</a>. In both cases, content can be uploaded using different methods that each of them supports.</p><h3>Conclusions</h3><p>Content Delivery Networks are crucial for optimizing content delivery and improving website performance. The first CDNs tended to be more distributed because, in their beginnings, it was not as common for Internet speeds to be as high as today. The first CDN providers invested exorbitant sums of money in building PoPs worldwide to be close to end users.</p><p>In the 2000s, interconnectivity between networks was evolving, and new CDNs began to build their PoPs in more centralized locations using Anycast routing methodology, making being so physically close to users no longer as advantageous as before. Although the costs of implementing a CDN using Anycast can be lower than the traditional model of having PoPs distributed worldwide because they do not need a network that big, its main disadvantage is that the implementation of its network is much more complex and requires much more careful planning. On the other hand, in the traditional model, which, although it is much more expensive to build and maintain, having its servers closer to the users will make its delivery times difficult to beat by a more centralized design.</p><p>In the upcoming articles, we will discuss the evolution of CDNs; We’ll review the different types that exist today, how CDNs have pivoted to offer other types of services, and what we can expect from them in the future.</p><h3>References</h3><ul><li><a href="https://en.wikipedia.org/wiki/Content_delivery_network">Content Delivery Networks</a></li><li><a href="https://en.wikipedia.org/wiki/Akamai_Technologies">Akamai Technologies</a></li><li><a href="https://www.cloudflare.com/learning/dns/what-is-dns/">How DNS Works — Cloudflare</a></li><li><a href="https://en.wikipedia.org/wiki/Anycast">Anycast</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a1feaa224c8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/content-delivery-networks-explained-5a1feaa224c8">Content Delivery Networks Explained</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[No Workload Left Behind: How to orchestrate with HashiCorp Nomad, Part 3]]></title>
            <link>https://medium.com/globant/no-workload-left-behind-how-to-orchestrate-with-hashicorp-nomad-part-3-867c87c26e6d?source=rss-8c6edd7c7991------2</link>
            <guid isPermaLink="false">https://medium.com/p/867c87c26e6d</guid>
            <category><![CDATA[cloudops]]></category>
            <category><![CDATA[orchestration]]></category>
            <category><![CDATA[hashicorp-nomad]]></category>
            <dc:creator><![CDATA[Juan Luis Baptiste]]></dc:creator>
            <pubDate>Mon, 24 Apr 2023 19:25:32 GMT</pubDate>
            <atom:updated>2023-04-24T19:25:32.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7lx_gLfTMwd620x4" /><figcaption>Photo by <a href="https://unsplash.com/@joshua_chehov?utm_source=medium&amp;utm_medium=referral">Joshua Chehov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is the third and last part of my introductory article to <a href="https://www.nomadproject.io/">HashiCorp Nomad</a>, a generic workload orchestrator that can be used to orchestrate anything in addition to containers. In the <a href="https://medium.com/globant/no-workload-left-behind-how-to-orchestrate-with-hashicorp-nomad-54d875e3914e">first part</a>, we reviewed Nomad’s features, architecture, and how it compares with other orchestrators like Kubernetes. In the <a href="https://medium.com/globant/no-workload-left-behind-how-to-orchestrate-with-hashicorp-nomad-part-2-19e0f8719c8b">second par</a>t, we reviewed some important concepts to understand how Nomad works, explained the different installation methods available, and performed a demo where Nomad was installed locally and ran a basic Nomad job to test it.</p><p>Now we will continue with the previous demo, running other jobs to test more advanced and unique features, including running other types of workloads different from containers.</p><h3>Prerequisites</h3><p>To perform the tasks from this article, you need to have done the demo from the <a href="https://medium.com/globant/no-workload-left-behind-how-to-orchestrate-with-hashicorp-nomad-part-2-19e0f8719c8b">previous article</a> to have a Nomad cluster already running—a quick recap on how to run Nomad locally.</p><p>From a terminal, launch nomad in <em>dev</em> mode:</p><pre>$ sudo nomad agent -dev -bind 0.0.0.0 -log-level INFO</pre><p>After Nomad starts, we can continue with the demo of this article.</p><h3>Testing basic orchestrator features</h3><p>First, we will test a set of features expected in any modern orchestrator: how to scale a running workload, how to update it to a new version, and how to do a rollback in case something goes wrong with an update.</p><h4>Job Escalation</h4><p>We will scale the Nomad job executed in the previous article. If you don’t already have the example job running, let’s review how to do it first. To create the example job file:</p><pre>$ nomad job init -short</pre><p>To run the job:</p><pre>$ nomad job run example.nomad</pre><p>Now we are ready to continue!</p><p>We can scale up or down jobs as required. To scale a job, we need to add the <em>count</em> parameter to the <em>group</em> section of the job definition.</p><p>Now we will scale up this job, but this time we will use the web UI for that. Remember the address format:</p><pre>http://IP_ADDRESS:4646/ui/</pre><p>Replace IP_ADDRESS with the address where you are running the Nomad binary. If you are doing it on your laptop, then you can use <em>localhost</em> or <em>127.0.0.1</em>; if you are running it remotely or in a VM, you will need to find out the corresponding IP address, like, for example:</p><pre>http://192.168.0.22:4646/ui/</pre><p>Go back to the Jobs page and click on the “Run Job” button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p-oVoFcnroDlTX6q" /><figcaption><em>Nomad job list</em></figcaption></figure><p>Copy the contents of the example.nomadfile and add the count=3 parameter to the <em>task</em> group stanza to scale up the job to use three replicas instead of one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*7m7z0fwlClFw5t75" /><figcaption><em>Nomad example job file</em></figcaption></figure><p>Now we click on the “Plan” button, and the UI will show us the planned changes to the job (for Terraform developers, it’s like when running terraform plan<em>)</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/0*vC1IdQqB7jwe9rhI" /><figcaption><em>Nomad job plan</em></figcaption></figure><p>The plan output will show us the proposed changes to validate their correctness. Click on the “Run” button and wait a little bit for the new allocations to be created. After a moment, the three allocations will appear with a running status:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MXF_g1fCG-kFD-UN" /><figcaption><em>Nomad job allocations</em></figcaption></figure><p>Now, let’s change it back to 1 but now from the command line:</p><pre>$ nomad job plan example.nomad<br>+/- Job: &quot;example&quot;<br>+/- Task Group: &quot;cache&quot; (2 destroy, 1 in-place update)<br>+/- Count: &quot;3&quot; =&gt; &quot;1&quot; (forces destroy)<br>    Task: &quot;redis&quot;<br><br>Scheduler dry-run:<br>- All tasks successfully allocated.<br><br>Job Modify Index: 21<br>To submit the job with version verification run:<br><br>hclnomad job run -check-index 21 example.nomad</pre><p>When we run a job from the command line, things work slightly differently. If you look carefully at the plan output, you will see that the <em>proposed</em> command to run the job is not just nomad job run; it adds another parameter, the -check-index parameter with a <em>number</em>. Nomad uses this index to guarantee that you are running the latest version of the job and that no other user has modified it in the cluster since we ran the plan. If another user has submitted a newer version of the job before we submit our changes, that index number would be different, making our plan invalid and aborting the job update. The -check-index parameter is not mandatory but is recommended when more than one user can submit jobs.</p><p>Let’s apply the plan with the suggested command:</p><pre>$ nomad job run -check-index 21 example.nomad<br>==&gt; 2022-12-15T11:59:50-05:00: Monitoring evaluation &quot;89892feb&quot;<br>    2022-12-15T11:59:50-05:00: Evaluation triggered by job &quot;example&quot;<br>    2022-12-15T11:59:50-05:00: Evaluation within deployment: &quot;e9ab122d&quot;<br>    2022-12-15T11:59:50-05:00: Allocation &quot;a5eb1f27&quot; modified: node &quot;956f8047&quot;, group &quot;cache&quot;<br>    2022-12-15T11:59:50-05:00: Evaluation status changed: &quot;pending&quot; -&gt; &quot;complete&quot;<br>==&gt; 2022-12-15T11:59:50-05:00: Evaluation &quot;89892feb&quot; finished with status &quot;complete&quot;<br>==&gt; 2022-12-15T11:59:50-05:00: Monitoring deployment &quot;e9ab122d&quot;<br> ✓ Deployment &quot;e9ab122d&quot; successful<br>    <br>   2022-12-15T12:00:01-05:00<br>   ID          = e9ab122d<br>   Job ID      = example<br>   Job Version = 2<br>   Status      = successful<br>   Description = Deployment completed successfully<br>    <br>   Deployed<br>   Task Group  Desired  Placed  Healthy  Unhealthy  Progress Deadline<br>   cache       1        1       1        0          2022-12-15T12:10:00-05:00</pre><p>Now we can see that the number of allocations in running state is 1. The others are in <em>stop</em> status; when they are stopped, their status changes to <em>complete</em>:</p><pre>$ nomad job status example<br><br>[...]<br><br>Allocations<br>ID        Node ID   Task Group  Version  Desired  Status    Created     Modified<br>4f66a1a1  956f8047  cache       1        stop     complete  8m1s ago    3m58s ago<br>fe22f72a  956f8047  cache       1        stop     complete  8m1s ago    3m59s ago<br>a5eb1f27  956f8047  cache       2        run      running   16m29s ago  3m49s ago</pre><h4>Job Update</h4><p>Now we are going to test the <em>rollback</em> feature. Let’s return to the web UI and edit the example job again. We will change the Redis image version and deploy it again:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/0*zN-7xkAm8-39_f57" /><figcaption><em>Nomad job plan after job update</em></figcaption></figure><p>We can see that the plan is changing the Redis version. After deploying this new version, it will take some time to download the new image, but after that, the logs of the allocation task will show it is using the new Redis version:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J8k1iXqWFcpS4raj" /><figcaption><em>Nomad job allocation task logs</em></figcaption></figure><h4>Job Roll Back</h4><p>But what if we want to <em>roll back</em> to the previous version? On the <em>versions</em> page of the job, we can see the list of previous deployments. With our example job, there are multiple versions of all the tests done so far:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tsHCmb8s2bJ7Kt6n" /><figcaption><em>Nomad job versions list</em></figcaption></figure><p>Let’s roll back the last version to the previous one, so we go back to Redis 7:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2MnVbEvVlqw9tMJo" /><figcaption><em>Nomad job version changes</em></figcaption></figure><p>On the allocation log, we can see that the Redis version is back to 7.0.4:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E6Dv1mu0hAi-EPDe" /><figcaption><em>Nomad job allocation task logs for selected version</em></figcaption></figure><h3>Testing other kinds of workloads</h3><p>Now let’s do a few more tests to showcase one of Nomad’s main features, executing other kinds of non-containerized workloads, like running a static binary and a Java application.</p><h4>Static Binary</h4><p>Let’s start with a very basic job using a static binary. We are going to run a ping command!</p><p>This is the job file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63aa69721ed6f42c63ecf5e075201f4f/href">https://medium.com/media/63aa69721ed6f42c63ecf5e075201f4f/href</a></iframe><p>The job uses the raw_exec driver to run a static binary. With the commandparameter, we set the <em>path</em> to the ping command, and with the argsparameter, we set the parameters passed to that command. With the configured parameters, we let the ping run 1000 times, so it runs long enough to see its output in the allocation logs. Go back to the Jobs page, click on the “Run Job” button, paste the previous job, and then click the “Run” button. Wait until the job appears in running state before checking out the allocation task logs. We can see the ping command is running:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kAsTJKcX4Pv7g8SD" /><figcaption><em>Nomad job allocation task logs</em></figcaption></figure><p>This is a fairly simple example, as the ping command is present on any OS. For a different binary, we would need to provision it somehow. Terraform or Packer could be used for this, but Nomad jobs also have a mechanism for this, using the <a href="https://developer.hashicorp.com/nomad/docs/job-specification/artifact">artifact block</a> to download something when the job runs and before the binary is executed. We will use this feature in the following example, running a Java application.</p><h4>Java Application</h4><p>This Java application for this example is pretty basic; it will only print <em>“Hello Nomad!”</em> and then sleep for one minute before stopping its execution. Our focus here is to showcase that Nomad can orchestrate any Java application. When running a Java application, you can execute a Jar file or a single compiled class file. We will run a Jar file containing the <em>class</em> file of our example app.</p><p>This is the job file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b74da7964d3f1df5061d93d1ccb1c462/href">https://medium.com/media/b74da7964d3f1df5061d93d1ccb1c462/href</a></iframe><p>This job will execute a Java jar file using the Java task driver, and use the artifactblock to download the jar file into the client node, where the job is launched in an isolated location. This is mandatory with the Java driver because this driver will not allow us to set an absolute path on the client node for security reasons.</p><p>Inside the artifact block, the source parameter is used to set the URL from where the jar file will be downloaded. The destinationparameter sets the location relative to the isolated directory where the file should be downloaded to. (The isolated directory is configured in the agent’s configuration file.) You can use an optionsblock to set other optional settings, like the checksum value of the downloaded file. Then, on the task’s configblock<em>,</em> we set the jar_path parameter to the jar file path inside the isolated directory. With the jvm_optionsparameter, we can pass any parameter to the Java virtual machine needed to run the Java application.</p><p>Finally, let’s run this job by copying the previous job in the <em>Run Job</em> window on the Jobs page, as we have done with the previous examples. After that, check out the allocation logs of the new job:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*mSnD2MbnLhieaNX6" /><figcaption><em>Nomad job allocation task logs</em></figcaption></figure><h3>Conclusions</h3><p>In this last hands-on article, we tested other advanced features expected in any orchestrator, like workload escalation update and rollback. We also tested the main feature that differentiates Nomad from other orchestrators: being able to run other workloads different from containers, like running a static binary and a Java application. As demonstrated, running other types of workloads is equally easy as when running containers; only use the correct driver for the kind of workload, and configure the options to run it, and the rest is the same for all types of workloads (resource configuration, escalation, rollbacks, etc.).</p><p>There are some important things that would be nice to test, too, like the ACL configuration, a must for a production deployment, and a hybrid cluster comprising multiple cloud providers (or self-hosted) using Nomad’s native federation feature. Hopefully, this set of articles sparked enough interest in this tool for you to want to evaluate Nomad for current or future projects.</p><h3>References</h3><ul><li><a href="https://www.nomadproject.io/">Nomad Project</a></li><li><a href="https://developer.hashicorp.com/nomad/docs">Nomad documentation</a></li><li><a href="https://developer.hashicorp.com/nomad/tutorials">Nomad tutorials</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=867c87c26e6d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/no-workload-left-behind-how-to-orchestrate-with-hashicorp-nomad-part-3-867c87c26e6d">No Workload Left Behind: How to orchestrate with HashiCorp Nomad, Part 3</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[No Workload Left Behind: How to orchestrate with HashiCorp Nomad, Part 2]]></title>
            <link>https://medium.com/globant/no-workload-left-behind-how-to-orchestrate-with-hashicorp-nomad-part-2-19e0f8719c8b?source=rss-8c6edd7c7991------2</link>
            <guid isPermaLink="false">https://medium.com/p/19e0f8719c8b</guid>
            <category><![CDATA[cloudops]]></category>
            <category><![CDATA[orchestration]]></category>
            <category><![CDATA[hashicorp-nomad]]></category>
            <category><![CDATA[hashicorp]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Juan Luis Baptiste]]></dc:creator>
            <pubDate>Wed, 15 Mar 2023 13:04:56 GMT</pubDate>
            <atom:updated>2023-03-15T13:04:56.984Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U1PNTc5xlww9Itoq" /><figcaption>Photo by <a href="https://unsplash.com/de/@dtopkin1?utm_source=medium&amp;utm_medium=referral">Dayne Topkin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is the second part of my <a href="https://medium.com/globant/no-workload-left-behind-how-to-orchestrate-with-hashicorp-nomad-54d875e3914e">introductory article</a> to HashiCorp <a href="https://www.nomadproject.io/">Nomad</a>, a generic workload orchestrator that can orchestrate anything besides containers. In that article, we reviewed Nomad&#39;s features, architecture, and how it compares with other orchestrators like Kubernetes.</p><p>In this article, we will review Nomad&#39;s installation methods and set up a local development environment to run some Jobs to test some of the core features we covered in the first article. And in the following article, we will review some of the features that make Nomad unique. But before that, we will delve into some essential concepts to understand how Nomad works.</p><h3>Nomad concepts</h3><p>You need to understand Nomad&#39;s core concepts to work with it.</p><ul><li><strong>Job: </strong>Declares the desired state of a workload for Nomad to run.</li><li><strong>Driver: </strong>the interface or context under which the task will run. For example: docker, java or win_iis.</li><li><strong>Task</strong>: the smallest unit of work and specifies the configuration, constraints, and resources required to run.</li><li><strong>Task Group</strong>: Related tasks that must be executed on the same client node and cannot be separated. A task group is the equivalent of a pod in Kubernetes.</li><li><strong>Client</strong>: basically the equivalent of a <em>worker node</em> in Kubernetes. Runs and manages tasks using its resources and must report to a server.</li><li><strong>Server</strong>: the equivalent of the <em>control plane</em> in Kubernetes. They are responsible for managing jobs, resource allocation, and running evaluations. Servers talk to each other and use a leader/follower load balancing method for HA.</li><li><strong>Allocation:</strong> a task group in a job executed in a client node. The Nomad servers create allocations as part of scheduling decisions made during an evaluation.</li><li><strong>Evaluation</strong>: a mechanism to validate if everything is in its desired state; if not, it allows the servers to perform corrective actions and perform changes in allocations if necessary.</li><li><strong>Data Center</strong>: an abstract grouping of clients within a region.</li><li><strong>Region</strong>: Contains one or more data centers. A region comprises servers, which can connect across regions to make a global network.</li><li><strong>Raft consensus protocol:</strong> Allows the cluster to elect a leader and set the followers.</li><li><strong>Gossip protocol:</strong> Securely shares information between servers and clients about its configuration and topology.</li></ul><h3>How to run Nomad?</h3><p>As mentioned in the previous article, Nomad is available as a <a href="https://nomadproject.io/downloads/">pre-compiled binary</a> or as a package for Linux, Windows, or macOS. For a local installation, it is as simple as downloading a single binary and running a server and at least one client. You can also test Nomad using Vagrant, but the recommended way is for a production cluster using Terraform and Packer to do all the provisioning.</p><h4>Local Install</h4><p>Remember that the Nomad binary is used for both server and client, and its role is set according to how it is configured in the configuration file that is passed to the binary at runtime. The binary can be executed like this:</p><pre>$ sudo nomad agent -config /etc/nomad.d/nomad.hcl</pre><p>The /etc/nomad.d/<strong>nomad.hcl</strong> file contains the server or client configuration. This is an example of a basic <em>server</em> configuration:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fdc0ac71c0a436493c37b7888d4a9ae/href">https://medium.com/media/1fdc0ac71c0a436493c37b7888d4a9ae/href</a></iframe><p>At the top of the file, there are some global configuration options, like:</p><ul><li>data_dir, the directory where Nomad&#39;s configuration and state files are stored</li><li>bind_addr, the IP address Nomad will bind to</li><li>datacenter, the name of the region this Nomad server belongs to</li></ul><p>Then there is the <a href="https://developer.hashicorp.com/nomad/docs/configuration/server"><em>server</em></a> stanza, which is the place where server configuration parameters are configured. For example, bootstrap_expect sets the number of expected servers on the cluster (1, 3, or 5 according to the Raft consensus protocol) to be able to start and reach a consensus. This option is <em>mandatory</em> for server configuration.</p><p>The <a href="https://developer.hashicorp.com/nomad/docs/configuration/consul">consul</a> stanza is used to point the Nomad cluster to a remote Consul cluster. But if Consul is already running on the same server where a Nomad server or client is running, Nomad will detect it and register itself on it without having to use the consul stanza. The <a href="https://developer.hashicorp.com/nomad/docs/configuration/vault">vault</a> stanza points Nomad to a Vault server for secrets management.</p><p>The <a href="https://developer.hashicorp.com/nomad/docs/configuration/acl">acl</a> stanza is used to configure access control to the Nomad server through the web GUI or the CLI, and to control Job deployment by defining <a href="https://developer.hashicorp.com/nomad/tutorials/access-control/access-control#acl-policies">ACL policies</a>. It is worth noting that this feature comes disabled by default and needs to be enabled and properly configured for a production setup. I guess that the reason for this is to facilitate testing and Job development by developers and to allow for complete customization according to each project&#39;s needs; ACL configuration is a <a href="https://developer.hashicorp.com/nomad/tutorials/access-control">complex topic</a> that would need a whole article just for that.</p><p>This is an example of a client configuration:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa90411f4b74f40eed6020a5d83ea09f/href">https://medium.com/media/fa90411f4b74f40eed6020a5d83ea09f/href</a></iframe><p>The main difference with the previous server configuration file is the <a href="https://developer.hashicorp.com/nomad/docs/configuration/client"><em>client</em></a> stanza. This configuration parameter defines Nomad&#39;s configuration as a client instead of a server. Here are defined things like the servers this client should join, or to <a href="https://developer.hashicorp.com/nomad/docs/configuration/client#options-parameters">enable the drivers</a> to run different kinds of workloads, according to what the node where the client is running supports (i.e., you cannot enable the Java driver in a node that does not have a JRE installed). Other options are common to the server configuration, like the consul or vault stanzas.</p><p>These binaries could be configured as system services, so they are launched at instance boot. In the case of Linux, you could define a Systemd file like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae937d2ca55b3b8552b911326a3e8b8a/href">https://medium.com/media/ae937d2ca55b3b8552b911326a3e8b8a/href</a></iframe><p>There are also instructions on <a href="https://developer.hashicorp.com/nomad/tutorials/windows/windows-agent?in=nomad%2Fwindows">how to set up a Windows service</a> in the official documentation. But to play around with nomad in your dev laptop, you can run the Nomad binary using the <em>-</em>dev parameter, which will launch Nomad as both server and client:</p><pre>$ sudo nomad agent -dev -bind 0.0.0.0 -log-level INFO</pre><h4>Vagrant</h4><p>You can also use <a href="https://www.vagrantup.com/">Vagrant</a> to set up a development environment for Nomad. Vagrant is another HashiCorp tool for building and managing local virtual machine environments, which is very useful for development or doing tests. After having <a href="https://www.vagrantup.com/docs/installation">installed Vagrant</a>, to run Nomad in it, you need a Vagrantfile. HashiCorp provides a <a href="https://raw.githubusercontent.com/hashicorp/nomad/master/demo/vagrant/Vagrantfile">Vagrantfile</a> that starts a small Nomad cluster. First, create a new directory for your Vagrant environment and cd into it:</p><pre>$ mkdir nomad-demo<br>$ cd nomad-demo</pre><p>Then download the Vagrantfile:</p><pre>$ curl -O https://raw.githubusercontent.com/hashicorp/nomad/master/demo/vagrant/Vagrantfile</pre><p>Now, start the VM:</p><pre>$ vagrant up</pre><p>An Ubuntu VM image will be downloaded and launched and then provisioned with Docker and Nomad:</p><pre>Bringing machine &#39;default&#39; up with &#39;virtualbox&#39; provider…<br>==&gt; default: Importing base box &#39;bento/ubuntu-18.04&#39;…<br>…<br>==&gt; default: Running provisioner: docker…</pre><p>Wait a few minutes, and the Vagrant box will be ready to use. Once the Vagrant box is running, use the ssh command to start a shell session.</p><pre>$ vagrant ssh</pre><p>To test that the nomad command is available, run this command:</p><pre>$ nomad version<br>Nomad v1.3.5 (1359c2580fed080295840fb888e28f0855e42d50)</pre><h4>Terraform &amp; Packer</h4><p>The previous installation methods are oriented towards a development or learning setup. Still, when deploying Nomad in a production environment, you will need a more automated deployment strategy that can scale over time as your infrastructure grows. For this task, then Terraform and Packer could be adequate options. Nomad could be packaged as part of a VM image using Packer, and Terraform can be used to deploy (and upgrade) a set of nodes in the cloud that use that image. But this topic deserves its own article; for now, you could check this <a href="https://github.com/hashicorp/learn-nomad-cluster-setup">example project</a> that deploys a Nomad cluster in AWS using both Terraform and Packer as a starting point for your own cluster.</p><h3>How to run a workload?</h3><p>To run anything in Nomad, we need to define a <em>Job</em>. These jobs are files written in the <a href="https://github.com/hashicorp/hcl">HCL</a> language, the same language used by other HashiCorp tools like Terraform. If you know the HCL language to write Terraform code, you won&#39;t have trouble writing Nomad client/server configuration files or Jobs.</p><p>A Job defines the <em>desired state</em> of the application; it defines the job configuration, things like the resources it needs, network configuration, and the <em>Nomad region</em> it should run. The Nomad servers are responsible for ensuring the <em>actual state</em> matches the user <em>desired</em> state, which is done by finding an optimal placement for each task such that resource utilization is maximized while satisfying all constraints specified by the job. These constraints could be technical requirements such as hardware architecture, the availability of GPUs, or a specific operating system and kernel version, etc.</p><p>Tasks are scheduled on the nodes in the cluster running Nomad, configured as a client. When a job is launched, a server creates an evaluation to find the most suitable client for the task groups defined for that job in particular. According to the evaluation result, it creates a Job allocation in the selected client nodes. An evaluation is created when the external state changes, either desired or emergent. This means that every time a Job is submitted and an evaluation determines that the desired state has changed, a current job will be updated (or deregistered).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HFsmEbbHDJd0RF2i" /><figcaption><em>Nomad job scheduling (Source:</em><a href="https://www.hashicorp.com/solutions/modern-application-delivery"><em> HashiCorp</em></a><em>)</em></figcaption></figure><p>The following is an example of a Nomad job:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/261c0b21a7e1d4287c1099bd3d2b2e1f/href">https://medium.com/media/261c0b21a7e1d4287c1099bd3d2b2e1f/href</a></iframe><p>The general hierarchy for a job is as follows:</p><pre>job<br>  \_ group<br>      \_ task</pre><p>Each job file has only a single job; however, a job may have multiple groups, and each group may have multiple tasks. The purpose of groups is co-locating tasks on the same machine. Each task is a unique action for Nomad to execute. Tasks define the task driver to use, its configuration, and the resources required by the task.</p><h3>Nomad Demo</h3><p>Now that we have covered Nomad&#39;s core concepts, we are ready to continue and set up a local environment to try it out. We are going to do a local Nomad install and launch three different jobs to test the following features:</p><ul><li>Run an example job and test the basic features anyone can expect in an orchestrator, like job deployment, job escalation, and rollbacks.</li><li>Run other kinds of workloads different from containers, like a static binary and a Java application.</li></ul><h4>Nomad installation</h4><p>Let&#39;s start by installing Nomad locally and executing it in dev mode. The following instructions are for Debian/Ubuntu Linux; if you are using a different OS, please refer to the <a href="https://developer.hashicorp.com/nomad/downloads">installation instructions</a> and look up the commands for your OS. Run the following commands in a terminal to add the HashiCorp deb repository as a source and install Nomad:</p><pre>$ wget -O- https://apt.releases.hashicorp.com/gpg | gpg - dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg<br>$ echo &quot;deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main&quot; | sudo tee /etc/apt/sources.list.d/hashicorp.list<br>$ sudo apt update &amp;&amp; sudo apt install nomad</pre><p>After finishing the installation, in a terminal launch nomad in dev mode:</p><pre>$ sudo nomad agent -dev -bind 0.0.0.0 -log-level INFO</pre><p>You will see the output of Nomad starting up. When you see these messages:</p><pre>2022–09–19T22:53:30.902–0500 [INFO] nomad: cluster leadership acquired<br>2022–09–19T22:53:30.903–0500 [INFO] nomad.core: established cluster id: cluster_id=d99996a7–8ab2-eba4–91d4–52c8d759366c create_time=1663646010903589813<br>2022–09–19T22:53:30.904–0500 [INFO] nomad: eval broker status modified: paused=false<br>2022–09–19T22:53:30.904–0500 [INFO] nomad: blocked evals status modified: paused=false<br>2022–09–19T22:53:30.926–0500 [INFO] client: node registration complete<br>2022–09–19T22:53:31.929–0500 [INFO] client: node registration complete</pre><p>Based on the info log, you can be sure that the Nomad server and agent started successfully, and we are ready to deploy a new job. Now, open a second terminal, from here we are going to launch a job (you can use something like tmux or screen commands if you are connecting remotely). First, let&#39;s check Nomad&#39;s available nodes. Run the command nomad node status to check that a node is up and running and ready to work:</p><pre>$ nomad node status<br>ID DC Name Class Drain Eligibility Status<br>c0d2fa96 dc1 nomad-demo &lt;none&gt; false eligible ready</pre><p>Now that we verified that one client node is running, we can run some jobs.</p><h4>Running an example job</h4><p>We are going to start with a simple job. To create an example job file, we can use the nomad job init command. This command will output a basic example of a job.</p><pre>$ nomad job init</pre><p>An example.nomad file will be created. The example job file is very well documented; it explains each configuration parameter in the job file. If you want a cleaner file without any comments, we can pass the -short parameter to the nomad job init command (this is the example job we presented before when explaining <em>how to run Nomad</em>). This example job runs a Redis database and defines the data center where the job should be deployed. If you remember from the nomad status command output, &quot;dc1&quot; is the name of the data center. It also defines the name of the Docker image to use and the resources to assign to it. Now let&#39;s deploy the job. For this, we use the nomad job run command.</p><pre>$ nomad job run example.nomad</pre><p>The command outputs information about the scheduling process:</p><pre>==&gt; Monitoring evaluation &quot;6792e7a6&quot;<br>    Evaluation triggered by job &quot;example&quot;<br>    Evaluation within deployment: &quot;99297d1d&quot;<br>    Allocation &quot;635a981a&quot; created: node &quot;3825e530&quot;, group &quot;cache&quot;<br>    Evaluation status changed: &quot;pending&quot; -&gt; &quot;complete&quot;<br>==&gt; Evaluation &quot;6792e7a6&quot; finished with status &quot;complete&quot;</pre><p>Here, the output indicates that an evaluation was performed to find a suitable node to deploy this job. The result of that was the creation of an allocation that is now running on the local node. Now, let&#39;s check the status of the job with nomad job status command:</p><pre>$ nomad job status example        <br>ID            = example<br>Name          = example<br>Submit Date   = 2022-09-23T09:56:08-05:00<br>Type          = service<br>Priority      = 50<br>Datacenters   = dc1<br>Namespace     = default<br>Status        = running<br>Periodic      = false<br>Parameterized = false<br><br>Summary<br>Task Group  Queued  Starting  Running  Failed  Complete  Lost  Unknown<br>cache       0       0         3        0       0         0     0<br><br>Latest Deployment<br>ID          = f351d71d<br>Status      = successful<br>Description = Deployment completed successfully<br><br>Deployed<br>Task Group  Desired  Placed  Healthy  Unhealthy  Progress Deadline<br>cache       3        3       3        0          2022-09-23T10:06:19-05:00<br><br>Allocations<br>ID        Node ID   Task Group  Version  Desired  Status   Created    Modified<br>a52e34e0  956f8047  cache       1        run      running  1h6m ago   1h5m ago<br>e2773027  956f8047  cache       1        run      running  1h6m ago   1h5m ago<br>bb177e47  956f8047  cache       1        run      running  1h27m ago  1h5m ago</pre><p>When Nomad runs a job, it creates allocations based on the task groups within the job. These allocations are equivalent to pods in Kubernetes. To inspect an allocation, use the nomad alloc status <a href="https://www.nomadproject.io/docs/commands/alloc/status">command</a>.</p><pre>$ nomad alloc status a52e34e0<br>ID                  = a52e34e0-4d30-ddd6-14ca-0b3a23201c2d<br>Eval ID             = 2cd0caed<br>Name                = example.cache[1]<br>Node ID             = 956f8047<br>Node Name           = nomad-demo<br>Job ID              = example<br>Job Version         = 1<br>Client Status       = running<br>Client Description  = Tasks are running<br>Desired Status      = run<br>Desired Description = &lt;none&gt;<br>Created             = 1h5m ago<br>Modified            = 1h5m ago<br>Deployment ID       = f351d71d<br>Deployment Health   = healthy<br><br>Allocation Addresses<br>Label  Dynamic  Address<br>*db    yes      127.0.0.1:24974 -&gt; 6379<br><br>Task &quot;redis&quot; is &quot;running&quot;<br>Task Resources<br>CPU        Memory           Disk     Addresses<br>4/500 MHz  2.4 MiB/256 MiB  300 MiB   <br><br>Task Events:<br>Started At     = 2022-09-23T14:56:09Z<br>Finished At    = N/A<br>Total Restarts = 0<br>Last Restart   = N/A<br><br>Recent Events:<br>Time                       Type        Description<br>2022-09-23T09:56:09-05:00  Started     Task started by client<br>2022-09-23T09:56:08-05:00  Task Setup  Building Task Directory<br>2022-09-23T09:56:08-05:00  Received    Task received by client</pre><p>We can see details of this particular allocation, like the hardware resources in use. Now let&#39;s see the logs of the Redis task:</p><pre>$ nomad alloc logs a52e34e0 redis<br>1:C 23 Sep 2022 14:56:09.775 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo<br>1:C 23 Sep 2022 14:56:09.793 # Redis version=7.0.4, bits=64, commit=00000000, modified=0, pid=1, just started<br>1:C 23 Sep 2022 14:56:09.793 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf<br>1:M 23 Sep 2022 14:56:09.793 * Increased maximum number of open files to 10032 (it was originally set to 1024).<br>1:M 23 Sep 2022 14:56:09.793 * monotonic clock: POSIX clock_gettime<br>1:M 23 Sep 2022 14:56:09.794 * Running mode=standalone, port=6379.<br>1:M 23 Sep 2022 14:56:09.794 # Server initialized<br>1:M 23 Sep 2022 14:56:09.794 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add &#39;vm.overcommit_memory = 1&#39; to /etc/sysctl.conf and then reboot or run the command &#39;sysctl v<br>m.overcommit_memory=1&#39; for this to take effect.<br>1:M 23 Sep 2022 14:56:09.794 * Ready to accept connections</pre><p>Until now, we have been working on the command line, but Nomad also has a web UI. To access it, open the <a href="http://ip_address:4646/ui/">http://IP_ADDRESS:4646/ui/</a> address in your browser, replacing IP_ADDRESS with the address where you are running the Nomad binary. If you are doing it in your laptop, then you can use localhost or 127.0.0.1, but if you are running it remotely or in a VM, you will need to find out the corresponding IP address, as in <a href="http://192.168.0.22:4646/ui/">http://192.168.0.22:4646/ui/</a>.</p><p>As we are running Nomad in a development mode, there isn&#39;t any kind of authentication, but ACLs should be enabled and configured for production deployment. After we enter the web UI, we land on the jobs page, where we can see the example job we launched on the command line:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RqYpg3Nlr1Rs2ev9ZsaJGQ.png" /><figcaption><em>Nomad Web GUI interface</em></figcaption></figure><p>We can see the list of jobs being executed in the Nomad cluster. We can see other information in the left panel, like the client and server nodes. Going back to the Jobs page, if we select a Job, we can see some more detailed information, like its execution status, the task groups, and allocations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RjOeTeWZa7KRbK8J" /><figcaption><em>Nomad job overview</em></figcaption></figure><p>When clicking on the <em>Task Group</em>, we can see the allocations of this group:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bRcZfVzcWkWq3DoQ" /><figcaption><em>Nomad job allocations</em></figcaption></figure><p>When clicking on an allocation, its details are shown, like resource utilization, the files part of the tasks part of the allocation, and the details of the tasks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B8zRgY42oOGLtKTt" /><figcaption><em>Nomad job allocation details</em></figcaption></figure><p>Here we can see the details of this particular task, the resources used, the list of the task&#39;s events, and log output and files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e6CkLnEqHfth76R2" /><figcaption><em>Nomad job allocation task events</em></figcaption></figure><p>To see the logs, click on the <em>Logs</em> tab at the top:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LIGNrCqXlTz9y2cP" /><figcaption><em>Nomad job allocation task logs</em></figcaption></figure><h3>Conclusions</h3><p>In this article, we tested some of Nomad&#39;s core features described in the <a href="https://medium.com/globant/no-workload-left-behind-how-to-orchestrate-with-hashicorp-nomad-54d875e3914e">first article</a>. We reviewed some important concepts to better understand Nomad&#39;s inner workings to prepare for the hands-on lab and learned different installation methods. About Nomad&#39;s job definition, I think we could say that using the HCL language to do the Job definition helps in making them simple, self-documented, and clear to understand without the need to use multiple files to run a single application. The client CLI is clear and straightforward to use, and it is nice to have an accompanying web GUI included as part of the server.</p><p>Finally, we ran an example job to test some core features expected in any modern orchestrator, but still, we have yet to test some of the features that make Nomad unique.</p><p>In the next part of this article series, we will test some of these features that differentiate Nomad from other orchestrators, such as being able to run workloads different from containers. Stay tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19e0f8719c8b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/no-workload-left-behind-how-to-orchestrate-with-hashicorp-nomad-part-2-19e0f8719c8b">No Workload Left Behind: How to orchestrate with HashiCorp Nomad, Part 2</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[No Workload Left Behind: How to orchestrate with HashiCorp Nomad]]></title>
            <link>https://medium.com/globant/no-workload-left-behind-how-to-orchestrate-with-hashicorp-nomad-54d875e3914e?source=rss-8c6edd7c7991------2</link>
            <guid isPermaLink="false">https://medium.com/p/54d875e3914e</guid>
            <category><![CDATA[hashicorp]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloudops]]></category>
            <category><![CDATA[hashicorp-nomad]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Juan Luis Baptiste]]></dc:creator>
            <pubDate>Thu, 05 Jan 2023 13:55:39 GMT</pubDate>
            <atom:updated>2023-01-05T16:28:20.944Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HAkGJuE2diN7Ja9F" /><figcaption>Photo by <a href="https://unsplash.com/@dialex?utm_source=medium&amp;utm_medium=referral">Diogo Nunes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Anyone could think that the DevOps community had already settled the debate of the best workload orchestrator for the cloud, and <a href="https://kubernetes.io/">Kubernetes</a> was chosen as the clear winner, becoming the de facto standard of the industry. But a particular project has been gaining popularity in the last years because of its different approach to orchestration and scheduling, addressing some gaps in this field. We are referring to <a href="https://www.nomadproject.io/">Nomad</a>, an open-source workload orchestrator developed by HashiCorp, the creators of other widely known tools like <a href="https://www.terraform.io/">Terraform</a>, <a href="https://www.packer.io/">Packer</a>, <a href="https://www.consul.io/">Consul</a>, and <a href="https://www.vaultproject.io/">Vault</a>.</p><p>In this article, we will review in more detail what Nomad is, its main features, and how it differentiates from other, more established orchestrators in the market like <a href="https://kubernetes.io/">Kubernetes</a>. In future articles, we will do a hands-on lab, setting up a local development environment for Nomad to test some of its features. But before we start, let&#39;s review a couple of important concepts for what we are going to talk about, what is an orchestrator and a workload.</p><h3>What is an Orchestrator?</h3><p>An orchestrator is a program that coordinates and schedules complex computer tasks across an infrastructure. The orchestrator is responsible for telling these tasks where to run, when to run, and place them in the available infrastructure in the most efficient way. Think of the orchestrator as the conductor of a musical orchestra. Every musician knows <em>how to play</em> their instrument and the musical phrasing, but someone needs to <em>give directions</em> to them, like setting the tempo, ensuring correct entries by ensemble members, etc. A workload orchestrator will have an equivalent responsibility for executing your infrastructure&#39;s tasks.</p><h3>What is a Workload?</h3><p>In IT, a workload is the amount of work a computer system or application requires to complete a specific task, and the resources it needs. An example of workload in a cloud environment could be a web application that processes user requests and uses a database to store information. If multiple infrastructure resources are needed to run and escalate the application, then coordination is crucial to run it successfully.</p><p>Today, the most used kind of workloads are container-based, orchestrated by tools like Kubernetes, Mesos, or Docker Swarm, but other types of workloads are still in use. These workloads have not yet been containerized to be run in the cloud, or they simply can&#39;t or do not make sense to run them that way. Think, for example, of some types of legacy applications or IoT devices.</p><h3>What is Nomad?</h3><p>Have you noticed that I have been talking about <strong><em>workload orchestration</em></strong> instead of <strong><em>container orchestration</em></strong>? The reason is that even nowadays, only some use containers to run their applications and processes. There are still plenty of organizations that run legacy applications and haven&#39;t started their journey to the cloud, or are in the middle of that adoption, having a mixed environment with one foot in the cloud and the other in their traditional data center (or in the cloud but still not using containers).</p><p>Nomad has taken a different approach to workload orchestration and scheduling, realizing that not all workloads in IT are container-based. Nomad is a workload orchestrator that can handle not only traditional containers but also non-containerized applications like legacy apps, batch workloads, virtual machines, or binaries. You can think of Nomad as a workload-agnostic orchestrator that can work with any kind of workload in different environments.</p><h3>Nomad Features</h3><p>Nomad has a different approach to workload orchestration; it possesses some neat features that set it apart from other, more established orchestrators. Let&#39;s review some of them.</p><p>First, Nomad is a single binary written in <em>golang</em>, which makes Nomad completely self-contained and easier to install by copying this binary and a configuration file to a server. This binary can be executed in operating systems (like Linux, macOS, or Windows) and in multiple hardware architectures in addition to x86, like ARM, common in IoT devices. Nomad can also take advantage of GPUs, FPGAs, and TPUs hardware devices to run machine learning (ML) and artificial intelligence (AI) workloads. One interesting case is <a href="https://thenewstack.io/conductor-why-we-migrated-from-kubernetes-to-nomad/">Conductor</a>, which uses Nomad to process huge batch workloads for 3D rendering using Nomad&#39;s GPU hardware capability.</p><p>This binary handles the main functionalities of a cluster, like task scheduling and resource management, application or node failure handling, or even <a href="https://developer.hashicorp.com/nomad/tutorials/manage-clusters/federation">cluster multi-region federation</a>. For other features, Nomad integrates with other tools that are part of the HashiCorp stack like:</p><ul><li><strong>Consul </strong>for service discovery and networking</li><li><strong>Vault </strong>for secrets management</li><li><strong>Terraform </strong>for cluster provisioning</li><li><strong>Packer </strong>for custom image build</li></ul><p>Although, since <a href="https://www.hashicorp.com/blog/nomad-1-3-adds-native-service-discovery-and-edge-workload-support">version 1.3</a>, Nomad provides basic service discovery support without using Consul, for more advanced use cases, Nomad can use an external Consul cluster. If Consul is already running before the Nomad server is started, Nomad will detect it and automatically register itself on it.</p><p>Another of Nomad&#39;s more important features is that Nomad can run other non-containerized workloads like static binaries, Java applications (e.g., a<a href="https://spring.io/projects/spring-boot"> Spring boot</a> application), virtual machines, or many other types of workloads. Pluggable task drivers execute these workloads, and because Nomad is open source, it means new drivers can be built by the community. In fact, there are already multiple community-maintained drivers to run workloads in <a href="https://www.nomadproject.io/plugins/drivers/community/containerd">Containerd</a>, <a href="https://www.nomadproject.io/plugins/drivers/community/firecracker-task-driver">Firecracker</a>, <a href="https://www.nomadproject.io/plugins/drivers/community/lxc">LXC</a>, <a href="https://www.nomadproject.io/plugins/drivers/community/rkt">Rkt</a>, or even on <a href="https://www.nomadproject.io/plugins/drivers/community/iis">Windows IIS</a>, but there are <a href="https://www.nomadproject.io/docs/drivers">many more</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*BjRWdtt6OBIH2Rhn" /><figcaption><em>Nomad generic workload scheduling (Source:</em><a href="https://www.hashicorp.com/solutions/modern-application-delivery"><em> HashiCorp</em></a><em>)</em></figcaption></figure><p>Workloads that will be executed in a Nomad cluster are defined as Jobs. These jobs represent a workload and are defined in a single file using the HashiCorp Configuration Language (HCL) declarative language (the same one used by Terraform). This single file includes all configurations required to run the workload, like its type (container, java application, virtual machine, etc.), where it should be executed, hardware resources, job version update strategy, network configuration, storage volumes, environment variables, health checks, etc. In a follow-up article, we will go into greater detail, where we will do an introductory lab to test some of Nomad&#39;s features.</p><p>Another of Nomad&#39;s powerful features is its scalability. Nomad has been proven to scale to clusters of 10K+ nodes in real-world production environments, a number much larger than what other orchestrators have been able to scale up to. To test Nomad&#39;s scalability, HashiCorp did a — <a href="https://www.hashicorp.com/c2m">2 million containers challenge</a>, which deployed 2 million containers in more than 6,000 nodes, in 22 minutes. To achieve this level of performance, Nomad uses bin-packing and anti-affinity to <a href="https://developer.hashicorp.com/nomad/docs/concepts/scheduling/scheduling?product_intent=nomad">efficiently schedule jobs</a> and optimize for resource utilization, avoiding wasting infrastructure resources. Bin-packing is a workload placement strategy that determines the most efficient way to &quot;pack&quot; workloads into the infrastructure resources. Anti-affinity is a workload placement strategy that doesn&#39;t allow backup or redundant jobs to be placed on the same piece of infrastructure, where an outage could cause a job to become unavailable.</p><h3>Nomad Architecture</h3><p>Nomad has a client-server architecture. The same binary can be executed as a server or client, depending on the configuration defined in the configuration file passed to it when launched. The servers use the <a href="https://www.nomadproject.io/docs/concepts/consensus">Raft consensus protocol</a> for leader election and a gossip protocol for communication between clusters (more on this below).</p><p>According to the <a href="https://www.nomadproject.io/docs/concepts/consensus">Raft consensus protocol</a>, the number of servers in a cluster must be 3 or 5 to form a consensus group and elect a cluster leader. These values also provide a good balance between availability in the case of failure and performance. The leader is responsible for processing all queries and transactions, but all servers participate in making scheduling decisions in parallel. Any server that is part of the cluster could be a leader.</p><p>In a multi-region setup, each region may have clients from multiple data centers, allowing a few servers to handle clusters of considerable size. There is no limit on the number of clients per region.</p><h3>Reference Architectures</h3><p>Now let&#39;s review in more detail the deployment strategies. Choosing between a single region or a multi-region deployment depends entirely on the workloads you want.</p><h3>Single Region</h3><p>The following diagram depicts a single region deployment of Nomad:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9v5a4KxkC1ncmHxQ" /><figcaption><em>Nomad Reference Architecture (Source:</em><a href="https://developer.hashicorp.com/nomad/tutorials/enterprise/production-reference-architecture-vm-with-consul#one-region"><em> HashiCorp</em></a><em>)</em></figcaption></figure><p>A single Nomad cluster is recommended for applications deployed in the same region. Within each region, we have both clients and servers. According to the Raft consensus protocol, each cluster should have three or five servers to maintain the high availability of the cluster. The Nomad Servers are responsible for accepting jobs from users, managing clients, and<a href="https://www.nomadproject.io/docs/concepts/scheduling/scheduling"> computing task placements</a>. Nomad can use Consul for service discovery, mesh networking, and dynamic configurations.</p><h3>Multi-Region</h3><p>To improve availability or scalability, Nomad can federate multiple clusters (regions in Nomad terms), so they work as a single one. At a high level, this setup looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nmJ8co5n1WzY4O1Z" /><figcaption><em>Nomad Multi-region Reference Architecture (Source:</em><a href="https://learn.hashicorp.com/"><em> HashiCorp</em></a><em>)</em></figcaption></figure><p>These Nomad regions could be inside the same cloud provider, or they could be in a different one, or even on private data centers running bare metal, OpenStack, or VMware. These regions communicate with each other using a <a href="https://www.nomadproject.io/docs/concepts/gossip">gossip protocol</a>, this allows users to submit a job to any region, and requests are forwarded to the appropriate server to be processed, returning the results to the requester.</p><h3>Nomad and other Orchestrators</h3><p>Nomad approaches workload orchestration with a different vision than traditional orchestrators. Its main goals are being simple to operate and install, being workload-agnostic, and having an impressive performance. This means Nomad has some overlapping features with them, but as we saw before, it has a set of unique features too. Let&#39;s first see how Nomad is similar to other orchestrators like Kubernetes.</p><h3>What are their similarities?</h3><p>Nomad approaches workload orchestration with the UNIX philosophy of doing one thing but doing it well. Nomad has some basic core features common to any other orchestrator, like automated scheduling, self-recovery of applications, rollouts and rollbacks, and storage orchestration. Still, for more advanced features, Nomad relies on external tools like Consul or Vault.</p><p>But the main similarity is the orchestration of containerized workloads, like <a href="https://developer.hashicorp.com/nomad/docs/drivers/docker">docker containers</a>. This type of workload supports the configuration of all the features supported by docker, like hardware resources, volumes, health checks, networking parameters, etc. Nomad also supports both <a href="https://developer.hashicorp.com/nomad/docs/job-specification/csi_plugin">CSI (Container Storage Interface)</a> and <a href="https://developer.hashicorp.com/nomad/docs/job-specification/network?product_intent=nomad#container-network-interface-cni">CNI (Container Networking Interface)</a> standards, so any storage or networking driver available for Kubernetes can be used with Nomad.</p><h3>What are their differences?</h3><p>The main difference between Nomad and other orchestrators, as mentioned before when we reviewed its features, is Nomad&#39;s ability to run all sorts of workloads in addition to containers, like virtual machines, static binaries, and Java applications, to name a few, and in multiple hardware and operating systems (please go back to the features section for more information on this). Kubernetes currently only handles containerized workloads, and the control and data plane components only run on Linux (without virtualization); only the kubectl CLI command used to interact with Kubernetes clusters is available for Windows and Mac.</p><p>Although containerized workloads are something Nomad has in common with other orchestrators, there are still some critical differences. As mentioned before, when reviewing Nomad&#39;s architecture, all the configuration for a containerized application is done in a single job file instead of multiple files (Deployments, ReplicaSets, Services, etc.) called <em>manifests</em> in Kubernetes, used to define the same functionalities. This makes introducing new developers to job writing easier, especially for anyone who has already worked with Terraform code (remember, Nomad also uses the HCL language for both server/client configuration and job specification). Kubernetes uses YAML for its configuration files, but it has been noted that YAML has many problems that make it <a href="https://noyaml.com/">not the best option</a> for writing configuration files, and some people think that <a href="https://medium.com/hashicorp-engineering/why-i-believe-hcl-is-better-than-yaml-78226a645b0d">HCL is a better option</a>.</p><p>Also, since Nomad is a single binary for the server and client, the installation process is more straightforward since only the binary needs to be copied to the destination servers with its respective configuration file to have a functional cluster. Tools like Terraform and Packer make this process even simpler and more automated. Nomad can be packaged as part of a VM image using Packer; thus, upgrading the cluster is a matter of spinning new images using the new VM image. And when paired with Terraform, a set of clusters can be created or upgraded in a matter of minutes. In Kubernetes, the installation is much more complex as it is composed of several components for the server (the control plane) and clients (the data plane), to the point that several tools cover different use cases to install Kubernetes. Granted, there are the managed offerings by many cloud providers that abstract part of this complexity avoiding the need to do your own cluster installation, but still, the data plane components are usually managed by the user of the cluster, still needing to deal with manual updates, version compatibility with the control plane, etc.</p><p>This means that small operations teams can handle the administrative tasks of a Nomad cluster. For example, <a href="https://www.roblox.com/">Roblox</a>, one of the biggest online gaming platforms, uses a team of just <a href="https://www.datocms-assets.com/2885/1582055208-hashicorprobloxcasestudy.pdf">4 SRE engineers</a> to administer a cluster of more than 11,000 nodes. And let&#39;s not forget Nomad&#39;s <a href="https://developer.hashicorp.com/nomad/tutorials/manage-clusters/federation">integrated cluster federation support</a> without the need for the installation, upgrading, and maintenance of third-party<a href="https://github.com/kubernetes-sigs/kubefed"> tools</a> like it is needed with Kubernetes, making the setup of hybrid or multi-cloud clusters easier. But let&#39;s put aside the technical details and talk about other things that are also critical when reviewing a project, like economics, available community, and third-party tools and integrations to extend functionalities.</p><p>Looking at economics, with Kubernetes, costs can be higher because Kubernetes needs more hardware resources to run all its control and data plane components than Nomad for its single binary. And because Nomad is more effective at packing scheduled workloads into clients, fewer resources are needed to execute them, allowing more workloads to be executed in the same resources. Another of Roblox&#39;s gains was that they could <a href="https://www.datocms-assets.com/2885/1582055208-hashicorprobloxcasestudy.pdf">double the number of game servers</a> they run on the same hardware. Also, having a smaller operations team with Nomad also means less operative costs. In a few words, <em>Nomad allows doing more with less.</em></p><p>Community-wise, Nomad&#39;s community is still far smaller than Kubernetes&#39;s community. This means that currently, there are fewer contributions to the project, and most of the development is done by HashiCorp. Someone planning to use Nomad will have a more challenging time getting adequate support and finding engineers experienced with this platform. The same happens with third-party tools and integrations with other products to extend Nomad features. Kubernetes has a far more extensive ecosystem, and as such, it can be extended in many ways that Nomad still can&#39;t. But at least HashiCorp has worked on extending its ecosystem by <a href="https://developer.hashicorp.com/nomad/docs/ecosystem">supporting the most widely used tools</a> by Cloud engineers.</p><p>Another important difference is scalability. Both platforms have been designed to scale to large cluster sizes of thousands of nodes. According to the <a href="https://kubernetes.io/docs/setup/best-practices/cluster-large/">Kubernetes documentation</a>, Kubernetes can support clusters with up to 5,000 nodes orchestrating a maximum of 300,000 containers. But some performance tests done with Nomad have shown that it can outpace Kubernetes in terms of cluster size, exceeding 11,000 nodes in production with millions of containers.</p><h3>When should I use one or the other?</h3><p>There isn&#39;t a definitive answer to give; it all depends on what the requirements of a project are. There are many factors to evaluate to make an informed decision. For example, if a company has not migrated to the cloud, is in the process of doing it, or has workloads that cannot or do not need to be migrated, Nomad could make more sense. With Nomad, both containerized and non-containerized workloads like virtual machines could be managed with the same set of tools, using a unified deployment workflow that simplifies the work of the operations team and allows a smooth migration path, even if those workloads are executed in different places (like in a datacenter for the virtual machines and a cloud provider for the already migrated applications).</p><p>Another case where Nomad could be a good fit is when performance and scalability are key. Suppose you are planning to run massive workloads that expand thousands of nodes or millions of containers, like 3D rendering batch processes or handling networks of IoT devices. In that case, Nomad can be a better option as it has been proven to escalate to such sizes maintaining performance and optimizing the resources in use.</p><p>But for a company with a large budget with cloud-native applications, it may make more sense to go with Kubernetes due to its large community, third-party tools ecosystem, and broad cloud provider support (I&#39;m curious why HashiCorp doesn&#39;t have a hosted Nomad version as they do with some of their other products). But if budget is an issue, you should consider Nomad a viable option. So, which one to use? As you can see, it depends on your use case, but Nomad can be a better option for some use cases.</p><h3>Conclusions</h3><p>In this article, we did a brief introduction to what HashiCorp Nomad is, its vision, design, and architecture. We reviewed what it can do and how it does compare to other orchestrators like Kubernetes and talked about when Nomad could be a suitable option and when Kubernetes could be a better option.</p><p>In the case of containerized workloads, Kubernetes may be a better option for cloud-native applications with more complex use cases that may require additional third-party tools as part of the Kubernetes ecosystem. But Nomad&#39;s vision is to be a generic workload orchestrator that is simpler to install and operate; for companies that have mixed workloads and a smaller budget and that are in the process of migrating to containerized workloads, Nomad can be a better option by allowing them to use a single platform to orchestrate everything with a smaller team dedicated to its operation. Additionally, not all workloads can be migrated to containers or do not make sense to migrate them, such as Windows games that make extensive use of GPU hardware or IoT processes that run in embedded devices, which is another reason to use Nomad.</p><p>Lastly, I recommend you check out some of <a href="https://developer.hashicorp.com/nomad/docs/who-uses-nomad">Nomad&#39;s case studies</a> to see how other companies in different areas of IT are using it. In the following articles, we will go deeper into Nomad&#39;s inner workings and set up a Nomad local development environment to run some Jobs and test some of its main features; stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54d875e3914e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/no-workload-left-behind-how-to-orchestrate-with-hashicorp-nomad-54d875e3914e">No Workload Left Behind: How to orchestrate with HashiCorp Nomad</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Drone.io CI/CD platform Part 3]]></title>
            <link>https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-part-3-15a3831cabf2?source=rss-8c6edd7c7991------2</link>
            <guid isPermaLink="false">https://medium.com/p/15a3831cabf2</guid>
            <category><![CDATA[globant]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[drone-io]]></category>
            <category><![CDATA[cicd-tools]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Juan Luis Baptiste]]></dc:creator>
            <pubDate>Mon, 05 Sep 2022 14:04:03 GMT</pubDate>
            <atom:updated>2022-09-05T15:31:38.031Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*cxX3whDsn3bOpcUe" /></figure><h3>Introduction</h3><p>This is the third and last part of this “Introduction to Drone.io CI/CD” series. On this last article, we are going to discuss some last important topics to complete this Drone overview, like:</p><ul><li>The Drone command line interface</li><li>Kubernetes’s secrets integration</li><li>Build promotions and rollbacks</li><li>How to do debugging</li></ul><p>Like in the previous articles, we will demonstrate all these features with detailed instructions on how to set them up and a hands-on lab.</p><h3>Prerequisites</h3><p>Before continuing, remember to go through the previous articles (part <a href="https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-1d43f8bc1728">one</a> and <a href="https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-part-2-fa9fdc6a3659">two</a>), to get the lab setup up and running to be able to perform the tasks from this article. As a quick recap, if you have been following these article’s series from your laptop and have already done all the needed setup and want to get it running for this article, you need to:</p><ul><li>Start <em>ngrok</em> and take note of the assigned hostname.</li><li>Go to your GitHub OAuth application settings page and update the <em>Homepage URL</em> and <em>Application callback URL</em> with the new ngrok hostname.</li><li>Go to the repository <em>webhook settings</em> and also update the hostname with the new ngrok hostname.</li><li>Start minikube cluster (if you have done the previous labs, you should have it ready with Drone already installed and configured, and the example guestbook application deployed).</li></ul><p>Let’s also review the commands needed to get the lab ready to continue with this article’s lab. First, run the following <em>kubectl</em> command to expose the Drone server using port forwarding:</p><pre>$ sudo kubectl — namespace drone port-forward svc/drone 80:80</pre><p>Access <a href="http://localhost/">http://localhost</a>, and you should have access to the Drone web interface. The <em>.drone.yaml</em> file is located at the root of the <a href="https://github.com/juanluisbaptiste/kubernetes-engine-samples"><em>kubernetes-engine-samples</em></a> repository. Inside this repository, we are using the <a href="https://github.com/juanluisbaptiste/kubernetes-engine-samples/tree/main/guestbook">guestbook</a> application for this lab. The Kubernetes manifests are inside that folder, and the frontend code is inside the <a href="https://github.com/juanluisbaptiste/kubernetes-engine-samples/tree/main/guestbook/php-redis"><em>php-redis</em></a> folder. To access the frontend application, you can use the <em>minikube service</em> command:</p><pre>$ minikube service frontend -n guestbook-demo</pre><p>Now we are ready to continue!</p><h3>Drone Command Line Interface (CLI)</h3><p>Drone <a href="https://docs.drone.io/quickstart/cli/">provides a command line interface</a> program to interact with a Drone server remotely. This CLI can be used to perform administrative tasks on the server, like viewing logs, managing users, secrets and <a href="https://docs.drone.io/template/">pipeline templates</a>. It can also be used to manage repositories, build jobs, cronjobs or <a href="https://docs.drone.io/cli/drone-exec/">execute local builds</a>. In this section, we are going to review some of those tasks.</p><h4>Installation and Configuration</h4><p>The installation of the CLI program is fairly easy, basically, download your platform’s binary to a directory in your user’s path and give it execution permissions. For example, for Linux you can use these commands:</p><pre>$ curl -L <a href="https://github.com/harness/drone-cli/releases/latest/download/drone_linux_amd64.tar.gz">https://github.com/harness/drone-cli/releases/latest/download/drone_linux_amd64.tar.gz</a> | tar zx</pre><pre>$ sudo install -t /usr/local/bin drone</pre><p>For other platforms, look at the official <a href="https://docs.drone.io/cli/install/">installation instructions</a>.</p><h4>Usage</h4><p>After the binary is installed, it needs to be <a href="https://docs.drone.io/cli/configure/">configured</a> to connect to the Drone server using environment variables. First, export the Drone server address:</p><pre>$ export DRONE_SERVER=http://drone.mycompany.com</pre><p>For this lab, the server address would be the ngrok hostname. Then, export the Drone personal token:</p><pre>$ export DRONE_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…</pre><p>Remember, the personal token is obtained from the user profile page in the Drone server web interface. After the previous variables have been exported, the CLI command can be executed. To test the CLI command, run this:</p><pre>$ drone info<br>User: yourgithubusername<br>Email: juan@youremaildomain.com</pre><h3>Kubernetes Secrets Integration</h3><p>Drone.io can be <a href="https://docs.drone.io/secret/external/">integrated with many external secret storage tools</a>, and allow the secrets stored in those tools to be used in a pipeline. With this feature, Kubernetes’s secrets can be used instead of Drone secrets. For Drone to be able to access Kubernetes secrets, three things needs to be done:</p><ul><li>Install the <a href="https://docs.drone.io/runner/extensions/kube/">Drone Kubernetes secrets extension</a></li><li>Create the Kubernetes secrets</li><li>Add the secrets resources to the Drone pipeline to access the Kubernetes secrets.</li></ul><h4>Extension Install</h4><p>The extension can be installed too <a href="https://github.com/drone/charts/blob/498bf298c0000acafa47b43308f4d06c6ab40e66/charts/drone-kubernetes-secrets/README.md">using a Helm chart</a>. First, the extension needs to be configured with a Helm <em>values.yaml</em> file, like the following one:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f00012bac5872e87aafe5e5c93439310/href">https://medium.com/media/f00012bac5872e87aafe5e5c93439310/href</a></iframe><p>Replace the value of SECRET_KEY with your own secret. You can create a random one with the <em>openssl</em> command:</p><pre>$ openssl rand -hex 16<br>a6ca63b531427e3165224112e02b1697</pre><p>Also, as you can see in the previous example, the extension will look for secrets in the default namespace, so if you want to use a different one, then the values of <em>secretNamespace</em> and <em>KUBERNETES_NAMESPACE</em> must be updated with the namespace to be used. Look at the <a href="https://docs.drone.io/runner/extensions/kube/">documentation</a> for other variables to set additional to the shared secret.</p><p>Save this file as <em>drone-kubernetes-secrets.yaml</em>, and then install the extension with the following Helm command:</p><pre>$ helm install — namespace drone drone-kubernetes-secrets drone/drone-kubernetes-secrets -f drone-kubernetes-secrets-values.yaml</pre><pre>NAME: drone-kubernetes-secrets<br>LAST DEPLOYED: Wed Jul 20 15:22:50 2022<br>NAMESPACE: drone<br>STATUS: deployed<br>REVISION: 1<br>TEST SUITE: None</pre><p>To check the extension was successfully installed, check the pod logs:</p><pre>$ kubectl — namespace drone logs \<br>-l ‘app.kubernetes.io/name=drone-kubernetes-secrets’ \<br>-l ‘app.kubernetes.io/component=drone-kubernetes-secrets’</pre><pre>time=”2020–01–29T00:02:18Z” level=info msg=”server listening on address :3000&quot;</pre><p>If you see in the last line a message saying “server listening on address :3000”, the extension is working as expected. The next step is to update the runners and configure them to use the Kubernetes secrets extension. For this, the runner’s Helm values file needs to be updated, adding the following configuration variables in the <em>env:</em> section of the file:</p><pre>DRONE_SECRET_PLUGIN_ENDPOINT: <a href="http://drone-kubernetes-secrets:3000/">http://drone-kubernetes-secrets:3000</a><br>DRONE_SECRET_PLUGIN_TOKEN: your-shared-secret-value-here</pre><p>Replace the value of <em>DRONE_SECRET_PLUGIN_TOKEN</em> variable with the secret value configured previously during the Kubernetes secrets installation. Leave the value of <em>DRONE_SECRET_PLUGIN_ENDPOINT</em> unmodified. Then, update the runner’s install using Helm:</p><pre>$ helm upgrade — namespace drone drone-runner-kube drone/drone-runner-kube -f drone-runner-kube-values.yaml</pre><pre>Release “drone-runner-kube” has been upgraded. Happy Helming!<br>NAME: drone-runner-kube<br>LAST DEPLOYED: Wed Jul 20 15:26:32 2022<br>NAMESPACE: drone<br>STATUS: deployed<br>REVISION: 2<br>TEST SUITE: None</pre><h4>Kubernetes Secrets Creation</h4><p>Now, create the Kubernetes secrets using <em>kubectl</em>. We are going to create all the secrets in use in the guestbook example application pipeline used in the previous article:</p><ul><li>Docker Hub credentials</li><li>The minikube parameters (CA certificate, server address and token)</li></ul><p>This manifest file can be used as a template to create the secrets:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39e46d3645e4e24c880048b4db5c68f3/href">https://medium.com/media/39e46d3645e4e24c880048b4db5c68f3/href</a></iframe><p>All values need to be base 64 encoded. To encode simple values, the following command can be used:</p><pre>$ echo -n value | base64</pre><p>For example,</p><pre>$ echo -n juanluisbaptiste | base64<br>anVhbmx1aXNiYXB0aXN0ZQ==</pre><p>Use that command to encode the docker hub username and password, and the minikube server address. Note the use of the -n parameter to avoid adding an end of line, this is crucial.</p><p>For the minikube CA certificate we can refer to the previous article as we already encoded it before with this command:</p><pre>$ cd ~/.minikube<br>$ cat ca.crt|base64 -w 0</pre><p>Note the use of the -w 0 parameter, it is used to disable line wrapping, so we get the encoded value in a single line, needed because of the length of the certificate value.</p><p>To encode the minikube token, we can also use the command given in the previous article to obtain its value, but with one small modification. Before, the token value was already base 64 encoded, and was decoded when extracted, so the command will be modified to avoid the base64 decoding:</p><pre>$ kubectl get secret `kubectl get secret -n kube-system|grep default|awk ‘{print $1}’|grep -v NAME` -o go-template=’{{ .data.token }}’ -n kube-system<br>S0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCakNDQWU2Z0F3SUJBZ0lCQVRBTkJna3Foa2lHOXcwQkFR<br>[…]</pre><p>After all values have been encoded, copy-paste them in the previous secrets manifests file and save it as <em>kubernetes-secrets.yaml</em>. Then, create the secrets with this command in the default namespace:</p><pre>$ kubectl apply -f kubernetes-secrets.yaml -n default<br>secret/docker configured<br>secret/k8s configured</pre><h4>Add Secrets Resources to Pipeline</h4><p>The last thing to do is to add the new secret resources to the Drone pipeline for the new Kubernetes secrets. Add the following secret definitions at the beginning of the <em>.drone.yml</em> file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7082c9de2ca6e09c8b109528fbe1615b/href">https://medium.com/media/7082c9de2ca6e09c8b109528fbe1615b/href</a></iframe><p>With those secrets resource definitions, the secret values used by the pipeline will be fetched from the Kubernetes secrets that were previously created.</p><h3>Pipeline Promotions</h3><p>Pipeline promotions is a very cool feature that can be used to move or “promote” a build output to a target environment. Promotions allow deploying code already built in a pipeline into different environments (dev, test, staging, prod, etc.), by running a new pipeline that only executes the deployment steps. These environments would be the infrastructure where applications should be deployed to be used, for example, a Kubernetes cluster. These image promotions have many advantages:</p><ul><li>Create repeatable deployments: be confident that every time a build is promoted to a different environment, it will always be the same code being deployed.</li><li>Improve the release times of new versions: When using promotions, the image with the new application code is built once and then moved around between environments until it ends up in the desired environment with the least amount of friction between development and operation teams.</li><li>Create an audit trail of versions being deployed: Know which image versions have been deployed on each environment at any time.</li><li>Segregation of duties: Let the QA team promote a new version between environments after their quality tests have passed, instead of having the operations team do it when QA needs it. This way, development teams can make new application versions available in a versioned manner, and QA and release managers can test and release these new versions to production when they feel confident, at their own pace.</li><li>Easily roll back a promoted image version to a previously one known to be working from a previous build.</li></ul><h4>How promotions work</h4><p>When promoting a build, Drone launches a new build of the application’s pipeline. This new build has its own build number, and inherits all the build parameters from the build being promoted. The new build will have its event type set to <em>promote</em>, which can be used to target a deployment environment in your infrastructure by using it in a trigger condition in the pipeline.</p><p>The Drone pipeline should define the steps needed to deploy the application somewhere, and then, the deployment target can be selected using the <em>promote</em> event type in a <em>trigger</em> (at pipeline level) or a <em>when</em> condition (at step level), combined with any other desired conditions.</p><p>From the <a href="https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-part-2-fa9fdc6a3659">previous article</a>, we already defined a pipeline that deploys to a local minikube cluster, so we will continue from there to demonstrate this feature.</p><h4>Promoting a Pipeline</h4><p>Continuing with the lab from the <a href="https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-part-2-fa9fdc6a3659">previous article</a>, there are two tasks needed to be done to use the pipeline promote feature. First, we have to modify the Drone pipeline and split it in two different pipelines: one for building and tagging the image and another for deploying it to a specific environment. Second, the application’s frontend manifest file has to be modified to deploy the image tag that was built and tagged with a git tag in the build pipeline. This also will allow us to do version rollbacks to specific versions from previous deployment pipelines.</p><p>To split the pipeline, add a new pipeline definition, give it a name and move the deployment steps to it. This is an example of how the file should look, but you can see the finished file <a href="https://github.com/juanluisbaptiste/kubernetes-engine-samples/blob/main/.drone.yml">here</a>:</p><pre>[ … <em>secrets definitions here</em> … ]<br>---<br>kind: pipeline<br>type: kubernetes<br>name: build</pre><pre>steps:<br>  - name: Build docker image<br>    image: plugins/docker<br>    settings:<br>      repo: juanluisbaptiste/guestbook-demo<br>      dockerfile: guestbook/php-redis/Dockerfile<br>      context: guestbook/php-redis<br>      username:<br>        from_secret: docker_username<br>      password:<br>        from_secret: docker_password<br>    tags:<br>      - latest<br>      - ${DRONE_BUILD_NUMBER}<br>    when:<br>      event:<br>        - push<br>        - pull_request<br>        - custom<br>  <strong>- name: Tag docker image<br>    image: plugins/docker<br>    settings:<br>      repo: juanluisbaptiste/guestbook-demo<br>      dockerfile: guestbook/php-redis/Dockerfile<br>      context: guestbook/php-redis<br>      username:<br>        from_secret: docker_username<br>      password:<br>        from_secret: docker_password<br>    tags:<br>      - latest<br>      - ${DRONE_TAG}<br>    when:<br>      event:<br>        - tag<br>---<br>kind: pipeline<br>type: kubernetes<br>name: deploy</strong></pre><pre><strong>steps:<br></strong>- name: Deploy frontend deployment<br>  image: danielgormly/drone-plugin-kube:0.2.0<br>  settings:<br>    <strong>image_tag: ${DRONE_TAG}<br>    </strong>template: guestbook/frontend-deployment.yaml<br>    namespace: guestbook-demo<br>    ca:<br>      from_secret: k8s_crt<br>    server:<br>      from_secret: k8s_server<br>    token:<br>      from_secret: k8s_token<br>  <strong>trigger:<br>    event:<br>      - promote<br>      - rollback<br>    target:<br>      - production</strong></pre><pre>[ … <em>rest of deployment steps</em> … ]</pre><p>I have highlighted in bold the new parts. Notice that we added another step to tag the image in the build pipeline. How it is defined is not the optimal way to do it as the image is being built twice (the image should be built in the build step only, but it is enough to demonstrate this feature). Also notice this new step has its condition defined to trigger with the <em>tag</em> event, and in the tags section, there’s a tag that uses the <em>${DRONE_TAG}</em> variable. This variable contains the value of the git tag that triggered the build.</p><p>Now, onto the deployment pipeline. To keep things simple, we are going to have only one environment where to deploy the example application. Normally, a project would have at least a staging and production environments, but for this demonstration with only production will suffice.</p><p>In the <em>deploy</em> pipeline, notice that on the first of the deployment steps, the one that deploys the frontend application, we are defining a variable named <em>image_tag</em> that receives the <em>${DRONE_TAG}</em> variable. This variable is passed to the frontend application manifest and used as a template variable. The trigger for this pipeline defines two events: <em>promote</em> and <em>rollback</em>, and adds another trigger called <em>target</em>. This target trigger is used to define the environment for which the pipeline (or step if defined at the step level) will be executed,. On his example, the target is the <em>production</em> environment.</p><p>Now, the frontend application manifest file has to be modified to use this variable:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6fd747132eb6054c4e2cf23b052d9ba/href">https://medium.com/media/f6fd747132eb6054c4e2cf23b052d9ba/href</a></iframe><p>The Kubernetes deployment plugin can parse the manifest file as a template and replace variables like <em>image_tag</em> with their values. This means that the frontend image to be deployed is the one that was tagged with the <em>${DRONE_TAG}</em> variable value. After these modifications are done, we are ready to do a pipeline promotion!</p><p>Commit these changes to your repo first. Now, edit the <a href="https://github.com/juanluisbaptiste/kubernetes-engine-samples/blob/main/guestbook/php-redis/index.html">guestbook/php-redis/index.html</a> file and add some text somewhere to simulate a change that creates a new version of the frontend application. For example, add the text “v2.0.0” to the h2 header and commit and push the change:</p><pre>[…]</pre><pre>&lt;h2&gt;Guestbook v2.0.0&lt;/h2&gt;</pre><pre>[…]</pre><p>The build image step from the build pipeline will trigger and build the image. Notice that now the deploy steps do not trigger because they are now in a separate pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/0*o0cFGYF10VDtC65A" /></figure><p>Wait until the build finishes and create a git tag with the value “v2.0.0”:</p><pre>$ git tag v.2.0.0</pre><p>Push the tag, now the <em>tag</em> step from the build pipeline will trigger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/0*M1n0ET50Jwur3YmM" /></figure><p>After it finishes, you can check in your docker hub repository that you have an image tagged with that tag. Now we are ready to promote the build. At the build triggered by the git tag, click on the three dots menu from the upper-right corner and select <em>Promote</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/171/0*sLdjYIiDiNHRDV_h" /></figure><p>On the <em>target</em> field write <em>production </em>(that is the name of the environment we defined in the <em>target </em>field of the trigger in the deployment pipeline), leave the rest of fields as it is and click ”Deploy”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/0*yqlukGLRhwwre4rf" /></figure><p>Now the <em>Deploy</em> pipeline will start and do the deployment of the frontend application image tagged with the git tag in the <em>production</em> target environment:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/0*FsrnlZSf_socuenU" /></figure><p>Go to the frontend application URL and the changes to the <em>index.html</em> file we just did should be visible:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/0*X5WfszGheqJH6cAB" /></figure><p>The build was promoted and deployed as expected. You can check the pods, and see that they were re-created:</p><pre>$ kubectl -n drone get pods<br>NAME                             READY STATUS  RESTARTS AGE<br>frontend-56d74fbb4b-crj9t        1/1   Running 0        36s<br>frontend-56d74fbb4b-qcfz5        1/1   Running 0        48s<br>frontend-56d74fbb4b-zw9tt        1/1   Running 0        30s<br>redis-follower-594666cdcd-dbd4f  1/1   Running 6        2d<br>redis-follower-594666cdcd-l6s8c  1/1   Running 6        2d<br>redis-leader-fb76b4755-bhfzh     1/1   Running 6        2d</pre><p>Also check the image tag that was used:</p><pre>$ kubectl describe pod/frontend-56d74fbb4b-crj9t</pre><pre>[...]<br>Containers:<br>  php-redis:<br>    Container ID: docker://426fb895586bd1415faaba8cb84b6a7edc475a5a7a82162132e2415f3270c86a<br>    Image: <strong>juanluisbaptiste/guestbook-demo:v2.0.0<br></strong>[...]</pre><p>Now, let’s do another modification to the frontend application. Edit again the <em>index.html</em> file and change the version text to “v2.1.0”:</p><pre>[…]</pre><pre>&lt;h2&gt;Guestbook v2.1.0&lt;/h2&gt;</pre><pre>[…]</pre><p>Commit and push the change, wait until the build finishes and create a git tag with the value “v2.1.0”:</p><pre>$ git tag v.2.1.0</pre><p>Push the tag to trigger the deployment, wait for it to finish and then promote again this new build (of v 2.1.0):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/0*Y1IgyEeDvvQc63hf" /></figure><p>After the pipeline finishes, go back to the frontend application and reload the page, you should see the new changes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/0*swJuKG47qxin5Anw" /></figure><p>As you can see, promoting a build is a straightforward and convenient way to move an application’s new version across environments. Promotions can also be executed using the CLI interface. This example could also have been done like this:</p><pre>$ drone build promote juanluisbaptiste/kubernetes-engine-samples 68 production</pre><pre>Number: 70<br>Status: pending<br>Event: promote<br>Commit: 1fbf81df2adf8753df698fc9ae1546127d54aa6e<br>Branch:<br>Ref: refs/tags/v2.1.0<br>Author: juanluisbaptiste &lt;juan@xxxxxx.tech&gt;<br>Message: Increase version text to v2.1.0</pre><p>You could use the cli to programaticallt do the pipeline promotion after a successful set of tests finish. Now we can check how to roll back to a previous version.</p><h4>Rolling back a Pipeline</h4><p>A <em>rollback</em> is deploying a previous application version deployed in an environment, for example because after the promotion was done, some errors appeared that unfortunately were not caught during testing. Continuing with the example, we are going to roll back from v2.1.0 to v2.0.0.</p><p>Go to the promoted build of v2.0.0:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/0*qC2F1QcH2KMqrFto" /></figure><p>Click again on the three dots menu in the upper-right corner, but this time click on the <em>rollback</em> select box (I know, very weird to have the rollback option inside the promote window!), and again on target put <em>production</em> and click on ”Deploy”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*3nfaWkaJ_Sko6D8K" /></figure><p>The Deploy pipeline will start. Click on the <em>clone</em> job and notice the git ref it checked out:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/0*XfmMhuKGIot60TwA" /></figure><p>As you can see, is the v2.0.0 tag, the pipeline is using the correct version for the rollback deployment. After the pipeline finishes, go back to the frontend application and refresh, you should see again the old v2.0.0 version!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/0*-xPGS_jAbkjkHCav" /></figure><h3>Debugging</h3><p>If you are having issues with your Drone setup, be it the server setup or while executing a build pipeline, there are some tools that will help you debug the issue and find out what is going on. The first thing to do when debugging an issue is reviewing <a href="https://docs.drone.io/cli/drone-log/">logs</a>. Drone has two types of logs:</p><ul><li>Server and agent logs</li><li>Pipeline build logs</li></ul><p>To see the server or agent logs, use the <em>kubectl</em> command, for example:</p><pre>$ kubectl -n drone get pods</pre><pre>NAME                                READY STATUS  RESTARTS AGE<br>drone-6c4c8dd65c-7rxdn              1/1   Running 2        4d<br>drone-runner-kube-7f79d87b75-fffn5  1/1   Running 2        4d</pre><pre>$ kubectl -n drone logs drone-6c4c8dd65c-7rxdn — tail 10</pre><pre>{“arch”:””,”kernel”:””,”kind”:”pipeline”,”level”:”debug”,”msg”:”manager: request queue item”,”os”:””,”time”:”2022–07-20T02:36:55Z”,”type”:”kubernetes”,”variant”:””}{“arch”:””,”kernel”:””,”kind”:”pipeline”,”level”:”debug”,”msg”:”manager: context canceled”,”os”:””,”time”:”2022–07–20T02:37:25Z”,”type”:”kubernetes”,”variant”:””}{“arch”:””,”kernel”:””,”kind”:”pipeline”,”level”:”debug”,”msg”:”manager: request queue item”,”os”:””,”time”:”2022–07-20T02:37:35Z”,”type”:”kubernetes”,”variant”:””}{“arch”:””,”kernel”:””,”kind”:”pipeline”,”level”:”debug”,”msg”:”manager: context canceled”,”os”:””,”time”:”2022–07–20T02:38:05Z”,”type”:”kubernetes”,”variant”:””}{“arch”:””,”kernel”:””,”kind”:”pipeline”,”level”:”debug”,”msg”:”manager: request queue item”,”os”:””,”time”:”2022–07-20T02:38:15Z”,”type”:”kubernetes”,”variant”:””}{“arch”:””,”kernel”:””,”kind”:”pipeline”,”level”:”debug”,”msg”:”manager: context canceled”,”os”:””,”time”:”2022–07–20T02:38:45Z”,”type”:”kubernetes”,”variant”:””}{“arch”:””,”kernel”:””,”kind”:”pipeline”,”level”:”debug”,”msg”:”manager: request queue item”,”os”:””,”time”:”2022–07-20T02:38:55Z”,”type”:”kubernetes”,”variant”:””}{“arch”:””,”kernel”:””,”kind”:”pipeline”,”level”:”debug”,”msg”:”manager: context canceled”,”os”:””,”time”:”2022–07–20T02:39:25Z”,”type”:”kubernetes”,”variant”:””}{“arch”:””,”kernel”:””,”kind”:”pipeline”,”level”:”debug”,”msg”:”manager: request queue item”,”os”:””,”time”:”2022–07-20T02:39:35Z”,”type”:”kubernetes”,”variant”:””}{“arch”:””,”kernel”:””,”kind”:”pipeline”,”level”:”debug”,”msg”:”manager: context canceled”,”os”:””,”time”:”2022–07–20T02:40:05Z”,”type”:”kubernetes”,”variant”:””}</pre><p>To look at the agent logs, run the same command, but with the agent pod. If needed, logs verbosity can be increased with <a href="https://docs.drone.io/runner/nomad/configuration/reference/drone-debug/"><em>DRONE_DEBUG</em></a> and <a href="https://docs.drone.io/runner/nomad/configuration/reference/drone-trace/"><em>DRONE_TRACE</em></a> environment variables. To set those variables, add them to the server or agent Helm configuration files (<em>drone-server-values.yaml</em> and <em>drone-runner-kube-values.yaml</em> in this lab), and redeploy the server and agent. To view the logs of a Drone repository, use the following command:</p><pre>drone log view &lt;repo/name&gt; &lt;build&gt; &lt;stage&gt; &lt;step&gt;</pre><p>For example:</p><pre>$ drone log view kubernetes-engine-samples 23 1 1</pre><pre>Initialized empty Git repository in /drone/src/.git/<br>+ git fetch origin +refs/heads/main:<br>From <a href="https://github.com/juanluisbaptiste/kubernetes-engine-samples">https://github.com/juanluisbaptiste/kubernetes-engine-samples</a><br>* branch main -&gt; FETCH_HEAD<br>* [new branch] main -&gt; origin/main<br>+ git checkout dd284331e3d24b5c9ab1b29cf5a0c00c18afbb10 -b main</pre><p>To tell the truth, it is a little weird to have to see the log of a build stage by stage, instead of being able to pull the whole log of a pipeline in one single call.</p><p>And of course, the CLI can also be used to trigger a rollback:</p><pre>$ drone build rollback juanluisbaptiste/kubernetes-engine-samples 63 production</pre><h3>Conclusions</h3><p>We have covered a lot of ground since we started this journey to explore Drone.io Continuous Integration and Delivery platform. We went from a <a href="https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-1d43f8bc1728">simple docker deployment to test some of Drone’s core features</a>, to <a href="https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-part-2-fa9fdc6a3659">deploy it in a local Kubernetes cluster using minikube</a>, where we tested other more advanced features like, integration with Kubernetes secrets, pipeline promotions and rollbacks, and the usage of its versatile CLI tool. There are still many more features to explore, but what we have covered until now can give you a good grasp of some of its main features.</p><p>I have seen Drone.io improve by leaps and bounds since I started using it many years ago around 0.5 version. There were few plugins available, something that has drastically changed over the years, even thought that other more traditional CI/CD platforms like Jenkins have a wider support of integration with 3rd party tools, drone has come to have more than one hundred plugins available that cover the most popular tools. But in what Drone.io shines is in the simplicity of their pipelines, its small footprint and how simple is it to install it and get it going. Being a cloud native tool built with docker containers makes its installation trivial, even in Kubernetes, thanks to the Helm charts. Also, as plugins are built as a docker image, they can be written in any language, using environment variables to expose its configuration, making it fairly easy to extend its functionality as needed.</p><p>One feature that is still missing, thought, is giving some love to the Kubernetes deployment. Currently, the only way to deploy to a Kubernetes cluster is by using one of the Open Source plugins, that aren’t developed by Drone.io, but by third-party contributors. Unfortunately, I do not think this is going to improve as Harness, the parent company of Drone.io, offers its own Continuous Delivery solution to complement Drone.io as a Continuous integration tool. I understand this, but I hope that Drone.io could deliver a functioning Kubernetes deployment plugin for basic use cases.</p><p>I hope you enjoyed reading this series of articles about Drone.io, as much as I enjoyed writing them, finding them useful and insightful as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15a3831cabf2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-part-3-15a3831cabf2">Introduction to Drone.io CI/CD platform Part 3</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to drone.io CI/CD platform Part 2]]></title>
            <link>https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-part-2-fa9fdc6a3659?source=rss-8c6edd7c7991------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa9fdc6a3659</guid>
            <category><![CDATA[cloudops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[drone-ci]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cicd-tools]]></category>
            <dc:creator><![CDATA[Juan Luis Baptiste]]></dc:creator>
            <pubDate>Wed, 01 Jun 2022 16:22:41 GMT</pubDate>
            <atom:updated>2022-06-01T16:22:41.929Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3ZWm4YKJR0zh_RPZ" /></figure><h3>Introduction</h3><p>This is the second part to my <a href="https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-1d43f8bc1728">Introduction to Drone.io</a> article I wrote some weeks ago. On this article, we are going to deploy Drone on a Kubernetes cluster using <a href="https://helm.sh/">Helm charts</a>, and build and deploy an example application on that cluster using Drone.</p><p>Like in the previous article, we will do a local Drone deployment for testing purposes only, there are many other elements needed to be configured for a proper production installation, like https, volumes configuration, secrets handling, permissions, load balancer or an ingress controller, etc. Those topics will be covered in future posts.</p><p>For this lab, we will be using <a href="https://minikube.sigs.k8s.io/docs/">minikube</a> as the Kubernetes cluster to follow the instructions of this laboratory, but any other Kubernetes engine could be used too. To access Drone interface again, we will be using <a href="https://ngrok.com/">ngrok</a>, please refer to the <a href="https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-1d43f8bc1728">previous post</a> for instructions on how to set it up.</p><p>The following sections will be reviewed in this article:</p><ul><li>Architecture</li><li>Kubernetes Deployment</li><li>Accessing Drone Interface</li><li>Deploying Example Application</li><li>Conclusions</li></ul><h3>Architecture</h3><p>Let’s recap Drone architecture components:</p><ul><li>Drone server</li><li>Drone agents (called runners)</li><li>Drone pipeline configuration file (on each git repository)</li><li>An SCM repository where applications to be delivered by Drone live</li></ul><p>This was the architecture diagram that depicted the interaction between all components in the previous article:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jp3D3q6WK-ptFgVIGhRL9w.png" /><figcaption>Drone.io architecture diagram</figcaption></figure><p>Now let’s see how those components fit into a Kubernetes cluster:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xIaEAuF_-72X_SMRl6PXIQ.png" /><figcaption>Drone.io Kubernetes deployment diagram</figcaption></figure><p>In a Kubernetes cluster, the server and runners will run as pods controlled by a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/"><em>ReplicaSet</em></a> and deployed by a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/"><em>Deployment</em></a> resource, which gives high availability and scalability to the Drone installation. The Drone pipelines will be executed in any of the pods of the runners available in any of the cluster nodes. The pods can escalate according to the build load being executed in the server and runners.</p><h3>Kubernetes Deployment</h3><h3>Prerequisites</h3><ul><li>A Kubernetes cluster like <a href="https://minikube.sigs.k8s.io/">minikube</a>.</li><li>Helm package manager.</li><li>Kubernetes CLI, <a href="https://kubernetes.io/docs/reference/kubectl/kubectl/">kubectl</a> command</li><li>A publicly accessible hostname that points to the Drone server. Because this lab is a local install, we will use again ngrok to get a public hostname.</li><li>SCM platform OAuth ID and token. For this article, we will be using GitHub, please refer to the previous article to read how to set this up, or the<a href="https://docs.drone.io/server/overview/"> official documentation</a> for instructions on how to set up other SCM platforms.</li><li>A secret for communication between server and runners. This is just a string of text that will be used as a password between them.</li><li>GitHub and Docker Hub accounts.</li></ul><p>Let’s recap the things you need to do from the previous article before starting to deploy Drone in Kubernetes:</p><ul><li>Run ngrok:</li></ul><pre>$ ngrok http 80</pre><ul><li>Create a GitHub OAuth application (or update the existing one if you did the lab from the previous article), configure it like explained in the previous article, using the ngrok URL from the previous step.</li></ul><p>Now we are ready to start this lab!</p><h3>Installing minikube</h3><p>Minikube installation is fairly simple, we are using Linux as the platform for this laboratory, if you are using any other platform, please refer to minikube <a href="https://minikube.sigs.k8s.io/docs/start/">installation instructions</a>. First, download minikube binary and install it. From a terminal run:</p><pre>$ curl -LO <a href="https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64">https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64</a></pre><pre>sudo install minikube-linux-amd64 /usr/local/bin/minikube</pre><p>After doing this, we are ready to start a minikube local cluster. From a terminal as a non-root user, run:</p><pre>$ minikube start</pre><p>Wait some minutes while minikube starts a Virtual Box machine for both the master and a worker node. After the minikube cluster finishes booting up, test it by running <em>kubectl</em> commands. You can <a href="https://kubernetes.io/docs/tasks/tools/">install <em>kubectl</em></a>, or use minikube to install it according to the current minikube Kubernetes version:</p><pre>$ minikube kubectl — get po -A</pre><p>To ease usage, add it as an alias of the shell script, add the following line to the configuration file of your shell:</p><pre>alias kubectl=”minikube kubectl --“</pre><p>Now we can use kubectl to access the cluster. For example, let’s check out the cluster nodes:</p><pre>$ kubectl get nodes<br>NAME     STATUS ROLES                AGE VERSION</pre><pre>minikube Ready  control-plane,master 29d v1.21.2</pre><p>If you cannot see an output similar to that one or any kind of error, you should follow the <a href="https://minikube.sigs.k8s.io/docs/handbook/troubleshooting/">troubleshooting</a> documentation.</p><h3>Installing Helm</h3><p>Helm installation is as easy as minikube. There are packages for different OS’s, but to install the latest version, download the official installation script and run it:</p><pre>$ curl -fsSL -o get_helm.sh <a href="https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3">https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3</a><br>$ chmod 700 get_helm.sh<br>$ ./get_helm.sh</pre><p>Test that helm was installed correctly:</p><pre>$ helm version<br>version.BuildInfo{Version:”v3.8.2&quot;, GitCommit:”6e3701edea09e5d55a8ca2aae03a68917630e91b”, GitTreeState:”clean”, GoVersion:”go1.17.5&quot;}</pre><p>We are now ready to install Drone on the minikube cluster.</p><h3>Installing Server and Runners Using Helm</h3><p>The installation of Drone on Kubernetes consists of installing two components: the server and runners. The first thing to do is to add the official Drone Helm repository:</p><pre>$ helm repo add drone <a href="https://charts.drone.io/">https://charts.drone.io</a><br>“drone” has been added to your repositories</pre><pre>$ helm repo update<br>Hang tight while we grab the latest from your chart repositories……Successfully got an update from the “drone” chart repository</pre><pre>Update Complete. ⎈Happy Helming!⎈</pre><p>After the Helm repository is added, the next step is to create a namespace where the Drone components will be deployed:</p><pre>$ kubectl create ns drone<br>namespace/drone created</pre><h3>Installing the Server</h3><p>When installing a Helm chart, a yaml file that contains the customization of the application being deployed has to be provided to the helm command. These files contain the same configuration parameters we covered in the <a href="https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-1d43f8bc1728">first part</a> of this introduction to Drone, but in yaml format, plus any Kubernetes-specific configuration options. Please refer to that article for an explanation of these values. This is the <em>values.yaml</em> file for the server:</p><pre>env:</pre><pre>  DRONE_SERVER_HOST: xxxxxxxxxx.ngrok.io<br>  DRONE_SERVER_PROTO: http<br>  DRONE_RPC_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>  DRONE_GITHUB_CLIENT_ID: xxxxxxxxxxxxxxxxxxxx<br>  DRONE_GITHUB_CLIENT_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>  DRONE_TLS_AUTOCERT: false<br>  DRONE_USER_CREATE: username:githubuser,admin:true</pre><pre>  # Optional, needed in case to debug<br>  DRONE_LOGS_DEBUG: true<br>  DRONE_LOGS_TRACE: true</pre><p>After the values file has been edited, replace them with your own values and proceed with the server installation:</p><pre>$ helm install — namespace drone drone drone/drone -f drone-server-values.yaml<br>NAME: drone<br>LAST DEPLOYED: Thu May 26 14:15:22 2022<br>NAMESPACE: drone<br>STATUS: deployed<br>REVISION: 1<br>TEST SUITE: None</pre><pre>NOTES:<br>1. Get the application URL by running these commands:<br>export POD_NAME=$(kubectl get pods — namespace drone -l “app.kubernetes.io/name=drone,app.kubernetes.io/instance=drone” -o jsonpath=”{.items[0].metadata.name}”)<br>export CONTAINER_PORT=$(kubectl get pod — namespace drone $POD_NAME -o jsonpath=”{.spec.containers[0].ports[0].containerPort}”)<br>echo “Visit <a href="http://127.0.0.1:8080/">http://127.0.0.1:8080</a> to use your application”<br>kubectl — namespace drone port-forward $POD_NAME 8080:$CONTAINER_PORT</pre><h3>Installing the Runner</h3><p>In the same way, we need to prepare the helm <em>values.yaml</em> file for the runner:</p><pre>rbac:<br>  buildNamespaces:<br>    - drone</pre><pre>Env:<br>  # This secret has to be the same configured on the serverDRONE_RPC_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>  DRONE_NAMESPACE_DEFAULT: drone<br>  # This is the drone server hostname internal to kubernetes, not the external hostname<br>  DRONE_RPC_HOST: drone<br>  DRONE_RPC_PROTO: http<br>  DRONE_RUNNER_NAME: “Drone_kube_runner_1”<br>  DRONE_DEBUG: true<br>  DRONE_TRACE: true</pre><p>After the values file has been edited, proceed with the runner installation:</p><pre>$ helm install — namespace drone drone-runner-kube drone/drone-runner-kube -f drone-runner-kube-values.yaml</pre><pre>NAME: drone-runner-kube<br>LAST DEPLOYED: Thu May 26 14:16:34 2022<br>NAMESPACE: drone<br>STATUS: deployed<br>REVISION: 1<br>TEST SUITE: None</pre><h3>Verifying the Installation</h3><p>To verify the installation was successful, check the deployed resources, all of them should be in the <em>running</em> state:</p><pre>$ kubectl get all -n drone</pre><pre>NAME                                  READY STATUS RESTARTS AGE<br>pod/drone-586c4d64bf-46qt9             1/1  Running 0      2m26s<br>pod/drone-runner-kube-7f79d87b75-fffn5 1/1  Running 0      75s</pre><pre>NAME                      TYPE      CLUSTER-IP EXTERNAL-IP PORT(S) AGE<br>service/drone             ClusterIP 10.101.218.16 &lt;none&gt;   80/TCP 2m26s<br>service/drone-runner-kube ClusterIP 10.111.102.5 &lt;none&gt;    3000/TCP 75s</pre><pre>NAME                              READY UP-TO-DATE AVAILABLE AGE<br>deployment.apps/drone             1/1   1          1         2m26s<br>deployment.apps/drone-runner-kube 1/1   1          1         75s</pre><pre>NAME                                         DESIRED CURRENT READY AGE<br>replicaset.apps/drone-586c4d64bf             1       1       1  2m26s<br>replicaset.apps/drone-runner-kube-7f79d87b75 1       1       1    75s</pre><p>If not, then, to check the pods logs:</p><pre>$ kubectl — namespace drone logs \<br>-l ‘app.kubernetes.io/name=drone’ \<br>-l ‘app.kubernetes.io/component=server’</pre><p>If the server started successfully, you should see a message like this one:</p><pre>time=”2020–05–26T13:49:03Z” level=info msg=”starting the server” addr=”:3000&quot;</pre><p>In the case of the runner, you should see a message like this one:</p><pre>time=”2022–05–26T14:05:05Z” level=info msg=”successfully pinged the remote server”<br>time=”2022–05–26T14:05:05Z” level=info msg=”polling the remote server” capacity=100 endpoint=”http://drone&quot; kind=pipeline type=kubernetes</pre><p>If there are errors with any of them, ask for help on Drone’s <a href="http://discourse.drone.io/">discourse server</a>.</p><h3>Accessing Drone Interface</h3><p>To access the Drone interface, we need to expose the Kubernetes service that was created when the server was deployed. There are many ways of exposing a Kubernetes service to the outside world, but as we are using minikube with ngrok to provide external access to the cluster, we will use the port-forward option of kubectl to expose the Drone interface to the port ngrok forwards the request to. Any other method, like <em>LoadBalancer</em>, <em>ExternalName</em> or an <em>Ingress controller</em> are outside the scope of this tutorial. To forward the Drone service to port 80, run this command</p><pre>$ sudo kubectl — namespace drone port-forward svc/drone 80:80<br>Password:</pre><pre>Forwarding from 127.0.0.1:80 -&gt; 80<br>Forwarding from [::1]:80 -&gt; 80</pre><p>We need to use sudo because we are binding to a port below 1024. Now access <a href="http://localhost/">http://localhost</a>, and you will be presented with the same interface we saw in the previous article:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U6ZRpw54mYXEIhnN" /></figure><h3>Deploying Example Application</h3><p>Now that Drone server and runner are deployed on the Kubernetes cluster, we are going to deploy an example application. We will use one of the example applications from the Kubernetes documentation, the <a href="https://kubernetes.io/docs/tutorials/stateless-application/guestbook/">demo guestbook</a>. The Drone pipeline will build the image, push it to docker hub and deploy it in the minikube Kubernetes cluster.</p><p>For the application deployment in the Kubernetes cluster there are various Drone plugins, we will <a href="https://plugins.drone.io/plugins/plugin-kube">use one</a> from the <a href="https://plugins.drone.io/">plugin’s marketplace</a>. This is the <a href="https://github.com/juanluisbaptiste/kubernetes-engine-samples/blob/main/.drone.yml"><em>.drone.yml</em></a> pipeline file that can be found in <a href="https://github.com/juanluisbaptiste/kubernetes-engine-samples">my fork</a> of the example application:</p><pre>---<br>kind: pipeline<br>type: kubernetes<br>name: guestbook-demo</pre><pre>steps:<br>  - name: docker<br>    image: plugins/docker<br>    settings:<br>      repo: juanluisbaptiste/guestbook-demo<br>      dockerfile: guestbook/php-redis/Dockerfile<br>      context: guestbook/php-redis<br>      username:<br>        from_secret: docker_username<br>      password:<br>        from_secret: docker_password<br>      tags:<br>        - latest<br>  - name: Deploy demo guestbook redis follower service<br>    image: danielgormly/drone-plugin-kube:0.2.0<br>    settings:<br>      build_number: ${DRONE_BUILD_NUMBER}<br>      template: guestbook/redis-follower-service.yaml<br>      ca:<br>        from_secret: k8s_crt<br>      server:<br>        from_secret: k8s_server<br>      token:<br>        from_secret: k8s_token<br>  - name: Deploy demo guest book redis follower deployment<br>    image: danielgormly/drone-plugin-kube:0.2.0<br>    settings:<br>      build_number: ${DRONE_BUILD_NUMBER}<br>      template: guestbook/redis-follower-deployment.yaml<br>      ca:<br>        from_secret: k8s_crt<br>      server:<br>        from_secret: k8s_server<br>      token:<br>        from_secret: k8s_token<br>  - name: Deploy demo guestbook redis leader service<br>    image: danielgormly/drone-plugin-kube:0.2.0<br>    settings:<br>      build_number: ${DRONE_BUILD_NUMBER}<br>      template: guestbook/redis-leader-service.yaml<br>      ca:<br>        from_secret: k8s_crt<br>      server:<br>        from_secret: k8s_server<br>      token:<br>        from_secret: k8s_token<br>  - name: Deploy demo guest book redis leader deployment<br>    image: danielgormly/drone-plugin-kube:0.2.0<br>    settings:<br>      build_number: ${DRONE_BUILD_NUMBER}<br>      template: guestbook/redis-leader-deployment.yaml<br>      ca:<br>        from_secret: k8s_crt<br>      server:<br>        from_secret: k8s_server<br>      token:<br>        from_secret: k8s_token<br>  - name: Deploy demo guestbook frontend service<br>    image: danielgormly/drone-plugin-kube:0.2.0<br>    settings:<br>      build_number: ${DRONE_BUILD_NUMBER}<br>      template: guestbook/frontend-service.yaml<br>      ca:<br>        from_secret: k8s_crt<br>      server:<br>        from_secret: k8s_server<br>      token:<br>        from_secret: k8s_token<br>  - name: Deploy demo guest book frontend deployment<br>    image: danielgormly/drone-plugin-kube:0.2.0<br>    settings:<br>      build_number: ${DRONE_BUILD_NUMBER}<br>      template: guestbook/frontend-deployment.yaml<br>      ca:<br>        from_secret: k8s_crt<br>      server:<br>        from_secret: k8s_server<br>      token:<br>        from_secret: k8s_token</pre><p>The pipeline will build the guestbook PHP frontend and push it to docker hub. Then, it will create a Kubernetes namespace for the application and deploy the image just built along with a set of Redis leader and follower databases. Unfortunately, the Kubernetes plugin is in its very early stages of development, and currently it does not support the deployment of a manifest that defines multiple resources, so we need to use a separate manifest for each of them.</p><p>Now, fork my repository and enable it in Drone. After it is enabled, create the following secrets that will be needed to push the image to docker hub and deploy the application in the Kubernetes cluster:</p><ul><li>docker_username: Docker hub username</li><li>docker_password: Docker hub password</li><li>k8s_crt: Base-64 encoded string of the Kubernetes CA certificate</li><li>k8s_server: URL to the Kubernetes manager node. For this lab, it would be the minikube instance.</li><li>k8s_token: Kubernetes service account token (Not base64 encoded)</li></ul><p>The first two secrets are the docker hub credentials, so Drone can push the image built during the run of the pipeline. The other three secrets are for the Kubernetes deployment plugin configuration.</p><p>To configure the <em>k8s_crt</em> secret, the minikube CA certificate is found on the <em>~/.minikube/ca.crt</em> file. To base64 encode it, run this command:</p><pre>$ cd ~/.minikube<br>$ cat ca.crt|base64 -w 0</pre><p>Copy and paste the output into the new <em>k8s_crt</em> secret, make sure it is not split in multiple lines, it must be in a single line. And for the <em>k8s_token</em> secret, to get the service account token, look for a Kubernetes secret called <em>default-token-xxxx</em> in the <em>kube-system</em> namespace and get its value:</p><pre>$ kubectl get secret -n kube-system|grep default<br><strong>default</strong>-token-vpbs9 kubernetes.io/service-account-token 3 301d</pre><pre>$ kubectl describe secret default-token-vpbs9 -n kube-system</pre><pre>Name: default-token-vpbs9<br>Namespace: kube-system<br>Labels: &lt;none&gt;<br>Annotations: kubernetes.io/service-account.name: default<br>kubernetes.io/service-account.uid: 5e9b0fec-3d0f-4734-b2d8-d6bee635671a<br>Type: kubernetes.io/service-account-token</pre><pre>Data<br>====<br>ca.crt: 1111 bytes<br>namespace: 11 bytes<br><strong>token: eyJhbGciOiJSUzI1NiIsImtpZCI6IlBzV0dVbkFEVVI4cUNjNDVlbml5WG1qMVN2cFY3TG5qclZyMlB0QmZWM2MifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2VuLXZwYnM5Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI1ZTliMGZlYy0zZDBmLTQ3MzQtYjJkOC1kNmJlZTYzNTY3MWEiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06ZGVmYXVsdCJ9.AKT7mFFdAwRcy8phR8MeIllsWGo2kU52SejZ5nD05K99M8BsHBdYTwM0HBLJTeDtAk8fs1KMaZ0OY0__Ct52E4r2RM3XCyYKXwMNPRgrgyvQ3QuHxD6Qux7O5LT6gX0LKjbzFk7VKey3trgQTgJZ4oOan_b3NMQs4nDSR2mM6Yt848x92w-vBOZ5Z0XUAbpjnSszK46zNQEqBeT3qX6PUfqOQfwDGqDJbwiZ033KwycPgZQ4ZLdD1mo6DHQtoRRXEyaetgCVlEqGIgHBTJyPAlQSxwu_nY4L4PMI8M8VcTJKC40wENUlNCfQzw_JWnwbtjfsFVwqd5theAzXVt3qKA</strong></pre><p>You can try this command to extract the value of the “token” field:</p><pre>$ kubectl get secret `kubectl get secret -n kube-system|grep default|awk &#39;{print $1}&#39;|grep -v NAME` -o go-template=&#39;{{ .data.token | base64decode }}&#39; -n kube-system</pre><p>You should get just that value:</p><pre>eyJhbGciOiJSUzI1NiIsImtpZCI6IlBzV0dVbkFEVVI4cUNjNDVlbml5WG1qMVN2cFY3TG5qclZyMlB0QmZWM2MifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2VuLXZwYnM5Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI1ZTliMGZlYy0zZDBmLTQ3MzQtYjJkOC1kNmJlZTYzNTY3MWEiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06ZGVmYXVsdCJ9.AKT7mFFdAwRcy8phR8MeIllsWGo2kU52SejZ5nD05K99M8BsHBdYTwM0HBLJTeDtAk8fs1KMaZ0OY0__Ct52E4r2RM3XCyYKXwMNPRgrgyvQ3QuHxD6Qux7O5LT6gX0LKjbzFk7VKey3trgQTgJZ4oOan_b3NMQs4nDSR2mM6Yt848x92w-vBOZ5Z0XUAbpjnSszK46zNQEqBeT3qX6PUfqOQfwDGqDJbwiZ033KwycPgZQ4ZLdD1mo6DHQtoRRXEyaetgCVlEqGIgHBTJyPAlQSxwu_nY4L4PMI8M8VcTJKC40wENUlNCfQzw_JWnwbtjfsFVwqd5theAzXVt3qKA</pre><p>Copy that value and create a secret called <em>k8s_token</em>, also make sure it is not split in multiple lines, it must be in a single line. After you have created the previous secrets, create a namespace called <em>guestbook-demo</em>:</p><pre>$ kubectl create ns guestbook-demo<br>namespace/guestbook-demo created</pre><p>Now we are ready to launch a new build. On the Drone interface, in the example application repository, click in the “+ NEW BUILD” button to launch a new build. On the left you will see the steps from the pipeline being executed, if any of them fails you can click on it to see the details:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WMzVIw-kw6RtZeVb" /></figure><p>When the pipeline finishes successfully, you can check what was done by checking which resources were created:</p><pre>$ kubectl get all -n guestbook-demo<br>NAME                                READY STATUS  RESTARTS AGE<br>pod/frontend-64bcc69c4b-6cc22       1/1   Running 2        4h<br>pod/frontend-64bcc69c4b-f9djm       1/1   Running 2        4h<br>pod/frontend-64bcc69c4b-g4n9v       1/1   Running 2        4h<br>pod/redis-follower-594666cdcd-xs9rk 1/1   Running 2        4h<br>pod/redis-follower-594666cdcd-z5tqj 1/1   Running 2        4h<br>pod/redis-leader-fb76b4755-vh7cm    1/1   Running 2        4h</pre><pre>NAME                   TYPE         CLUSTER-IP    EXTERNAL-IP   PORT(S)      AGE<br>service/frontend       LoadBalancer 10.101.46.1   &lt;pending&gt; 80:31526/TCP 4h<br>service/redis-follower ClusterIP    10.109.70.101 &lt;none&gt;     6379/TCP     4h<br>service/redis-leader   ClusterIP    10.99.118.103 &lt;none&gt;     6379/TCP     4h</pre><pre>NAME                           READY UP-TO-DATE AVAILABLE AGE<br>deployment.apps/frontend       3/3   3          3         4h<br>deployment.apps/redis-follower 2/2   2          2         4h<br>deployment.apps/redis-leader 1/1     1          1         4h</pre><pre>NAME                                      DESIRED CURRENT READY AGE<br>replicaset.apps/frontend-64bcc69c4b       3       3       3     4h<br>replicaset.apps/redis-follower-594666cdcd 2       2       2     4h<br>replicaset.apps/redis-leader-fb76b4755    1       1       1     4h</pre><p>You should see the frontend and Redis pods, the services, deployments and replica sets for them, all in running state. Now, to access the guestbook application, we need to expose the application’s frontend service. Because the frontend service is of <em>LoadBalancer</em> type, we can use the minikube service command to expose it:</p><pre>$ minikube service frontend -n guestbook-demo<br>|--------------|--------|-----------|---------------------------|<br>|   NAMESPACE  |  NAME  |TARGET PORT|           URL             |<br>|--------------|--------|-----------|---------------------------|<br>|guestbook-demo|frontend|        80 |<a href="http://192.168.99.100:31856/">http://192.168.99.100:31856</a>|<br>|--------------|--------|-----------|---------------------------|<a href="https://medium.com/p/fa9fdc6a3659/edit">https://medium.com/p/fa9fdc6a3659/edit</a></pre><p>🎉 Opening service guestbook-demo/frontend in default browser…</p><p>That command will open a browser window that will access the frontend service URL. This URL is the minikube IP address and a port that was randomly assigned when the service was created. You can now test the guestbook application!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/0*T-H7z7sHBxRngIVV" /></figure><h3>Conclusions</h3><p>On this article, we have expanded the Drone deployment from a basic docker installation using <em>docker-compose</em>, to a Kubernetes deployment using Helm charts on a local minikube cluster. But still, this Drone installation was fairly simple, it lacked some features expected on a production deployment that will be covered in a future post. Kubernetes will allow us to do things like load balancing, pod horizontal scaling, application version rollouts and rollbacks, among others.</p><p>Also, the Kubernetes plugins seem to be in a very early stage of development, the one I tested works but lacks some features, like the creation of namespaces, or the deployment of multiple resources in a single manifest file. I hope Harness releases a properly supported deployment plugin in the future.</p><p>In general, I’m very satisfied with Drone’s ease of deployment, even on a Kubernetes cluster. I will continue to explore what can be done with it on this platform and how it compares with more established products in future articles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa9fdc6a3659" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-part-2-fa9fdc6a3659">Introduction to drone.io CI/CD platform Part 2</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to drone.io CI/CD platform]]></title>
            <link>https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-1d43f8bc1728?source=rss-8c6edd7c7991------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d43f8bc1728</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[drones]]></category>
            <category><![CDATA[globant]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Juan Luis Baptiste]]></dc:creator>
            <pubDate>Thu, 23 Dec 2021 20:31:01 GMT</pubDate>
            <atom:updated>2021-12-23T20:31:01.355Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In a world full of CI/CD products, who would think there is space for another? This article introduces<a href="https://www.drone.io/"> Drone.io</a>, another player in the CI/CD arena that has gained a lot of popularity in recent years thanks to a set of unique features that make it stand out from the other players in this field. Drone is an open source Continuous Integration and Delivery platform built completely on docker. It is truly Docker native; all components are docker containers, and all pipeline steps execution from an application take place as containers too. Docker works as an encapsulation method for isolating builds and deployments.</p><p>Drone has more than 50 thousand users and is used by some big name companies like eBay,<a href="https://open.blogs.nytimes.com/2017/01/12/continuous-deployment-to-google-cloud-platform-with-drone/"> NY Times</a>,<a href="https://devnetsandbox.cisco.com/sandbox-instructions/CICD_Pipeline/helloworld.html"> Cisco</a> and VMWare among others. They were recently acquired by<a href="https://harness.io/"> Harness</a>, and since then they have released version 2 which is the one we will review in this article.</p><p>We will go through setting up Drone locally, so you can test Drone and play around with it to get to know its multiple features. Deploying on Kubernetes is incredibly easy too using helm charts, but that is out of the scope of this article, the idea is to concentrate on learning the features of Drone more than how to properly deploy it for a production setup. We will cover that in a later article.</p><p>The following sections will be reviewed in this article:</p><ul><li>Features</li><li>Architecture</li><li>Installation</li><li>Usage</li><li>Conclusions</li></ul><h3>Features</h3><p>The following is a list of the main Drone features:</p><ul><li>Drone is very lightweight as it is written in Go and all components run as docker containers. This makes it easy to deploy Drone in many platforms or cloud providers in a matter of minutes. By default, each pipeline step is executed inside an isolated docker container that is automatically downloaded at runtime. Also, Drone has a very low learning curve, compared with other CI/CD products like Jenkins.</li><li>Runners are available for multiple operating systems and architectures, including Linux amd64, Linux arm/arm64, Windows and Mac servers. With such broad platform support, a single product can be used for a mix of use case scenarios: from traditional cloud deployments, to IoT, to native Windows or Mac builds.</li><li>Scalable architecture: Drone provides autoscalers for different cloud providers that will launch runners based on demand, helping developers save on their cloud bills by avoiding the need of having dedicated resources assigned for them.</li><li>It is available to install on-premise, or as a SaaS offering with additional features, so you can pick what best fits your needs.</li><li>Functionality can be extended with plugins and extensions. Plugins add functionality to pipelines and extensions to Drone core itself. Plugins are very easy to develop because they can be written in any language, and they run isolated in a container.</li><li>Pipelines are defined in YAML format with a simple and well-defined syntax.</li><li>Different database backend options. By default, it uses SQLite and works out of the box, but for production deployments it can work with external PostgreSQL or MySQL databases.</li><li>And the better for the end, It is open source!</li></ul><p>But Drone also has some drawbacks, thus far I have noticed the following:</p><ul><li>The Drone server must be reachable over the Internet so SCM platforms can reach webhooks on the Drone server.</li><li>Although Drone has around 100 plugins, that isn’t as near as much the amount of plugins available for other products like Jenkins.</li><li>It only supports git SCM platforms, but for any modern project this shouldn’t be an issue.</li><li>A Drone server instance can only access one git SCM platform at a time, if you work with multiple platforms then you will need to instantiate multiple Drone servers, one per SCM.</li></ul><h3>Architecture</h3><p>Drone has a very simple client and server-based architecture, it is composed of three things:</p><ul><li>Drone server</li><li>Drone agents (called runners)</li><li>Drone pipeline configuration file (on each git repository)</li></ul><p>The following diagram depicts its architecture with more detail:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_QSWVDyXD_jLyxGW" /><figcaption>Drone architecture diagram</figcaption></figure><h4>The server</h4><p>The Drone Server is the main component. It is a go binary, and it is packaged as a docker image that can be run as a docker container on Linux, Mac, Windows machines or in a Kubernetes cluster. There is also a SaaS version, but that is not what we are going to talk about in this article.</p><p>The server is in charge of monitoring the git repositories in an SCM platform (like GitHub, Bitbucket, Gitea and others) for changes and then instructing a runner what to do according to a configuration file stored on the repository. This file is what is commonly known as the pipeline definition. The server authenticates with the git repository using OAuth, and with runners using a shared secret.</p><p>The Drone server automatically creates a webhook on the git repository when it is activated on the server. Then, when an event occurs, for example a developer pushes some code to a branch, the webhook is triggered and the Drone server is notified about that. When this happens, the drone server pulls the drone configuration file from the git repository, parses it and queues the specified tasks (pipeline steps) on it on the appropriate runner.</p><h4>The runners</h4><p>The runners execute the steps specified on the Drone configuration file of a repository. Like the server, the runners are packaged as a docker image and also can be run as a docker container on Linux, Mac, Windows machines, on a Kubernetes cluster or directly on a VM. There are several types of runners:</p><ul><li><em>Docker runner:</em> This runner is a daemon that executes pipeline steps inside ephemeral docker containers. It is run as a container on Linux, Mac or Windows machines. It can be installed as a single docker runner, or on multiple machines to create a build cluster.</li><li><em>Kubernetes runner:</em> This runner is a standalone service that executes pipelines inside pods.</li><li><em>Local execution runner:</em> This runner is a daemon that executes build pipelines directly on the host machine without isolation, using the default shell. It is recommended for workloads that cannot be executed inside containers, or cannot easily be adapted to container-based pipelines. This runner is especially useful for operating systems and architectures that do not support containers.</li><li><em>SSH runner:</em> This runner executes pipeline commands on a remote server using the SSH protocol. The pipeline commands are executed directly on the remote server without isolation, using the default shell.</li><li><em>Cloud runners for DigitalOcean, AWS and Macstadium:</em> This type of runner is recommended for pipelines that require privileged access to a full virtual machine, and are unsuitable for execution inside containers. These runners execute pipelines in dedicated, ephemeral virtual machines, and provide secure isolation for untrusted workloads.</li></ul><p>Runners run one job at a time, so to be able to run many jobs in parallel, then multiple runners must be used.</p><h4>The configuration file</h4><p>The configuration file defines the set of steps that define the pipeline for a git repository. It is a YAML file that lives within the git repository, and it is named <em>.drone.yml</em>. In recent Drone versions some other formats to define this config file have been introduced, like<a href="https://jsonnet.org/"> Jsonet</a> and<a href="https://docs.bazel.build/versions/main/skylark/language.html"> Starlark</a> that bring templating and scripting capabilities for more complex pipelines, but to keep things simple, we will use the default YAML format.</p><h4>Plugins &amp; Extensions</h4><p>Drone’s functionality can be extended with<a href="http://plugins.drone.io/"> plugins</a> and<a href="https://docs.drone.io/extensions/overview/"> extensions</a>. Plugins add new functionalities to application pipelines, actions that can be executed as part of the pipeline. Currently, Drone already has hundreds of plugins for different types of tasks. For example, notification plugins (slack, telegram, email), deployment (ECS, EKS), publishing (docker, ECR, GCR, npm, scp, rsync ) monitoring (Datadog), etc. Drone does not have as many plugins as other CI/CD platforms like Jenkins, but as plugins can be written in any language and are encapsulated in a docker container, it makes it really easy to create new ones. So if you miss any feature found in other CI/CD systems, it could be easily added as a plugin to Drone.</p><p>Extensions on the other side extends Drone’s core functionalities, for example, add new ACL controls, pipeline processing rules, secrets backends, configuration file linting, etc.</p><h3>Installation</h3><p>In general terms, as Drone runs as docker containers, its setup is very simple. For this lab, we will be using local docker containers for both server and runners deployed in your computer. But as mentioned before, due to Drone needing to be publicly accessible over the Internet, we need to use a tunneling tool like<a href="https://ngrok.com/"> ngrok</a> to make the server accessible by the SCM platforms on your local computer. If you have access to a VM on a cloud provider you can skip this step and use the VM’s hostname instead, only make sure that HTTP and HTTPS ports are publicly accessible.</p><p>Ngrok setup instructions are outside the scope of this article (to avoid making it unnecessarily long), but basically what you need to do is to sign up at<a href="https://ngrok.com/"> ngrok.com</a> and<a href="https://dashboard.ngrok.com/get-started/setup"> follow these instructions</a> to set it up. Take note of the hostname from the tunnel configuration, as we will be needing it further on.</p><h4>Prerequisites:</h4><ul><li>Docker and docker-compose installed on your computer.</li><li>A publicly accessible hostname that points to the Drone server. Because this lab is a local install, we will use the ngrok hostname.</li><li>SCM platform OAuth ID and token. For this article we will be using GitHub, refer to the<a href="https://docs.drone.io/server/overview/"> official documentation</a> for instructions on how to set up other SCM platforms.</li><li>Define a secret for communication between server and runners. This is just a string of text that will be used as a password between them.</li><li>GitHub and Docker Hub accounts.</li></ul><p>After having all prerequisites met, these are the steps needed to get Drone up and running:</p><p><strong>Create the OAuth authentication in an SCM platform.</strong></p><p>Go to your GitHub account and navigate to the<a href="https://github.com/settings/developers"> developers settings</a> and select the OAuth apps from the left menu. Click on the “New OAuth App” button and fill up the fields. Here you will need the hostname where Drone is deployed. The call back URL <em>must</em> end with “/login”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/0*LjHOsT6hez870y7-" /></figure><p>Click on the “Register Application” button. On the next screen, click on the “Generate a new client secret” button, then put your password when asked to generate a new access secret:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*hXZJN8-J2WYS1Jxt" /></figure><p>Take note of the Client ID and secret.</p><p><strong>Configure the Drone server and runners.</strong></p><p>Server configuration is done using environment variables. To simplify the setup, we are going to use <em>docker-compose</em>. Create a text file named <em>.env</em> to store the environment variables that will configure both server and runners, refer to the<a href="https://docs.drone.io/server/reference/"> official documentation</a> for a more in depth explanation of them.</p><p>Add the following variables:</p><pre># Server configuration<br>DRONE_SERVER_HOST=&lt;ngrok hostname&gt;<br>DRONE_SERVER_PROTO=http<br>DRONE_GITHUB_CLIENT_ID=&lt;github client ID&gt;<br>DRONE_GITHUB_CLIENT_SECRET=&lt;github secret&gt;<br>DRONE_RPC_SECRET=&lt;Drone secret&gt;<br>DRONE_TLS_AUTOCERT=false<br>DRONE_USER_CREATE=username:&lt;github_username&gt;,admin:true</pre><pre># Runners configuration<br>DRONE_RPC_HOST=&lt;ngrok hostname&gt;<br>DRONE_RPC_PROTO=http<br>DRONE_RUNNER_NAME=&quot;Drone.io_runner&quot; # It CANNOT contain spaces!</pre><p>Now we need to create the configuration file for docker-compose to launch both server and runner containers. Create a file named <em>docker-compose.yml</em> with the following contents:</p><pre>version: &#39;3.8&#39;</pre><pre>services:<br>  drone:<br>    image: &#39;drone/drone:2&#39;<br>    volumes:<br>      - &quot;/var/run/docker.sock:/var/run/docker.sock&quot;<br>      - &quot;./volumes/drone:/data&quot;<br>      - &#39;/etc/localtime:/etc/localtime:ro&#39;<br>    restart: always<br>    ports:<br>      - 80:80<br>    env_file:<br>    - .env</pre><pre>  drone-agent:<br>    image: drone/drone-runner-docker:1<br>    command: agent<br>    restart: always<br>    depends_on:<br>      - drone<br>    volumes:<br>      - /var/run/docker.sock:/var/run/docker.sock<br>      - &#39;/etc/localtime:/etc/localtime:ro&#39;<br>    env_file:<br>      - .env</pre><p>We need to use port 80 for HTTP as we do not have an SSL certificate. Drone has built-in<a href="https://letsencrypt.org/"> Let’s Encrypt</a> support with the DRONE_TLS_AUTOCERT variable, but to use it we need to own the DNS domain where Drone is available because Drone uses the ACME HTTP challenge for domain validation.</p><p>Now you can start Drone:</p><pre>$ docker-compose up</pre><p>Wait some seconds for the containers to start up and then open the ngrok hostname in your browser, if Drone started successfully you should see a screen like this one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T-dE-eY8HIQDzDog" /></figure><p>Click on “CONTINUE”. Next you will be asked to register, if you do not want to subscribe then leave the fields empty and click “Submit”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JoxOe6pWBY10U_xb" /></figure><p>GitHub will ask you to authorize Drone, click on “Authorize”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/0*Ei611KcQZ70C6CdD" /></figure><p>Now you will be presented with the Drone dashboard with the list of all your repositories:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*-JflxA3IetNswgxO" /></figure><p>Congratulations, your Drone server is up and running !!</p><h3>Usage</h3><p>After the Drone server and runner has been set up, the pipeline for an application has to be configured. For this, we need to create a file called <em>.drone.yml</em> and put it on the application’s root folder. This file will tell Drone the tasks to execute, like build, test and deploy the application. For example, build the code using an appropriate docker image, package it (inside a docker container or as an npm package), and deploy it somewhere, like a docker or npm registry.</p><p>For this lab, we will use this<a href="https://github.com/juanluisbaptiste/docker-hello-world"> hello world docker image</a>. The pipeline of this application will build the image and push it to docker hub. This is a very basic example that will help us showcase Drone workflow and basic features. In a follow-up article, we will do a more complete example that also deploys the application in a remote system.</p><p>To start, please fork the example repository. This is the <em>.drone.yml</em> file you will find on that application:</p><pre>---<br>kind: pipeline<br>type: docker<br>name: hello-world<br>steps:<br>- name: docker<br> image: plugins/docker<br> settings:<br>   repo:&lt;dockerhub_username&gt;/docker-hello-world<br>   username:<br>     from_secret: docker_username<br>   password:<br>     from_secret: docker_password<br>   tags:<br>     - latest</pre><p>Replace <em>&lt;dockerhub_username&gt;</em> with your Docker Hub user. In the settings section, we will set up the secrets for the docker hub’s username and password, more on this later. After doing these changes, commit and push them.</p><p>Go to your docker hub account and create a new repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*yKLpSQ1vOhs7TVeG" /></figure><p>Give it a name, set its visibility to Public and select <em>GitHub</em> as the source code repository, so you can select the repository of this lab. If you haven’t linked your GitHub account yet, then please<a href="https://hub.docker.com/settings/linked-accounts"> do this first</a> to be able to select the lab repository:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/0*FqxO-Ln17nlMd73s" /></figure><p>Leave the other fields with default values and click on “Create” to create the docker hub repository. Next, we need to sync GutHub repositories in the Drone server. Because we added a new GitHub repository, we need to make Drone aware of it. Go to the Drone dashboard and click on the “Sync” button at the upper right part of the screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*X3ocWqR_UgxaE6Uv" /></figure><p>Search for the <em>docker-hello-world</em> repository and click on it. As this is a new repository, you will be on the <em>Settings</em> page. Click on the “+ ACTIVATE REPOSITORY” button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*oDADNhpstqkozisV" /></figure><p>Now add docker hub credentials as secrets. Click on the “Secrets” menu entry on the left and then on the “+ NEW SECRET” button to create a new secret:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*nenT3q_HLYzZF3h7" /></figure><p>Create two secrets, “docker_username” and “docker_password” with the corresponding values for your account:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/0*Vwfd6JlHrvnyv2Az" /></figure><p>Now we are ready to launch a test build! Click on the “Builds” tab and then on the “+NEW BUILD” button to manually launch a build:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*gitFMPkqrTDs2drt" /></figure><p>Normally, the builds will be launched when pushing commits to the repository (and according to the rules in the <em>.drone.yml</em> file). A window will appear to customize the build, leave it with the default settings and click on the “Create” button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/0*a0c0iJZ0Mu0jyZIq" /></figure><p>The pipeline execution will start now, you can see the steps that are being executed along with its output and execution status:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*IBTbnKhA0PwYWmWu" /></figure><p>There’s also a graph view of the pipeline steps that can help understand the pipeline’s workflow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T9Y5ug5k2wogNYbz" /></figure><p>After some minutes, the pipeline execution should have finished. Take a look at the last execution for the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c-EMRl8f8KuQc1yD" /></figure><p>Go to docker hub and check if there is a new image!</p><h3>Conclusions</h3><p>This is a very simple setup and does not reflect what would be needed for an application being built and deployed for production usage, but it serves to showcase Drone basic features and the ease of setting it up and the simplicity of the pipeline configurations.</p><p>Drone is a modern CI/CD product built for the cloud era. It might not have all the bells and whistles of other more established (and older) products like Jenkins or CircleCI or “insert your preferred CI/CD product here”, but being container native gives it a lot of other features much more needed for the cloud.</p><p>First, its ease of deployment, being docker native makes it extremely easy and fast to get Drone up and running in a matter of minutes, even on a Kubernetes cluster, which we will cover in a future article.</p><p>Second, the support of Arm hardware architecture makes it available in a variety of other industries different to the cloud, like IoT and embedded systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/0*sFT3Zobl_AtlHfeM.png" /></figure><p>Visit us at <a href="https://www.globant.com/studio/cloud-ops">https://www.globant.com/studio/cloud-ops</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d43f8bc1728" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/introduction-to-drone-io-ci-cd-platform-1d43f8bc1728">Introduction to drone.io CI/CD platform</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>