<?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 Abhay Sharma on Medium]]></title>
        <description><![CDATA[Stories by Abhay Sharma on Medium]]></description>
        <link>https://medium.com/@abhi_24s?source=rss-073e47ae5014------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MFGV_RzxUwTy_Vv8</url>
            <title>Stories by Abhay Sharma on Medium</title>
            <link>https://medium.com/@abhi_24s?source=rss-073e47ae5014------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:53:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhi_24s/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[Setup Linux Self-Hosted Agent for CI/CD Pipelines in Azure DevOps]]></title>
            <link>https://medium.com/@abhi_24s/setup-linux-self-hosted-agent-for-ci-cd-pipelines-in-azure-devops-6fe07ca3a49d?source=rss-073e47ae5014------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fe07ca3a49d</guid>
            <dc:creator><![CDATA[Abhay Sharma]]></dc:creator>
            <pubDate>Thu, 10 Jul 2025 06:10:27 GMT</pubDate>
            <atom:updated>2025-07-10T06:10:27.031Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C2mCMEOYs3N5_EGexNH1OQ.jpeg" /></figure><p>In this article I’ll walk you through on how to Setup Linux Self-Hosted Agent for CI/CD Pipelines in Azure DevOps.</p><blockquote><strong><em>Why we need to use Self-Hosted Agents when we have Microsoft Hosted Agents available to run pipelines?</em></strong></blockquote><p>The reason is when we have Azure resources deployed in a VNet with Private Endpoints enabled, Microsoft Hosted Agents cannot talk to resources during deployment and results in pipeline failure. So, we need to create a VM in the same VNet where our resources are deployed and configure that VM as a self hosted agent to be used in pipelines for deployments.</p><p>Another reason is when our applications need any custom libraries or softwares to build and deploy them, we can install them in Self Hosted Agents.</p><blockquote><strong><em>Steps involved in creating a Self Hosted Agent</em></strong></blockquote><ol><li>Create a Linux VM.</li><li>Create a PAT(Personal Access Token) token.</li><li>Configure the VM as a Self Hosted Agent.</li><li>Use self-hosted agent in Azure YAML Pipeline.</li></ol><blockquote><strong><em>Create a Linux VM</em></strong></blockquote><ol><li>Got to Azure Portal and login with your credentials <a href="https://portal.azure.com/#home">https://portal.azure.com/#home</a></li><li>Search for Virtual Machines in Search box and configure VM by following below screenshots.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*6N2kZpg8yVvc9kog.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*H-o-8BLydNjDLQXh.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*OnKsZ4z62XHTatIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*eI0YrqLaYEIsDksB.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*2u-PXyEzIyBBvlix.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ja1JvWI3uNZ0h2-L.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*cnK8cRISauiJunZ-.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*7fhpSkZ7Hj6LRGs3.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ceAryOPBfN-6rnYc.png" /></figure><p>After entering all required details for VM, click on <strong>Review + create</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*xOOsV5OMy2J5ijDS.png" /></figure><p>Click on <strong>Create </strong>button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*lGYQWRwK8I6SvETz.png" /></figure><p>Download the private key as you won’t be able to retrieve it later. We need this private key to login into VM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*1yDR1QZPecEgo68Y.png" /></figure><blockquote><strong><em>Create a PAT(Personal Access Token) token</em></strong></blockquote><p>Follow below steps to create a PAT token. PAT token is used for authentication purpose from VM (i.e. Self-Hosted Agent) to DevOps portal while setting up the Self-Hosted Agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*7Mwwh-F0lRsaMOPy.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*wY9P0Os1bO126Xp2.png" /></figure><p>Provide name, Select PAT token expiration date as per your requirements and choose the scope as <strong>Custom defined</strong> and grant access to only <strong>Agent Pools </strong>and click on <strong>Create </strong>button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*hcY7YLpU8ZiJ6avB.png" /></figure><p>Copy the PAT toke and note it down in a notepad. We need this PAT token for authenticating the VM (i.e. Self-Hosted Agent) to DevOps portal in the later steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Pu-WJokK6GOd2cXr.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*V2_rLFdHWq-1fwq0.png" /></figure><blockquote><strong><em>Configure the VM as a Self Hosted Agent.</em></strong></blockquote><p>Login to Azure DevOps portal and follow below screenshots to configure the Linux VM that we created as a Self-Hosted Agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Z7UxOWtk18_G088R.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*W-jAZZjoy6TYcySt.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*T8yEgRKSL8jabLhx.png" /></figure><p>Provide a name &amp; description to agent pool and click on <strong>Create </strong>button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*pRxY8BZx724JbrGa.png" /></figure><p>As you can see, a new Agent Pool is created. Make a note of the Agent Pool Name (<strong>linux-self-hosted-agent-pool</strong>) as we will be using the same name in YAML pipeline in pool definition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*pF-XoPQ5VMTYL0sV.png" /></figure><p>Now, lets create a New agent under the Agent Pool. Follow below screenshots for the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*RgWTsO0LVf18hHFF.png" /></figure><p>Since the VM we created is of Ubuntu OS, select Linux here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*L4-A1LZLXq2CBv1G.png" /></figure><p>Click on the clipboard icon to copy the url of the agent configuration file. Note it down in a notepad as we need it in the later steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*QZ1jrHLEBiVdHbyf.png" /></figure><blockquote><strong><em>Login into Ubuntu VM using private key and IP address</em></strong></blockquote><ol><li>Login to Ubuntu VM using private key and IP address.</li><li>Replace <strong>azureuser@xx.xxx.xxx.xx </strong>with your VM username and public IP address.</li><li>Also provide the path(<strong>C:\Users\Varaprasad.Reddy\Downloads\linux-self-hosted-agent-vm_key.pem</strong>) where you downloaded your private key.</li></ol><pre>ssh -i C:\Users\Varaprasad.Reddy\Downloads\linux-self-hosted-agent-vm_key.pem azureuser@xx.xxx.xxx.xx</pre><p><strong>ssh -i C:\Users\Varaprasad.Reddy\Downloads\linux-self-hosted-agent-vm_key.pem azureuser@xx.xxx.xxx.xx</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0cF3wylVQEpVo1sP.png" /></figure><p>Once logged into Linux VM, create a new directory called <strong>Downloads </strong>using mkdir command. Change the directory/move to the directory using <strong>cd </strong>command.</p><pre>mkdir downloads<br>ls<br>cd Downloads</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*L4vHRBrnp3VSyzyb.png" /></figure><p>Download the agent configuration file using the <strong>curl </strong>command and the url that we copied using clipboard in the previous steps. The curl command will download the agent configuration file (<strong>vsts-agent-linux-x64–3.240.1.tar.gz</strong>) into <strong>Downloads </strong>folder.</p><pre>curl -O https://vstsagentpackage.azureedge.net/agent/3.240.1/vsts-agent-linux-x64-3.240.1.tar.gz</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*3aZvQHSFGpJSaigC.png" /></figure><p>Now go back to the root folder using <strong>cd\</strong> command. Create a new directory called <strong>myagent </strong>and extract the contents of the downloaded agent configuration file (<strong>vsts-agent-linux-x64–3.240.1.tar.gz</strong>) into <strong>myagent </strong>directory.</p><pre>cd\<br>mkdir myagent &amp;&amp; cd myagent<br>tar zxvf ~/Downloads/vsts-agent-linux-x64-3.240.1.tar.gz</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*JwzRix7CXU8E2KSs.png" /></figure><p>Once all the files are extracted into <strong>myagent </strong>directory, make sure you are in <strong>myagent </strong>directory and execute below command.</p><pre>./config.sh</pre><p><strong>Enter server URL</strong>: The URL of your DevOps Organization. For example <a href="https://dev.azure.com/organization_name">https://dev.azure.com/<strong>organization_name</strong></a></p><p>Press Enter for authentication type as PAT</p><p>Enter PAT token</p><p>Press Enter for <strong>_work </strong>folder to be as default work folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Gk9mezeLtI--C3lm.png" /></figure><p>The self-hosted agent is now registered, but it is in Offline mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*N9iNOxC6YYGfCVXN.png" /></figure><p>Run the command <strong>./run.sh</strong> from the <strong>myagent </strong>directory to make the self-hosted agent Online.</p><pre>./run.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Bt4tnK6QXGUIoWdS.png" /></figure><p>Now, the self-hosted agent status is showing as Online.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*OZdo1Tj8TH_exq_a.png" /></figure><p>One issue we have here is, when we exit from the terminal the self-hosted agent will stop and will be in Offline mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/0*Jae_S-ChwtRLXU04.png" /></figure><p>As you can see the image below, the self-hosted agent is in Offline mode after exiting from the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*l46V6ykZ_-RwnAjZ.png" /></figure><p>In order to fix this, we need to run our self-hosted agnet as a service. Make sure you are in <strong>myagent </strong>directory and execute below commands to run self-hosted agent as a service.</p><pre>sudo ./svc.sh install<br>./runsvc.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ApC1Jw76U1TL7Y1t.png" /></figure><p>As you can see the self-hosted agent is now up and running and in Online state. As long as the VM is up and running, the self-hosted agent will be up and running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*hYLqMZd0rTGp9Tmm.png" /></figure><blockquote><strong><em>Use self-hosted agent in Azure YAML Pipeline</em></strong></blockquote><p>Create an Azure YAML pipeline and use the pool name that we have given while setting up the Agent Pool in the previous steps. Here in the below YAML pipeline code, my agent pool name is <strong>linux-self-hosted-agent-poo</strong>l</p><pre>trigger: none</pre><pre>pr: none</pre><pre>pool: &quot;linux-self-hosted-agent-pool&quot;</pre><pre>steps:<br>  - script: echo Hello, world!<br>    displayName: &quot;Run a one-line script&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*acxVnBJgc-Ft_BrZ.png" /></figure><p>When the pipeline is triggered, it will ask for permission to run the pipeline with self-hosted agent for the first time. Grant the permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*6vr-Ud5KwMkjvUT0.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*G_JKKQkEP0Oh8fpG.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*TFQ_juExfYxj3iRL.png" /></figure><p>As you can see, the pipeline is now using the self-hosted agent to run the jobs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*K_IYbmqw0GYq-sc4.png" /></figure><p>I hope you enjoyed reading this article. Please give a clap and follow me for more such interesting and useful articles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fe07ca3a49d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon EKS Upgrade Journey From 1.30 to 1.31]]></title>
            <link>https://medium.com/@abhi_24s/amazon-eks-upgrade-journey-from-1-30-to-1-31-cd06b8247ac6?source=rss-073e47ae5014------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd06b8247ac6</guid>
            <dc:creator><![CDATA[Abhay Sharma]]></dc:creator>
            <pubDate>Tue, 26 Nov 2024 08:05:10 GMT</pubDate>
            <atom:updated>2024-11-26T08:05:10.846Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BpVdZfmdhn-sPM_LOH168w.jpeg" /></figure><h3>Amazon EKS Upgrade Journey From 1.30 to 1.31</h3><p>We are now welcoming “<strong>Mandala” release</strong><em>. Process and considerations while upgrading EKS control-plane to version 1.31.</em></p><h3>Overview</h3><p>Welcome to this cosmic journey with Kubernetes v1.31!</p><p>As noted by the Kuberentes maintainers; <em>this release is inspired by the beautiful art form that is Mandala- a symbol of the universe in its perfection. Our tight-knit universe of around 40 Release Team members, backed by hundreds of community contributors, has worked tirelessly to turn challenges into joy for millions worldwide.</em></p><p>Again, I would like to thank the community for their great support and implementations they offer. In many companies, specialists are not valued and are simply ignored which isn’t right. Hence, I would like to point this out in the public.</p><p>In the spirit of Mandala’s transformative symbolism, Kubernetes v1.31 celebrates Kubernetes project’s evolution. Like stars in the Kubernetes universe, each contributor, user, and supporter lights the way. Together, we create a universe of possibilities — one release at a time.</p><h3>Previous Stories and Upgrades</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/0*urls8kqP1_aOKK7F.gif" /></figure><h3>Prerequisites to upgrade</h3><p>Before upgrading to Kubernetes v1.31 in Amazon EKS, there are some important tasks you need to complete. Theses can be easily viewed within EKS console view under “Upgrade Insights”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i6T2nsyx2gzRENb2qcnQ4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9fNJqZdyooPWoL3S5LW2tw.png" /></figure><p>Actions to take:</p><ul><li>Update the API version of FlowSchema and PriorityLevelConfiguration.<br>The deprecated<a href="https://kubernetes.io/blog/2024/08/13/kubernetes-v1-31-release/"> <em>flowcontrol.apiserver.k8s.io/v1beta2</em></a> API version of FlowSchema and PriorityLevelConfiguration are no longer served in Kubernetes v1.31. If you have manifests or client software that uses the deprecated beta API group, then you should change these before you upgrade to v1.31. To learn more, see the <a href="https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.31.md">deprecated API migration guide.</a></li></ul><h3>Kuberentes 1.31- changes in this release</h3><p>As always if you want to find a complete list of changes and updates in Kubernetes version 1.31, check out the Kubernetes <a href="https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.31.md">change log</a>. Below you can find couple of enhancements that are worth mentioning in the v1.31 release. For a complete list go <a href="https://kubernetes.io/blog/2024/08/13/kubernetes-v1-31-release/">here</a>.</p><ul><li><strong>Advanced pod management feature</strong> reached beta status in Kubernetes v1.31. It introduces a sophisticated array of pod management features. #753 has graduated to beta and the SidecarContainers feature gate is enabled by default. This feature allows init containers to continuously run until pod terminates, effectively turning them into sidecar containers. This means that it solves the problem of managing long-running auxiliary processes that need to run alongside the main containers in a pod. For example, if a pod has a main application container and a logging container that collects and forwards logs from the main application, the logging container can be defined as a sidecar container. This allows the logging container to continue running and collecting logs for as long as the main application container is running, providing continuous log collection and forwarding.</li><li>#2799 has graduated to beta and the <strong>LegacyServiceAccountTokenCleanUp</strong> feature gate is enabled by default. This feature allows automatic cleanup of unused legacy service account tokens that are secret-based. Specifically, it labels legacy auto-generated secret-based tokens as invalid if they have not been used for a long time (1 year by default), and automatically removes them if use is not attempted for a long time after being marked as invalid (1 additional year by default). To check whether you are using unused tokens, run the following command:</li></ul><pre>kubectl get cm kube-apiserver-legacy-service-account-token-tracking -n kube-system</pre><ul><li>#3299 has graduated to stable and the <strong>KMSv2</strong> and KMSv2KDF feature gates are enabled by default in Kubernetes v1.31. However, it’s important to note that KMSv2 is currently not supported in Amazon EKS.</li></ul><p>More interesting items can be seen in the links provided below</p><ul><li><a href="https://kep.k8s.io/3458">Remove transient node predicates from KCCM’s service controller</a></li><li><a href="https://kep.k8s.io/3668">Reserve nodeport ranges for dynamic and static allocation</a></li><li><a href="https://kep.k8s.io/1040">Priority and Fairness for API Server Requests</a></li><li><a href="https://kep.k8s.io/3299">KMS v2 Improvements</a></li><li><a href="https://kep.k8s.io/365">Support paged LIST queries from the Kubernetes API</a></li><li><a href="https://kep.k8s.io/2485">ReadWriteOncePod PersistentVolume Access Mode</a></li><li><a href="https://kep.k8s.io/3466">Kubernetes Component Health SLIs</a></li><li><a href="https://kep.k8s.io/2876">CRD Validation Expression Language</a></li><li><a href="https://kep.k8s.io/3107">Introduce nodeExpandSecret in CSI PV source</a></li><li><a href="https://kep.k8s.io/2879">Track Ready Pods in Job status</a></li><li><a href="https://kep.k8s.io/727">Kubelet Resource Metrics Endpoint</a></li></ul><h3>Removed API versions and features</h3><p>Nowadays, it’s not uncommon for Kubernetes Application Programming Interface (API) versions and features to be deprecated or removed when a new version of Kubernetes is released. When this happens, it’s imperative that you update all manifests and controllers to the newer versions and features listed in this section before <a href="https://docs.aws.amazon.com/eks/latest/userguide/update-cluster.html">upgrading to </a>v1.31. Below are the top call-outs in the v1.31 release. For a complete list, refer to all Deprecations a<a href="https://kubernetes.io/blog/2024/08/13/kubernetes-v1-31-release/">nd removals in Kubernetes v1.31</a>.</p><h3>Deprecations</h3><ul><li>The <strong>.status.kubeProxyVersion</strong> field for Node objects is now deprecated, and the Kubernetes project is proposing to remove that field in a future release. The deprecated field is not accurate and has historically been managed by kubelet, which does not actually know the kube-proxy version, or even whether kube-proxy is running. If you’ve been using this field in client software, then stop because the information isn’t reliable and the field is now deprecated.</li></ul><h3>Upgrade your EKS with terraform</h3><p>I used following providers for the upgrade:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*MqZHOFEGFqNr4oX7.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*7SsaFEvHRC1S4F-2.png" /></figure><p>This time upgrade of the control plane takes around ~8 minutes. I would say this is super fast and zero issues afterwards have been experienced by me. I don’t even think I noticed any unavailable from API server itself which did happen in previous upgrades. AWS are doing a great job at reducing the time it takes to upgrade EKS control plane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Kv3kYpCRkEIWWzHO.png" /></figure><p>I immediately upgraded worker nodes which took around ~15 minutes to join the upgraded EKS cluster. This time is dependent on how many worker nodes you have and how many pods need to be drained from old nodes.</p><p>In general full upgrade process controlplane + worker nodes took around ~22 mins. Really good time I would say.</p><p>I personally use Terraform to deploy and upgrade my EKS clusters. Here is an example of the EKS cluster resource.</p><pre>resource &quot;aws_eks_cluster&quot; &quot;cluster&quot; {<br>  enabled_cluster_log_types = [&quot;audit&quot;]<br>  name                      = local.name_prefix<br>  role_arn                  = aws_iam_role.cluster.arn<br>  version                   = &quot;1.31&quot;  <br>  <br>  vpc_config {<br>    subnet_ids              = flatten([module.vpc.public_subnets, module.vpc.private_subnets])<br>    security_group_ids      = []<br>    endpoint_private_access = &quot;true&quot;<br>    endpoint_public_access  = &quot;true&quot;<br>  }<br>      <br>  encryption_config {<br>    resources = [&quot;secrets&quot;]<br>    provider {<br>      key_arn = module.kms-eks.key_arn<br>    }<br>  }<br>   <br>  tags = var.tags<br>}</pre><p>For the worker nodes I have used official AMI with id: <a href="https://eu-west-2.console.aws.amazon.com/ec2/home?region=eu-west-2#Images:visibility=public-images;imageId=ami-0317d520659f7a502">ami-0317d520659f7a502</a><strong>. </strong>I didn’t notice any issues after rotating all nodes. Nodes are running following version: <strong>v1.31.0-eks-5e0fdde</strong></p><h3>Upgrading Managed EKS Add-ons</h3><p>In this case the change is trivial and works fine, simply update the version of the add-on. In my case, from this release I utilise <strong>kube-proxy, coreDNS and ebs-csi-driver.</strong></p><h3>Terraform resources for add-ons</h3><pre>resource &quot;aws_eks_addon&quot; &quot;kube_proxy&quot; {<br>  cluster_name      = aws_eks_cluster.cluster[0].name<br>  addon_name        = &quot;kube-proxy&quot;<br>  addon_version     = &quot;v1.31.0-eksbuild.2&quot;<br>  resolve_conflicts = &quot;OVERWRITE&quot;<br>}</pre><pre>resource &quot;aws_eks_addon&quot; &quot;core_dns&quot; {<br>  cluster_name      = aws_eks_cluster.cluster[0].name<br>  addon_name        = &quot;coredns&quot;<br>  addon_version     = &quot;v1.11.3-eksbuild.1&quot;<br>  resolve_conflicts = &quot;OVERWRITE&quot;<br>}</pre><pre>resource &quot;aws_eks_addon&quot; &quot;aws_ebs_csi_driver&quot; {<br>  cluster_name      = aws_eks_cluster.cluster[0].name<br>  addon_name        = &quot;aws-ebs-csi-driver&quot;<br>  addon_version     = &quot;v1.18.3-eksbuild.2&quot;<br>  resolve_conflicts = &quot;OVERWRITE&quot;<br>}</pre><h3>After upgrading EKS control-plane</h3><p>Remember to upgrade core deployments and daemon sets that are recommended for EKS 1.31.</p><ol><li><strong>CoreDNS</strong> — v1.11.3-eksbuild.1</li><li><strong>Kube-proxy </strong>— v1.31.0-eksbuild.2</li><li><strong>aws-ebs-csi-driver</strong>- v1.18.3-eksbuild.2</li></ol><p>The above is just a recommendation from AWS. You should look at upgrading all your components to match the 1.31 Kubernetes version. They could include:</p><ol><li>load balancer controller</li><li>calico-node</li><li>cluster-autoscaler or Karpenter</li><li>external secrets operator</li><li>kube-state-metrics</li><li>metrics-server</li><li>csi-secrets-store</li><li>calico-typha and calico-typha-horizontal-autoscaler</li><li>reloader</li><li>keda (event driven autoscaler)</li><li>nvidia device plugin (used while utilising GPUs)</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd06b8247ac6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configure AWS EC2 with Ansible]]></title>
            <link>https://medium.com/@abhi_24s/configure-aws-ec2-with-ansible-e3ab86d1f6e9?source=rss-073e47ae5014------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3ab86d1f6e9</guid>
            <dc:creator><![CDATA[Abhay Sharma]]></dc:creator>
            <pubDate>Mon, 25 Nov 2024 06:15:49 GMT</pubDate>
            <atom:updated>2024-11-25T06:15:49.789Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AOvJMUmm4CK0yxPbPu30Ag.jpeg" /></figure><p>In the previous article we were able to author Terraform configuration that allows us to spin up one of several Linux distributions as an EC2 instance. In it we were able to achieve the following accomplishments:</p><ul><li>provide a modular solution</li><li>specify the distro as a command line arg</li><li>keeps things relatively DRY with symlinks</li></ul><p>We will have more issues that arise with our Terraform configuration as we start to incorporate Ansible, so rather than say goodbye to Terraform we will set another seat at the table and welcome its assistance. Specifically, Ansible has an inventory that depends on Terraform state, so Terraform will be responsible for managing it too. But we will address this a bit later in the article, let’s go ahead and dive into Ansible now.</p><p>The first obstacle is to install Ansible, which will either be incredible easy or incredibly impossible (if you have a corrupted Python install). Let’s opt for the former … you are already using something like pyenv and pip is up to date and healthy. You should be able to simply issue:</p><pre>$ pip install ansible-core</pre><p>But if some reason you receive errors, consult with the official documentation: <a href="https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html">Installing Ansible</a> as there is ample information about working with Python and Pip.</p><p>Once Ansible is installed and works without issues, we can start working with it. I recommend creating a subproject directory for Ansible within your Terraform project directory, simply called ansible. Now that we are already within the Terraform project directory we can spin up a resource to work with. You may select whatever distro you like, such as:</p><pre>$ terraform plan -out run.me -var server=aws_linux<br>$ terraform apply run.me</pre><p>and store the public IP address of the new resource somewhere temporarily for now. We will need it later.</p><p>Before we start writing Ansible configuration we need an inventory file. This will let Ansible know crucial information such as the IP address of the server and username to use. I am opting to use the system wide inventory file located at /etc/ansible/hostson my laptop. It is going to change often and there is no reason to check it into the repository. Create the directory path if it does not exist and change the ownership:</p><pre>$ sudo mkdir -p /etc/ansible<br>$ sudo chown your-user /etc/ansible<br>$ touch /etc/ansible/hosts</pre><p>Edit /etc/ansible/hosts and add one line to it:</p><pre>my-server ansible_host=3.84.192.190 ansible_user=ec2-user</pre><p>And now we can interact with like so:</p><pre>$ ansible my-server -m ping<br>$ anisble all -m ping</pre><p>Since we only have one inventory item, all will have the same effect as just specifying the name of our item. Let’s add more servers … oh wait! We can’t as of yet. Let’s remedy that. Switching gears back to Terraform momentarily. Right now we can only specify one server when we invoke Terraform plan, first we need to change our server variable definition to be a list of strings. Here is how it should now look in variables.tf:</p><pre>variable &quot;server&quot; {<br>  description = &quot;Server to configure.&quot;<br>  type        = list(string)<br>  default     = [&quot;aws_linux&quot;,&quot;debian&quot;,&quot;red_hat&quot;,&quot;suse&quot;,&quot;ubuntu&quot;]<br>}</pre><p>Then we only need to change our top level “main” files that call our modules. Here is the one for aws_linux.tf:</p><pre>locals {<br>  aws_linux_servers = [for name in var.server : name if name == &quot;aws_linux&quot;]<br>}</pre><pre>module &quot;aws_linux&quot; {<br>    source          = &quot;./modules/aws_linux&quot;<br>    instance_type   = local.instance_type<br>    ssh_rsa         = file(local.id_rsa_path)<br>    security_groups = [local.allow_ssh, local.allow_http]<br>    ami             = &quot;ami-06b21ccaeff8cd686&quot;<br>    username        = &quot;ec2-user&quot;<br>    servername      = &quot;Amazon-Linux&quot;</pre><pre>    for_each = toset(local.aws_linux_servers)<br>}</pre><pre>output &quot;aws_linux_ssh&quot; {<br>    value = length(module.aws_linux) &gt; 0 ? module.aws_linux[&quot;aws_linux&quot;].public_ip : &quot;&quot;<br>}</pre><p>I will leave it as an exercise to the reader to produce the “main” level files for the other distributions. But let’s talk about what is going on here. When Terraform gathers up all the configuration files and starts executing tasks, everything is under a global scope. That is, if I declare a variable in say, aws_linux.tf that same variable now is reserved in debian.tf and ubuntu.tf and the rest. In order to now use our server list variable, we will have to:</p><ol><li>declare a unique list for each module</li><li>populate it with a true value if it is in the command line argument list</li><li>trigger some kind of flag so that Terraform will provision it</li></ol><p>Not pretty I know, but Terraform wasn’t exactly designed to do this kind of specialized work. And the best part … it actually works. Items 1 and 2 are fulfilled in the first directive:</p><pre>aws_linux_servers = [for name in var.server : name if name == &quot;aws_linux&quot;]</pre><p>And item 3 is fulfilled in this line:</p><pre>for_each = toset(local.aws_linux_servers)</pre><p>Because we are now using toset we need to obtain the value for the public_ip using module.aws_linux[&quot;aws_linux&quot;] instead of modules.aws_linux[0] which is less than awesome, but it works.[1]</p><p>If you have implemented the rest of the top level “main” files, then you should be able to spin them all up with:</p><pre>$ terraform plan -out run.me<br>$ terraform apply run.me</pre><p>However, we have to populate /etc/ansible/hosts manually. You don’t have to do so now, but if you do you would need to have something like:</p><pre>suse ansible_host=54.236.142.176 ansible_user=ec2-user<br>aws-linux ansible_host=3.84.192.190 ansible_user=ec2-user<br>debian ansible_host=54.205.89.241 ansible_user=admin<br>ubuntu ansible_host=44.201.181.146 ansible_user=ubuntu<br>red-hat ansible_host=54.86.42.222 ansible_user=ec2-user</pre><p>The first item on each line is an arbitrarily named key. The next two items specify the server’s public IP and the default username to use. Now we can ping one or more of them:</p><pre>$ ansible red-hat -m ping<br>$ anisble all -m ping</pre><p>If everything works then pat yourself on the back, but we can finish this article up by now having Terraform manage that inventory file for us. If you opted to use symlinks for your module files then you will only need to edit main.shared, otherwise you will need to add these blocks to all of your modules files. It is the last two local-exec blocks but I am including the entire contents of the file so as to hopefully be clearer to you:</p><pre>resource &quot;aws_instance&quot; &quot;host&quot; {<br>    ami           = var.ami<br>    instance_type = var.instance_type</pre><pre>    user_data = &lt;&lt;-EOF<br>        #!/bin/bash<br>        echo &quot;${var.ssh_rsa}&quot; &gt; /home/${var.username}/.ssh/authorized_keys<br>        EOF</pre><pre>    vpc_security_group_ids = var.security_groups<br>    tags = {<br>        Name = var.servername<br>    }</pre><pre>    provisioner &quot;local-exec&quot; {<br>      command = &quot;sleep 60; ssh-keyscan ${self.public_ip} &gt;&gt; ~/.ssh/known_hosts&quot;<br>    }</pre><pre>    provisioner &quot;local-exec&quot; {<br>      command = &quot;echo ${var.servername} id=${self.id} ansible_host=${self.public_ip} ansible_user=${var.username} &gt;&gt; /etc/ansible/hosts&quot;<br>    }</pre><pre>    provisioner &quot;local-exec&quot; {<br>      command = &quot;sleep $((RANDOM % 20)); sed -i \&quot;\&quot; &#39;/${self.id}/d&#39; /etc/ansible/hosts&quot;<br>      when = destroy<br>    }<br>}</pre><p>The first local-exec block was already there from last time. It is the next two that you need to add. The first one writes a custom record to /etc/ansible/hosts using servername, the public_id and the username as hopefully is expected:</p><pre>echo ${var.servername} id=${self.id} ansible_host=${self.public_ip} ansible_user=${var.username} &gt;&gt; /etc/ansible/hosts</pre><p>but we also add the id so that we may use it to delete the record when the resource is destroyed:</p><pre>sleep $((RANDOM % 20)); sed -i \&quot;\&quot; &#39;/${self.id}/d&#39; /etc/ansible/hosts</pre><p>The flaw with this solution is when we attempt to destroy the resource. Terraform will execute this line simultaneously for all created instances, resulting in a race condition that prevents all but the first process to run. In order to prevent that I have added a command to sleep for a random amount of time, but even this will fail once in a blue moon if the same random numbers are ever selected.</p><p>But now when we run:</p><pre>$ terraform apply run.me</pre><p>Whatever servers we specified will be spun up and they will have an inventory record inserted in the inventory file. And when they are destroyed:</p><pre>$ terraform destroy -auto-approve</pre><blockquote><em>If you found this article helpful, please </em><strong><em>don’t forget</em></strong><em> to hit the </em><strong><em>Follow</em></strong><em> and </em><strong><em>Clap </em></strong><em>buttons to help me write more articles like this.<br></em><strong><em>Thank You 🖤</em></strong></blockquote><blockquote><strong><em>You can contact me on: </em></strong><a href="http://www.linkedin.com/in/abhi-sharma24"><em>LinkedIn</em></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3ab86d1f6e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Terraform -From Basics to Advanced Concepts — Week Fifteen]]></title>
            <link>https://medium.com/@abhi_24s/exploring-terraform-from-basics-to-advanced-concepts-week-fifteen-dbf4f5ecc60f?source=rss-073e47ae5014------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbf4f5ecc60f</guid>
            <dc:creator><![CDATA[Abhay Sharma]]></dc:creator>
            <pubDate>Fri, 22 Nov 2024 05:02:22 GMT</pubDate>
            <atom:updated>2024-11-22T05:02:22.926Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AxbrIy2KOOLePDDoXgKInw.jpeg" /></figure><h3>Exploring Terraform -From Basics to Advanced Concepts — Week Fifteen</h3><h3>Hello Medium Community! 🌟</h3><p>In this week’s deep dive, we explored Terraform, an Infrastructure as Code (IaC) tool that allows you to build, change, and version infrastructure safely and efficiently. Terraform is a powerful tool for managing and provisioning cloud resources, and in this blog, we’ll cover its essential concepts, how it compares with other tools like Ansible, and provide a step-by-step guide to getting started with Terraform on AWS and GitHub. The practical aspects of Terraform, focusing on creating and managing AWS resources. We’ll cover setting up an EC2 instance, generating and assigning SSH keys, creating security groups, and managing Terraform workspaces</p><h3>What is Terraform?</h3><p>Terraform is an open-source IaC tool developed by HashiCorp that allows users to define and provision infrastructure using a high-level configuration language. Terraform supports multiple cloud providers, making it a versatile tool for managing infrastructure across various platforms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/0*7JytlNttalhlHDKN.jpeg" /></figure><h3>Why Use Terraform?</h3><p>Terraform is widely used because it offers several key advantages:</p><ul><li><strong>Provider Agnostic:</strong> Terraform supports multiple cloud providers (AWS, Azure, Google Cloud) and other platforms like GitHub, allowing you to manage your entire infrastructure using a single tool.</li><li><strong>Declarative Language:</strong> Terraform uses a declarative language, meaning you define the desired state of your infrastructure, and Terraform automatically figures out how to achieve it.</li><li><strong>Automation:</strong> Terraform allows you to automate the provisioning and management of your infrastructure with simple commands.</li><li><strong>Version Control:</strong> With Terraform, you can track changes to your infrastructure over time, similar to how you version control your code.</li></ul><h3>Terraform vs. Ansible</h3><ul><li><strong>Infrastructure Creation:</strong> Terraform is specifically designed for creating infrastructure, whereas Ansible is more focused on configuration management.</li><li><strong>Configuration Management:</strong> Ansible is ideal for deploying and configuring software, while Terraform is better suited for building and managing infrastructure.</li><li><strong>State Management:</strong> Terraform maintains a state file that tracks the current state of your infrastructure, enabling it to make precise changes. Ansible does not maintain state in the same way, which can lead to differences between the desired and actual state of your resources.</li></ul><h3>Getting Started with Terraform on Windows</h3><h3>Installing Terraform</h3><ol><li><strong>Download Terraform:</strong></li></ol><ul><li>Visit the official Terraform website and download the appropriate version for Windows.</li><li>Extract the downloaded file.</li></ul><p><strong>2. Add Terraform to System Path:</strong></p><ul><li>Search for “Edit the system environment variables” in the Windows search bar.</li><li>Click on “Environment Variables.”</li><li>Under “System Variables,” find and select “Path,” then click “Edit.”</li><li>Add the path to the Terraform executable and save the changes.</li></ul><p><strong>3. Verify Installation:</strong></p><ul><li>Open Command Prompt and type terraform -help to confirm that Terraform is installed correctly.</li></ul><p><strong>4. Set Up Text Editor:</strong></p><ul><li>Use a text editor like Visual Studio Code (VS Code).</li><li>Install the HashiCorp Terraform extension for syntax highlighting and other features.</li></ul><h3>Writing Your First Terraform Configuration</h3><ol><li><strong>Create a Terraform File:</strong></li></ol><ul><li>Create a new file with a .tf extension, for example, first.tf.</li></ul><p><strong>2. Basic Terraform Syntax:</strong></p><ul><li>Terraform configurations are written in blocks that define resources or settings. Each block has a label and a body, for example:</li></ul><pre>output &quot;Hello1&quot; </pre><pre>  { <br>    value = &quot;Hello World&quot; <br>  }</pre><p><strong>3. Executing Terraform Commands:</strong></p><ul><li>Run terraform plan in the terminal to see the planned actions.</li><li>Terraform will output the defined values, showing that the configuration is correct.</li></ul><h3>Working with Multiple Blocks and Files</h3><h3>Multiple Blocks in a Single File</h3><p>You can define multiple blocks in a single Terraform file. This helps organize related configurations together.</p><pre>output &quot;FirstOutput&quot; {<br>    value = &quot;First Output of Terraform&quot;<br>}<br>output &quot;SecondOutput&quot; {<br>    value = &quot;Second Output of Terraform&quot;<br>}<br>output &quot;ThirdOutput&quot; {<br>    value = &quot;Third Output of Terraform&quot;<br>}</pre><h3>Multiple Terraform Files in a Directory</h3><p>Terraform automatically processes all .tf files in a directory, which allows you to separate different aspects of your infrastructure into different files. For example, you can have one file for EC2 instances and another for application configurations.</p><h3>Working with Variables</h3><h3>Defining Variables</h3><p>Variables allow you to parameterize your Terraform configurations, making them more flexible and reusable.</p><pre>variable &quot;username&quot; {<br>}<br>output &quot;printname&quot; {<br>    value = &quot;Hello ${var.username}&quot;<br>}</pre><h3>Passing Variables from the Command Line</h3><p>You can pass variable values directly from the command line when executing Terraform commands:</p><pre>terraform plan -var &quot;username=Shubham&quot;</pre><h3>Using Multiple Variables</h3><p>Terraform supports multiple variables in the same configuration, which can be used to customize different aspects of your infrastructure.</p><pre>variable &quot;username&quot; {<br>    type = string<br>    default = &quot;world&quot;<br>}<br>variable &quot;age&quot; {<br>    type = number<br>    default = 25<br>}<br>output &quot;printname&quot; {<br>    value = &quot;Hello ${var.username}, and your age is ${var.age}&quot;<br>}</pre><h3>Advanced Terraform Features</h3><h3>Lists and Maps</h3><p>Terraform supports complex data structures like lists and maps, allowing for more sophisticated configurations.</p><ul><li><strong>List Example:</strong></li></ul><pre>variable &quot;users&quot; {<br>    type = list(string)<br>}</pre><pre>output &quot;printFirst&quot; {<br>    value = &quot;First user is ${var.users[0]}&quot;<br>}</pre><ul><li><strong>Map Example:</strong></li></ul><pre>variable &quot;userage&quot; {<br>    type = map<br>    default = {<br>        &quot;Shubham&quot; = 25<br>        &quot;Asif&quot; = 30<br>    }<br>}</pre><pre>output &quot;userage&quot; {<br>    value = &quot;My name is ${var.username} and my age is ${lookup(var.userage, var.username)}&quot;<br>}</pre><h3>Terraform State and Commands</h3><ul><li><strong>Terraform Init:</strong> Initializes a Terraform working directory, downloading any necessary plugins.</li><li><strong>Terraform Plan:</strong> Creates an execution plan, showing what actions Terraform will take.</li><li><strong>Terraform Apply:</strong> Applies the changes required to reach the desired state of the configuration.</li><li><strong>Terraform Destroy:</strong> Destroys the infrastructure managed by Terraform.</li><li><strong>Terraform Validate:</strong> Validates the configuration files.</li><li><strong>Terraform Refresh:</strong> Refreshes the state file with the real infrastructure state.</li><li><strong>Terraform FMT:</strong> Formats the configuration files for readability.</li></ul><h3>Managing Resources with Terraform</h3><h3>Creating AWS Resources</h3><p>You can create AWS resources using Terraform, such as EC2 instances. Here’s a basic example:</p><pre>provider &quot;aws&quot; {<br>    region = &quot;us-west-2&quot;<br>    access_key = &quot;&lt;your-access-key&gt;&quot;<br>    secret_key = &quot;&lt;your-secret-key&gt;&quot;<br>}<br>resource &quot;aws_instance&quot; &quot;web&quot; {<br>    ami = &quot;ami-0e472ba48eb589f49&quot;<br>    instance_type = &quot;t2.micro&quot;<br>    tags = {<br>        Name = &quot;first-tf-instance&quot;<br>    }<br>}</pre><h3>Managing GitHub Repositories</h3><p>Terraform can also manage resources on platforms like GitHub. Here’s how you can create a GitHub repository using Terraform:</p><pre>provider &quot;github&quot; {<br>    token = &quot;&lt;your-github-token&gt;&quot;<br>}<br>resource &quot;github_repository&quot; &quot;First_repo_to_github&quot; {<br>    name        = &quot;First_repo_from_github&quot;<br>    description = &quot;My awesome codebase&quot;<br>    visibility  = &quot;public&quot;<br>}</pre><h3>Setting Up the AWS Provider</h3><p>Before creating any resources in AWS, you need to configure the AWS provider in Terraform. The provider block is essential as it allows Terraform to authenticate and interact with your AWS account.</p><pre>provider &quot;aws&quot; {<br>  region     = &quot;us-west-2&quot;<br>  access_key = &quot;&lt;your-access-key&gt;&quot;<br>  secret_key = &quot;&lt;your-secret-key&gt;&quot;<br>}</pre><h3>Creating Your First AWS Resource: EC2 Instance</h3><p>With the provider set up, let’s create an EC2 instance. This is one of the most basic and essential resources in AWS.</p><pre>resource &quot;aws_instance&quot; &quot;web&quot; {<br>  ami           = &quot;ami-0e472ba48eb589f49&quot;  # Amazon Machine Image (AMI) ID<br>  instance_type = &quot;t2.micro&quot;  # Instance type</pre><pre>  tags = {<br>    Name = &quot;first-tf-instance&quot;  # Tagging the instance for identification<br>  }<br>}</pre><p>This code will launch a t2.micro EC2 instance using the specified AMI.</p><h3>Creating an AWS SSH Key and Reading a File in Terraform</h3><p>To securely access your EC2 instance, you need to generate an SSH key pair. You can create this key pair using the ssh-keygen command in your terminal.</p><p><strong>Command to Generate SSH Key:</strong></p><pre>ssh-keygen -t rsa -b 2048 -f ~/.ssh/my-key-pair</pre><p>To use this SSH key with your EC2 instance in Terraform, you can read the public key file and assign it to the instance.</p><p><strong>Code Example:</strong></p><pre>resource &quot;aws_key_pair&quot; &quot;deployer&quot; {<br>  key_name   = &quot;my-key-pair&quot;<br>  public_key = file(&quot;~/.ssh/my-key-pair.pub&quot;)<br>}</pre><p>Then, you can reference this key pair in your EC2 instance configuration:</p><pre>resource &quot;aws_instance&quot; &quot;web&quot; {<br>  ami           = &quot;ami-0e472ba48eb589f49&quot;<br>  instance_type = &quot;t2.micro&quot;<br>  key_name      = aws_key_pair.deployer.key_name</pre><pre>  tags = {<br>    Name = &quot;first-tf-instance&quot;<br>  }<br>}</pre><h3>Creating a Security Group Using Terraform</h3><p>A security group acts as a virtual firewall for your instance to control inbound and outbound traffic. You can create a security group in Terraform and apply it to your EC2 instance.</p><h3>Code Example:</h3><pre>resource &quot;aws_security_group&quot; &quot;web_sg&quot; {<br>  name        = &quot;allow_ssh_http&quot;<br>  description = &quot;Allow SSH and HTTP traffic&quot;<br>  vpc_id      = &quot;&lt;your-vpc-id&gt;&quot;</pre><pre>  ingress {<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }</pre><pre>  ingress {<br>    from_port   = 80<br>    to_port     = 80<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }</pre><pre>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br>}</pre><p>This configuration allows SSH and HTTP traffic to the instance and allows all outbound traffic.</p><h3>Visualizing Terraform Configuration: Terraform Graph</h3><p>Terraform provides a graph command that can generate a visual representation of your infrastructure, helping you understand dependencies and resource relationships.</p><h3>Command to Generate a Graph:</h3><pre>terraform graph | dot -Tpdf &gt; graph.pdf</pre><p>This command outputs a PDF file (graph.pdf) that visually represents the resources defined in your Terraform configuration.</p><h3>Managing Environments with Terraform Workspaces</h3><p>Terraform workspaces allow you to manage multiple environments (e.g., development, staging, production) from a single Terraform configuration. Each workspace has its own state file, keeping environments isolated.</p><h3>Common Terraform Workspace Commands:</h3><pre>terraform workspace list          # List all workspaces<br>terraform workspace new dev       # Create a new workspace named &#39;dev&#39;<br>terraform workspace show          # Show the current workspace<br>terraform workspace select dev    # Switch to the &#39;dev&#39; workspace</pre><h3>Closure</h3><p>Terraform is a powerful tool that simplifies the process of managing and provisioning infrastructure. Whether you’re setting up cloud resources on AWS or managing repositories on GitHub, Terraform provides a consistent and efficient way to manage infrastructure as code. By mastering the basics and exploring advanced features, you can automate complex environments and improve the reliability of your deployments.</p><blockquote>If you found this article helpful, please <strong>don’t forget</strong> to hit the <strong>Follow</strong> and <strong>Clap </strong>buttons to help me write more articles like this.<br><strong>Thank You 🖤</strong></blockquote><blockquote><strong>You can contact me on: </strong><a href="http://www.linkedin.com/in/abhi-sharma24">LinkedIn</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbf4f5ecc60f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with DevOps!]]></title>
            <link>https://medium.com/@abhi_24s/getting-started-with-devops-849d54c8e253?source=rss-073e47ae5014------2</link>
            <guid isPermaLink="false">https://medium.com/p/849d54c8e253</guid>
            <dc:creator><![CDATA[Abhay Sharma]]></dc:creator>
            <pubDate>Wed, 20 Nov 2024 05:19:33 GMT</pubDate>
            <atom:updated>2024-11-20T05:19:33.178Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*yGTX-bgjjNxRFgV3BEmUMA.png" /></figure><h3>What is DevOps ?</h3><p>DevOps is a combination of practices, cultural philosophies, and tools that help organizations to deliver applications and services at a high velocity. It allows businesses to improve and evolve their products faster than traditional software development and infrastructure management processes.</p><h3>What is Automation, Scaling, Infrastructure?</h3><p>DevOps includes three key components:</p><ul><li><strong>Automation: </strong>DevOps automation involves using technology to perform tasks with reduced human assistance, enabling operations and development teams to deploy iterative updates to applications in production faster.</li><li><strong>Scaling:</strong> DevOps enables businesses to configure their systems to expand during high demand and scale down when demand falls. It offers several practices that make it an ideal area to achieve the desired level of scalability.</li><li><strong>Infrastructure:</strong> Infrastructure as code is a DevOps methodology that uses a descriptive model to define and deploy infrastructure like networks, virtual machines, load balancers, and connection topologies.</li></ul><h3>Why DevOps is Important?</h3><p>DevOps is important for several reasons:</p><ul><li><strong>Speed: </strong>DevOps enables businesses to move at high velocity, innovate for customers faster, adapt to changing markets better, and grow more efficiently, driving better business results.</li><li><strong>Rapid Delivery: </strong>DevOps increases the frequency and pace of releases, allowing organizations to innovate and improve products faster. The quicker businesses can release new features and fix bugs, the faster they can respond to their customers’ needs and build a competitive advantage.</li><li><strong>Reliability:</strong> DevOps ensures the quality of application updates and infrastructure changes, leading to better reliability and a positive end-user experience. DevOps practices like continuous integration and delivery help test each change to ensure its functionality and safety, while monitoring and logging practices enable businesses to stay informed of performance in real-time.</li><li><strong>Scale: </strong>DevOps helps businesses operate and manage their infrastructure and development processes at scale. Automation and consistency reduce risks and increase efficiency, and infrastructure as code allows for the repeatable and efficient management of development, testing, and production environments.</li><li><strong>Improved Collaboration: </strong>DevOps fosters better collaboration between developers and operations teams, encouraging values like ownership and accountability. Developers and operations teams can collaborate closely, share responsibilities, and combine their workflows, reducing inefficiencies and saving time.</li><li><strong>Security: </strong>DevOps allows businesses to move quickly while retaining control and preserving compliance. Automated compliance policies, fine-grained controls, and configuration management techniques enable businesses to adopt a DevOps model without sacrificing security. For example, using infrastructure as code and policy as code, businesses can define and track compliance at scale.</li></ul><blockquote>If you found this article helpful, please <strong>don’t forget</strong> to hit the <strong>Follow</strong> and <strong>Clap </strong>buttons to help me write more articles like this.<br><strong>Thank You 🖤</strong></blockquote><blockquote><strong>You can contact me on: </strong><a href="http://www.linkedin.com/in/abhi-sharma24">LinkedIn</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=849d54c8e253" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Monitoring and Performance Tuning in Linux -DevOps Prerequisite 5]]></title>
            <link>https://medium.com/@abhi_24s/system-monitoring-and-performance-tuning-in-linux-devops-prerequisite-5-d07520ea32ea?source=rss-073e47ae5014------2</link>
            <guid isPermaLink="false">https://medium.com/p/d07520ea32ea</guid>
            <dc:creator><![CDATA[Abhay Sharma]]></dc:creator>
            <pubDate>Tue, 19 Nov 2024 08:19:49 GMT</pubDate>
            <atom:updated>2024-11-19T08:19:49.909Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*yZZbkbVwc65jovu8umPkCw.png" /></figure><p>## System Monitoring and Performance Tuning in Linux</p><p>System monitoring and performance tuning are essential tasks for ensuring that your Linux environment runs efficiently and effectively. This article will cover a range of tools and techniques for monitoring system performance and tuning various aspects of a Linux system. We will delve into CPU, memory, disk I/O, and network monitoring, as well as provide strategies for optimizing system performance.</p><p>### Table of Contents</p><p>1. **Introduction to System Monitoring and Performance Tuning**<br>2. **Monitoring Tools**<br> — top<br> — htop<br> — vmstat<br> — iostat<br> — dstat<br> — netstat and ss<br> — iftop<br>3. **CPU Monitoring and Tuning**<br> — Monitoring CPU Usage<br> — Tuning CPU Performance<br>4. **Memory Monitoring and Tuning**<br> — Monitoring Memory Usage<br> — Tuning Memory Performance<br>5. **Disk I/O Monitoring and Tuning**<br> — Monitoring Disk I/O<br> — Tuning Disk Performance<br>6. **Network Monitoring and Tuning**<br> — Monitoring Network Traffic<br> — Tuning Network Performance<br>7. **Best Practices for System Monitoring and Performance Tuning**<br>8. **Conclusion**</p><p>### 1. Introduction to System Monitoring and Performance Tuning</p><p>System monitoring involves continuously checking various system metrics to ensure that your system is running smoothly. Performance tuning involves making adjustments to system parameters and configurations to improve performance. Effective system monitoring and performance tuning can help prevent bottlenecks, reduce downtime, and ensure optimal resource utilization.</p><p>### 2. Monitoring Tools</p><p>Linux offers a variety of tools for monitoring system performance. Here are some of the most commonly used tools:</p><p>#### top</p><p>The `top` command provides a dynamic real-time view of the system’s processes, showing CPU and memory usage.</p><pre>bash<br>top</pre><p>#### htop</p><p>`htop` is an enhanced version of `top`, providing a more user-friendly interface and additional features such as mouse support and visual indicators.</p><pre>bash<br>sudo apt install htop<br>htop</pre><p>#### vmstat</p><p>`vmstat` reports information about processes, memory, paging, block I/O, traps, and CPU activity.</p><pre>bash<br>vmstat 2</pre><p>This command updates every 2 seconds.</p><p>#### iostat</p><p>`iostat` provides statistics on CPU and I/O usage.</p><pre>bash<br>sudo apt install sysstat<br>iostat -xz 2</pre><p>This command shows extended statistics (-x) with device utilization (-z) every 2 seconds.</p><p>#### dstat</p><p>`dstat` combines the functionality of `vmstat`, `iostat`, `netstat`, and `ifstat`.</p><pre>bash<br>sudo apt install dstat<br>dstat</pre><p>#### netstat and ss</p><p>`netstat` and `ss` are used for network statistics.</p><pre>bash<br>netstat -tuln<br>ss -tuln</pre><p>#### iftop</p><p>`iftop` displays bandwidth usage on an interface by host.</p><pre>bash<br>sudo apt install iftop<br>sudo iftop -i eth0</pre><p>### 3. CPU Monitoring and Tuning</p><p>#### Monitoring CPU Usage</p><p>Use `top`, `htop`, `vmstat`, and `iostat` to monitor CPU usage.</p><pre>bash<br>top -d 1</pre><p>The `-d` option sets the delay between updates to 1 second.</p><p>#### Tuning CPU Performance</p><p>- **Adjust CPU Scheduling**: Use `chrt` to set real-time scheduling policies.</p><pre>bash<br> sudo chrt -f -p 99 $(pgrep your_process)</pre><p>- **Set CPU Affinity**: Use `taskset` to bind processes to specific CPUs.</p><pre>bash<br> sudo taskset -c 0,1 your_process</pre><p>- **Enable/Disable Hyper-Threading**: Modify the BIOS/UEFI settings to enable or disable hyper-threading.</p><p>### 4. Memory Monitoring and Tuning</p><p>#### Monitoring Memory Usage</p><p>Use `free`, `vmstat`, and `htop` to monitor memory usage.</p><pre>bash<br>free -h</pre><p>The `-h` option displays the output in human-readable format.</p><p>#### Tuning Memory Performance</p><p>- **Adjust Swappiness**: The `swappiness` parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk.</p><pre>bash<br> sudo sysctl vm.swappiness=10</pre><p>- **Cache Pressure**: The `vfs_cache_pressure` parameter controls the tendency of the kernel to reclaim memory used for caching.</p><pre>bash<br> sudo sysctl vm.vfs_cache_pressure=50</pre><p>- **Use HugePages**: HugePages can improve performance for applications with large memory requirements.</p><pre>bash<br> sudo sysctl vm.nr_hugepages=128</pre><p>### 5. Disk I/O Monitoring and Tuning</p><p>#### Monitoring Disk I/O</p><p>Use `iostat`, `dstat`, and `iotop` to monitor disk I/O.</p><pre>bash<br>sudo iotop -o</pre><p>The `-o` option shows only processes or threads actually doing I/O.</p><p>#### Tuning Disk Performance</p><p>- **Use the Correct I/O Scheduler**: The I/O scheduler can be changed using `sysfs`.</p><pre>bash<br> echo noop | sudo tee /sys/block/sda/queue/scheduler</pre><p>- **Enable Write Caching**: Write caching can improve performance but at the risk of data loss in case of power failure.</p><pre>bash<br> sudo hdparm -W1 /dev/sda</pre><p>- **Tune Filesystem Parameters**: Mount options such as `noatime` can reduce I/O operations.</p><pre>bash<br> sudo mount -o remount,noatime /dev/sda1</pre><p>### 6. Network Monitoring and Tuning</p><p>#### Monitoring Network Traffic</p><p>Use `iftop`, `netstat`, `ss`, and `nload` to monitor network traffic.</p><pre>bash<br>sudo apt install nload<br>sudo nload</pre><p>#### Tuning Network Performance</p><p>- **Adjust TCP Settings**: Tune various TCP parameters using `sysctl`.</p><pre>bash<br> sudo sysctl -w net.ipv4.tcp_fin_timeout=30<br> sudo sysctl -w net.ipv4.tcp_window_scaling=1</pre><p>- **Use NIC Offloading**: Enable or disable NIC offloading features such as TCP segmentation offload (TSO).</p><pre>bash<br> sudo ethtool -K eth0 tso on</pre><p>**Optimize Network Buffers**: Increase the size of network buffers to handle more data.</p><pre>bash<br> sudo sysctl -w net.core.rmem_max=16777216<br> sudo sysctl -w net.core.wmem_max=16777216</pre><p>### 7. Best Practices for System Monitoring and Performance Tuning</p><p>- **Regular Monitoring**: Set up regular monitoring to catch issues before they become critical.<br>- **Automate Tasks**: Use tools like `cron` and monitoring software to automate regular checks and alerts.<br>- **Document Changes**: Keep a log of all tuning changes to understand their impact.<br>- **Start Small**: Make small, incremental changes and monitor their effects before making further adjustments.<br>- **Balance Performance and Stability**: Ensure that performance improvements do not compromise system stability.</p><p>### 8. Conclusion</p><p>System monitoring and performance tuning are critical skills for maintaining a healthy and efficient Linux environment. By using the right tools and techniques, you can monitor CPU, memory, disk I/O, and network performance, and make informed adjustments to optimize your system. Regular monitoring and tuning not only improve performance but also help in proactive problem detection and resolution.</p><p>Mastering these skills will ensure that your Linux systems run smoothly, providing a reliable platform for your applications and services. Whether you’re managing a single server or a fleet of machines, effective system monitoring and performance tuning are indispensable for any Linux administrator.</p><p>### Code Snippets Recap</p><pre>bash<br># top command<br>top</pre><pre># htop command<br>sudo apt install htop<br>htop</pre><pre># vmstat command<br>vmstat 2</pre><pre># iostat command<br>sudo apt install sysstat<br>iostat -xz 2</pre><pre># dstat command<br>sudo apt install dstat<br>dstat</pre><pre># netstat and ss commands<br>netstat -tuln<br>ss -tuln</pre><pre># iftop command<br>sudo apt install iftop<br>sudo iftop -i eth0</pre><pre># Adjust CPU Scheduling<br>sudo chrt -f -p 99 $(pgrep your_process)</pre><pre># Set CPU Affinity<br>sudo taskset -c 0,1 your_process</pre><pre># Monitoring Memory Usage<br>free -h</pre><pre># Adjust Swappiness<br>sudo sysctl vm.swappiness=10</pre><pre># Cache Pressure<br>sudo sysctl vm.vfs_cache_pressure=50</pre><pre># Use HugePages<br>sudo sysctl vm.nr_hugepages=128</pre><pre># Monitoring Disk I/O<br>sudo iotop -o</pre><pre># Use the Correct I/O Scheduler<br>echo noop | sudo tee /sys/block/sda/queue/scheduler</pre><pre># Enable Write Caching<br>sudo hdparm -W1 /dev/sda</pre><pre># Tune Filesystem Parameters<br>sudo mount -o remount,noatime /dev/sda1</pre><pre># Monitoring Network Traffic<br>sudo apt install nload<br>sudo nload</pre><pre># Adjust TCP Settings<br>sudo sysctl -w net.ipv4.tcp_fin_timeout=30<br>sudo sysctl -w net.ipv4.tcp_window_scaling=1</pre><pre># Use NIC Offloading<br>sudo ethtool -K eth0 tso on</pre><pre># Optimize Network Buffers<br>sudo sysctl -w net.core.rmem_max=16777216<br>sudo sysctl -w net.core.wmem_max=167</pre><p>By implementing these practices and utilizing these tools, you can maintain a robust and high-performing Linux environment. Happy monitoring and tuning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d07520ea32ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Architecture Explained | of DevOps]]></title>
            <link>https://medium.com/@abhi_24s/kubernetes-architecture-explained-of-devops-19becee9d2f7?source=rss-073e47ae5014------2</link>
            <guid isPermaLink="false">https://medium.com/p/19becee9d2f7</guid>
            <dc:creator><![CDATA[Abhay Sharma]]></dc:creator>
            <pubDate>Fri, 15 Nov 2024 04:22:33 GMT</pubDate>
            <atom:updated>2024-11-15T04:22:33.755Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2b8V7yaPJg_q7dJ9pY3s2A.jpeg" /></figure><p>In this blog, I will explain the architecture of Kubernetes, one of the most popular tools for container orchestration and management.</p><p>Kubernetes is an open-source, cloud-native platform that allows you to deploy, scale, and manage your applications across multiple nodes and clusters.</p><h3>Kubernetes Overview</h3><p>Before diving into the architecture of Kubernetes, let’s first understand what Kubernetes is and why we call it k8s. Kubernetes is a Greek word that means “helmsman” or “pilot”. It is also the origin of the word “cybernetic”, which means “the science of control and communication in animals and machines”. Kubernetes is a fitting name for a tool that helps you control and communicate with your containers and machines.</p><p>Kubernetes is also abbreviated as k8s, where the number 8 represents the number of letters between the first and the last letter of Kubernetes. This is a common way of shortening long names in the tech industry, such as i18n for internationalization and a11y for accessibility.</p><h3>Benefits of using Kubernetes</h3><p>Kubernetes provides many benefits for developers and operators who want to run their applications in containers. Some of the benefits are:</p><ul><li>High availability: Kubernetes ensures that your applications are always up and running by automatically restarting failed containers, rescheduling them to different nodes, or scaling them to meet demand.</li><li>Load balancing: Kubernetes distributes the traffic among your containers by exposing them as services with their own IP addresses and DNS names. It also supports service discovery and routing mechanisms to connect your services with each other.</li><li>Scalability: Kubernetes allows you to easily scale your applications up or down by changing the number of replicas or using horizontal pod autoscaling. You can also scale your cluster by adding or removing nodes as needed.</li><li>Portability: Kubernetes enables you to run your applications on any platform that supports Kubernetes, such as public clouds, private clouds, hybrid clouds, or bare metal servers. You can also migrate your applications across different environments without changing your code or configuration.</li><li>Automation: Kubernetes automates many tasks that are otherwise tedious or error-prone, such as deployment, rollback, configuration management, secret management, service discovery, resource allocation, health monitoring, etc.</li><li>Extensibility: Kubernetes is designed to be modular and pluggable, so you can customize it to suit your needs. You can use various tools and plugins that integrate with Kubernetes, such as Helm, Istio, Prometheus, etc. You can also extend Kubernetes by adding your own custom resources and controllers.</li></ul><h3>Architecture of Kubernetes</h3><p>Kubernetes follows a client-server architecture that consists of two main components: the control plane and the data plane. The control plane is responsible for managing the state and configuration of the cluster, while the data plane is responsible for running the workloads and services on the cluster.</p><p><strong>The control plane </strong>consists of several components that communicate with each other through the API server. The API server is the central hub that exposes the Kubernetes API and processes all requests from clients and other components. The etcd is a distributed key-value store that stores the cluster data in a consistent and reliable way. The scheduler is responsible for assigning pods to nodes based on various factors such as resource requirements, affinity rules, etc. The controller manager runs various controllers that handle different aspects of the cluster such as node lifecycle, replication, service endpoints, etc. The cloud controller manager interacts with the underlying cloud provider to manage cloud-specific resources such as load balancers, storage volumes, etc.</p><p><strong>The data plane</strong> consists of several components that run on each node in the cluster. The node is a physical or virtual machine that hosts one or more pods. A pod is a group of one or more containers that share the same network namespace and storage volumes. A container is a lightweight and isolated environment that runs an application process. The kubelet is an agent that runs on each node and communicates with the API server to register the node, report its status, and execute pod operations. The kube-proxy is a network proxy that maintains network rules on each node and enables service abstraction by forwarding requests to backend pods. The container runtime is software that runs and manages containers on each node. Kubernetes supports various container runtimes such as Docker, containerd, CRI-O, etc.</p><p>The following diagram illustrates the architecture of Kubernetes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3FUNyxukxrvTLL1xc4kBWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*_rIc4HJoX1Yj9acw.png" /></figure><p>Kubernetes Architecture</p><h3>Control plane</h3><p>The control plane is the component of Kubernetes that controls and manages the state and configuration of the cluster. It consists of several components that communicate with each other through the API server. The control plane components are:</p><ul><li>API server: The central hub that exposes the Kubernetes API and processes all requests from clients and other components.</li><li>etcd: A distributed key-value store that stores the cluster data in a consistent and reliable way.</li><li>scheduler: Responsible for assigning pods to nodes based on various factors such as resource requirements, affinity rules, etc.</li><li>controller manager: Runs various controllers that handle different aspects of the cluster such as node lifecycle, replication, service endpoints, etc.</li><li>cloud controller manager: Interacts with the underlying cloud provider to manage cloud-specific resources such as load balancers, storage volumes, etc.</li></ul><p>The control plane components can run on a single node or multiple nodes for high availability and fault tolerance. The control plane node is also called the master node.</p><h3>Difference between kubectl and kubelet</h3><p>kubectl and kubelet are two different tools that are used to interact with Kubernetes. The main difference between them are:</p><ul><li>kubectl is a command-line interface (CLI) tool that allows you to communicate with the API server and perform various operations on the cluster, such as creating, updating, deleting, or inspecting resources. You can use kubectl on any machine that can access the API server, such as your local machine or a remote server.</li><li>kubelet is an agent that runs on each node in the cluster and communicates with the API server to register the node, report its status, and execute pod operations. You can use kubelet to manage the pods and containers on a specific node, such as starting, stopping, or restarting them.</li></ul><h3>Role of the API server</h3><p>The API server is the central hub of the Kubernetes control plane that exposes the Kubernetes API and processes all requests from clients and other components. The API server performs the following roles:</p><ul><li>It validates and configures the data for the API objects, such as pods, services, deployments, etc.</li><li>It updates the etcd store with the latest state of the API objects.</li><li>It provides a RESTful interface for clients to access and manipulate the API objects.</li><li>It handles the authentication and authorization of clients and enforces admission control policies on requests.</li><li>It supports various features such as versioning, discovery, aggregation, webhooks, etc.</li></ul><p>The API server is designed to be scalable and extensible. You can run multiple instances of the API server and balance the traffic between them. You can also extend the API server by adding custom resources and controllers.</p><blockquote><em>If you found this article helpful, please </em><strong><em>don’t forget</em></strong><em> to hit the </em><strong><em>Follow</em></strong><em> and </em><strong><em>Clap </em></strong><em>buttons to help me write more articles like this.<br></em><strong><em>Thank You 🖤</em></strong></blockquote><blockquote><strong><em>You can contact me on: </em></strong><a href="http://www.linkedin.com/in/abhi-sharma24"><em>LinkedIn</em></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19becee9d2f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bash Scripts Every DevOps Engineer Should Automate]]></title>
            <link>https://medium.com/@abhi_24s/bash-scripts-every-devops-engineer-should-automate-57c33f0fe7e9?source=rss-073e47ae5014------2</link>
            <guid isPermaLink="false">https://medium.com/p/57c33f0fe7e9</guid>
            <dc:creator><![CDATA[Abhay Sharma]]></dc:creator>
            <pubDate>Thu, 14 Nov 2024 04:13:02 GMT</pubDate>
            <atom:updated>2024-11-14T04:13:02.859Z</atom:updated>
            <content:encoded><![CDATA[<p>In DevOps, time is everything. The more you automate, the more you can focus on innovation. From routine server maintenance to cloud integrations, Bash scripts are an invaluable tool for automating your workflows, making your day-to-day work faster, simpler, and error-free.</p><p>Here’s a list of Bash scripts every DevOps engineer should know. These scripts cover core operations that can be customized to fit any environment and scaled for larger infrastructures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*NNrIH9_3BBYWPdFC7AUmiA.png" /></figure><h3>1. Automate Server Updates</h3><p><strong>Purpose:</strong> Keep your OS up-to-date without manual work. Schedule automatic updates for better security and stability.</p><p><strong>Script:</strong></p><pre>#!/bin/bash<br># Update and upgrade system packages<br>echo &quot;Starting system update...&quot;<br>sudo apt update &amp;&amp; sudo apt upgrade -y<br>echo &quot;System update completed.&quot;<br><br></pre><p><strong>Pro Tip:</strong> Set this up to run weekly with cron jobs and send email alerts for failed updates.</p><h3>2. Automated MySQL Database Backup and Restore</h3><p><strong>Purpose:</strong> Ensure you always have a recent backup of your databases.</p><p><strong>Script:</strong></p><pre>#!/bin/bash<br>DATE=$(date +&quot;%Y%m%d&quot;)<br>mysqldump -u username -p&#39;password&#39; database_name &gt; /backups/db_backup_$DATE.sql</pre><p><strong>Pro Tip:</strong> Extend this to automatically transfer backups to AWS S3 or any off-site storage for extra safety.</p><h3>3. Monitor Disk Usage</h3><p><strong>Purpose:</strong> Get notified when storage levels get critical.</p><p><strong>Script:</strong></p><pre>!/bin/bash<br># Check disk usage and send alert if usage exceeds 80%<br>THRESHOLD=80<br>df -h | awk &#39;{ if($5+0 &gt; THRESHOLD) print $0; }&#39; | while read output;<br>do<br>    echo &quot;Disk usage alert: $output&quot;<br>done</pre><p><strong>Pro Tip:</strong> Add alert notifications to know when storage usage hits a critical threshold.</p><h3>4. Log File Cleanup</h3><p><strong>Purpose:</strong> Free up disk space by purging old log files.</p><p><strong>Script:</strong></p><pre>#!/bin/bash<br>find /var/log -type f -name &quot;*.log&quot; -mtime +30 -exec rm -f {} \;</pre><p><strong>Pro Tip:</strong> Use this script to delete logs only when disk usage is high, but keep the most recent ones for audits.</p><h3>5. Bulk User Management</h3><p><strong>Purpose:</strong> Quickly add or manage multiple users with a single script.</p><p><strong>Script:</strong></p><pre>#!/bin/bash<br>while read user; do<br>  sudo useradd -m $user<br>done &lt; users.txt</pre><p><strong>Pro Tip:</strong> Integrate this with role-based access controls for efficient, secure user management.</p><h3>6. Automate Service Restarts</h3><p><strong>Purpose:</strong> Restart critical services automatically if they crash, ensuring uptime.</p><p><strong>Script:</strong></p><pre>#!/bin/bash<br>service_name=&quot;nginx&quot;<br>if ! systemctl is-active --quiet $service_name; then<br>  systemctl restart $service_name<br>  echo &quot;$service_name restarted on $(date)&quot; &gt;&gt; /var/log/service_restart.log<br>fi</pre><p><strong>Pro Tip:</strong> Add alert notifications for when a service is restarted.</p><h3>7. SSH Key Deployment</h3><p><strong>Purpose:</strong> Deploy SSH keys across multiple servers for secure access.</p><p><strong>Script:</strong></p><pre>#!/bin/bash<br>for server in $(cat server_list.txt); do<br>  ssh-copy-id -i ~/.ssh/id_rsa.pub $server<br>done</pre><p><strong>Pro Tip:</strong> Use this script to quickly onboard new team members with secure access to development servers.</p><h3>8. Automated SSL Certificate Renewal</h3><p><strong>Purpose:</strong> Keep your sites secure by automatically renewing SSL certificates.</p><p><strong>Script:</strong></p><pre>#!/bin/bash<br>certbot renew --quiet<br>echo &quot;SSL certificate renewed on $(date)&quot; &gt;&gt; /var/log/ssl_renew.log</pre><p><strong>Pro Tip:</strong> Set this up to run monthly, and configure it to alert you if there are any issues during renewal.</p><h3>9. Server Health Check</h3><p><strong>Purpose:</strong> Monitor server health stats like CPU, memory, and disk usage.</p><p><strong>Script:</strong></p><pre>#!/bin/bash<br>echo &quot;CPU Load: $(top -bn1 | grep &quot;load average&quot; | awk &#39;{print $10}&#39;)&quot;<br>echo &quot;Memory Usage: $(free -h | grep Mem)&quot;<br>echo &quot;Disk Usage: $(df -h)&quot;</pre><p><strong>Pro Tip:</strong> Use this to create daily health reports or integrate it with monitoring tools like Grafana.</p><h3>10. Firewall Configuration</h3><p><strong>Purpose:</strong> Quickly configure basic firewall rules for improved security.</p><p><strong>Script:</strong></p><pre>#!/bin/bash<br>ufw default deny incoming<br>ufw allow 22/tcp<br>ufw allow 80/tcp<br>ufw allow 443/tcp<br>ufw enable</pre><p><strong>Pro Tip:</strong> Customize this to restrict access to specific IP addresses or services as needed.</p><h3>11. S3 Bucket Sync for Off-Site Backups</h3><p><strong>Purpose:</strong> Add an extra layer of data security by syncing files to an S3 bucket.</p><p><strong>Script:</strong></p><pre>#!/bin/bash<br>aws s3 sync /path/to/files s3://my-bucket</pre><p><strong>Pro Tip:</strong> Set this script to run daily or weekly to automatically back up critical directories.</p><h3>12. Automate Package Installation</h3><p><strong>Purpose:</strong> Install essential packages on new servers with a single command.</p><p><strong>Script:</strong></p><pre>#!/bin/bash<br>apt update<br>apt install -y nginx mysql-server python3</pre><p><strong>Pro Tip:</strong> Use this as a foundation for more extensive provisioning scripts when setting up new environments.</p><h3>Wrapping Up</h3><p>These scripts aren’t just time-savers; they’re foundational tools for DevOps engineers looking to automate routine tasks and build a reliable infrastructure. Implement a few of these, adapt them to your environment, and start enjoying the freedom to focus on higher-impact work.</p><blockquote><em>If you found this article helpful, please </em><strong><em>don’t forget</em></strong><em> to hit the </em><strong><em>Follow</em></strong><em> and </em><strong><em>Clap </em></strong><em>buttons to help me write more articles like this.<br></em><strong><em>Thank You 🖤</em></strong></blockquote><blockquote><strong><em>You can contact me on: </em></strong><a href="http://www.linkedin.com/in/abhi-sharma24"><em>LinkedIn</em></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57c33f0fe7e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS DevOps Project: CI/CD Pipeline with Infrastructure as Code, Monitoring and more]]></title>
            <link>https://medium.com/@abhi_24s/aws-devops-project-ci-cd-pipeline-with-infrastructure-as-code-monitoring-and-more-00109c6c591d?source=rss-073e47ae5014------2</link>
            <guid isPermaLink="false">https://medium.com/p/00109c6c591d</guid>
            <dc:creator><![CDATA[Abhay Sharma]]></dc:creator>
            <pubDate>Wed, 13 Nov 2024 07:11:52 GMT</pubDate>
            <atom:updated>2024-11-13T11:30:18.179Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to build Advanced Automated CI/CD Pipeline with IAC, Microservices, Service Mesh, and Monitoring</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*OdZOqUe0qCFrkX3a0VTGOg.png" /></figure><h3>General Intro</h3><p>Welcome back to everyone. I am so glad I finally get to do this. This has been a pretty unique journey for me so far. In this <strong>AWS DevOps project (advanced)</strong>, we will build a really sophisticated CI/CD pipeline which will automate the deployment of microservices-based application on AWS. To do this, we’ll leverage key DevOps practices like <strong>Infrastructure as Code (IaC)</strong> — <strong>Terraform</strong>, container orchestration — <strong>Amazon EKS (Elastic Kubernetes Service)</strong>, <strong>service mesh integration</strong> — <strong>Istio</strong>, and <strong>comprehensive monitoring and logging</strong> — <strong>Prometheus</strong>, <strong>Grafana</strong>, and <strong>Fluentd</strong>.</p><p>We designed this project to cover complex, real-world scenarios that Cloud &amp; DevOps engineers frequently face, providing you with an in-depth understanding of how we can architect, deploy, and manage modern cloud-native applications.</p><h3>1. Project Overview</h3><p>This advanced project will guide us through setting up a complex CI/CD pipeline automating the deployment of a microservices-based application on AWS using EKS, Istio (service mesh), and Jenkins (for CI/CD). We will be covering the full lifecycle from infrastructure provisioning (using Terraform) to deploying and managing our microservices in a secure, scalable, and observable environment.</p><h3>2. Prerequisites</h3><ul><li><strong>AWS Account (Cloud)</strong>: Administrative access to an AWS account.</li><li><strong>AWS CLI</strong>: Installed and configured with appropriate credentials.</li><li><strong>Terraform (IAC)</strong>: Installed on your local machine.</li><li><strong>kubectl (K8S cli)</strong>: Installed for managing Kubernetes clusters.</li><li><strong>Jenkins</strong>: Installed on an EC2 instance or set up via Docker.</li><li><strong>Docker</strong>: Installed and running on your local machine.</li><li><strong>Git (Version control)</strong>: Installed and configured.</li><li><strong>Helm</strong>: Installed for Kubernetes package management.</li></ul><h3>3. Cloud Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*vWdJy_Npo6qw4ap6xGn_KQ.png" /></figure><p>The architecture of our project consists of a VPC which has public and private subnets. There is also an EKS cluster deployed across multiple AZs, Jenkins is deployed in a HA (highly available) configuration on EC2 with Auto-Scaling, RDS database for persistent data storage, and Istio for service mesh integration. The monitoring is handled by Prometheus and Grafana, while Fluentd does centralizes logging.</p><pre>VPC<br>├── Public Subnet<br>│   └── Jenkins (EC2 with Auto-Scaling)<br>├── Private Subnet<br>│   ├── EKS Cluster (Multi-AZ)<br>│   │   ├── Istio (Service Mesh)<br>│   │   ├── Prometheus (Monitoring)<br>│   │   └── Grafana (Monitoring)<br>│   └── RDS (Persistent Storage)<br>└── Fluentd (Centralized Logging)</pre><h3>Architecture Diagram Overview</h3><p><strong>Developer Workstations</strong></p><ul><li>Developers commit code to a GitHub repository.</li></ul><p><strong>Continuous Integration</strong></p><ul><li>Jenkins pulls the latest code from GitHub.</li><li>Builds and tests the application.</li><li>Creates Docker images and pushes them to Amazon ECR.</li></ul><p><strong>Infrastructure as Code</strong></p><ul><li>Terraform provisions AWS infrastructure:<br>- VPC<br>- IAM Roles and Policies<br>- EKS Cluster<br>- RDS</li></ul><p><strong>Continuous Deployment</strong></p><ul><li>Jenkins deploys Docker images to EKS.</li><li>Istio manages traffic between microservices.</li></ul><p><strong>Service Mesh</strong></p><ul><li>Istio provides traffic management, security, and observability.</li><li>Ingress Gateway manages external access.</li></ul><p><strong>Monitoring and Logging</strong></p><ul><li>Prometheus collects metrics.</li><li>Grafana visualizes metrics.</li><li>Fluentd centralizes logging.</li><li>Alertmanager integrates with Prometheus for alerting.</li></ul><p><strong>Continuous Feedback</strong></p><ul><li>Alertmanager sends notifications.</li><li>Jenkins provides feedback to developers.</li><li>Verify that Istio is correctly routing traffic, and Prometheus/Grafana are providing the needed observability.</li></ul><h3>Diagram Components</h3><ul><li><strong>GitHub</strong>: Version control and source code repository.</li><li><strong>Jenkins</strong>: CI/CD server for automation.</li><li><strong>Docker</strong>: Containerization tool.</li><li><strong>Terraform</strong>: Infrastructure provisioning.</li><li><strong>Amazon ECR</strong>: Docker image repository.</li><li><strong>Amazon EKS</strong>: Kubernetes service.</li><li><strong>Istio</strong>: Service mesh management.</li><li><strong>Prometheus &amp; Grafana</strong>: Monitoring stack.</li><li><strong>Fluentd</strong>: Centralized logging solution.</li><li><strong>Alertmanager</strong>: Manages alerts.</li></ul><h3>Architecture Flow</h3><ol><li><strong>Code Commit</strong>: The developers push (upload) code to GitHub.</li><li><strong>CI Pipeline</strong>: Jenkins (CICD tool) builds, tests, and creates Docker images.</li><li><strong>Image Push</strong>: Jenkins pushes docker images to Amazon ECR.</li><li><strong>Infrastructure Deployment</strong>: Terraform here provisions our AWS infrastructure.</li><li><strong>CD Pipeline</strong>: Jenkins deploys applications using Istio managing routing.</li><li><strong>Service Mesh Management</strong>: Istio here handles communication and monitoring.</li><li><strong>Monitoring &amp; Logging</strong>: Prometheus collects metrics; while Fluentd forwards logs to CloudWatch.</li><li><strong>Alerting</strong>: Alertmanager tool sends alerts based on metrics.</li></ol><h3>4. Step-by-Step</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*x2-oKs580xHNm93rc6yZzA.png" /></figure><h3>Infrastructure as Code with Terraform</h3><h3>Step 1 — Setting Up our VPC and Networking</h3><ul><li>Create a new directory for your Terraform files:</li></ul><pre>mkdir advanced-aws-devops-project<br>  cd advanced-aws-devops-project</pre><ul><li>Initialize our Terraform project:</li></ul><pre>terraform init</pre><ul><li>Next, we will create a main.tf file with the following content. It defines our VPC, subnets, and networking components:</li></ul><pre>provider &quot;aws&quot; {<br>    region = &quot;us-west-2&quot;<br>  }<br><br>resource &quot;aws_vpc&quot; &quot;main_vpc&quot; {<br>    cidr_block = &quot;10.0.0.0/16&quot;<br>    enable_dns_support = true<br>    enable_dns_hostnames = true<br>    tags = {<br>      Name = &quot;advanced-devops-vpc&quot;<br>    }<br>  }<br>  resource &quot;aws_subnet&quot; &quot;public_subnet&quot; {<br>    vpc_id            = aws_vpc.main_vpc.id<br>    cidr_block        = &quot;10.0.1.0/24&quot;<br>    map_public_ip_on_launch = true<br>    availability_zone = &quot;us-west-2a&quot;<br>    tags = {<br>      Name = &quot;public-subnet&quot;<br>    }<br>  }<br>  resource &quot;aws_subnet&quot; &quot;private_subnet&quot; {<br>    vpc_id            = aws_vpc.main_vpc.id<br>    cidr_block        = &quot;10.0.2.0/24&quot;<br>    availability_zone = &quot;us-west-2b&quot;<br>    tags = {<br>      Name = &quot;private-subnet&quot;<br>    }<br>  }<br>  resource &quot;aws_internet_gateway&quot; &quot;igw&quot; {<br>    vpc_id = aws_vpc.main_vpc.id<br>    tags = {<br>      Name = &quot;main-igw&quot;<br>    }<br>  }<br>  resource &quot;aws_route_table&quot; &quot;public_route_table&quot; {<br>    vpc_id = aws_vpc.main_vpc.id<br>    route {<br>      cidr_block = &quot;0.0.0.0/0&quot;<br>      gateway_id = aws_internet_gateway.igw.id<br>    }<br>    tags = {<br>      Name = &quot;public-route-table&quot;<br>    }<br>  }<br>  resource &quot;aws_route_table_association&quot; &quot;public_subnet_association&quot; {<br>    subnet_id      = aws_subnet.public_subnet.id<br>    route_table_id = aws_route_table.public_route_table.id<br>  }</pre><ul><li>Next, we will apply our terraform config</li></ul><pre>terraform apply</pre><h3>Step 2 — IAM Roles and Policies</h3><ul><li>For step 2, let’s create a iam.tf file where we will define IAM roles and policies for EKS, RDS, and other AWS services we’ll use:</li></ul><pre>resource &quot;aws_iam_role&quot; &quot;eks_role&quot; {<br>    name = &quot;eks_role&quot;<br>    assume_role_policy = jsonencode({<br>      &quot;Version&quot;: &quot;2012-10-17&quot;,<br>      &quot;Statement&quot;: [{<br>        &quot;Action&quot;: &quot;sts:AssumeRole&quot;,<br>        &quot;Effect&quot;: &quot;Allow&quot;,<br>        &quot;Principal&quot;: {<br>          &quot;Service&quot;: &quot;eks.amazonaws.com&quot;<br>        }<br>      }]<br>    })<br>  }<br><br>resource &quot;aws_iam_role_policy_attachment&quot; &quot;eks_policy_attachment&quot; {<br>    role       = aws_iam_role.eks_role.name<br>    policy_arn = &quot;arn:aws:iam::aws:policy/AmazonEKSClusterPolicy&quot;<br>  }<br>  <br>resource &quot;aws_iam_role&quot; &quot;rds_role&quot; {<br>    name = &quot;rds_role&quot;<br>    assume_role_policy = jsonencode({<br>      &quot;Version&quot;: &quot;2012-10-17&quot;,<br>      &quot;Statement&quot;: [{<br>        &quot;Action&quot;: &quot;sts:AssumeRole&quot;,<br>        &quot;Effect&quot;: &quot;Allow&quot;,<br>        &quot;Principal&quot;: {<br>          &quot;Service&quot;: &quot;rds.amazonaws.com&quot;<br>        }<br>      }]<br>    })<br>  }<br><br>resource &quot;aws_iam_role_policy_attachment&quot; &quot;rds_policy_attachment&quot; {<br>    role       = aws_iam_role.rds_role.name<br>    policy_arn = &quot;arn:aws:iam::aws:policy/AmazonRDSFullAccess&quot;<br>  }</pre><ul><li>Again we Apply the IAM role configuration:</li></ul><pre>terraform apply</pre><h3>Step 3 — Creating our EKS Cluster</h3><ul><li>To do this, let us go ahead and add the following to our main.tf to create an EKS cluster with auto-scaling node groups:</li></ul><pre>module &quot;eks&quot; {<br>    source          = &quot;terraform-aws-modules/eks/aws&quot;<br>    cluster_name    = &quot;advanced-eks-cluster&quot;<br>    cluster_version = &quot;1.24&quot;<br>    vpc_id          = aws_vpc.main_vpc.id<br>    subnets         = [aws_subnet.public_subnet.id, aws_subnet.private_subnet.id]<br>    node_groups = {<br>      eks_nodes = {<br>        desired_capacity = 3<br>        max_capacity     = 5<br>        min_capacity     = 2<br>        instance_type = &quot;t3.medium&quot;<br>        key_name      = &quot;your-key-pair&quot;<br>        tags = {<br>          Name = &quot;advanced-eks-node&quot;<br>        }<br>      }<br>    }<br>  }</pre><ul><li>Now we apply the new config to create our EKS</li></ul><pre>terraform apply</pre><p><strong>Step 4: Integrating with RDS for Persistent Storage</strong></p><ul><li>Great job so far. Now let us create an RDS instance for persistent storage in our rds.tf file:</li></ul><pre>resource &quot;aws_db_instance&quot; &quot;db_instance&quot; {<br>    allocated_storage    = 20<br>    engine               = &quot;mysql&quot;<br>    engine_version       = &quot;8.0&quot;<br>    instance_class       = &quot;db.t3.micro&quot;<br>    name                 = &quot;microservicesdb&quot;<br>    username             = &quot;admin&quot;<br>    password             = &quot;password&quot;<br>    parameter_group_name = &quot;default.mysql8.0&quot;<br>    skip_final_snapshot  = true<br>    vpc_security_group_ids = [aws_security_group.eks_sg.id]<br>    db_subnet_group_name   = aws_db_subnet_group.rds_subnet_group.name<br>  }<br>  resource &quot;aws_db_subnet_group&quot; &quot;rds_subnet_group&quot; {<br>    name       = &quot;rds-subnet-group&quot;<br>    subnet_ids = [aws_subnet.private_subnet.id]<br>    tags = {<br>      Name = &quot;RDS Subnet Group&quot;<br>    }<br>  }</pre><p>Again we apply this and create the RDS</p><pre>terraform apply</pre><h3>Deploying Jenkins in a HA Configuration</h3><h3>Step 5: Setting Up Jenkins on EC2 (with Auto-Scaling)</h3><ul><li>Launch Jenkins on an EC2 instance with Auto-Scaling enabled:</li></ul><pre>resource &quot;aws_launch_configuration&quot; &quot;jenkins_lc&quot; {<br>    image_id      = &quot;ami-0abcdef1234567890&quot;<br>    instance_type = &quot;t3.medium&quot;<br>    key_name      = &quot;your-key-pair&quot;<br>    security_groups = [aws_security_group.jenkins_sg.id]<br>    lifecycle {<br>      create_before_destroy = true<br>    }<br>    user_data = &lt;&lt;-EOF<br>              #!/bin/bash<br>              sudo yum update -y<br>              sudo yum install -y java-1.8.0-openjdk<br>              sudo wget -O /etc/yum.repos.d/jenkins.repo \<br>                https://pkg.jenkins.io/redhat-stable/jenkins.repo<br>              sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key<br>              sudo yum install -y jenkins<br>              sudo systemctl start jenkins<br>              sudo systemctl enable jenkins<br>              EOF<br>  }<br><br>  resource &quot;aws_autoscaling_group&quot; &quot;jenkins_asg&quot; {<br>    launch_configuration = aws_launch_configuration.jenkins_lc.id<br>    min_size             = 2<br>    max_size             = 4<br>    desired_capacity     = 2<br>    vpc_zone_identifier  = [aws_subnet.public_subnet.id]<br>    tags = [<br>      {<br>        key                 = &quot;Name&quot;<br>        value               = &quot;Jenkins Instance&quot;<br>        propagate_at_launch = true<br>      },<br>    ]<br>  }</pre><ul><li>Now let us apply our new changes</li></ul><pre>terraform apply</pre><blockquote><em>NB: Please update the Jenkins URL I am using here in case it does not work for you, the Jenkins version may have changed or updated.</em></blockquote><h3>Step 6: Configuring Jenkins Master-Slave Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*7uCyQnwXM-ptrBF1kFy1yQ.jpeg" /></figure><p>We will be using the Jenkins Master-Slave architecture. It allows us to distribute the workload of building, testing, and deploying applications across multiple machines. This unique architecture helps alot, first it enhances performance and also it provides better resource utilization, especially in large-scale environments. Below’s a detailed guide to setting up Jenkins in this architecture.</p><p>We will be using the Jenkins Master-Slave architecture. It allows us to distribute the workload of building, testing, and deploying applications across multiple machines. This unique architecture helps alot, first it enhances performance and also it provides better resource utilization, especially in large-scale environments. Below’s a detailed guide to setting up Jenkins in this architecture.</p><p><strong>Prerequisites</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M_NWcIkBgVn7OgV9gkWZgA.jpeg" /></figure><ol><li><strong>Jenkins Master Node</strong>: The main or Master Jenkins server (also known as the controller), which will orchestrate the build tasks and distributes them to the agent nodes.</li><li><strong>Jenkins Agent Nodes</strong>: These are additional servers (slaves) that execute the build tasks assigned by the Jenkins master node.</li></ol><p><strong>Step 6.1: Setting Up the Jenkins Master</strong></p><p>Normally, we’ve already set up Jenkins on an EC2 instance in the previous steps. This instance will serve as our Jenkins master. To proceed, ensure the following are in place:</p><ul><li><strong>Java is installed</strong>: Jenkins requires Java to run. Verify that Java is installed:</li></ul><pre>java -version</pre><p>If it’s not installed, you can do so with the command below:</p><pre>sudo yum install -y java-1.8.0-openjdk</pre><ul><li><strong>Jenkins Installation</strong>: Now lets access it. Our Jenkins should be running and accessible via a web browser. Confirm this by navigating to http://&lt;Jenkins_Master_IP&gt;:8080 in your browser.</li></ul><p><strong>Step 6.2: Preparing Jenkins Agent Nodes</strong></p><p>As mentioned before, we need additional EC2 instances that will act as our Jenkins agents. Here’s how to do that:</p><ol><li><strong>Launch EC2 Instances for Jenkins Agents</strong>:</li></ol><ul><li>Using the AWS Management Console, launch new EC2 instances. You can select an Amazon Linux 2 AMI (or any other Linux distribution).</li><li>Make sure that these instances have sufficient resources (e.g., t2.micro) and are in the <strong>same VPC as the Jenkins master</strong>.</li></ul><p><strong>2. Security Groups</strong>:</p><ul><li>Make sure that the security groups allow SSH access from the Jenkins master node, by adding it to the security group.</li><li>Also, allow communication on ports required for Jenkins agent-master communication (default SSH port 22).</li></ul><p><strong>3. Install Java on Agent Nodes</strong>:</p><p>Now we will SSH into each agent node and install Java:</p><pre>sudo yum update -y sudo yum install -y java-1.8.0-openjdk</pre><p><strong>4. Create Jenkins User on Agent Nodes</strong>:</p><p>To use Jenkins fully in this server, we need to create a user for it.</p><pre>sudo useradd jenkins</pre><p>Set up SSH access for this user, that way the Jenkins master can connect:</p><pre>sudo mkdir /home/jenkins/.ssh  <br>sudo chown jenkins:jenkins /home/jenkins/.ssh  <br>sudo chmod 700 /home/jenkins/.ssh</pre><ul><li>We will need the SSH keys, so let us go ahead and copy the SSH public key from the Jenkins master to each agent’s /home/jenkins/.ssh/authorized_keys file.</li></ul><p><strong>Install Jenkins Agent on Agent Nodes</strong>:</p><ol><li>Download the Jenkins agent (also called agent.jar) from the Jenkins website =&gt;</li><li>Transfer this agent.jar file to each agent node, placing it in a directory like /home/jenkins.</li></ol><p><strong>Step 6.3: Configuring our Jenkins Master to Use Agents</strong></p><ol><li><strong>Adding New Nodes in Jenkins</strong>:</li></ol><p>On the Jenkins dashboard, we’ll go to <strong>Manage Jenkins &gt; Manage Nodes and Clouds &gt; New Node</strong>.</p><ul><li>Now we can enter a name for the new node (e.g., Agent-1), select <strong>Permanent Agent</strong>, and click <strong>OK</strong>.</li></ul><p><strong>2. Configure Node Settings</strong>:</p><ul><li><strong>Remote root directory</strong>: We’ll specify the directory on the agent where our Jenkins should operate, e.g., /home/jenkins.</li><li><strong>Labels</strong>: Refers to assigning labels to the node for easy job allocation (e.g., linux-agent).</li><li><strong>Launch method</strong>: Selecting the <strong>Launch agents via SSH</strong>.</li><li><strong>Host</strong>: Here we enter the private IP address of the agent node.</li><li><strong>Credentials</strong>: Add SSH credentials (username and private key) for the jenkins user.</li></ul><p><strong>Test our Connection</strong>:</p><ul><li>First click on <strong>Save</strong> and then &gt; <strong>Launch agent via SSH</strong>.</li><li>Once we do this, Jenkins will try to connect to the agent node via SSH. If successful, you will see the agent status change to “Connected”.</li></ul><p><strong>3. Additional Agents</strong>:</p><ul><li>We can simply repeat the above steps to configure any additional Jenkins agents.</li></ul><p><strong>Step 6.4: Configuring our Jenkins Jobs to Use Specific Nodes/Agents</strong></p><p>Now that we have connected our Jenkins master to agent nodes, now we can configure jobs to run on specific agents:</p><ol><li><strong>Create or Configure a Jenkins Job</strong>:</li></ol><ul><li>Go &gt; <strong>New Item</strong> on the Jenkins dashboard or select an <strong>existing job</strong>.</li></ul><p><strong>2. Specify Node Usage</strong>:</p><ul><li>Now, under the job configuration, we will look for the section <strong>Restrict where this project can be run</strong>. The name clearly says what it does.</li><li>All left to do now is to enter the label of the agent (e.g., linux-agent) where you want the job to run.</li></ul><p><strong>3. Save and Build</strong>:</p><ul><li>We are done, so we save the job configuration and &gt; trigger a build.</li><li>This job should now execute on our specified Jenkins agent node.</li></ul><p><strong>Step 6.5: Monitoring and Managing Jenkins Agents</strong></p><p><strong>Node Monitoring</strong>:</p><ul><li>Like we already know. Jenkins does provide built-in monitoring for each agent node. View this by navigating to <strong>Manage Jenkins &gt; Manage Nodes and Clouds</strong>, where we can see the status, idle time, and load for each agent.</li></ul><p><strong>Scaling Agents</strong>:</p><ul><li>For large-scale cloud environments, we can configure auto-scaling for our agent nodes using AWS Auto Scaling Groups. This allows Jenkins to automatically scale the number of agents based on the workload.</li></ul><p><strong>Agent Availability</strong>:</p><ul><li>This ensures agents are always available by configuring them with robust health checks (such as CPU, memory, and disk usage monitoring). Integrating with monitoring tools like CloudWatch or Prometheus can help us automate this.</li></ul><h3>Building and Dockerizing Microservices</h3><h3>Step 7: Microservices Application Overview</h3><ul><li>First we will assume that we have a microservices application with the following components:</li><li><strong>User Service</strong>: Which manages user authentication and profiles.</li><li><strong>Order Service</strong>: This handles order processing and management.</li><li><strong>Payment Service</strong>: It integrates with payment gateways to process payments.</li><li>Create Dockerfiles for each service:</li></ul><p><strong>Dockerfile — User Service</strong>:</p><pre>FROM openjdk:8-jdk-alpine<br>  VOLUME /tmp<br>  ARG JAR_FILE=target/user-service.jar<br>  COPY ${JAR_FILE} user-service.jar<br>  ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/user-service.jar&quot;]</pre><p><strong>Dockerfile — Order Service</strong>:</p><pre>FROM openjdk:8-jdk-alpine<br>  VOLUME /tmp<br>  ARG JAR_FILE=target/order-service.jar<br>  COPY ${JAR_FILE} order-service.jar<br>  ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/order-service.jar&quot;]</pre><p><strong>Dockerfile — Payment Service</strong>:</p><pre>FROM openjdk:8-jdk-alpine<br>  VOLUME /tmp<br>  ARG JAR_FILE=target/payment-service.jar<br>  COPY ${JAR_FILE} payment-service.jar<br>  ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/payment-service.jar&quot;]</pre><ul><li>Now we can finally build and push our Docker images to Amazon ECR:</li></ul><pre># Build our docker images<br>docker build -t user-service ./user-service<br>docker build -t order-service ./order-service<br>docker build -t payment-service ./payment-service</pre><pre># Push images to ECR<br>  aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin &lt;aws_account_id&gt;.dkr.ecr.us-west-2.amazonaws.com<br>  docker tag user-service:latest &lt;aws_account_id&gt;.dkr.ecr.us-west-2.amazonaws.com/user-service:latest<br>  docker push &lt;aws_account_id&gt;.dkr.ecr.us-west-2.amazonaws.com/user-service:latest</pre><h3>Implementing Service Mesh with Istio</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JArdGjkCc_IOIP-e32w4LA.jpeg" /></figure><h3>Step 8: Installing Istio on EKS</h3><ul><li>First we need to install Istio on our EKS cluster using Helm:</li></ul><pre>helm repo add istio https://istio-release.storage.googleapis.com/charts<br>helm install istio-base istio/base -n istio-system --create-namespace<br>helm install istiod istio/istiod -n istio-system<br>helm install istio-ingress istio/gateway -n istio-system</pre><h3>Step 9: Configuring Traffic Management, Security, and Observability</h3><ul><li>Now let us define our <strong>Istio</strong> <strong>VirtualService</strong> and <strong>DestinationRule</strong> for traffic management. :</li></ul><pre>#virtualservice.yaml<br>apiVersion: networking.istio.io/v1alpha3<br>  kind: VirtualService<br>  metadata:<br>    name: user-service<br>  spec:<br>    hosts:<br>      - user-service<br>    http:<br>      - route:<br>          - destination:<br>              host: user-service<br>              subset: v1</pre><pre>apiVersion: networking.istio.io/v1alpha3<br>  kind: DestinationRule<br>  metadata:<br>    name: user-service<br>  spec:<br>    host: user-service<br>    subsets:<br>      - name: v1<br>        labels:<br>          version: v1</pre><ul><li>Next, we will apply security policies using Istio’s Mutual TLS (mTLS):</li></ul><pre>apiVersion: security.istio.io/v1beta1<br>  kind: PeerAuthentication<br>  metadata:<br>    name: default<br>    namespace: istio-system<br>  spec:<br>    mtls:<br>      mode: STRICT</pre><blockquote><em>Great job making it this far</em></blockquote><ul><li>We will also need to enable observability by integrating Istio telemetry with Prometheus and Grafana. We will do that at step 13.</li></ul><h3>Setting Up Jenkins CI/CD Pipeline</h3><h3>Step 10: Integrating GitHub, Jenkins, Docker, and EKS</h3><ul><li>To do this, we will use a Jenkinsfile to automate the build, test, and deployment process:</li></ul><pre>pipeline {<br>    agent any<br>    stages {<br>      stage(&#39;Checkout&#39;) {<br>        steps {<br>          git &#39;https://github.com/your-repo/microservices-app.git&#39;<br>        }<br>      }<br>      stage(&#39;Build&#39;) {<br>        steps {<br>          sh &#39;mvn clean package&#39;<br>        }<br>      }<br>      stage(&#39;Docker Build &amp; Push&#39;) {<br>        steps {<br>          script {<br>            docker.build(&quot;user-service:latest&quot;).push(&quot;${env.BUILD_TAG}&quot;)<br>          }<br>        }<br>      }<br>      stage(&#39;Deploy to EKS&#39;) {<br>        steps {<br>          script {<br>            sh &#39;kubectl apply -f k8s/deployment.yaml&#39;<br>            sh &#39;kubectl apply -f k8s/service.yaml&#39;<br>          }<br>        }<br>      }<br>    }<br>  }</pre><h3>Step 11: Implementing Blue-Green Deployments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nNOCeCUWChz54cCyGCX6ow.jpeg" /></figure><ul><li>Now we will define our deployment method. For this scenario we will go with the blue-green deployment strategy:</li></ul><pre>#user-service-green.yaml<br>apiVersion: apps/v1<br>  kind: Deployment<br>  metadata:<br>    name: user-service-green<br>  spec:<br>    replicas: 3<br>    selector:<br>      matchLabels:<br>        app: user-service<br>        version: green<br>    template:<br>      metadata:<br>        labels:<br>          app: user-service<br>          version: green<br>      spec:<br>        containers:<br>        - name: user-service<br>          image: &lt;aws_account_id&gt;.dkr.ecr.us-west-2.amazonaws.com/user-service:green<br>          ports:<br>          - containerPort: 8080</pre><ul><li>If you’ve never heard of it, please click here to read more about it. Now that we have our k8s/user-service-green.yaml ready let us apply it as well as our k8s/virtualservice.yaml.</li></ul><pre>kubectl apply -f k8s/user-service-green.yaml<br>kubectl apply -f k8s/virtualservice.yaml</pre><h3>Step 12: Automating Canary Deployments using Istio</h3><ul><li>At this step, we will implement canary deployment strategy in your Istio VirtualService:</li></ul><pre>apiVersion: networking.istio.io/v1alpha3<br>  kind: VirtualService<br>  metadata:<br>    name: user-service<br>  spec:<br>    hosts:<br>      - user-service<br>    http:<br>      - route:<br>          - destination:<br>              host: user-service<br>              subset: v1<br>            weight: 90<br>          - destination:<br>              host: user-service<br>              subset: v2<br>            weight: 10</pre><h3>Monitoring, Logging, and Alerting</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*qOX0nNDDqCAaRztoUYOnHQ.png" /></figure><h3>Step 13: Setting Up Prometheus and Grafana</h3><ul><li>Installing Prometheus and Grafana via Helm:</li></ul><pre>helm install prometheus prometheus-community/prometheus<br>  helm install grafana grafana/grafana</pre><ul><li>Next, we need to access the grafana (through the URL) and add Prometheus as a data source. We can then import Istio dashboards for monitoring. Go ahead and do that.</li></ul><p>Next we will configure our FluentD for Centralized logging.</p><h3>Step 14: Configuring Fluentd for Centralized Logging</h3><ul><li>Setting up Fluentd DaemonSet on our EKS cluster to aggregate logs from all microservices:</li></ul><pre>apiVersion: apps/v1<br>  kind: DaemonSet<br>  metadata:<br>    name: fluentd<br>  spec:<br>    selector:<br>      matchLabels:<br>        app: fluentd<br>    template:<br>      metadata:<br>        labels:<br>          app: fluentd<br>    spec:<br>      containers:<br>      - name: fluentd<br>        image: fluent/fluentd-kubernetes-daemonset:v1.11<br>        env:<br>          - name: FLUENT_ELASTICSEARCH_HOST<br>            value: &quot;elasticsearch&quot;<br>          - name: FLUENT_ELASTICSEARCH_PORT<br>            value: &quot;9200&quot;<br>        volumeMounts:<br>        - name: varlog<br>          mountPath: /var/log<br>        - name: varlibdockercontainers<br>          mountPath: /var/lib/docker/containers<br>          readOnly: true</pre><h3>Step 15: Setting Up Alertmanager for Incident Response</h3><ul><li>This is the last step in our project. Like we said we need to set up alerts for incident management. To do that we will configure Prometheus Alertmanager to send alerts based on metrics and thresholds. You can use my sample config filebelow:</li></ul><pre>global:<br>    smtp_smarthost: &#39;smtp.gmail.com:587&#39;<br>    smtp_from: &#39;alertmanager<br>@example.com&#39;<br>    smtp_auth_username: &#39;example@gmail.com&#39;<br>    smtp_auth_password: &#39;password&#39;<br>  route:<br>    receiver: &#39;email-alert&#39;<br>  receivers:<br>  - name: &#39;email-alert&#39;<br>    email_configs:<br>    - to: &#39;your-email@example.com&#39;</pre><h3>Extra step for you</h3><p>As an extra step, try to Integrate <strong>Alertmanager with Slack</strong> for real-time incident notifications. I did not include in this project but I will include it in the next projects (Follow for more).</p><h3>Conclusion:</h3><p>Have you made it this far and completed the project ?</p><blockquote><em>Hats off to you. You are one of the select patient devs in the world. You deserve a standing ovation.</em></blockquote><p>In review, this project showcases a unique and advanced AWS DevOps setup. It incorporates a <strong>multi-service architecture</strong>, <strong>Jenkins CI/CD</strong> pipelines, <strong>Docker</strong>, <strong>Kubernetes</strong>, and <strong>Istio service mesh</strong>. The step-by-step process covered everything that we needed to do. From infrastructure provisioning, automated deployments, monitoring, logging, even to alerting. I believe that this project gave you (as well as I), a comprehensive guide that all Cloud &amp; DevOps engineers can follow. The setup we used ensures HA, scalability, security, as well as observability, making it a really robust solution for managing microservices in a cloud-native environment.</p><blockquote>If you found this article helpful, please <strong>don’t forget</strong> to hit the <strong>Follow</strong> and <strong>Clap </strong>buttons to help me write more articles like this.<br><strong>Thank You 🖤</strong></blockquote><blockquote><strong>You can contact me on: </strong><a href="http://www.linkedin.com/in/abhi-sharma24">LinkedIn</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00109c6c591d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top Kubernetes Tools]]></title>
            <link>https://medium.com/@abhi_24s/top-kubernetes-tools-2bdd5dfa92c5?source=rss-073e47ae5014------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bdd5dfa92c5</guid>
            <dc:creator><![CDATA[Abhay Sharma]]></dc:creator>
            <pubDate>Tue, 12 Nov 2024 04:14:41 GMT</pubDate>
            <atom:updated>2024-11-12T04:14:41.292Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4m1jC2W3qUAwxJuZSKb0og.png" /></figure><p>Kubernetes is the most popular container orchestration tool, but it gets even better when combined with other tools. The Kubernetes ecosystem contains a huge range of tools for command line, simplifying cluster management, monitoring, security, and deployment tasks. With so many options, it can be unclear which you should use when, or what the benefits are.</p><p>In this round-up, we’ll tour 25+ leading tools that support your Kubernetes clusters. We’ll explain each tool’s key features and how it improves your Kubernetes experience.</p><h3>Why do you need Kubernetes tools?</h3><p>Kubernetes is a powerful platform with robust functionality for running containers at scale in production-grade environments. However, while it wraps containers with some higher-level concepts, it’s still a complex system that lacks crucial components required for real-world applications.</p><p>Ecosystem tools plug these gaps. They make it easier to integrate Kubernetes with your other DevOps processes, such as by supporting GitOps and <a href="https://spacelift.io/blog/kubernetes-ci-cd">CI/CD-driven deployment</a>. Kubernetes tools can also help simplify Kubernetes itself by allowing you to conveniently provision new clusters, inspect your workloads, and monitor utilization and costs.</p><h3>Top Kubernetes tools</h3><p>Establishing a robust Kubernetes toolchain allows you to interact with your clusters and workloads with optimum efficiency. To select the right tools, you should evaluate different options that offer the features you require, then assess their popularity, reliability, and how well they integrate with other solutions you’re using.</p><h3>1. Spacelift</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lxrvwyRsOYEwz0xu3jtddA.png" /><figcaption><a href="https://spacelift.io/">https://spacelift.io/</a></figcaption></figure><p>Spacelift is the most flexible Infrastructure as Code management platform, providing powerful CI/CD for your infrastructure. Your team can collaborate on infrastructure changes right from your pull requests. Spacelift lets you visualize your resources, enable self-service access, and protect against configuration drift.</p><p>Use Spacelift to manage your Kubernetes clusters without directly interacting with your cloud providers or IaC tools like Terraform, OpenTofu, Pulumi, or CloudFormation. For example, you can create a Spacelift stack that provisions a new AWS EKS cluster with Terraform, giving team members the ability to safely test their changes on demand.</p><p>Spacelift also has you covered when it comes to deploying a cluster and then deploying your application inside it. To learn more, check out: <a href="https://spacelift.io/blog/how-to-maintain-operations-around-kubernetes-cluster">How to Maintain Operations Around Kubernetes Cluster</a>.</p><h3>2. Kubectl</h3><p><a href="https://kubernetes.io/docs/reference/kubectl">Kubectl</a> is the definitive Kubernetes tool. It’s the official CLI so most Kubernetes users will frequently interact with it. Compared to manually calling the Kubernetes API, Kubectl makes it much easier to list your cluster’s resources, add new objects, and apply declarative state changes.</p><pre>kubectl [command] [TYPE] [NAME] [flags]</pre><p>Nonetheless, few users take the time to fully learn Kubectl. Mastering the available commands and options can make operations quicker and easier, improving your cluster management experience. Kubectl can also provide detailed documentation that helps you learn more about Kubernetes and your resources without having to leave your terminal.</p><h3>3. Helm</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*lj5LlDOtUHcTQWyN" /><figcaption><a href="https://helm.sh/">https://helm.sh/</a></figcaption></figure><p>Helm is a Kubernetes package management solution. It allows you to bundle your Kubernetes manifests as reusable units called charts. You can then install charts in your clusters to easily manage versioned releases and ensure that app dependencies are available.</p><p>Helm charts can also be shared with others through centralized repositories. This allows you to distribute your Kubernetes apps without making users manually modify and apply YAML files. Helm is, therefore, the ideal solution for adding Kubernetes support to an app, including all of its components, config options, and dependencies.</p><h3>4. Kustomize</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*84yVa7VEDceK3tTo" /><figcaption><a href="https://kustomize.io/">https://kustomize.io/</a></figcaption></figure><p>Kustomize is a configuration management tool that lets you customize the objects defined in Kubernetes YAML files each time they’re used. You can create a base configuration, then override it with custom layers that provide unique options for different environments such as production or staging.</p><p>Kustomize provides declarative configuration management that acts as a simple but flexible alternative to a Helm chart. Each of your overrides is created as its own YAML file, making them fully compatible with GitOps and IaC workflows. Read more: <a href="https://spacelift.io/blog/kustomize-vs-helm">Kustomize vs. Helm — How to Use &amp; Comparison</a>.</p><h3>5. kube ns and kube ctx</h3><p>kube ns and kube ctx are a pair of Kubectl plugins that make it much more convenient to work with multi-tenant Kubernetes environments. You can use kube ns &lt;namespace-name&gt; to switch between namespaces, while kube ctx &lt;context-name&gt; changes your active cluster context — letting you effortlessly move between tenants without any long-winded -n/--namespace flags or kubectl config commands.</p><h3>6. Kubernetes Dashboard</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*bfN7OFfo7-AeiHfI" /></figure><p><a href="https://github.com/kubernetes/dashboard">Kubernetes Dashboard</a> is the official Kubernetes web interface. It provides a visual overview of the workload objects in your cluster, allowing you to quickly monitor resources, change scaling options, and check Node-level CPU and memory utilization. The Dashboard is a great alternative to Kubectl when you don’t want to remember complex terminal commands.</p><h3>7. Lens</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zOhf8mT6LsnCi1gd9kv66g.png" /><figcaption><a href="https://k8slens.dev/">https://k8slens.dev/</a></figcaption></figure><p>Lens is another Kubernetes management tool with a powerful visual interface. It’s a desktop app that aims to offer an IDE-like Kubernetes experience. Lens’s features include support for Helm charts, app templates, metrics monitoring across several engines, and seamless multi-cluster connectivity. You can also use Lens to control <a href="https://spacelift.io/blog/kubernetes-rbac">Kubernetes RBAC</a> configs and invite team members to your clusters.</p><p>Learn more with our <a href="https://spacelift.io/blog/lens-kubernetes">Kubernetes Lens tutorial</a>.</p><h3>8. Argo CD</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*hFR8L5jIv_H7nAht" /></figure><p>Argo CD is a continuous delivery (CD) solution that makes it easier to automate app deployments to your Kubernetes clusters. It uses a GitOps strategy to periodically sync changes directly from your Git repositories. Argo also defends against configuration drift by regularly verifying that the objects in your cluster match those defined in your repository.</p><p><a href="https://spacelift.io/blog/argocd">ArgoCD</a> comes with a robust CLI and web interface. It allows you to take control of your Kubernetes deployments without directly exposing cluster access to developers.</p><h3>9. Argo Rollouts</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*6oKp_gw4FGbgNVtd" /></figure><p><a href="https://argoproj.github.io/rollouts">Argo Rollouts</a> enables progressive app delivery to your clusters. It lets you increase deployment safety by using strategies such as blue-green, canary, and experimental rollouts. You can declaratively configure your rollouts and the criteria that let them proceed, such as initially exposing a new release to 50% of users and gradually expanding the rollout based on time delays, metrics, or manual actions.</p><h3>10. Flux</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*gMdMirZPuJNYwz1M" /></figure><p><a href="https://fluxcd.io/">Flux CD</a> provides a toolkit of components for implementing GitOps-powered continuous delivery to your Kubernetes clusters. Similarly to ArgoCD, it automatically reconciles your cluster’s state to your Git repositories and other sources, while preventing drift.</p><p>Flux is simple to configure, easy to integrate with IaC solutions, and supported by a strong ecosystem of compatible tools and platforms.</p><h3>11. Kubecost</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*9s4dreVDaLd-XiSo" /></figure><p>Cost management is one of the most frequently encountered Kubernetes challenges.</p><p><a href="https://www.kubecost.com/">Kubecost</a> solves this problem by providing real-time insights into the costs accrued by your Kubernetes clusters running in the cloud. It lets you monitor costs over time, check which workloads are having the biggest cost impact, and identify potential savings options.</p><p>Read more about <a href="https://spacelift.io/blog/kubecost">Kubecost and how to use it</a>.</p><h3>12. Amazon EKS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*pHiaI4yBZq_TjgYJ" /></figure><p>Amazon’s <a href="https://aws.amazon.com/eks">Elastic Kubernetes Service (EKS)</a> is a managed Kubernetes service that allows you to <a href="https://spacelift.io/blog/kubernetes-on-aws">provision new clusters in AWS</a> within minutes. EKS automatically manages your cluster’s control plane and Nodes, letting you concentrate on deploying your workloads. This eliminates many of the challenges associated with starting, maintaining, and updating your own clusters, so it’s ideal when you want Kubernetes without the administration overheads.</p><p>💡 You might also like:</p><ul><li><a href="https://spacelift.io/blog/container-orchestration-tools">Top Container Orchestration Tools</a></li><li><a href="https://spacelift.io/blog/infrastructure-as-code-tools">Best Infrastructure as Code (IaC) Tools</a></li><li><a href="https://spacelift.io/blog/ci-cd-tools">Top Most Useful CI/CD Tools for DevOps</a></li></ul><h3>13. Google GKE</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*iKae9dRqgwApdMnU" /></figure><p><a href="https://cloud.google.com/kubernetes-engine">Google Kubernetes Engine (GKE)</a> is another managed Kubernetes service that lets you spin up new cloud clusters on demand. It’s specifically designed to help you run Kubernetes workloads without specialist Kubernetes expertise, and it includes a range of optional features that provide more automation for admin tasks. These include powerful capabilities around governance, compliance, security, and configuration management, all of which can be challenging to implement if you’re directly managing your own clusters.</p><h3>14. Terraform</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*mTnyG-qnb-lyHG1c" /></figure><p><a href="https://www.terraform.io/">Terraform</a> is a leading Infrastructure as Code (IaC) tool that allows you to <a href="https://spacelift.io/blog/what-is-terraform">automate cloud provisioning</a> and management activities.</p><p>For Kubernetes users, Terraform can create new clusters in any cloud based on consistent config files you version in a Git repository. Terraform can also be used to deploy workloads inside your cluster, such as from Kubernetes manifest files or Helm charts.</p><h3>15. Prometheus</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*CI2IuF__eL6fBoYG" /></figure><p><a href="https://prometheus.io/">Prometheus</a> is the best-known time-series database engine. It has many use cases, but in the context of Kubernetes, it’s a great way to store and query metrics that provide observability for your cluster and its workloads. You can receive alerts when metrics change, such as a Node CPU usage spike or a Pod failure, and integrate with tools like Grafana to visualize your values on dashboards.</p><p>Kubernetes doesn’t include any monitoring solution by default, so Prometheus is commonly used to add these crucial missing capabilities. See <a href="https://spacelift.io/blog/prometheus-kubernetes">how to set up Prometheus monitoring for the Kubernetes cluster</a>.</p><h3>16. Istio</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*awhyEETFaetaBDOy" /></figure><p><a href="https://istio.io/">Istio</a> is a service mesh that enables simpler networking, traffic management, service discovery, and monitoring for your Kubernetes clusters. It coordinates communications between your app’s microservices, providing much more control than the plain Kubernetes Service model.</p><p>Istio offers application-aware networking that understands your app’s requirements. It uses the <a href="https://www.envoyproxy.io/">Envoy proxy</a> to abstract the underlying networking environment and facilitate universal traffic management.</p><h3>17. Loki</h3><p><a href="https://github.com/grafana/loki">Loki</a> is a log collation tool from the Grafana family of observability solutions. It aggregates, groups, and labels logs from your applications, helping you troubleshoot problems and monitor activity. Although Loki is a general-purpose tool, it’s well-suited to Kubernetes and comes with several Kubernetes-specific features. It automatically scrapes and indexes metadata from your Kubernetes workload objects, such as Pod labels, to accompany your Pod logs.</p><h3>18. Metrics Server</h3><p><a href="https://github.com/kubernetes-sigs/metrics-server">Metrics Server</a> is a Kubernetes addon that collects CPU and memory resource utilization information at the Node and Pod level. It’s a lightweight, single-cluster, Kubernetes-only alternative to more complex monitoring solutions like Prometheus.</p><p>Metrics Server support is integrated with Kubectl. Its data can be accessed via the kubectl top command. Metrics Server is required to use Kubernetes auto-scaling features, including <a href="https://spacelift.io/blog/kubernetes-hpa-horizontal-pod-autoscaler">Horizontal Pod Autoscaler (HPA)</a> and <a href="https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler">Vertical Pod Autoscaler (VPA)</a>, so it’s a best practice addition to production clusters.</p><h3>19. Portainer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*2euZ-tMBlZ-Xr7nW" /></figure><p><a href="https://www.portainer.io/">Portainer</a> is a container management platform that provides a powerful web interface to administer your workloads. It natively supports Kubernetes environments to help you manage your Pods, Deployments, Helm charts, and other cluster resources. Portainer also provides robust RBAC capabilities and an external authentication layer, letting you grant team members access to Kubernetes through Portainer without directly exposing your cluster.</p><h3>20. Rancher</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*IhG30GJU29yGHdTW" /></figure><p>SUSE’s <a href="https://www.rancher.com/">Rancher</a> is a Kubernetes management tool that’s targeted at enterprise use. It provides a centralized platform for managing your Kubernetes clusters across cloud providers and on-premises datacenters. You can provision new clusters, monitor your workloads, and conduct security scans to efficiently govern your environments and maintain compliance.</p><p>Rancher is a good tool to use when you’re running Kubernetes at scale and are struggling to move between separate platforms.</p><h3>21. Ingress NGINX</h3><p>Ingress resources are crucial to Kubernetes networking: they allow you to expose apps externally using HTTP routes. However, to use Ingress, you need an Ingress controller in your cluster. <a href="https://spacelift.io/blog/kubernetes-ingress">Ingress NGINX</a> is the most popular choice — it’s fast, powerful, and easy to configure.</p><p>As the name implies, Ingress NGINX works by using an NGINX web server to reverse proxy incoming requests to your Kubernetes services. The proxy routes are automatically configured from the Ingress resources you add to your cluster. If you want a simple Ingress solution that works across multiple cluster distributions, then Ingress NGINX could be right for you.</p><h3>22. Minikube</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*U0_2zR6Yf2YR0EZc" /></figure><p><a href="https://minikube.sigs.k8s.io/docs">Minikube</a> makes it easy to start your own local cluster. With one command, you can bring up a complete Kubernetes environment on your workstation, letting you conveniently develop your project and test deployments.</p><p>Minikube can run your cluster’s components as a virtual machine, container, or bare-metal on your host. Bundled add-ons make it simple to enable advanced optional features, including Ingress, Istio, Elastic Stack, and GPU support, so it’s ideal for Kubernetes newcomers and experienced users alike.</p><h3>23. K3s</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*e_iRDoEBk-ih-OT6" /></figure><p><a href="https://k3s.io/">K3s</a> is another compact Kubernetes distribution. Developed by SUSE, it’s packaged as a single binary that comes in at less than 70MB. Despite this tiny footprint, K3s is certified as compatible with upstream Kubernetes, is ready for production use, and supports high availability.</p><p>K3s is equally well-suited to local development use and real-world applications scaled across hundreds of Nodes. The small binary size also makes K3s ideal for heavily resource-constrained environments, including IoT devices.</p><h3>24. Kind</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*sb5BPQ9mDvztByBK" /></figure><p><a href="https://kind.sigs.k8s.io/">Kind</a> is our third tool that can be used to start a Kubernetes cluster, but this one has a slightly different focus. It lets you run Kubernetes environments in Docker containers, with each container acting as a Node.</p><p>It’s intended to make it easier to test cluster behavior when developing Kubernetes itself, so you might benefit from using it if you plan to contribute features. Kind can also be a good alternative to Minikube if you already have Docker installed.</p><h3>25. K9s</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*K23bfPTi4NZ4sv_e" /></figure><p>Looking for a terminal-based Kubernetes experience but one that’s a bit more sophisticated than Kubectl? <a href="https://k9scli.io/">K9s</a> is a complete terminal UI that lets you monitor, manage, and benchmark your Kubernetes workloads. It offers a versatile dashboard-like interface in your console.</p><p>K9s is customizable with different views and columns, letting you easily access the information you need. It’s heavily dependent on aliases and hotkeys to quickly navigate the interface. You can also add skins and plugins that extend the tool’s functionality.</p><blockquote><em>If you found this article helpful, please </em><strong><em>don’t forget</em></strong><em> to hit the </em><strong><em>Follow</em></strong><em> and </em><strong><em>Clap </em></strong><em>buttons to help me write more articles like this.<br></em><strong><em>Thank You 🖤</em></strong></blockquote><blockquote><strong><em>You can contact me on: </em></strong><a href="http://www.linkedin.com/in/abhi-sharma24"><em>LinkedIn</em></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bdd5dfa92c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>