Installing on Linode
OpenCost may be installed on Kubernetes clusters running on Linode Kubernetes Service (LKS).
You will need to install Prometheus, create your OpenCost namespace, configure your cluster pricing and cloud costs, and then install OpenCost.
Install Prometheus
Prometheus is a prerequisite for OpenCost installation. OpenCost requires Prometheus for scraping metrics and data storage. For the installation of Prometheus please use the following command:
helm install prometheus --repo https://prometheus-community.github.io/helm-charts prometheus \
--namespace prometheus-system --create-namespace \
--set prometheus-pushgateway.enabled=false \
--set alertmanager.enabled=false \
-f https://raw.githubusercontent.com/opencost/opencost/develop/kubernetes/prometheus/extraScrapeConfigs.yaml
This will install Prometheus in the prometheus-system
namespace with default settings for use with OpenCost.
If you wish to use a different Prometheus installation or work with another compatible technology, please refer to the Prometheus installation page.
Create the OpenCost Namespace
Create the opencost
namespace for your installation:
kubectl create namespace opencost
Alternate namespaces may be used if necessary.
Linode Configuration
Cost Allocation
OpenCost will automatically read the node information node.spec.providerID
to determine the cloud service provider (CSP) in use. If it detects the CSP is LKE, it will attempt to pull the Linode on-demand pricing with no further configuration required.
For clusters with a High Availability Control Plane, there's an additional step required. Please refer to the Security for Linode integration section.
To accurately allocate costs for Linode, you need to enable monitoring.coreos.com/v1.ServiceMonitor. This is necessary because the default node prices are replaced by the provider, and without metrics data, the provider can't calculate the prices correctly.
Custom Pricing
Custom Pricing is not fully supported by the Linode provider. You can only modify the following values.
opencost:
customPricing:
enabled: true
configmapName: pricing-configs
provider: linode
costModel:
description: Modified Linode prices
linodeTokenSecret: Modified token secret namespaced name
zoneNetworkEgress: 0.0
regionNetworkEgress: 0.0
internetNetworkEgress: 0.0
defaultLBPrice: 0.15
controlPlaneCosts: 0.0
HaControlPlaneCosts: 0.9
Security for Linode integration
OpenCost uses the Linode SDK for Go to pull price data.
Linode integration works out of the box and uses the default token located at kube-system/linode, but OpenCost does not have the necessary permissions to use it.
Without the required permissions, the Linode provider cannot detect High Availability Control Plane clusters, which means it won't be able to calculate pricing correctly. To resolve this, please create the following role and binding to grant the necessary permissions.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: get-secret-linode
rules:
- apiGroups: [""]
resources: ["secrets"]
resourceNames: ["linode"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: opencost-secret-access-linode
subjects:
- kind: ServiceAccount
name: opencost
namespace: default
roleRef:
kind: ClusterRole
name: get-secret-linode
apiGroup: rbac.authorization.k8s.io
Sometimes, it's beneficial to maintain a separate token or manage token rotation to ensure proper security and functionality.
First create Linode API token with Read-Only Kubernetes access.
Create your own secret.
kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
name: linode
namespace: opencost
type: Opaque
data:
token: $(echo -n "$LINODE_TOKEN" | base64 -w0)
EOF
Ensure permissions to read secret.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: get-secret-linode
namespace: opencost
rules:
- apiGroups: [""]
resources: ["secrets"]
resourceNames: ["linode"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: opencost-secret-access-linode
namespace: opencost
subjects:
- kind: ServiceAccount
name: opencost
namespace: opencost
roleRef:
kind: Role
name: get-secret-linode
apiGroup: rbac.authorization.k8s.io
Configure custom pricing.
opencost:
customPricing:
enabled: true
configmapName: pricing-configs
provider: linode
costModel:
linodeTokenSecret: opencost/linode
Alternatively, you can override the secret by setting the Helm value opencost.exporter.linode.tokenSecret.
Linode Cloud Costs
Cloud Cost integration is not supported at this time.
Install OpenCost
Helm is the preferred installation method for OpenCost.
Using the OpenCost Helm Chart
You may check out the source for the OpenCost Helm Chart or you may install the Helm chart directly to your Kubernetes cluster. Review the values.yaml for the settings available for customization. With your custom settings in the Helm values file local.yaml
, install OpenCost:
helm install opencost --repo https://opencost.github.io/opencost-helm-chart opencost \
--namespace opencost -f local.yaml
Updating OpenCost via Helm
Upgrading the Helm chart version or updating settings may be done with the following:
helm upgrade opencost --repo https://opencost.github.io/opencost-helm-chart opencost \
--namespace opencost -f local.yaml
Installing with the OpenCost Manifest
Installing from the OpenCost manifest is supported on Linode.
For basic Kubernetes Cost Allocations without Cloud Costs or any customizations you may use the OpenCost manifest. Prometheus is still required and the Helm chart installation is recommended for anything beyond this simple use case.
kubectl apply --namespace opencost -f https://raw.githubusercontent.com/opencost/opencost/develop/kubernetes/opencost.yaml