Skip to content

Commit

Permalink
Update Dockerfile and GitHub Actions for multi-arch builds (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
night-codes authored Oct 28, 2024
1 parent 82c5efd commit ad24b4c
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 67 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/build_and_push_docker_image.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Push Docker Image
name: Build and Push Multi-Arch Docker Image

on:
push:
Expand Down Expand Up @@ -38,16 +38,19 @@ jobs:
registry-type: public
registries: public.ecr.aws/flexera

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug

- name: Build and push Docker image
uses: docker/build-push-action@v2
- name: Build and push multi-arch Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
public.ecr.aws/flexera/cbi-oi-kubecost-exporter:${{ steps.extract_version.outputs.version }}
Expand Down
62 changes: 33 additions & 29 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,102 +1,106 @@
# Changelog

## v1.21.1

- Added support for multi-arch builds

## v1.21.0

- Added pagination for Kubecost Allocation API requests.
- Added pagination for Kubecost Allocation API requests.

## v1.20.0

- Setting the default value of the INCLUDE_PREVIOUS_MONTH to true.
- Setting the default value of the INCLUDE_PREVIOUS_MONTH to true.

## v1.19.0

- Exit with error code 1 in case of any failure during bill upload.
- Exit with error code 1 in case of any failure during bill upload.

## v1.18.0

- Changed the default schedule of the cronJob scheduler to run an export task to - Once in every 24 hours.
- Changed the default schedule of the cronJob scheduler to run an export task to - Once in every 24 hours.

## v1.17.0

- Added labels "kc-cluster" for cluster-name, "kc-namespace" for namespace to the exported field "labels" in the CSV file.
- Added labels "kc-cluster" for cluster-name, "kc-namespace" for namespace to the exported field "labels" in the CSV file.

## v1.16.0

- Allow creation of Bill Connect (if not existing) conditionally based on flag CREATE_BILL_CONNECT_IF_NOT_EXIST
- To support the creation of Bill Connect, introduced additional Parameter - VENDOR_NAME. This parameter is only used when the CREATE_BILL_CONNECT_IF_NOT_EXIST is set to true.
- Added query parameter 'accumulate' for Kubecost Allocation API requests to sum the entire range of time intervals into a single set and reduce response size.
- Allow creation of Bill Connect (if not existing) conditionally based on flag CREATE_BILL_CONNECT_IF_NOT_EXIST
- To support the creation of Bill Connect, introduced additional Parameter - VENDOR_NAME. This parameter is only used when the CREATE_BILL_CONNECT_IF_NOT_EXIST is set to true.
- Added query parameter 'accumulate' for Kubecost Allocation API requests to sum the entire range of time intervals into a single set and reduce response size.

## v1.15.0

- Added some modifications building aggregation query param to address Kubecost Allocation API changes made for versions 2.3 and higher.
- Added some modifications building aggregation query param to address Kubecost Allocation API changes made for versions 2.3 and higher.

## v1.14.0

- Improved OpenCost support. Added description of settings for integration with OpenCost in README.md
- Improved OpenCost support. Added description of settings for integration with OpenCost in README.md

## v1.13.0

- Fixed crash on getConfigs request for OpenCost
- Fixed crash on getConfigs request for OpenCost

## v1.12.0

- Implemented compression and chunking for large CSV files to improve file upload reliability and performance with Flexera CBI.
- Implemented compression and chunking for large CSV files to improve file upload reliability and performance with Flexera CBI.

## v1.11.1

- Enhanced Helm chart to dynamically configure `activeDeadlineSeconds` through `values.yaml`, providing greater flexibility for cron job execution duration.
- Enhanced Helm chart to dynamically configure `activeDeadlineSeconds` through `values.yaml`, providing greater flexibility for cron job execution duration.

## v1.11.0

- Added labels "kc-container" for container, "kc-controller" for controller, "kc-node" for node, "kc-pod-id" for pod and "kc-provider-id" for providerID to the exported field "labels" in the CSV file.
- Added labels "kc-container" for container, "kc-controller" for controller, "kc-node" for node, "kc-pod-id" for pod and "kc-provider-id" for providerID to the exported field "labels" in the CSV file.

## v1.10.0

- Added Flexera Service Accounts support (SERVICE_APP_CLIENT_ID and SERVICE_APP_CLIENT_SECRET env variables)
- Added Flexera Service Accounts support (SERVICE_APP_CLIENT_ID and SERVICE_APP_CLIENT_SECRET env variables)

## v1.9.1

- Addressed an issue with Kubecost where it returns "empty" data for selected date ranges. Also ensured that no data is written to files in cases where the data is empty.
- Addressed an issue with Kubecost where it returns "empty" data for selected date ranges. Also ensured that no data is written to files in cases where the data is empty.

## v1.9

- Added new env var REQUEST_TIMEOUT to manage the timeout of the requests. Default value is 5 minutes.
- Added new query param 'step' set to '1d' to get daily data metrics from kubecost API.
- Added new env var REQUEST_TIMEOUT to manage the timeout of the requests. Default value is 5 minutes.
- Added new query param 'step' set to '1d' to get daily data metrics from kubecost API.

## v1.8

- The bill upload process is aborted if an error occurs during the same process. If at the time the exporter wants to start the bill upload process there is another one in progress for the same organization and period, it is aborted and a new one is started.
- The bill upload process is aborted if an error occurs during the same process. If at the time the exporter wants to start the bill upload process there is another one in progress for the same organization and period, it is aborted and a new one is started.

## v1.7

- The MD5 hash of the files is verified to ensure the integrity of the uploaded files.
- The MD5 hash of the files is verified to ensure the integrity of the uploaded files.

## v1.6

- Save two months of cvs files instead of only current month.
- When uploading files for previous month, exporter validates that the number of files to upload match with the number of days of the previous month.
- Save two months of cvs files instead of only current month.
- When uploading files for previous month, exporter validates that the number of files to upload match with the number of days of the previous month.

## v1.5

- Added costAdjustments for cpuCost, gpuCost, ramCost, pvCost, networkCost and loadBalancerCost
- Added new env var IDLE_BY_NODE to manage if idle allocations are created on a per node basis
- Added costAdjustments for cpuCost, gpuCost, ramCost, pvCost, networkCost and loadBalancerCost
- Added new env var IDLE_BY_NODE to manage if idle allocations are created on a per node basis

## v1.4

- Time window sent to kubecost API was corrected. Was added a config var to allow send previous month of data to Flexera.
- 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
- Added namespaceLabels field to the exported field "labels" in the CSV file

## v1.2

- Added `apiPath` to `kubecost` configuration to support custom API paths.
- Added `apiPath` to `kubecost` configuration to support custom API paths.

## v1.1

- Added AU shard and changed default aggregate value to "pod"
- Added AU shard and changed default aggregate value to "pod"

## v1.0

- Initial release
- Initial release
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dockerfile
FROM golang:1.22 as base
FROM --platform=$BUILDPLATFORM golang:1.22 as base

RUN adduser \
--disabled-password \
Expand All @@ -19,7 +19,8 @@ COPY . .
RUN go mod download
RUN go mod verify

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOCACHE=/tmp/go-cache go build -buildvcs=false -o ./exporter .
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH GOCACHE=/tmp/go-cache go build -buildvcs=false -o ./exporter .

FROM scratch

Expand Down
2 changes: 1 addition & 1 deletion helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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.21.0
version: 1.21.1

# 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
Expand Down
4 changes: 2 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.21.0](https://img.shields.io/badge/Version-1.21.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.21](https://img.shields.io/badge/AppVersion-1.21-informational?style=flat-square)
![Version: 1.21.1](https://img.shields.io/badge/Version-1.21.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.21](https://img.shields.io/badge/AppVersion-1.21-informational?style=flat-square)

### Kubecost exporter helm chart for Kubernetes

Expand Down Expand Up @@ -102,7 +102,7 @@ You should see 200/201s in the logs, which indicates that the exporter is workin
| image.repository | string | `"public.ecr.aws/flexera/cbi-oi-kubecost-exporter"` | |
| image.tag | string | `"1.21"` | |
| 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. |
| includePreviousMonth | bool | `true` | Indicates whether to collect and export previous month. |
| 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.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
Binary file added helm-chart/cbi-oi-kubecost-exporter-1.21.1.tgz
Binary file not shown.
Loading

0 comments on commit ad24b4c

Please sign in to comment.