Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 65 additions & 35 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,84 @@ on:
push:
paths:
- 'version/version.go'
env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
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: .
push: true
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'
Expand All @@ -53,19 +99,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 }}


16 changes: 0 additions & 16 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

18 changes: 0 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions charts/metrics-agent/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.12.0
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.12.0
appVersion: 2.13.0
4 changes: 2 additions & 2 deletions charts/metrics-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pollInterval: 180
uploadRegion: "us-west-2"

image:
name: cloudability/metrics-agent
tag: 2.12.0
name: ghcr.io/cloudability/metrics-agent
tag: 2.13.0
pullPolicy: Always

imagePullSecrets: []
Expand Down
2 changes: 1 addition & 1 deletion deploy/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package version

// VERSION is the current version of the agent
var VERSION = "2.12.0"
var VERSION = "2.13.0"