Deploy Kubecost on Amazon EKS for precise Kubernetes cost visibility
Running Kubernetes on AWS can quickly become a cost management challenge. Without proper visibility, your EKS clusters might be silently draining your cloud budget through overprovisioned resources, idle capacity, or inefficient configurations. Deploying Kubecost on Amazon EKS provides the transparency and analysis tools needed to take control of your Kubernetes spending.
What is Kubecost and why deploy it on EKS?
Kubecost is a specialized cost monitoring solution that integrates with Amazon EKS to provide granular visibility into your Kubernetes spending. Unlike general AWS cost management tools, Kubecost breaks down expenses at the pod, namespace, and node levels, giving you actionable insights to optimize your containerized workloads.
According to AWS’s own documentation, Kubecost offers several key advantages for EKS users:
- Detailed cost allocation by namespace, deployment, and pod
- Resource usage breakdowns (CPU, memory, storage)
- Identification of idle and underutilized resources
- Integration with AWS Cost and Usage Reports (CUR)
Think of Kubecost as your financial X-ray machine for Kubernetes—it reveals the hidden cost structures that general monitoring tools simply can’t see, helping you identify exactly where your cloud budget is being consumed.
Prerequisites for deploying Kubecost on EKS
Before starting the installation process, ensure your environment meets these requirements:
- Helm 3.9 or later
kubectl
configured to access your EKS cluster- Amazon EBS CSI driver (required for clusters running Kubernetes 1.23 or later)
- An IAM service account with
AmazonEBSCSIDriverPolicy
permissions - Sufficient cluster resources (minimum 2 vCPUs and 4GB RAM for Kubecost components)
These requirements are particularly important because Kubecost needs persistent storage access to retain historical cost data, which is why the EBS CSI driver is crucial for newer Kubernetes versions.
Step-by-step Kubecost deployment on Amazon EKS
1. Install the EBS CSI driver (for clusters ≥1.23)
eksctl create iamserviceaccount \ --name ebs-csi-controller-sa \ --namespace kube-system \ --cluster YOUR_CLUSTER_NAME \ --attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy \ --approve \ --role-only \ --role-name AmazonEKS_EBS_CSI_DriverRole
Then install the EBS CSI driver add-on:
eksctl create addon \ --name aws-ebs-csi-driver \ --cluster YOUR_CLUSTER_NAME \ --service-account-role-arn arn:aws:iam::ACCOUNT_ID:role/AmazonEKS_EBS_CSI_DriverRole \ --force
2. Deploy Kubecost using Helm
AWS and Kubecost have collaborated to create an AWS-optimized bundle for EKS users, making deployment straightforward:
helm upgrade -i kubecost oci://public.ecr.aws/kubecost/cost-analyzer \ --version 1.99.0 \ --namespace kubecost \ --create-namespace \ -f https://raw.githubusercontent.com/kubecost/cost-analyzer-helm-chart/develop/cost-analyzer/values-eks-cost-monitoring.yaml
This command installs Kubecost with a configuration specifically optimized for EKS environments. The values file contains pre-configured settings that work seamlessly with Amazon EKS, including appropriate resource requests and storage configurations.
3. Access the Kubecost dashboard
After successful installation, port-forward the Kubecost service to access the dashboard:
kubectl port-forward -n kubecost deployment/kubecost-cost-analyzer 9090
Then open your browser and navigate to http://localhost:9090
to access the Kubecost interface.
For production environments, you might want to configure a proper ingress with authentication, but this quick port-forwarding approach allows you to immediately verify your installation.
Understanding Kubecost cost allocation insights
Kubecost provides several views to help you understand and optimize your EKS spending:
Cluster overview
The overview dashboard displays aggregate metrics for your entire cluster, showing total costs broken down by:
- Compute resources (CPU/memory)
- Storage resources (persistent volumes)
- Network resources
This high-level view helps identify overall spending trends and potential areas for optimization. It’s like getting a monthly statement for your Kubernetes infrastructure, showing exactly where your cloud dollars are going.
Namespace-level cost allocation
One of Kubecost’s most valuable features is its ability to allocate costs by namespace. This capability is particularly useful for:
- Charging back costs to different teams or departments
- Setting spending limits for development, testing, and production environments
- Identifying namespaces with unexpected cost growth
For example, you might discover that your development namespace is actually consuming more resources than production due to inefficient test configurations or forgotten workloads—something that would be difficult to spot with traditional AWS cost tools.
Pod and workload cost analysis
Drill down further to see costs at the pod and workload level, enabling you to:
- Identify expensive microservices
- Right-size container resource requests and limits
- Detect idle or underutilized pods
At hykell, we’ve found that properly sizing pod resource requests can lead to savings of up to 40% on Kubernetes workloads, as this directly impacts node provisioning and utilization. Many organizations unknowingly overprovision their containers out of caution, which leads to wasted resources that Kubecost can help identify.
Exporting Kubecost metrics
To integrate Kubecost data with your existing monitoring systems:
Prometheus integration
Kubecost exposes metrics via a Prometheus endpoint at /metrics
, allowing you to scrape and visualize cost data alongside other operational metrics in tools like Grafana. This is particularly valuable for creating comprehensive dashboards that combine performance, availability, and cost metrics in one view.
CloudWatch integration
For AWS-native monitoring, you can configure Kubecost to push metrics to CloudWatch:
- Create an IAM role with CloudWatch write permissions
- Annotate the Kubecost service account with this role
- Configure the Kubecost Prometheus exporter to push to CloudWatch
This integration enables you to set up CloudWatch alarms for cost thresholds, giving you proactive notifications when spending exceeds expected levels.
AWS Cost and Usage Report (CUR) integration
For the most accurate cost allocation, integrate Kubecost with AWS Cost and Usage Reports:
- Enable AWS CUR in your AWS Billing console
- Configure an S3 bucket to receive the reports
- Update your Kubecost configuration to access these reports:
kubecostProductConfigs: awsServiceKeyName: YOUR_ACCESS_KEY awsServiceKeyPassword: YOUR_SECRET_KEY awsSpotDataEnabled: true awsSpotDataRegion: us-east-1 currencyCode: USD productKey: kubecost-token
This integration provides enhanced accuracy by incorporating AWS-specific pricing data, including savings from Reserved Instances and Savings Plans. Without this integration, Kubecost uses estimated on-demand pricing that might not reflect your actual AWS discounts.
Best practices for Kubernetes cost optimization with Kubecost
Based on our experience at hykell, here are key strategies to maximize your cost savings:
1. Implement consistent labeling
Apply consistent labels across all resources to improve cost allocation accuracy:
metadata: labels: app.kubernetes.io/name: application-name app.kubernetes.io/component: database environment: production team: backend
These labels become the foundation for meaningful cost reporting. Without them, you’ll struggle to attribute costs to specific applications or teams, making optimization efforts much more challenging.
2. Set up spending alerts
Configure Kubecost alerts to notify you when costs exceed predefined thresholds:
alertConfigs: namespace: dailyReport: enabled: true threshold: 50.0 # $50 per day recipients: - team@example.com
These alerts serve as an early warning system for unexpected cost increases, allowing you to address issues before they significantly impact your cloud bill. For example, a development team might accidentally deploy a resource-intensive workload that would otherwise go unnoticed until the end of the billing cycle.
3. Right-size your workloads
Use Kubecost’s recommendation engine to identify over-provisioned resources and adjust accordingly:
- Remove unused persistent volumes
- Reduce CPU/memory requests for underutilized pods
- Consider using AWS Spot Instances for non-critical workloads
Kubecost provides detailed utilization data that shows the gap between requested resources and actual usage. This information is invaluable for right-sizing your workloads to match their real requirements rather than conservative estimates.
4. Analyze idle resources
Regularly review Kubecost’s idle resource reports to identify:
- Empty nodes that can be removed from your cluster
- Overprovisioned node groups that can be scaled down
- Redundant services that can be consolidated
In many organizations, idle resources can account for 15-30% of cloud costs. Kubecost helps you find these hidden cost drains and reclaim that wasted budget.
Conclusion: Maximizing EKS cost efficiency
Deploying Kubecost on Amazon EKS provides the visibility and tools needed to take control of your Kubernetes spending. By following the deployment steps and best practices outlined in this guide, you can identify cost-saving opportunities and implement targeted optimizations that reduce your AWS bill without compromising performance.
For organizations seeking to further automate their AWS cost optimization beyond just Kubernetes, hykell provides comprehensive solutions that can help reduce your overall cloud spending by up to 40% through automated resource optimization and intelligent scaling.
Whether you’re managing a small development cluster or enterprise-scale Kubernetes deployments, the combination of Kubecost’s detailed insights and strategic optimization can transform your EKS cost management approach from reactive to proactive.