From 75762c5af337f907a283b43038bd7f4fb3bd5ac4 Mon Sep 17 00:00:00 2001 From: Oleksiy Chechel Date: Thu, 19 Oct 2023 16:29:41 -0600 Subject: [PATCH] Add versioning for Docker images (#25) * Add versioning for Docker images * Update github-actions * Exclude tagging and PR builds from GitHub-actions * Use only a minor update that does not affect the application version --- .../build_and_push_docker_image.yaml | 12 ++++++- Makefile | 30 ++++++++++++++++++ go.mod | 2 +- helm-chart/Chart.yaml | 2 +- helm-chart/README.md | 11 +++---- helm-chart/cbi-oi-kubecost-exporter-1.4.2.tgz | Bin 0 -> 4343 bytes helm-chart/values.yaml | 2 +- index.yaml | 22 +++++++++---- 8 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 Makefile create mode 100644 helm-chart/cbi-oi-kubecost-exporter-1.4.2.tgz diff --git a/.github/workflows/build_and_push_docker_image.yaml b/.github/workflows/build_and_push_docker_image.yaml index 4662b62..7efd6a8 100644 --- a/.github/workflows/build_and_push_docker_image.yaml +++ b/.github/workflows/build_and_push_docker_image.yaml @@ -17,6 +17,14 @@ jobs: - name: Check out repository uses: actions/checkout@v2 + - name: Extract version from Chart.yaml + id: extract_version + run: | + VERSION=$(awk -F": " '/appVersion:/ {print $2}' ./helm-chart/Chart.yaml | tr -d '"') + echo "Extracted version: $VERSION" + echo "::set-output name=version::$VERSION" + shell: bash + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v2 with: @@ -41,4 +49,6 @@ jobs: with: context: . push: true - tags: public.ecr.aws/flexera/cbi-oi-kubecost-exporter:latest + tags: | + public.ecr.aws/flexera/cbi-oi-kubecost-exporter:${{ steps.extract_version.outputs.version }} + public.ecr.aws/flexera/cbi-oi-kubecost-exporter:latest diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9718305 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +.PHONY: generate test depend + +generate: depend test + # Extract appVersion from Chart.yaml and update it in values.yaml + @VERSION=$$(grep 'appVersion:' ./helm-chart/Chart.yaml | awk '{print $$2}' | tr -d '"') && \ + sed -i '' -E "s/^( tag: ).*/\1\"$$VERSION\"/" ./helm-chart/values.yaml + + # Run go generate + @go generate ./... + + # Update README + @cd ./helm-chart && helm-docs + + # Package the Helm chart + @cd ./helm-chart && helm package . + + # Update Helm repo index + @helm repo index . + +# Run Go tests +test: + @go test ./... + +# Install dependencies +depend: + # Install Go dependencies + @go mod download + + # Install helm-docs + @go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest diff --git a/go.mod b/go.mod index ca449aa..53c0205 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module cbi-oi-kubecost-exporter -go 1.21.2 +go 1.21 require github.com/caarlos0/env/v7 v7.1.0 diff --git a/helm-chart/Chart.yaml b/helm-chart/Chart.yaml index a7753fa..6cb1c27 100644 --- a/helm-chart/Chart.yaml +++ b/helm-chart/Chart.yaml @@ -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.4.1 +version: 1.4.2 # 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 diff --git a/helm-chart/README.md b/helm-chart/README.md index 6b52dbd..57f3f6a 100644 --- a/helm-chart/README.md +++ b/helm-chart/README.md @@ -1,6 +1,6 @@ # cbi-oi-kubecost-exporter -![Version: 1.4.1](https://img.shields.io/badge/Version-1.4.1-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) +![Version: 1.4.2](https://img.shields.io/badge/Version-1.4.2-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 @@ -84,17 +84,17 @@ 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 (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 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.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"` | | +| image.tag | string | `"1.4"` | | | imagePullSecrets | list | `[]` | | | includePreviousMonth | bool | `false` | Include data from previous month to export process | | kubecost.aggregation | string | `"pod"` | Aggregation Level ("namespace", "controller", "pod") | @@ -108,6 +108,3 @@ You should see 200/201s in the logs, which indicates that the exporter is workin | persistentVolume.enabled | bool | `true` | Enable Persistent Volume. If this setting is disabled, it may lead to inability to store history and data uploads older than 15 days in Flexera One | | persistentVolume.size | string | `"1Gi"` | Persistent Volume size | ---- - -Autogenerated from chart metadata using [helm-docs v1.11.3](https://github.com/norwoodj/helm-docs/releases/v1.11.3) diff --git a/helm-chart/cbi-oi-kubecost-exporter-1.4.2.tgz b/helm-chart/cbi-oi-kubecost-exporter-1.4.2.tgz new file mode 100644 index 0000000000000000000000000000000000000000..231f69d64bbe46a4ebbc796daa60dbb4c378547a GIT binary patch literal 4343 zcmVDc zVQyr3R8em|NM&qo0PK8wbKAJC`2MX=fpvaorp>RGA9?Iu&+WP6P24u8c}<*lr?b10 z&=PF1p+uFWoVrc#XTL*Ik|kSywcU2l9_$WO=V`aKtrfLG2nm~Xo z1W)S<47o4>B0`1IiAabYSfpQ$n#9-v632{sL{oRh*}yG#-)%eJTQdI{ZQ=eO6PBR- zDh6Q1{@>qg{xrM)+lL3+{r@f64jki zibf+XJD*Ao?LPskAS4rDNPI0O8j%5IR88~;sklH0sQx2b4(AaSW&Zl#e6^0-oT}zxV*87oeXoO^|~~A|O#} z<3SO52SkAi5Ck0s3KR{|(U|=ds{^$r>^2TzSO2TQ4&WHY1P&qKiI9$yE?q9yD;x@x z0bKJtj9@5um@#ho-hnqf0gprw3qGbk+R;-iWw2-j>YjsMWJ|Z@!Z8)-DK-J36;vug zqmlg*AVW7}cA%zp@Wzn32~c3ofVExC8w!j()Qe+SBZXrPq*0t|qFE={&Gbz0u+Rr7 z?n|6p;jr`tfITf!In^zo)DY(+MBqasfH^kGH12TH$r!RTGu=Dz5+_Dn0j7B1@kkLG zX+4;etTQL7TDESvc8L**=m&Fd!^yD&z{TjqFM|F;8G|DpMd&FDGN6p59R_rEAGdPc zen5l|k80=Lv)U7=^U9WdWHPKKOoR%Xp|s^*16giSu60EuEuJ%m6z zG2Dv8ON7uH)?276Ikv9vw;n+UJzF=myAjJNsc`?!)Dwg%mFh(2Wr)PxLNl+ zYUk(X&&{b6iPV-;1;#FCI$&I|?&S$!Uyl|sd~v@Ad>n!21wh2ayA_+u)$$cH$IJeK$tU6ZCh(`qVtB0SXebVq8}vS~6cK!q08 zAjX1g8%B9V7@K5VoEX$0VG@fPXN^oYV7Bmlj3UtHSs!0Yf=s+Xo0shSkVIsJq0yD% zRIf22kvBQgePup%7la8@G-lKsThkBP`E90#`WP81H0P>>5k_c*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