From c36109dd23c075d88c740a2736319e3359fd03ab Mon Sep 17 00:00:00 2001 From: Daniel Spray Date: Thu, 20 Mar 2025 15:45:39 -0700 Subject: [PATCH 1/4] update actions --- .github/workflows/deploy.yml | 99 +++++++++++++++++++++----------- .github/workflows/validate.yml | 16 ------ Makefile | 18 ------ README.md | 4 +- charts/metrics-agent/Chart.yaml | 4 +- charts/metrics-agent/values.yaml | 2 +- deploy/docker/Dockerfile | 2 +- version/version.go | 2 +- 8 files changed, 71 insertions(+), 76 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a92dff80..81522ec0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,38 +4,83 @@ on: push: paths: - 'version/version.go' +env: + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + jobs: - deploy: + build-and-deploy: name: Build and Deploy # only build/deploy for beta and master branches if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta' runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write steps: - - name: Login to DockerHub - uses: docker/login-action@v1 + - name: Checkout Repository + uses: actions/checkout@v4 + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 + + # Login against a Docker registry + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 with: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_PASSWORD }} - - uses: actions/setup-go@v2 + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 with: - go-version: '1.22' - - uses: actions/checkout@v2 - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Docker Build Master and Push - # If pushing to the master branch, we want to correctly tag the builds - # in docker-hub with the new master makefile command + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Set Master variables if: github.ref == 'refs/heads/master' - run: make container-build-master - - name: Docker Build Beta and Push - # If pushing to the beta branch, we want to correctly tag the builds - # in docker-hub with the new beta makefile command + run: | + VER=$(sed -nE 's/^var[[:space:]]VERSION[[:space:]]=[[:space:]]"([^"]+)".*/\1/p' version/version.go) + LATEST="latest" + echo "VERSION=$VER" >> $GITHUB_ENV + echo "LATEST_TAG=$LATEST" >> $GITHUB_ENV + - name: Set Beta variables if: github.ref == 'refs/heads/beta' - run: make container-build-beta + run: | + VER=$(sed -nE 's/^var[[:space:]]VERSION[[:space:]]=[[:space:]]"([^"]+)".*/\1-beta/p' version/version.go) + LATEST="beta-latest" + echo "VERSION=$VER" >> $GITHUB_ENV + echo "LATEST_TAG=$LATEST" >> $GITHUB_ENV + # Build and push Docker image with Buildx + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 + with: + context: . + tags: | + ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VERSION }} + ghcr.io/${{ env.IMAGE_NAME }}:${{ env.LATEST_TAG }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + file: ./deploy/docker/Dockerfile + platforms: linux/amd64, linux/arm64/v8 + build-args: | + golang_version=1.22 + package=github.com/${{ env.IMAGE_NAME }} + application=metrics-agent helmRelease: name: Cut Helm Release when Updated - needs: deploy + needs: build-and-deploy runs-on: ubuntu-latest # Only cut release if pushing to master if: github.ref == 'refs/heads/master' @@ -53,19 +98,3 @@ jobs: uses: helm/chart-releaser-action@v1.1.0 env: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - slackFinish: - name: Notify Finish - needs: helmRelease - runs-on: ubuntu-22.04 - steps: - - uses: technote-space/workflow-conclusion-action@v2 - - uses: 8398a7/action-slack@v3 - with: - fields: repo,message,commit,author,action,eventName,ref,workflow - status: ${{ env.WORKFLOW_CONCLUSION }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - - diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index b974e415..e97171ca 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -32,19 +32,3 @@ jobs: - name: run e2e AMD tests run: make test-e2e-all - - slackFinish: - name: Notify Finish - needs: test_e2e - runs-on: ubuntu-22.04 - if: always() - steps: - - uses: technote-space/workflow-conclusion-action@v2 - - uses: 8398a7/action-slack@v3 - with: - fields: repo,message,commit,author,action,eventName,ref,workflow - status: ${{ env.WORKFLOW_CONCLUSION }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - diff --git a/Makefile b/Makefile index c3858af9..475cf197 100644 --- a/Makefile +++ b/Makefile @@ -49,24 +49,6 @@ default: build: GOARCH=$(ARCH) CGO_ENABLED=0 go build -o metrics-agent main.go -# Build a container image and push to DockerHub master with correct version tags -container-build-master: - docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \ - --build-arg golang_version=$(GOLANG_VERSION) \ - --build-arg package=$(PKG) \ - --build-arg application=$(APPLICATION) \ - -t $(PREFIX)/metrics-agent:$(RELEASE-VERSION) \ - -t $(PREFIX)/metrics-agent:latest -f deploy/docker/Dockerfile . --push - -# Build a container image and push to DockerHub beta with correct version tags -container-build-beta: - docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \ - --build-arg golang_version=$(GOLANG_VERSION) \ - --build-arg package=$(PKG) \ - --build-arg application=$(APPLICATION) \ - -t $(PREFIX)/metrics-agent:$(RELEASE-VERSION)-beta \ - -t $(PREFIX)/metrics-agent:beta-latest -f deploy/docker/Dockerfile . --push - # Build a local container image with the linux AMD architecture container-build-single-platform: docker build --platform $(PLATFORM) \ diff --git a/README.md b/README.md index 319538ae..aafff6da 100644 --- a/README.md +++ b/README.md @@ -150,10 +150,10 @@ make deploy-local ## Local Development -The makefile target _deploy-local_ assumes that you have [docker](https://www.docker.com/community-edition) and kubernetes (with a context: docker-for-desktop) running locally. The target does the following: +The makefile target _deploy-local_ assumes that you have [docker](https://www.docker.com/community-edition)/podman and kubernetes (with a context: docker-for-desktop) running locally. The target does the following: - Builds a container with the local project codebase - Locally creates a deployment / pod with the local metrics agent container ### Testing -In addition to running all go tests via the make step `make test`, `make test-e2e-all` runs end to end tests by spinning up a [kind](https://github.com/kubernetes-sigs/kind) cluster, building the metrics agent, deploying it to the reference clusters, then testing the collected data. The use of kind requires a local docker daemon to be running. +In addition to running all go tests via the make step `make test`, `make test-e2e-all` runs end to end tests by spinning up a [kind](https://github.com/kubernetes-sigs/kind) cluster, building the metrics agent, deploying it to the reference clusters, then testing the collected data. The use of kind requires a local docker/podman daemon to be running. diff --git a/charts/metrics-agent/Chart.yaml b/charts/metrics-agent/Chart.yaml index f372d37a..7f362e8f 100644 --- a/charts/metrics-agent/Chart.yaml +++ b/charts/metrics-agent/Chart.yaml @@ -14,8 +14,8 @@ type: application # 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. -version: 2.11.40 +version: 2.13.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. -appVersion: 2.11.40 \ No newline at end of file +appVersion: 2.13.0 \ No newline at end of file diff --git a/charts/metrics-agent/values.yaml b/charts/metrics-agent/values.yaml index a2f2c341..20fab78a 100644 --- a/charts/metrics-agent/values.yaml +++ b/charts/metrics-agent/values.yaml @@ -26,7 +26,7 @@ uploadRegion: "us-west-2" image: name: cloudability/metrics-agent - tag: 2.11.40 + tag: 2.13.0 pullPolicy: Always imagePullSecrets: [] diff --git a/deploy/docker/Dockerfile b/deploy/docker/Dockerfile index f310184e..351d94bd 100644 --- a/deploy/docker/Dockerfile +++ b/deploy/docker/Dockerfile @@ -13,7 +13,7 @@ ENV GOOS=linux COPY . /go/src/${package} RUN go build -FROM alpine:3 +FROM public.ecr.aws/docker/library/alpine:latest ARG package ARG application diff --git a/version/version.go b/version/version.go index 9595ae59..d876a058 100644 --- a/version/version.go +++ b/version/version.go @@ -1,4 +1,4 @@ package version // VERSION is the current version of the agent -var VERSION = "2.11.40" +var VERSION = "2.13.0" From 13c8dee0e6fc8c174a331b84af122593795ec16e Mon Sep 17 00:00:00 2001 From: Daniel Spray Date: Thu, 20 Mar 2025 16:19:27 -0700 Subject: [PATCH 2/4] push true --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 81522ec0..9b8aad53 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -65,6 +65,7 @@ jobs: uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 with: context: . + push: true tags: | ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VERSION }} ghcr.io/${{ env.IMAGE_NAME }}:${{ env.LATEST_TAG }} From 5cc8435d9592e44d413391a05ff49e5a56285772 Mon Sep 17 00:00:00 2001 From: Daniel Spray Date: Thu, 20 Mar 2025 16:22:23 -0700 Subject: [PATCH 3/4] trigger flow --- charts/metrics-agent/Chart.yaml | 4 ++-- charts/metrics-agent/values.yaml | 2 +- version/version.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/metrics-agent/Chart.yaml b/charts/metrics-agent/Chart.yaml index 7f362e8f..56033690 100644 --- a/charts/metrics-agent/Chart.yaml +++ b/charts/metrics-agent/Chart.yaml @@ -14,8 +14,8 @@ type: application # 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. -version: 2.13.0 +version: 2.13.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. -appVersion: 2.13.0 \ No newline at end of file +appVersion: 2.13.1 \ No newline at end of file diff --git a/charts/metrics-agent/values.yaml b/charts/metrics-agent/values.yaml index 20fab78a..afaa5bfd 100644 --- a/charts/metrics-agent/values.yaml +++ b/charts/metrics-agent/values.yaml @@ -26,7 +26,7 @@ uploadRegion: "us-west-2" image: name: cloudability/metrics-agent - tag: 2.13.0 + tag: 2.13.1 pullPolicy: Always imagePullSecrets: [] diff --git a/version/version.go b/version/version.go index d876a058..606bc264 100644 --- a/version/version.go +++ b/version/version.go @@ -1,4 +1,4 @@ package version // VERSION is the current version of the agent -var VERSION = "2.13.0" +var VERSION = "2.13.1" From e66e878c8f5f8d1ff0929768257f4b978bf5307f Mon Sep 17 00:00:00 2001 From: Daniel Spray Date: Thu, 20 Mar 2025 16:26:25 -0700 Subject: [PATCH 4/4] update path in helm --- charts/metrics-agent/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/metrics-agent/values.yaml b/charts/metrics-agent/values.yaml index afaa5bfd..226a79e9 100644 --- a/charts/metrics-agent/values.yaml +++ b/charts/metrics-agent/values.yaml @@ -25,7 +25,7 @@ pollInterval: 180 uploadRegion: "us-west-2" image: - name: cloudability/metrics-agent + name: ghcr.io/cloudability/metrics-agent tag: 2.13.1 pullPolicy: Always