Skip to content

Commit

Permalink
FOPTS-2222, 2223 Added new config var to allow send previous month of…
Browse files Browse the repository at this point in the history
… data to flexera, Updated format of time window sent to kubecost (#19)

* FOPTS-2223 Time window sent to kubecost corrected

* FOPTS-2222 Allow to send previous month of data to flexera

* FOPTS-2222 Updated helm-chart files: README.md, values.yaml and template/cronjob.yaml

* FOPTS-2222 Updated config var name from ALLOW_PREVIOUS_MONTH to INCLUDE_PREVIOUS_MONTH
  • Loading branch information
JesusParada authored Oct 16, 2023
1 parent 263ce32 commit edd0010
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 99 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.4

- Time window sent to kubecost API was corrected. Was added a config var to allow send previous month of data to Flexera.

## v1.3

- Added namespaceLabels field to the exported field "labels" in the CSV file
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ go install github.com/flexera-public/cbi-oi-kubecost-exporter
The app is configured using environment variables defined in a .env file. The following configuration options are available:

- `KUBECOST_HOST` - the hostname of the Kubecost instance
- `KUBECOST_API_PATH` - the base path for the Kubecost API endpoints
- `BILL_CONNECT_ID` - the ID of the bill connect to which to upload the data. To learn more about Bill Connect, and how to obtain your BILL_CONNECT_ID, please refer to [this guide](https://docs.flexera.com/flexera/EN/Optima/CreateKubecostBillConnect.htm) in the Flexera documentation.
- `SHARD` - the region of your Flexera One account. Valid values are NAM, EU or AU.
- `ORG_ID` - the ID of your Flexera One organization.
Expand All @@ -27,18 +28,19 @@ The app is configured using environment variables defined in a .env file. The fo
- `SHARE_TENANCY_COSTS` - a flag indicating whether to share tenancy costs among clusters
- `MULTIPLIER` - a multiplier to apply to the cost data
- `IDLE` - whether to include idle resources in the usage data. valid values are true or false.
- `FILE_ROTATION` - whether to delete files generated during the previous month (or the month before the previous month if INCLUDE_PREVIOUS_MONTH is set to true). Valid values are true or false.
- `FILE_PATH` - the path where the CSV files are stored
- `UPLOAD_TIMEOUT` - the timeout for uploading the CSV files to Flexera One, in seconds.
- `INCLUDE_PREVIOUS_MONTH` - whether to include data from previous month to export process. Valid values are true or false.

To use this app, run:

```bash
flexera-kubecost-exporter
```

### Helm package manager
### Kubecost exporter helm chart for Kubernetes

There are two different approaches for passing custom Helm config values into the kubecost-exporter:
There are two different ways to transfer custom Helm configuration values to the kubecost-exporter:

#### 1. Pass exact parameters via --set command-line flags:

Expand Down Expand Up @@ -118,18 +120,19 @@ You should see 200/201s in the logs, which indicates that the exporter is workin
## Values

| Key | Type | Default | Description |
| --- | --- | --- | --- |
|-----|------|---------|-------------|
| cronSchedule | string | `"0 */6 * * *"` | Setting up a cronJob scheduler to run an export task at the right time |
| filePath | string | `"/var/kubecost"` | Filepath to mount persistent volume |
| fileRotation | bool | `true` | Delete files generated for the previous month |
| fileRotation | bool | `true` | Delete files generated for the previous month (or the month before the previous month if INCLUDE_PREVIOUS_MONTH is set to true) |
| flexera.billConnectId | string | `"cbi-oi-kubecost-1"` | Bill Connect ID |
| flexera.orgId | string | `""` | Flexera Organization ID |
| flexera.refreshToken | string | `""` | Refresh Token from FlexeraOne |
| flexera.refreshToken | string | `""` | Refresh Token from FlexeraOne You can provide the refresh token in two ways: 1. Directly as a string: refreshToken: "your_token_here" 2. Reference it from a Kubernetes secret: refreshToken: valueFrom: secretKeyRef: name: flexera-secrets # Name of the Kubernetes secret key: refresh_token # Key in the secret containing the refresh token |
| flexera.shard | string | `"NAM"` | Shard ("NAM", "EU", "AU") |
| image.pullPolicy | string | `"Always"` | |
| image.repository | string | `"public.ecr.aws/flexera/cbi-oi-kubecost-exporter"` | |
| image.tag | string | `"latest"` | |
| imagePullSecrets | list | `[]` | |
| includePreviousMonth | bool | `false` | Include data from previous month to export process |
| kubecost.aggregation | string | `"pod"` | Aggregation Level ("namespace", "controller", "pod") |
| kubecost.apiPath | string | `"/model/"` | Base path for the Kubecost API endpoints |
| 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 |
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.3.0
version: 1.4.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.3"
appVersion: "1.4"
9 changes: 5 additions & 4 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.2.0](https://img.shields.io/badge/Version-1.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2](https://img.shields.io/badge/AppVersion-1.2-informational?style=flat-square)
![Version: 1.4.0](https://img.shields.io/badge/Version-1.4.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.4](https://img.shields.io/badge/AppVersion-1.4-informational?style=flat-square)

### Kubecost exporter helm chart for Kubernetes

Expand Down Expand Up @@ -87,15 +87,16 @@ You should see 200/201s in the logs, which indicates that the exporter is workin
|-----|------|---------|-------------|
| cronSchedule | string | `"0 */6 * * *"` | Setting up a cronJob scheduler to run an export task at the right time |
| filePath | string | `"/var/kubecost"` | Filepath to mount persistent volume |
| fileRotation | bool | `true` | Delete files generated for the previous month |
| fileRotation | bool | `true` | Delete files generated for the previous month (or the month before the previous month if INCLUDE_PREVIOUS_MONTH is set to true) |
| flexera.billConnectId | string | `"cbi-oi-kubecost-1"` | Bill Connect ID |
| flexera.orgId | string | `""` | Flexera Organization ID |
| flexera.refreshToken | string | `""` | Refresh Token from FlexeraOne |
| flexera.refreshToken | string | `""` | Refresh Token from FlexeraOne You can provide the refresh token in two ways: 1. Directly as a string: refreshToken: "your_token_here" 2. Reference it from a Kubernetes secret: refreshToken: valueFrom: secretKeyRef: name: flexera-secrets # Name of the Kubernetes secret key: refresh_token # Key in the secret containing the refresh token |
| flexera.shard | string | `"NAM"` | Shard ("NAM", "EU", "AU") |
| image.pullPolicy | string | `"Always"` | |
| image.repository | string | `"public.ecr.aws/flexera/cbi-oi-kubecost-exporter"` | |
| image.tag | string | `"latest"` | |
| imagePullSecrets | list | `[]` | |
| includePreviousMonth | bool | `false` | Include data from previous month to export process |
| kubecost.aggregation | string | `"pod"` | Aggregation Level ("namespace", "controller", "pod") |
| kubecost.apiPath | string | `"/model/"` | Base path for the Kubecost API endpoints |
| 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 |
Expand All @@ -108,4 +109,4 @@ You should see 200/201s in the logs, which indicates that the exporter is workin
| persistentVolume.size | string | `"1Gi"` | Persistent Volume size |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
Autogenerated from chart metadata using [helm-docs v1.11.3](https://github.com/norwoodj/helm-docs/releases/v1.11.3)
Binary file added helm-chart/cbi-oi-kubecost-exporter-1.4.0.tgz
Binary file not shown.
2 changes: 2 additions & 0 deletions helm-chart/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ spec:
value: "{{ .Values.fileRotation }}"
- name: FILE_PATH
value: "{{ .Values.filePath }}"
- name: INCLUDE_PREVIOUS_MONTH
value: "{{ .Values.includePreviousMonth }}"
volumeMounts:
- name: persistent-configs
mountPath: {{ .Values.filePath }}
Expand Down
5 changes: 4 additions & 1 deletion helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ kubecost:
# -- Cost multiplier
multiplier: 1.0

# -- Delete files generated for the previous month
# -- Delete files generated for the previous month (or the month before the previous month if INCLUDE_PREVIOUS_MONTH is set to true)
fileRotation: true

# -- Filepath to mount persistent volume
filePath: "/var/kubecost"

# -- Include data from previous month to export process
includePreviousMonth: false
20 changes: 15 additions & 5 deletions index.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
apiVersion: v1
entries:
cbi-oi-kubecost-exporter:
- apiVersion: v2
appVersion: "1.4"
created: "2023-10-13T11:21:44.396278-06:00"
description: Kubecost exporter helm chart for Kubernetes
digest: 671339fe2b3198825e11bad8203b080e896fc04bcdc4020738db2f121d4133e1
name: cbi-oi-kubecost-exporter
type: application
urls:
- helm-chart/cbi-oi-kubecost-exporter-1.4.0.tgz
version: 1.4.0
- apiVersion: v2
appVersion: "1.3"
created: "2023-09-14T16:04:16.019889-06:00"
created: "2023-10-13T11:21:44.395125-06:00"
description: Kubecost exporter helm chart for Kubernetes
digest: a9c88dd6e4e2f52f0cf00f28e4a4760591287c35647ccb529109a945950019d3
digest: 0d967927bfab5f4bb6d40ce062710679e98b145c4b3f38709c0bf5d216ad8606
name: cbi-oi-kubecost-exporter
type: application
urls:
- helm-chart/cbi-oi-kubecost-exporter-1.3.0.tgz
version: 1.3.0
- apiVersion: v2
appVersion: "1.2"
created: "2023-09-14T16:04:16.018246-06:00"
created: "2023-10-13T11:21:44.394041-06:00"
description: Kubecost exporter helm chart for Kubernetes
digest: d0c724c7bb085a1801e27f60ff748bc69aba14425cfd27fd132f99966692ed80
name: cbi-oi-kubecost-exporter
Expand All @@ -23,12 +33,12 @@ entries:
version: 1.2.0
- apiVersion: v2
appVersion: "1.1"
created: "2023-09-14T16:04:16.017805-06:00"
created: "2023-10-13T11:21:44.393271-06:00"
description: Kubecost exporter helm chart for Kubernetes
digest: c6f2681575b704b5934efea2357921896d55c4ad5e09692f31ab92b9e614cfea
name: cbi-oi-kubecost-exporter
type: application
urls:
- helm-chart/cbi-oi-kubecost-exporter-1.1.0.tgz
version: 1.1.0
generated: "2023-09-14T16:04:16.0155-06:00"
generated: "2023-10-13T11:21:44.392264-06:00"
Loading

0 comments on commit edd0010

Please sign in to comment.