<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Blink Ops</title>
    <description>The latest articles on DEV Community by Blink Ops (@blink-ops).</description>
    <link>https://dev.to/blink-ops</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F5737%2F6efcd97a-9943-4848-a6f1-b40489b7a747.png</url>
      <title>DEV Community: Blink Ops</title>
      <link>https://dev.to/blink-ops</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/blink-ops"/>
    <language>en</language>
    <item>
      <title>Reducing Your Cloud Costs: An Operational Optimization Guide</title>
      <dc:creator>Patrick Londa</dc:creator>
      <pubDate>Mon, 17 Oct 2022 14:49:20 +0000</pubDate>
      <link>https://dev.to/blink-ops/reducing-your-cloud-costs-an-operational-optimization-guide-3eh6</link>
      <guid>https://dev.to/blink-ops/reducing-your-cloud-costs-an-operational-optimization-guide-3eh6</guid>
      <description>&lt;p&gt;Cloud costs are top of mind as many business leaders and teams are focusing attention on honing their operational efficiency.&lt;/p&gt;

&lt;p&gt;In April at CIO.com’s Future of Cloud Summit, Dave McCarthy, research vice president of cloud infrastructure services at IDC, shared that cloud spending represents roughly &lt;a href="https://www.cio.com/article/403231/cios-contend-with-rising-cloud-costs.html" rel="noopener noreferrer"&gt;30% of current IT budgets&lt;/a&gt;. In the 2022 State of Cloud Report by Flexera, 750 surveyed executives shared that they estimate they are &lt;a href="https://www.forbes.com/sites/joemckendrick/2020/04/29/one-third-of-cloud-spending-wasted-but-still-accelerates/?sh=5a313399489e" rel="noopener noreferrer"&gt;wasting 30% of their cloud spend&lt;/a&gt;, while also saying that they expect costs to increase 47% over the next year. If you combine those stats, there is an efficiency opportunity roughly the size of 10% of IT budgets.&lt;/p&gt;

&lt;p&gt;Achieving those cost savings isn’t as easy as flipping a switch. There is wasted spend embedded across multiple resource types, regions, and services. By function, the main categories of cloud spending are compute time, data storage, and data transfer.&lt;/p&gt;

&lt;p&gt;In this post, we’ll outline a framework for reviewing your cloud spending today, identifying wasted resources, and reviewing your long-term infrastructure efficiency.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reviewing Your Current Spending
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;“What are we currently spending money on?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To start, you can review your current spend at the account-level with the major cloud providers. AWS, Azure, and GCP all have reporting options that enable you to view and filter your spending over a period of time.&lt;/p&gt;

&lt;p&gt;In AWS, you can create &lt;a href="https://docs.aws.amazon.com/cur/latest/userguide/cur-create.html" rel="noopener noreferrer"&gt;Cost and Usage Reports&lt;/a&gt;. In GCP, you can review your &lt;a href="https://cloud.google.com/billing/docs/how-to/reports" rel="noopener noreferrer"&gt;Cloud Billing Report&lt;/a&gt; and view spend by “Project” or other filters. In the Azure portal, you can download usage and charges from the “&lt;a href="https://learn.microsoft.com/en-us/azure/cost-management-billing/understand/download-azure-daily-usage" rel="noopener noreferrer"&gt;Cost Management + Billing&lt;/a&gt;” section.&lt;/p&gt;

&lt;p&gt;These views may be useful to get started and see transactional costs, such as from data transfers. In order to get more granular details on your cloud spending, you should leverage resource labels and tags to accurately categorize expenses.&lt;/p&gt;

&lt;p&gt;With labels and tags, you can associate resources with specific cost centers, projects, business units, or teams. You can then easily organize your resource data, create custom reports, and run specific queries.&lt;/p&gt;

&lt;p&gt;If you do not currently have a mechanism or standard practice around resource tags and labels, you can refer to these how-to guides for setting up mandatory tags:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS: &lt;a href="https://www.blinkops.com/blog/enforcing-mandatory-tags-across-aws-resources" rel="noopener noreferrer"&gt;Enforcing Mandatory Tags Across Your AWS Resources&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GCP: &lt;a href="https://www.blinkops.com/blog/enforcing-labels-and-tags-across-your-gcp-resources" rel="noopener noreferrer"&gt;Enforcing Labels and Tags Across Your GCP Resources&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Azure: &lt;a href="https://www.blinkops.com/blog/enforcing-mandatory-tags-across-azure-resources" rel="noopener noreferrer"&gt;Enforcing Mandatory Tags Across Your Azure Resources&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you use more than one cloud computing provider, you’ll need to aggregate invoices and usage reports across vendors. In this scenario, having consistent tagging methods across platforms is even more useful as it can offer a consistent way to view your resource usage and expenses.&lt;/p&gt;

&lt;p&gt;Once you have a clear sense of your current spending, you can look for opportunities to reduce your expenses.&lt;/p&gt;

&lt;h2&gt;
  
  
  Eliminating Unnecessary Resources
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;“What resources are we spending money on and not using at all?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As projects are spun up and shut down, there are often resources that become unattached and left behind. While they are no longer in use, they are still costing your organization money on a recurring basis.&lt;/p&gt;

&lt;p&gt;Ideally, you have an automated way to regularly catch and delete these unattached resources. With a no-code platform like &lt;a href="https://app.blinkops.com/signup" rel="noopener noreferrer"&gt;Blink&lt;/a&gt;, teams can scale up scheduled automations to continuously detect and remove unnecessary resources.&lt;/p&gt;

&lt;p&gt;If you don’t have automations already in place, you can manually review resources in the console and remove unused ones in bulk. It can be time-consuming, but you may be able to reduce your operating costs significantly this way in the short-term.&lt;/p&gt;

&lt;p&gt;To know what types of resources to review, here are some common examples:&lt;/p&gt;

&lt;h4&gt;
  
  
  Unattached Disks
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;AWS: &lt;a href="https://www.blinkops.com/blog/how-to-find-and-delete-unattached-aws-resources" rel="noopener noreferrer"&gt;How to Find and Delete Unattached AWS Volumes and Gateways&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Azure: &lt;a href="https://www.blinkops.com/blog/finding-and-deleting-unattached-disks-with-the-azure-cli" rel="noopener noreferrer"&gt;Finding and Deleting Unattached Disks with the Azure CLI&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GCP: &lt;a href="https://www.blinkops.com/blog/how-to-find-and-delete-unattached-gcp-disks" rel="noopener noreferrer"&gt;How to Find and Delete Unattached GCP Disks&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Unattached IP Addresses
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;AWS: &lt;a href="https://www.blinkops.com/blog/finding-and-removing-unattached-aws-elastic-ip-addresses" rel="noopener noreferrer"&gt;Finding and Removing Unattached AWS Elastic IP Addresses&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Azure: &lt;a href="https://www.blinkops.com/blog/how-to-detect-and-remove-unattached-azure-public-ip-addresses" rel="noopener noreferrer"&gt;How to Detect and Remove Unattached Azure Public IP Addresses&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GCP: &lt;a href="https://www.blinkops.com/blog/finding-and-removing-unattached-gcp-external-ip-addresses" rel="noopener noreferrer"&gt;Finding and Removing Unattached GCP External IP Addresses&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Old Snapshots
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;AWS: &lt;a href="https://www.blinkops.com/blog/how-to-find-and-remove-old-ebs-snapshots" rel="noopener noreferrer"&gt;How to Find and Remove Old EBS Snapshots&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Azure: &lt;a href="https://www.blinkops.com/blog/how-to-find-and-remove-old-azure-snapshots" rel="noopener noreferrer"&gt;How to Find and Remove Old Azure Snapshots&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GCP: &lt;a href="https://www.blinkops.com/blog/how-to-find-and-remove-old-gcp-disk-snapshots" rel="noopener noreferrer"&gt;How to Find and Remove Old GCP Disk Snapshots&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finding and removing idle resources is a clear way to cut your operating costs, but it also is an important practice for maintaining a strong security posture. If you leave resources like unattached IP addresses, &lt;a href="https://www.blinkops.com/blog/how-to-find-and-delete-unattached-aws-resources" rel="noopener noreferrer"&gt;idle NAT Gateways&lt;/a&gt;, &lt;a href="https://www.blinkops.com/blog/tracking-down-amazon-load-balancers-with-no-target" rel="noopener noreferrer"&gt;load balancers with no target&lt;/a&gt;, or &lt;a href="https://www.blinkops.com/blog/getting-and-deleting-orphaned-secrets-with-kubectl" rel="noopener noreferrer"&gt;orphaned Secrets&lt;/a&gt; lying around, bad actors could find them and take advantage of the information. In this way, resource management is key to reducing costs and reducing risk.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimizing and Updating Resources
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;“How can we optimize our existing resources?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now that you’ve reviewed and removed unused resources, you can now look at optimizing the resources you are using.&lt;/p&gt;

&lt;h4&gt;
  
  
  Using the Right Family for the Job
&lt;/h4&gt;

&lt;p&gt;Whether you are creating new resources or evaluating existing ones, it’s important to consider which family of resources best fits your needs. If you’re using general-purpose machines, there might be another more cost-effective machine that is a better fit.&lt;/p&gt;

&lt;p&gt;Depending on your usage, you may need more capacity in some specifications than others. For example, if you’re using AWS, there are Compute Optimized instances under the C family (e.g. EC2 C7g instances) which offer optimal price performance for especially computing-intense use cases, like batch processing workloads and scientific modeling. Other families include Memory Optimized (e.g. EC2 R6a instances) and Storage Optimized (Ec2 lm4gn instances). There are lots of other families (e.g. IOPs, network, accelerator-optimized) depending on the platform and the specification you want to optimize for.&lt;/p&gt;

&lt;p&gt;When considering your performance requirements, you might have use cases like batch jobs or workloads that are fault-tolerant. &lt;a href="https://azure.microsoft.com/en-us/products/virtual-machines/spot/#overview" rel="noopener noreferrer"&gt;Azure&lt;/a&gt;, &lt;a href="https://cloud.google.com/spot-vms" rel="noopener noreferrer"&gt;GCP&lt;/a&gt;, and &lt;a href="https://aws.amazon.com/ec2/spot/" rel="noopener noreferrer"&gt;AWS&lt;/a&gt; all have unused capacity that they offer as less expensive, less reliable Spot VMs. Compared to on-demand instances, they are up to 90% less expensive to run.&lt;/p&gt;

&lt;h4&gt;
  
  
  Updating to New Machines
&lt;/h4&gt;

&lt;p&gt;Within each of these families, there are often newer versions being offered. Often, the newer versions run more efficiently or have higher performance, so it’s a good best practice to upgrade to newer versions as much as you can. &lt;/p&gt;

&lt;p&gt;One example of this is with EBS volumes. By switching from &lt;a href="https://www.blinkops.com/blog/switching-gp2-volumes-to-gp3-volumes-to-lower-aws-ebs-costs" rel="noopener noreferrer"&gt;EBS GP2 volumes to EBS GP3 volumes&lt;/a&gt;, you can reduce your costs by 20%. There are some small performance tradeoffs, but it’s important to keep these types of upgrade opportunities in mind.&lt;/p&gt;

&lt;p&gt;Another AWS example is switching from older machines to ones that use the new AWS Graviton2 processors. Instances running on Graviton2 processors vs. Intel processors offer up to 40% better price performance, with specific efficiencies varying by family.&lt;/p&gt;

&lt;h4&gt;
  
  
  Looking for Low CPU Usage
&lt;/h4&gt;

&lt;p&gt;One way to optimize your spending is by rightsizing resources to match the usage level that you need. For example, you may be running an instance or virtual machine that has more computer capacity than you need.&lt;/p&gt;

&lt;p&gt;By reviewing your usage data, you can determine if you are running at an average CPU usage of 30% or less for example. By reducing the size or type of instance, you can slightly reduce your spend, which adds up over time.&lt;/p&gt;

&lt;p&gt;Here are some how-to guides that show examples for each platform:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS: &lt;a href="https://www.blinkops.com/blog/finding-and-resizing-amazon-ec2-instances-with-low-cpu-usage" rel="noopener noreferrer"&gt;Finding and Resizing Amazon EC2 Instances with Low CPU Usage&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GCP: &lt;a href="https://www.blinkops.com/blog/finding-and-resizing-gcp-compute-instances-with-low-cpu-usage" rel="noopener noreferrer"&gt;Finding and Resizing GCP Compute Instances with Low CPU Usage&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Azure: &lt;a href="https://www.blinkops.com/blog/finding-and-resizing-azure-virtual-machines-with-low-cpu-usage" rel="noopener noreferrer"&gt;Finding and Resizing Azure Virtual Machines with Low CPU Usage&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Using Long-Term Resourcing for Predictable CPU Usage
&lt;/h4&gt;

&lt;p&gt;Another way to optimize your costs is by leveraging reserved instances or committed use discounts. In exchange for predictable computing expectations, the major cloud providers offer resources at a discount with a committed term, such as 1 year or 3 years.&lt;/p&gt;

&lt;p&gt;Here are some how-to guides that show examples for each platform:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS: &lt;a href="https://www.blinkops.com/blog/lowering-costs-on-long-running-aws-ec2-instances" rel="noopener noreferrer"&gt;Lowering Costs on Long Running AWS EC2 Instances&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GCP: &lt;a href="https://www.blinkops.com/blog/lowering-costs-for-long-running-gcp-instances-with-committed-use-discounts" rel="noopener noreferrer"&gt;Lower Costs for Long Running GCP Instances with Committed Use Discounts&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Azure: &lt;a href="https://www.blinkops.com/blog/optimizing-costs-for-long-running-azure-vms-with-reserved-instances" rel="noopener noreferrer"&gt;Optimizing Costs for Long Running Azure VMs with Reserved Instances&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Starting Nightly Non-Production Scale-Downs
&lt;/h4&gt;

&lt;p&gt;Are there any resources that you can shut-down when they are not being used? For example, if your team is working with a test environment during certain work hours, you don’t need to run it 24 hours a day. You can scale it down at night and scale it back up the next morning.&lt;/p&gt;

&lt;p&gt;With some automation, pausing and restarting a non-production cluster could be as simple as clicking an approval button in a slack message, and reducing your daily cloud costs.&lt;/p&gt;

&lt;p&gt;Here are a couple examples of how to pause and restart clusters nightly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS: &lt;a href="https://www.blinkops.com/blog/how-to-scale-down-aws-eks-clusters-nightly-to-lower-ec2-costs" rel="noopener noreferrer"&gt;How to Scale Down AWS EKS Clusters Nightly&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GCP: &lt;a href="https://www.blinkops.com/blog/how-to-pause-your-gke-cluster-nightly" rel="noopener noreferrer"&gt;How to Pause Your GKE Cluster Nightly&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Azure: &lt;a href="https://www.blinkops.com/blog/how-to-pause-your-aks-clusters-nightly" rel="noopener noreferrer"&gt;How to Pause Your AKS Cluster Nightly&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Storing and Moving Data Efficiency
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;“Can we optimize how our data is stored and transferred?”&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Storing Only Relevant Data
&lt;/h4&gt;

&lt;p&gt;Your cloud bill is also impacted by how much data you are storing. While it’s useful to collect data to see how your services are running, it likely becomes less useful and relevant over time. Even if you want to maintain as much data as possible, you’ll want to employ a strategy of periodically switching data over to less-costly, long-term storage vehicles, such as Amazon’s &lt;a href="https://aws.amazon.com/archive/" rel="noopener noreferrer"&gt;S3 Glacier storage&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here are some how-to guides for AWS on how to identify data that hasn’t changed in a while and how to reduce logging storage costs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS: &lt;a href="https://www.blinkops.com/blog/detecting-aws-dynamodb-tables-with-stale-data" rel="noopener noreferrer"&gt;Detecting AWS DynamoDB Tables with Stale Data&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;AWS: &lt;a href="https://www.blinkops.com/blog/lowering-aws-cloudtrail-costs-by-removing-redundant-trails" rel="noopener noreferrer"&gt;Lowering AWS CloudTrail Costs by Removing Redundant Trails&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;AWS: &lt;a href="https://www.blinkops.com/blog/ensuring-aws-cloudwatch-log-groups-have-set-retention-periods" rel="noopener noreferrer"&gt;Ensuring AWS CloudWatch Log Groups Have Set Retention Periods&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Optimizing Data Transfers
&lt;/h4&gt;

&lt;p&gt;Data transfers may also account for a significant part of your cloud costs, and vary greatly depending on their source, destination, method of transport, and size.&lt;/p&gt;

&lt;p&gt;You can also likely expect charges if you are transferring data across regions or across availability zones. Unless your business case requires it, you should look to avoid data transfers that go across regions and availability zones.&lt;/p&gt;

&lt;p&gt;While inbound (or ingress) data transfers between the internet and your cloud provider are not charged, outbound transfers are charged per service. You should reduce outbound data transfers from your cloud to external destinations as much as possible.&lt;/p&gt;

&lt;p&gt;If you are transferring data across AWS services for example, you should be utilizing private endpoints. This way, when you are accessing a S3 bucket from an EC2 instance, you can avoid data transfer charges. &lt;/p&gt;

&lt;p&gt;The same principle applies for transferring data from your cloud to on-premises locations, and tools like AWS &lt;a href="https://aws.amazon.com/directconnect/" rel="noopener noreferrer"&gt;Direct Connect&lt;/a&gt;, GCP &lt;a href="https://cloud.google.com/network-connectivity/docs/direct-peering" rel="noopener noreferrer"&gt;Direct Peering&lt;/a&gt;, and Azure &lt;a href="https://azure.microsoft.com/en-us/products/expressroute/#overview" rel="noopener noreferrer"&gt;ExpressRoute&lt;/a&gt; which may offer lower cost per GB compared to transfers over the internet. Actual savings depends on the amount of data you are moving, and if you are below a certain threshold, it might not make sense.&lt;/p&gt;

&lt;p&gt;You can read more about the types of data transfer charges in the &lt;a href="https://docs.aws.amazon.com/wellarchitected/latest/cost-optimization-pillar/plan-for-data-transfer.html" rel="noopener noreferrer"&gt;Cost Optimization&lt;/a&gt; pillar of the AWS Well-Architected Framework, or these &lt;a href="https://aws.amazon.com/blogs/architecture/overview-of-data-transfer-costs-for-common-architectures/" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;, &lt;a href="https://cloud.google.com/vpc/network-pricing" rel="noopener noreferrer"&gt;GCP&lt;/a&gt;, and &lt;a href="https://azure.microsoft.com/en-us/pricing/details/bandwidth/" rel="noopener noreferrer"&gt;Azure&lt;/a&gt; resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  Achieving Operational Excellence with Blink Automations
&lt;/h2&gt;

&lt;p&gt;So far, we have covered several areas where you and your team can focus and optimize your costs, but significant savings over time takes new processes.&lt;/p&gt;

&lt;p&gt;Beyond finding unused resources, you need an automated process for alerting you to cost reduction opportunities, and then making approval for removing resources as easy as clicking a button. If you only rely on scripts, you may accidentally take down environments or orphaned resources that should have been left up.&lt;/p&gt;

&lt;p&gt;With &lt;a href="https://www.blinkops.com/" rel="noopener noreferrer"&gt;Blink&lt;/a&gt;, you can use no-code automations to achieve operational excellence. In the cost optimization context, Blink lets you create and run dozens of common resource checks and send reports to email or Slack channels with simple, actionable options.&lt;/p&gt;

&lt;p&gt;By running these Blink automations on a schedule, you’ll be able to confidently ensure that you are achieving operational excellence not just one time, but daily. You can take the same Blink automation approach for other operational excellence categories, like security operations, incident response, troubleshooting, and permissions management.&lt;/p&gt;

&lt;p&gt;Get started with a &lt;a href="https://app.blinkops.com/signup" rel="noopener noreferrer"&gt;free Blink account&lt;/a&gt; or reach out to us directly to &lt;a href="https://www.blinkops.com/contact" rel="noopener noreferrer"&gt;hear more&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Finding and Deleting Orphaned ConfigMaps</title>
      <dc:creator>Patrick Londa</dc:creator>
      <pubDate>Thu, 16 Jun 2022 18:00:03 +0000</pubDate>
      <link>https://dev.to/blink-ops/finding-and-deleting-orphaned-configmap-g4p</link>
      <guid>https://dev.to/blink-ops/finding-and-deleting-orphaned-configmap-g4p</guid>
      <description>&lt;p&gt;If you don’t take steps to maintain your Kubernetes cluster, you could end up wasting money and storage on orphaned resources. Orphaned (or unused) resources, like ConfigMaps, Secrets, and Services, should be regularly located and removed to clear up storage space and prevent performance issues. &lt;/p&gt;

&lt;p&gt;In this post, we’ll be focusing on how to find and remove orphaned ConfigMaps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://kubernetes.io/docs/concepts/configuration/configmap/" rel="noopener noreferrer"&gt;ConfigMaps&lt;/a&gt; are API objects created to hold small amounts of visible configuration data. These objects support unbinding of configuration data from container images and application code for optimum portability of applications, but they cannot hold secret/encrypted data.&lt;/p&gt;

&lt;p&gt;ConfigMaps may get orphaned if they are left isolated from the deployment they were created to support, or if their owners have been purged. Once orphaned, these ConfigMaps waste temporary storage and increase the risk of cluster instability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding and Deleting Orphaned ConfigMaps
&lt;/h2&gt;

&lt;p&gt;Here are some steps you can take to find and remove orphaned ConfigMaps:&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Find all ConfigMaps
&lt;/h3&gt;

&lt;p&gt;First off, you can generate a list of all ConfigMaps using this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get configmaps –all-namespaces -o json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will return the list of ConfigMaps across all namespaces, but as you’ll see, the ConfigMap object does not reference its owner. You’ll need to run another command to identify which of the ConfigMaps have owners and are in use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Compare with a List of Used ConfigMaps
&lt;/h3&gt;

&lt;p&gt;To find any orphaned ConfigMaps, you have to get the list of pods across your cluster and list all ConfigMaps in use. Alternatively you can use the following to diff the list of ConfigMaps and used ConfigMaps, and get unused ConfigMaps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;volumesCM=$( kubectl get pods -o
jsonpath='{.items[*].spec.volumes[*].configMap.name}' | xargs -n1)
volumesProjectedCM=$( kubectl get pods -o
jsonpath='{.items[*].spec.volumes[*].projected.sources[*].configMap.name}' | xargs -n1)
envCM=$( kubectl get pods -o
jsonpath='{.items[*].spec.containers[*].env[*].ValueFrom.configMapKeyRef.name}' | xargs -n1)
envFromCM=$( kubectl get pods -o
jsonpath='{.items[*].spec.containers[*].envFrom[*].configMapKeyRef.name}' | xargs -n1)

diff \
&amp;lt;(echo "$volumesCM\n$volumesProjectedCM\n$envCM\n$envFromCM" | sort | uniq) \
&amp;lt;(kubectl get configmaps -o jsonpath='{.items[*].metadata.name}' | xargs -n1 | sort | uniq)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, you can compare the two lists and delete ConfigMaps from the first list that are not in use by any pod.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Delete Orphaned ConfigMaps
&lt;/h3&gt;

&lt;p&gt;Now that you have a list of orphaned ConfigMaps, you can run this command to delete them and free up memory in your cluster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete configmap/samplemap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;configmap "samplemap" deleted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you’ve deleted all the orphaned ConfigMaps you found, you’ll have removed unneeded, unused resources from your cluster and freed up memory and storage space. If you remove orphaned resources regularly, you’ll ensure that your team is maintaining optimal Kubernetes resource management.&lt;/p&gt;

&lt;p&gt;Thanks for reading! Let me know if this worked for you.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
