Installing on Oracle Cloud Infrastructure (OCI)
OpenCost may be installed on Kubernetes clusters running on OCI or on the Container Engine for Kubernetes (OKE).
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.
OCI Configuration
Cost Allocation
OpenCost will automatically detect OCI as the cloud service provider (CSP) by reading node information from node.spec.providerID
. When OCI is detected as the CSP, OpenCost attempts to retrieve pricing data from the OCI Price List API.
No API key is required to retrieve the public pricing data.
If your cluster is an OKE cluster, OpenCost will apply enhanced cluster pricing by default.
OCI Cloud Costs
The Cloud Costs feature is included in the stable releases as of 1.108.0. Please ensure you have the latest release to access this new feature.
To configure OpenCost for your OCI account, use an existing or new OCI authorizer info for your account.
<YOUR-TENANCY-OCID>
is the OCI Tenancy OCID for your account. A full example isocid1.tenancy.oc1..aaaaaaaaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxkguca
.<YOUR-HOME-REGION>
is the home region of your account. You should have chosen one region when creating your OCI account. A full example isus-ashburn-1
.<YOUR-USER-OCID>
is the user OCID for your account. This user should have permissions to view all resources in your tenancy. A full example isocid1.user.oc1..aaaaaaaaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxeyra
.<YOUR-FINGERPRINT-OF-APIKEY>
is the fingerprint of the API key for the above user. A full example is71:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:03
.<YOUR-PRIVATE-KEY-OF-APIKEY>
is the private key (.pem) of the API key for the above user. This line must be one line, including line breaks. A full example is-----BEGIN PRIVATE KEY-----\~~~-----END PRIVATE KEY-----
.
{
"oci": {
"usageApi": [
{
"tenancyID": "<YOUR-TENANCY-OCID>",
"region": "<YOUR-HOME-REGION>",
"authorizer": {
"authorizerType": "OCIRawConfigProvider",
"tenancyID": "<YOUR-TENANCY-OCID>",
"userID": "<YOUR-USER-OCID>",
"region": "<YOUR-HOME-REGION>",
"fingerprint": "<YOUR-FINGERPRINT-OF-APIKEY>",
"privateKey": "<YOUR-PRIVATE-KEY-OF-APIKEY>"
}
}
]
}
}
Load the cloud-integration.json
into a Kubernetes secret in your opencost
namespace.
kubectl create secret generic cloud-costs --from-file=./cloud-integration.json --namespace opencost
Update your local OpenCost Helm values file to match the name of the secret and enable Cloud Costs:
opencost:
cloudIntegrationSecret: cloud-costs
cloudCost:
enabled: true
You may refer to the Cloud Costs documentation for configuring Cloud Costs for multiple accounts and cloud service providers.
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 OCI.
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