Skip to content

Commit

Permalink
FOPTS-5415 Added new env vars to be able to use different host to get…
Browse files Browse the repository at this point in the history
… kubecost configuration (#59)
  • Loading branch information
JesusParada authored Oct 31, 2024
1 parent 436d4e8 commit b376db0
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 47 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.23.0

- Were added 3 new environment variables. KUBECOST_CONFIG_HOST and KUBECOST_CONFIG_API_PATH to configure a specific host and API path to get the Kubecost configuration if it is different from the one used for the Allocation API. And DEFAULT_CURRENCY, which is used when something fails while getting the Kubecost configuration.

## v1.22.0

- The validation to ensure we have complete data from the previous month to upload to Optima API was corrected.
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ You should see 200/201s in the logs, which indicates that the exporter is workin
|-----|------|---------|-------------|
| activeDeadlineSeconds | int | `10800` | The maximum duration in seconds for the cron job to complete |
| cronSchedule | string | `"0 */24 * * *"` | Setting up a cronJob scheduler to run an export task at the desired time. |
| defaultCurrency | string | `"USD"` | Indicates the default currency to use in case something fails while getting the currency from the kubecost configuration. |
| env | object | `{}` | Pod environment variables. Example using envs to use proxy: {"NO_PROXY": ".svc,.cluster.local", "HTTP_PROXY": "http://proxy.example.com:80", "HTTPS_PROXY": "http://proxy.example.com:80"} |
| filePath | string | `"/var/kubecost"` | File path to mount persistent volume. |
| fileRotation | bool | `true` | Indicates whether to delete files generated for previous months. Note: current and previous months data is kept. |
Expand All @@ -182,11 +183,13 @@ You should see 200/201s in the logs, which indicates that the exporter is workin
| flexera.vendorName | string | `"Kubecost"` | Vendor name for the Bill Connect. It is used when CREATE_BILL_CONNECT_IF_NOT_EXIST is set to true. |
| image.pullPolicy | string | `"Always"` | |
| image.repository | string | `"public.ecr.aws/flexera/cbi-oi-kubecost-exporter"` | |
| image.tag | string | `"1.22"` | |
| image.tag | string | `"1.23"` | |
| imagePullSecrets | list | `[]` | |
| includePreviousMonth | bool | `true` | Indicates whether to collect and export previous month data. Default is true. Setting this flag to false will prevent collecting and uploading the data from previous month and only upload data for the current month. Partial Data (i.e. missing data for some days) for previous month will not be uploaded even if the flag value is set to true. |
| kubecost.aggregation | string | `"pod"` | The level of granularity to use when aggregating the cost data. Valid values are namespace, controller, node, or pod. |
| kubecost.apiPath | string | `"/model/"` | The base path for the Kubecost API endpoint. |
| kubecost.configApiPath | string | `""` | The base path to get the kubecost configuration. This is an optional configuration, if not configured, the same api path value used for the allocation API is used. |
| kubecost.configHost | string | `""` | Indicates the host to use to obtain the Kubecost configuration. This is an optional configuration, if not configured, the same host value used for the allocation API is used. |
| kubecost.host | string | `"kubecost-cost-analyzer.kubecost.svc.cluster.local:9090"` | Default kubecost-cost-analyzer service host on the current cluster. For current cluster is serviceName.namespaceName.svc.cluster.local |
| kubecost.idle | bool | `true` | Indicates whether to include cost of idle resources. |
| kubecost.idleByNode | bool | `false` | Indicates whether idle allocations are created on a per node basis. |
Expand Down
4 changes: 2 additions & 2 deletions helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ description: Kubecost exporter helm chart for Kubernetes
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.22.0
version: 1.23.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.22"
appVersion: "1.23"
7 changes: 5 additions & 2 deletions helm-chart/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# cbi-oi-kubecost-exporter

![Version: 1.22.0](https://img.shields.io/badge/Version-1.22.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.22](https://img.shields.io/badge/AppVersion-1.22-informational?style=flat-square)
![Version: 1.23.0](https://img.shields.io/badge/Version-1.23.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.23](https://img.shields.io/badge/AppVersion-1.23-informational?style=flat-square)

### Kubecost exporter helm chart for Kubernetes

Expand Down Expand Up @@ -87,6 +87,7 @@ You should see 200/201s in the logs, which indicates that the exporter is workin
|-----|------|---------|-------------|
| activeDeadlineSeconds | int | `10800` | The maximum duration in seconds for the cron job to complete |
| cronSchedule | string | `"0 */24 * * *"` | Setting up a cronJob scheduler to run an export task at the desired time. |
| defaultCurrency | string | `"USD"` | Indicates the default currency to use in case something fails while getting the currency from the kubecost configuration. |
| env | object | `{}` | Pod environment variables. Example using envs to use proxy: {"NO_PROXY": ".svc,.cluster.local", "HTTP_PROXY": "http://proxy.example.com:80", "HTTPS_PROXY": "http://proxy.example.com:80"} |
| filePath | string | `"/var/kubecost"` | File path to mount persistent volume. |
| fileRotation | bool | `true` | Indicates whether to delete files generated for previous months. Note: current and previous months data is kept. |
Expand All @@ -100,11 +101,13 @@ You should see 200/201s in the logs, which indicates that the exporter is workin
| flexera.vendorName | string | `"Kubecost"` | Vendor name for the Bill Connect. It is used when CREATE_BILL_CONNECT_IF_NOT_EXIST is set to true. |
| image.pullPolicy | string | `"Always"` | |
| image.repository | string | `"public.ecr.aws/flexera/cbi-oi-kubecost-exporter"` | |
| image.tag | string | `"1.22"` | |
| image.tag | string | `"1.23"` | |
| imagePullSecrets | list | `[]` | |
| includePreviousMonth | bool | `true` | Indicates whether to collect and export previous month data. Default is true. Setting this flag to false will prevent collecting and uploading the data from previous month and only upload data for the current month. Partial Data (i.e. missing data for some days) for previous month will not be uploaded even if the flag value is set to true. |
| kubecost.aggregation | string | `"pod"` | The level of granularity to use when aggregating the cost data. Valid values are namespace, controller, node, or pod. |
| kubecost.apiPath | string | `"/model/"` | The base path for the Kubecost API endpoint. |
| kubecost.configApiPath | string | `""` | The base path to get the kubecost configuration. This is an optional configuration, if not configured, the same api path value used for the allocation API is used. |
| kubecost.configHost | string | `""` | Indicates the host to use to obtain the Kubecost configuration. This is an optional configuration, if not configured, the same host value used for the allocation API is used. |
| kubecost.host | string | `"kubecost-cost-analyzer.kubecost.svc.cluster.local:9090"` | Default kubecost-cost-analyzer service host on the current cluster. For current cluster is serviceName.namespaceName.svc.cluster.local |
| kubecost.idle | bool | `true` | Indicates whether to include cost of idle resources. |
| kubecost.idleByNode | bool | `false` | Indicates whether idle allocations are created on a per node basis. |
Expand Down
Binary file added helm-chart/cbi-oi-kubecost-exporter-1.23.0.tgz
Binary file not shown.
6 changes: 6 additions & 0 deletions helm-chart/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ spec:
value: "{{ .Values.kubecost.host }}"
- name: KUBECOST_API_PATH
value: "{{ .Values.kubecost.apiPath }}"
- name: KUBECOST_CONFIG_HOST
value: "{{ .Values.kubecost.configHost }}"
- name: KUBECOST_CONFIG_API_PATH
value: "{{ .Values.kubecost.configApiPath }}"
- name: AGGREGATION
value: "{{ .Values.kubecost.aggregation }}"
- name: SHARE_NAMESPACES
Expand All @@ -73,6 +77,8 @@ spec:
value: "{{ .Values.includePreviousMonth }}"
- name: REQUEST_TIMEOUT
value: "{{ .Values.requestTimeout }}"
- name: DEFAULT_CURRENCY
value: "{{ .Values.defaultCurrency }}"
- name: CREATE_BILL_CONNECT_IF_NOT_EXIST
value: "{{ .Values.flexera.createBillConnectIfNotExist }}"
- name: VENDOR_NAME
Expand Down
9 changes: 8 additions & 1 deletion helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
image:
repository: public.ecr.aws/flexera/cbi-oi-kubecost-exporter
pullPolicy: Always
tag: "1.22"
tag: "1.23"

imagePullSecrets: []

Expand Down Expand Up @@ -53,6 +53,10 @@ kubecost:
host: "kubecost-cost-analyzer.kubecost.svc.cluster.local:9090"
# -- The base path for the Kubecost API endpoint.
apiPath: "/model/"
# -- Indicates the host to use to obtain the Kubecost configuration. This is an optional configuration, if not configured, the same host value used for the allocation API is used.
configHost: ""
# -- The base path to get the kubecost configuration. This is an optional configuration, if not configured, the same api path value used for the allocation API is used.
configApiPath: ""
# -- The level of granularity to use when aggregating the cost data. Valid values are namespace, controller, node, or pod.
aggregation: "pod"
# -- Comma-separated list of namespaces to share costs with the remaining non-idle, unshared allocations.
Expand Down Expand Up @@ -82,6 +86,9 @@ includePreviousMonth: true
# -- Indicates the timeout per each request in minutes.
requestTimeout: 5

# -- Indicates the default currency to use in case something fails while getting the currency from the kubecost configuration.
defaultCurrency: "USD"

# -- Pod environment variables.
# Example using envs to use proxy:
# {"NO_PROXY": ".svc,.cluster.local", "HTTP_PROXY": "http://proxy.example.com:80", "HTTPS_PROXY": "http://proxy.example.com:80"}
Expand Down
Loading

0 comments on commit b376db0

Please sign in to comment.