aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • Engineering
  • Tools

Monitor Kubernetes Cloud Costs With Open Source Tools

  • aster.cloud
  • March 20, 2023
  • 3 minute read

OpenCost is a cloud cost monitoring tool that integrates seamlessly with Kubernetes, allowing you to track your cloud spend in real-time so you can optimize your resources accordingly.

Kubernetes is a powerful platform for managing dynamic containerized applications in the cloud, but it may be difficult to understand where costs are incurred. Managing the cost efficiency of Kubernetes resources can be a challenge. That’s where OpenCost comes in. OpenCost is a cloud cost monitoring tool that integrates seamlessly with Kubernetes, allowing you to track your cloud spend in real-time so you can optimize your resources accordingly.


Partner with aster.cloud
for your next big idea.
Let us know here.



From our partners:

CITI.IO :: Business. Institutions. Society. Global Political Economy.
CYBERPOGO.COM :: For the Arts, Sciences, and Technology.
DADAHACKS.COM :: Parenting For The Rest Of Us.
ZEDISTA.COM :: Entertainment. Sports. Culture. Escape.
TAKUMAKU.COM :: For The Hearth And Home.
ASTER.CLOUD :: From The Cloud And Beyond.
LIWAIWAI.COM :: Intelligence, Inside and Outside.
GLOBALCLOUDPLATFORMS.COM :: For The World's Computing Needs.
FIREGULAMAN.COM :: For The Fire In The Belly Of The Coder.
ASTERCASTER.COM :: Supra Astra. Beyond The Stars.
BARTDAY.COM :: Prosperity For Everyone.

OpenCost is an open source CNCF Sandbox project and specification for the real-time monitoring of cloud costs associated with Kubernetes deployments. The specification models current and historical Kubernetes cloud spend and resource allocation by service, deployment, namespace, labels, and much more. This data is essential for understanding and optimizing Kubernetes for both cost and performance from the applications down through the infrastructure.

Requirements and installation

Getting started with OpenCost is a relatively straightforward process. OpenCost uses Prometheus for both monitoring and metric storage. You can install it from the Prometheus Community Kubernetes Helm Chart.

Install Prometheus

Begin by installing Prometheus using the following command:

$ helm install my-prometheus --repo https://prometheus-community.github.io/helm-charts prometheus \
 --namespace prometheus --create-namespace \
 --set pushgateway.enabled=false --set alertmanager.enabled=false -f \
https://raw.githubusercontent.com/opencost/opencost/develop/kubernetes/prometheus/extraScrapeConfigs.yaml

Install OpenCost

Next, install OpenCost using the kubectl command:

$ kubectl apply --namespace opencost -f \
https://raw.githubusercontent.com/opencost/opencost/develop/kubernetes/opencost.yaml

This command deploys OpenCost to your cluster and starts collecting data. That is all that most installations require. You can use your own Prometheus installation or customize the deployment with the OpenCost Helm Chart.

Read More  How Bink Powers Digital Loyalty Transactions Of Some Of The Biggest Banks In The UK

Testing and access

OpenCost automatically detects whether it runs on AWS, Azure, or GCP, and you can configure it to provide pricing for on-premises Kubernetes deployments. Begin by forwarding ports for API and UI access:

$ kubectl port-forward --namespace opencost service/opencost 9003 9090

Within about five minutes, you can verify the UI and server are running, and you may access the OpenCost UI at http://localhost:9090.

Monitor costs

You are ready to start monitoring your cloud costs with OpenCost deployed to your Kubernetes cluster. The OpenCost dashboard provides real-time visibility into your cloud spend, allowing you to identify cost anomalies and optimize your cloud resources. You can view your cloud spend by nodes, namespaces, pods, tags, and more.

(Matthew Ray, CC BY-SA 4.0)

The kubectl cost plugin provides easy CLI queries to Kubernetes cost allocation metrics. It allows developers, operators, and others to determine the cost and efficiency for any Kubernetes workload quickly.

$ kubectl cost --service-port 9003 \
--service-name opencost --kubecost-namespace opencost \
--allocation-path /allocation/compute pod \
--window 5m --show-efficiency=true

+-------+---------+-------------+----------+---------------+
|CLUSTER|NAMESPACE|POD          |MONTH RATE|COST EFFICIENCY|
+-------+---------+-------------+----------+---------------+
|cl-one |kube-syst|coredns-db...| 1.486732 |      0.033660 |
|       |         |coredns-...dm| 1.486732 |      0.032272 |
|       |         |kube-prox...7| 1.359577 |      0.002200 |
|       |         |kube-prox...x| 1.359577 |      0.002470 |
|       |opencost |opencost...5t| 0.459713 |      0.187180 |
|       |kube-syst|aws-node-cbwl| 0.342340 |      0.134960 |
|       |         |aws-node-gbfh| 0.342340 |      0.133760 |
|       |prometheu|my-prome...pv| 0.000000 |      0.000000 |
|       |         |my-prome...hn| 0.000000 |      0.000000 |
|       |         |my-prome...89| 0.000000 |      0.000000 |
+-------+---------+-------------+----------+---------------+
| SUMMED|         |             | 6.837011 |               |
+-------+---------+-------------+----------+---------------+

You can also integrate an API to extract the data programmatically into your platform of choice.

Kubernetes optimization strategies

Now that you have a handle on your cloud costs, it’s time to optimize your Kubernetes environment. Optimization is an iterative process. Start at the top of the stack (containers) and work through each layer. The efficiencies compound at each step. There are many ways to optimize Kubernetes for cost efficiency, such as:

  1. Look for abandoned workloads and unclaimed volumes: Pods and storage that are no longer in use or are disconnected continue to consume resources without providing value.
  2. Right-size your workloads: Ensure you’re using the right size containers for your workloads. Investigate over- and under-allocated containers.
  3. Autoscaling: Autoscaling can help you save costs by only using resources when needed.
  4. Right-size your cluster: Too many or too-large nodes may be inefficient. Finding the right balance between capacity, availability, and performance may greatly reduce costs.
  5. Investigate cheaper node types: There’s a lot of variation in CPU, RAM, networking, and storage. Switching to ARM architectures may unlock even greater savings.
  6. Invest in a FinOps team: A dedicated team within your organization can look for ways to unlock greater savings by coordinating reserved instances, spot instances, and savings plans.
Read More  Google Meet In 2021: A Year Of Accelerated Innovation

Get started today

Monitoring costs in a Kubernetes environment can be challenging, but with OpenCost, it doesn’t have to be. To get started with OpenCost and take control of your cloud spend, visit the OpenCost website, get the code in GitHub, check out the OpenCost documentation, and get involved in the #opencost channel in the CNCF Slack.

By: Matt Ray
Originally published at Opensource

Source: Cyberpogo


For enquiries, product placements, sponsorships, and collaborations, connect with us at [email protected]. We'd love to hear from you!

Our humans need coffee too! Your support is highly appreciated, thank you!

aster.cloud

Related Topics
  • Containers
  • Kubernetes
  • OpenCost
You May Also Like
View Post
  • Engineering
  • Technology

Apple supercharges its tools and technologies for developers to foster creativity, innovation, and design

  • June 9, 2025
View Post
  • Engineering

Just make it scale: An Aurora DSQL story

  • May 29, 2025
notta-ai-header
View Post
  • Featured
  • Tools

Notta vs Fireflies: Which AI Transcription Tool Deserves Your Attention in 2025?

  • May 16, 2025
View Post
  • Engineering
  • Technology

Guide: Our top four AI Hypercomputer use cases, reference architectures and tutorials

  • March 9, 2025
View Post
  • Computing
  • Engineering

Why a decades old architecture decision is impeding the power of AI computing

  • February 19, 2025
View Post
  • Engineering
  • Software Engineering

This Month in Julia World

  • January 17, 2025
View Post
  • Engineering
  • Software Engineering

Google Summer of Code 2025 is here!

  • January 17, 2025
View Post
  • Data
  • Engineering

Hiding in Plain Site: Attackers Sneaking Malware into Images on Websites

  • January 16, 2025

Stay Connected!
LATEST
  • 1
    Pure Accelerate 2025: All the news and updates live from Las Vegas
    • June 18, 2025
  • 2
    ‘This was a very purposeful strategy’: Pure Storage unveils Enterprise Data Cloud in bid to unify data storage, management
    • June 18, 2025
  • What is cloud bursting?
    • June 18, 2025
  • 4
    There’s a ‘cloud reset’ underway, and VMware Cloud Foundation 9.0 is a chance for Broadcom to pounce on it
    • June 17, 2025
  • What is confidential computing?
    • June 17, 2025
  • Oracle adds xAI Grok models to OCI
    • June 17, 2025
  • Fine-tune your storage-as-a-service approach
    • June 16, 2025
  • 8
    Advanced audio dialog and generation with Gemini 2.5
    • June 15, 2025
  • 9
    A Father’s Day Gift for Every Pop and Papa
    • June 13, 2025
  • 10
    Global cloud spending might be booming, but AWS is trailing Microsoft and Google
    • June 13, 2025
about
Hello World!

We are aster.cloud. We’re created by programmers for programmers.

Our site aims to provide guides, programming tips, reviews, and interesting materials for tech people and those who want to learn in general.

We would like to hear from you.

If you have any feedback, enquiries, or sponsorship request, kindly reach out to us at:

[email protected]
Most Popular
  • Google Cloud, Cloudflare struck by widespread outages
    • June 12, 2025
  • What is PC as a service (PCaaS)?
    • June 12, 2025
  • 3
    Crayon targets mid-market gains with expanded Google Cloud partnership
    • June 10, 2025
  • By the numbers: Use AI to fill the IT skills gap
    • June 11, 2025
  • 5
    Apple services deliver powerful features and intelligent updates to users this autumn
    • June 11, 2025
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.