Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding support to custom pricing configuration in helm chart #109

2 changes: 1 addition & 1 deletion charts/opencost/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ keywords:
- kubecost
- opencost
- monitoring
version: 1.19.3
version: 1.19.4
maintainers:
- name: mattray
url: https://mattray.dev
Expand Down
30 changes: 23 additions & 7 deletions charts/opencost/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

OpenCost and OpenCost UI

![Version: 1.19.3](https://img.shields.io/badge/Version-1.19.3-informational?style=flat-square)
![Version: 1.19.4](https://img.shields.io/badge/Version-1.19.4-informational?style=flat-square)
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![AppVersion: 1.105.2](https://img.shields.io/badge/AppVersion-1.105.2-informational?style=flat-square)

## Maintainers

| Name | Url |
| ---- | --- |
| mattray | <https://mattray.dev> |
| toscott | |
| Name | Email | Url |
| ---- | ------ | --- |
| mattray | | <https://mattray.dev> |
| toscott | | |

## Installing the Chart

Expand All @@ -28,13 +28,20 @@ $ helm install opencost opencost/opencost
| annotations | object | `{}` | Annotations to add to the all the resources |
| extraVolumes | list | `[]` | A list of volumes to be added to the pod |
| fullnameOverride | string | `""` | Overwrite all resources name created by the chart |
| imagePullSecrets | list | `[]` | List of secret names to use for pulling the images |
| nameOverride | string | `""` | Overwrite the default name of the chart |
| opencost.affinity | object | `{}` | Affinity settings for pod assignment |
| opencost.customPricing.configPath | string | `"/tmp/custom-config"` | Path for the pricing configuration. |
| opencost.customPricing.configmapName | string | `"custom-pricing-model"` | |
| opencost.customPricing.costModel | object | `{"CPU":1.25,"GPU":0.95,"RAM":0.5,"description":"Modified prices based on your internal pricing","internetNetworkEgress":0.12,"provider":"custom","regionNetworkEgress":0.01,"spotCPU":0.006655,"spotRAM":0.000892,"storage":0.25,"zoneNetworkEgress":0.01}` | More information about these values here: https://www.opencost.io/docs/configuration/on-prem#custom-pricing-using-the-opencost-helm-chart |
| opencost.customPricing.createConfigmap | bool | `true` | Configures the pricing model provided in the values file. |
| opencost.customPricing.enabled | bool | `false` | Enables custom pricing for on-premise setup. |
| opencost.exporter.aws.access_key_id | string | `""` | AWS secret key id |
| opencost.exporter.aws.secret_access_key | string | `""` | AWS secret access key |
| opencost.exporter.cloudProviderApiKey | string | `""` | The GCP Pricing API requires a key. This is supplied just for evaluation. |
| opencost.exporter.csv_path | string | `""` | |
| opencost.exporter.defaultClusterId | string | `"default-cluster"` | Default cluster ID to use if cluster_id is not set in Prometheus metrics. |
| opencost.exporter.env | list | `[]` | List of additional environment variables to set in the container |
| opencost.exporter.extraEnv | object | `{}` | Any extra environment variables you would like to pass on to the pod |
| opencost.exporter.extraVolumeMounts | list | `[]` | A list of volume mounts to be added to the pod |
| opencost.exporter.image.pullPolicy | string | `"IfNotPresent"` | Exporter container image pull policy |
Expand All @@ -43,7 +50,7 @@ $ helm install opencost opencost/opencost
| opencost.exporter.image.tag | string | `""` (use appVersion in Chart.yaml) | Exporter container image tag |
| opencost.exporter.livenessProbe.enabled | bool | `true` | Whether probe is enabled |
| opencost.exporter.livenessProbe.failureThreshold | int | `3` | Number of failures for probe to be considered failed |
| opencost.exporter.livenessProbe.initialDelaySeconds | int | `30` | Number of seconds before probe is initiated |
| opencost.exporter.livenessProbe.initialDelaySeconds | int | `120` | Number of seconds before probe is initiated |
| opencost.exporter.livenessProbe.periodSeconds | int | `10` | Probe frequency in seconds |
| opencost.exporter.persistence.accessMode | string | `""` | Access mode for persistent volume |
| opencost.exporter.persistence.annotations | object | `{}` | Annotations for persistent volume |
Expand All @@ -52,7 +59,7 @@ $ helm install opencost opencost/opencost
| opencost.exporter.persistence.storageClass | string | `""` | Storage class for persistent volume |
| opencost.exporter.readinessProbe.enabled | bool | `true` | Whether probe is enabled |
| opencost.exporter.readinessProbe.failureThreshold | int | `3` | Number of failures for probe to be considered failed |
| opencost.exporter.readinessProbe.initialDelaySeconds | int | `30` | Number of seconds before probe is initiated |
| opencost.exporter.readinessProbe.initialDelaySeconds | int | `120` | Number of seconds before probe is initiated |
| opencost.exporter.readinessProbe.periodSeconds | int | `10` | Probe frequency in seconds |
| opencost.exporter.replicas | int | `1` | Number of OpenCost replicas to run |
| opencost.exporter.resources.limits | object | `{"cpu":"999m","memory":"1Gi"}` | CPU/Memory resource limits |
Expand All @@ -77,6 +84,15 @@ $ helm install opencost opencost/opencost
| opencost.prometheus.password | string | `""` | Prometheus Basic auth password |
| opencost.prometheus.password_key | string | `"DB_BASIC_AUTH_PW"` | Key in the secret that references the password |
| opencost.prometheus.secret_name | string | `nil` | Secret name that contains credentials for Prometheus |
| opencost.prometheus.thanos.enabled | bool | `false` | |
| opencost.prometheus.thanos.external.enabled | bool | `false` | |
| opencost.prometheus.thanos.external.url | string | `"https://thanos-query.example.com/thanos"` | |
| opencost.prometheus.thanos.internal.enabled | bool | `true` | |
| opencost.prometheus.thanos.internal.namespaceName | string | `"opencost"` | |
| opencost.prometheus.thanos.internal.port | int | `10901` | |
| opencost.prometheus.thanos.internal.serviceName | string | `"my-thanos-query"` | |
| opencost.prometheus.thanos.maxSourceResolution | string | `""` | |
| opencost.prometheus.thanos.queryOffset | string | `""` | |
| opencost.prometheus.username | string | `""` | Prometheus Basic auth username |
| opencost.prometheus.username_key | string | `"DB_BASIC_AUTH_USERNAME"` | Key in the secret that references the username |
| opencost.tolerations | list | `[]` | Toleration labels for pod assignment |
Expand Down
13 changes: 13 additions & 0 deletions charts/opencost/templates/configmap.yaml
HoussemCharf marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if and .Values.opencost.customPricing.createConfigmap .Values.opencost.customPricing.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.opencost.customPricing.configmapName }}
data:
default.json: |-
HoussemCharf marked this conversation as resolved.
Show resolved Hide resolved
{
HoussemCharf marked this conversation as resolved.
Show resolved Hide resolved
{{- range $key, $val := .Values.opencost.customPricing.costModel }}
{{ $key | quote | indent 6}}: {{ $val | quote }},
{{- end}}
}
{{- end }}
19 changes: 17 additions & 2 deletions charts/opencost/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,27 @@ spec:
{{- with .Values.opencost.exporter.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.opencost.customPricing.enabled }}
- name: CONFIG_PATH
value: {{ .Values.opencost.customPricing.configPath | quote }}
{{- end }}
# Add any additional provided variables
{{- range $key, $value := .Values.opencost.exporter.extraEnv }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- if or .Values.opencost.exporter.persistence.enabled .Values.opencost.exporter.extraVolumeMounts }}
{{- if or .Values.opencost.exporter.persistence.enabled .Values.opencost.exporter.extraVolumeMounts .Values.opencost.customPricing.enabled}}
volumeMounts:
{{- if .Values.opencost.exporter.persistence.enabled }}
- mountPath: /mnt/export
name: opencost-export
readOnly: false
{{- end }}
{{- if .Values.opencost.customPricing.enabled }}
- mountPath: {{ .Values.opencost.customPricing.configPath }}
name: custom-configs
readOnly: true
{{- end }}
{{- with .Values.opencost.exporter.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -191,8 +201,13 @@ spec:
volumeMounts: {{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if or .Values.opencost.exporter.persistence.enabled .Values.extraVolumes }}
{{- if or .Values.opencost.exporter.persistence.enabled .Values.extraVolumes .Values.opencost.customPricing.enabled}}
volumes:
{{- if .Values.opencost.customPricing.enabled }}
- name: custom-configs
configMap:
name: {{ .Values.opencost.customPricing.configmapName }}
{{- end }}
{{- if .Values.opencost.exporter.persistence.enabled }}
- name: opencost-export
persistentVolumeClaim:
Expand Down
22 changes: 22 additions & 0 deletions charts/opencost/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,28 @@ opencost:
# -- Any extra environment variables you would like to pass on to the pod
extraEnv: {}
# FOO: BAR
customPricing:
# -- Enables custom pricing for on-premise setup.
enabled: false
configmapName: custom-pricing-model
# -- Path for the pricing configuration.
configPath: /tmp/custom-config
# -- Configures the pricing model provided in the values file.
createConfigmap: true
# -- More information about these values here: https://www.opencost.io/docs/configuration/on-prem#custom-pricing-using-the-opencost-helm-chart
costModel:
provider: custom
description: Modified prices based on your internal pricing
CPU: 1.25
spotCPU: 0.006655
RAM: 0.50
spotRAM: 0.000892
GPU: 0.95
storage: 0.25
zoneNetworkEgress: 0.01
regionNetworkEgress: 0.01
internetNetworkEgress: 0.12


metrics:
serviceMonitor:
Expand Down