The [Argo](https://argoproj.github.io/) container-native workflow engine for Kubernetes is a tremendously popular open source option for teams looking to run workflows, manage clusters, orchestrate parallel jobs, and more.\n\n\\\nPairing Kubernetes and Argo, multiple dev teams can run workloads on centrally-managed clusters, sharing compute resources to increase efficiency and reduce overhead. However, keeping track of each team’s spending—and spending efficiency—in the Kubernetes shared resources environment has become an all-too-familiar challenge. Teams routinely struggle with budgeting projections and waste reduction efforts without visibility into historical resource usage data and the ability to break down cost responsibilities by team. That visibility is crucial to addressing minor inefficiencies before they grow and lead to significant waste as workflows scale.\n\n\\\n !(https://cdn.hackernoon.com/images/-0ne3q7j.png)\n\n*\\[A completed Argo workflow, its costs completely unknown\\]*\n\n\\\n**Enter Kubecost, Argo’s spend-conscious companion**\n \nKubecost, a Kubernetes cost monitoring tool with a [free community version](https://github.com/kubecost), enables dev teams to accurately measure Argo workflow costs in real-time, allocate costs to teams, recognize resource efficiencies, and suggest opportunities for optimization.\n\n\\\nThe following guide demonstrates how teams managing Kubernetes workloads with Argo Workflows can deploy Kubecost to analyze and control their workflow spending. Those interested in beginning to leverage Argo Workflows should follow this [simple Quick Start guide](https://argoproj.github.io/argo-workflows/quick-start/) on GitHub. Kubecost itself can be installed using [Helm](https://helm.sh/), and should be given its own namespace:\n\n\\\n !(https://cdn.hackernoon.com/images/-gaa3pjo.png) Once installed, Kubecost will collect cost data on running Argo Workflows.\n\n\\\n**Create an example workflow**\n \nFor this guide, let’s define an Argo Workflow by creating a *WorkflowTemplate* CRD. We’ll make the workflow mimic high resource usage by having the [stress-ng](https://hub.docker.com/r/polinux/stress-ng) Docker container make resource-consuming Pods. The workflow will perform its single “stress” stage, running the stress-ng image, along with inputs Argo will handle in the launched workflow.\n \nTo create the *WorkflowTemplate* CRD in the Argo namespace, save the following yaml to a file and run *argo template create $filename -n argo*.\n\n\\\n !(https://cdn.hackernoon.com/images/-zg93prl.png)The workflow requests 1200m CPU and 40M memory, while the running stress-ng container uses 1 CPU and 30M memory. That gap represents wasteful inefficiency, as the over-provisioned container uses more cluster compute resources than it requires to operate.\n\n\\\n**Measure Kubernetes costs with Kubecost**\n \nBecause Argo Workflow jobs all feature the metadata label *[workflows.argoproj.io/workflow](http://workflows.argoproj.io/workflow)*, viewing each workflow’s costs and efficiency metrics within Kubecost is simple. In the Kubecost UI, go to the Cost Allocation page and change the “Aggregate By” field to “Label: workflows_argoproj_io_workflow.” This will display the following per-workflow cost and efficiency data:\n\n\\\n !(https://cdn.hackernoon.com/images/-mzc3qxh.png)\n\n\\\nEach time a workflow runs, that run receives a unique name based on the template and an added identifier. In the below example, the stress-ng workflow’s first run is named stress-ng-q9wdz. Filtering to this specific workflow run, Kubecost displays that its cost efficiency was just 57%. Clicking the workflow name to open the Details view shows the degree to which CPU and RAM overprovisioning caused this inefficiency: only 55% of requested CPU and 60% of requested RAM actually went to use!\n\n\\\n !(https://cdn.hackernoon.com/images/-oog3qh1.png)\n\n\\\n**Use the kubectl-cost CLI for quick cost inspection**\n \nClusters with Kubecost installed are available for inspection using the kubectl-cost CLI tool as well as the UI. Use Krew to install kubectl-cost:\n \n`kubectl krew install cost`\n \nIn the CLI, workflow costs are available with the command *kubectl cost label --label [workflows.argoproj.io/workflow](http://workflows.argoproj.io/workflow:)*[:](http://workflows.argoproj.io/workflow:)\n\n\\\n !(https://cdn.hackernoon.com/images/-zph3qp4.png)\n\n**Boost the precision of cost insights**\n\n\\\nThe Kubecost tool uses the major cloud providers’ publicly-listed prices by default, but integrating [actual cloud provider billing data](https://guide.kubecost.com/hc/en-us/articles/4407595968919-Setting-Up-Cloud-Integrations) will yield even more precise cost analysis. Doing so can also account for any custom discounts, reserved instances, or other pricing differences that might be relevant to your environment.