mirror of
https://github.com/bloomberg/goldpinger.git
synced 2026-02-22 22:04:21 +00:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
114b39a970 | ||
|
|
00ca071c22 | ||
|
|
0715e438b9 | ||
|
|
c3a37636c3 | ||
|
|
5961c48854 | ||
|
|
3f4d041c17 | ||
|
|
9acc894fde | ||
|
|
f1ee7f5a49 | ||
|
|
76f054ba50 | ||
|
|
406f6e0ed0 | ||
|
|
b907f30c2f | ||
|
|
d304200ede | ||
|
|
0755c8521f | ||
|
|
9b1d8f8195 | ||
|
|
3cda043118 | ||
|
|
555709de0a | ||
|
|
f89a07a420 | ||
|
|
30f4d378f5 | ||
|
|
b4ffe5dea2 | ||
|
|
42632de0cb | ||
|
|
2f77502b0a | ||
|
|
46bc22ef0f | ||
|
|
10277adc58 | ||
|
|
50ac3f0101 | ||
|
|
56b438abad | ||
|
|
fcc30fbe75 | ||
|
|
6aee150cd0 |
@@ -1 +1,3 @@
|
||||
.git/
|
||||
bin/
|
||||
vendor/
|
||||
|
||||
55
.github/workflows/main.yml
vendored
Normal file
55
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master ]
|
||||
pull_request:
|
||||
branches: [ main, master ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
|
||||
# local build
|
||||
- name: Compile the binary
|
||||
run: |
|
||||
make bin/goldpinger
|
||||
./bin/goldpinger -h
|
||||
|
||||
# simple Docker build
|
||||
- name: Build the Docker image
|
||||
run: |
|
||||
make build
|
||||
docker run `make version` --help
|
||||
|
||||
# multi-arch build
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Build regular image
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
build-args: GO_MOD_ACTION=download
|
||||
platforms: linux/amd64,linux/arm64
|
||||
target: simple
|
||||
- name: Build vendor image
|
||||
id: docker_build_vendor
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
flavor: |
|
||||
suffix: -vendor,onlatest=false
|
||||
file: ./Dockerfile
|
||||
build-args: GO_MOD_ACTION=vendor
|
||||
platforms: linux/amd64,linux/arm64
|
||||
target: vendor
|
||||
57
.github/workflows/publish.yml
vendored
Normal file
57
.github/workflows/publish.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
# Publish `v*` tags as releases.
|
||||
tags:
|
||||
- v*
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
if: github.event_name != 'pull_request'
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USER }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
images: bloomberg/goldpinger
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
build-args: GO_MOD_ACTION=download
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
target: simple
|
||||
- name: Build and push vendor
|
||||
id: docker_build_vendor
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
flavor: |
|
||||
suffix: -vendor,onlatest=false
|
||||
file: ./Dockerfile
|
||||
build-args: GO_MOD_ACTION=vendor
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
target: vendor
|
||||
38
.travis.yml
38
.travis.yml
@@ -1,38 +0,0 @@
|
||||
language: go
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
go:
|
||||
- "1.14.x"
|
||||
- master
|
||||
|
||||
script:
|
||||
- docker --version
|
||||
|
||||
# build locally and run locally
|
||||
- make clean && make vendor && make && ./bin/goldpinger --help
|
||||
|
||||
# build an image and run the image
|
||||
- make clean && make vendor && make build
|
||||
- docker images
|
||||
- docker run `make version` --help
|
||||
|
||||
# build an image using the multistage builder
|
||||
- make clean && make build-multistage
|
||||
- docker images
|
||||
- docker run `make version` --help
|
||||
|
||||
# build an image with the vendor folder
|
||||
- make clean && make vendor && make vendor-build
|
||||
- docker images
|
||||
- docker run `make version`-vendor --help
|
||||
|
||||
deploy:
|
||||
provider: script
|
||||
script: bash docker_deploy.sh
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
go: "1.14.x"
|
||||
condition: -n "$DOCKER_PASSWORD"
|
||||
19
Dockerfile
19
Dockerfile
@@ -1,4 +1,7 @@
|
||||
FROM golang:1.14-alpine as builder
|
||||
FROM golang:1.15-alpine as builder
|
||||
ARG TARGETARCH
|
||||
ARG TARGETOS
|
||||
ENV GO111MODULE=on
|
||||
|
||||
# Install our build tools
|
||||
|
||||
@@ -7,17 +10,21 @@ RUN apk add --update git make bash
|
||||
# Get dependencies
|
||||
|
||||
WORKDIR /w
|
||||
COPY go.mod go.sum /w/
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Build goldpinger
|
||||
|
||||
COPY . ./
|
||||
RUN make bin/goldpinger
|
||||
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make bin/goldpinger
|
||||
# Create vendor folder
|
||||
RUN go mod vendor
|
||||
|
||||
# Build the asset container, copy over goldpinger
|
||||
|
||||
FROM scratch
|
||||
FROM scratch as simple
|
||||
COPY --from=builder /w/bin/goldpinger /goldpinger
|
||||
COPY ./static /static
|
||||
ENTRYPOINT ["/goldpinger", "--static-file-path", "/static"]
|
||||
|
||||
# For vendor builds, use the simple build and add the vendor'd files
|
||||
FROM simple as vendor
|
||||
COPY --from=builder /w/vendor /goldpinger-vendor-sources
|
||||
|
||||
42
Makefile
42
Makefile
@@ -1,15 +1,16 @@
|
||||
name ?= goldpinger
|
||||
version ?= v3.3.0
|
||||
version ?= v3.4.0
|
||||
bin ?= goldpinger
|
||||
pkg ?= "github.com/bloomberg/goldpinger"
|
||||
tag = $(name):$(version)
|
||||
goos ?= ${GOOS}
|
||||
goarch ?= ${GOARCH}
|
||||
namespace ?= "bloomberg/"
|
||||
files = $(shell find . -iname "*.go")
|
||||
|
||||
|
||||
bin/$(bin): $(files)
|
||||
GOOS=${goos} PKG=${pkg} ARCH=amd64 VERSION=${version} BIN=${bin} ./build/build.sh
|
||||
GOOS=${goos} PKG=${pkg} ARCH=${goarch} VERSION=${version} BIN=${bin} ./build/build.sh
|
||||
|
||||
clean:
|
||||
rm -rf ./vendor
|
||||
@@ -24,34 +25,21 @@ swagger:
|
||||
swagger generate server -t pkg -f ./swagger.yml --exclude-main -A goldpinger && \
|
||||
swagger generate client -t pkg -f ./swagger.yml -A goldpinger
|
||||
|
||||
build-multistage:
|
||||
docker build -t $(tag) -f ./Dockerfile .
|
||||
|
||||
build: GOOS=linux
|
||||
build: bin/$(bin)
|
||||
docker build -t $(tag) -f ./build/Dockerfile-simple .
|
||||
|
||||
tag:
|
||||
docker tag $(tag) $(namespace)$(tag)
|
||||
|
||||
push:
|
||||
docker push $(namespace)$(tag)
|
||||
|
||||
run:
|
||||
go run ./cmd/goldpinger/main.go
|
||||
|
||||
build:
|
||||
docker build -t $(namespace)$(tag) --target simple -f ./Dockerfile .
|
||||
|
||||
build-vendor:
|
||||
docker build -t $(namespace)$(tag)-vendor --target vendor -f ./Dockerfile .
|
||||
|
||||
build-release:
|
||||
docker buildx build --push --platform linux/amd64,linux/arm64 --target simple -t $(namespace)$(tag) -f ./Dockerfile .
|
||||
docker buildx build --push --platform linux/amd64,linux/arm64 --target vendor -t $(namespace)$(tag)-vendor -f ./Dockerfile .
|
||||
|
||||
version:
|
||||
@echo $(tag)
|
||||
@echo $(namespace)$(tag)
|
||||
|
||||
|
||||
vendor-build:
|
||||
docker build -t $(tag)-vendor --build-arg TAG=$(tag) -f ./build/Dockerfile-vendor .
|
||||
|
||||
vendor-tag:
|
||||
docker tag $(tag)-vendor $(namespace)$(tag)-vendor
|
||||
|
||||
vendor-push:
|
||||
docker push $(namespace)$(tag)-vendor
|
||||
|
||||
|
||||
.PHONY: clean vendor swagger build build-multistage vendor-build vendor-tag vendor-push tag push run version
|
||||
.PHONY: clean vendor swagger build build-release build-vendor run version
|
||||
|
||||
20
README.md
20
README.md
@@ -1,6 +1,6 @@
|
||||
# Goldpinger
|
||||
|
||||
[](https://travis-ci.com/bloomberg/goldpinger)
|
||||
[](https://github.com/bloomberg/goldpinger/actions/workflows/publish.yml)
|
||||
|
||||
__Goldpinger__ makes calls between its instances to monitor your networking.
|
||||
It runs as a [`DaemonSet`](#example-yaml) on `Kubernetes` and produces `Prometheus` metrics that can be [scraped](#prometheus), [visualised](#grafana) and [alerted](#alert-manager) on.
|
||||
@@ -68,21 +68,20 @@ The repo comes with two ways of building a `docker` image: compiling locally, an
|
||||
You will need `docker` version 17.05+ installed to support multi-stage builds.
|
||||
|
||||
```sh
|
||||
# step 1: launch the build
|
||||
make build-multistage
|
||||
# Build a local container without publishing
|
||||
make build
|
||||
|
||||
# step 2: push the image somewhere
|
||||
namespace="docker.io/myhandle/" make tag
|
||||
namespace="docker.io/myhandle/" make push
|
||||
# Build & push the image somewhere
|
||||
namespace="docker.io/myhandle/" make build-release
|
||||
```
|
||||
|
||||
This was contributed via [@michiel](https://github.com/michiel) - kudos !
|
||||
|
||||
### Compiling locally
|
||||
|
||||
In order to build `Goldpinger`, you are going to need `go` version 1.13+ and `docker`.
|
||||
In order to build `Goldpinger`, you are going to need `go` version 1.15+ and `docker`.
|
||||
|
||||
Building from source code consists of compiling the binary and building a [Docker image](./build/Dockerfile-simple):
|
||||
Building from source code consists of compiling the binary and building a [Docker image](./Dockerfile):
|
||||
|
||||
```sh
|
||||
# step 0: check out the code
|
||||
@@ -95,11 +94,10 @@ make bin/goldpinger
|
||||
./bin/goldpinger --help
|
||||
|
||||
# step 2: build the docker image containing the binary
|
||||
make build
|
||||
namespace="docker.io/myhandle/" make build
|
||||
|
||||
# step 3: push the image somewhere
|
||||
namespace="docker.io/myhandle/" make tag
|
||||
namespace="docker.io/myhandle/" make push
|
||||
docker push $(namespace="docker.io/myhandle/" make version)
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
FROM scratch
|
||||
|
||||
COPY bin/goldpinger /goldpinger
|
||||
COPY static /static
|
||||
|
||||
ENTRYPOINT ["/goldpinger", "--static-file-path", "/static"]
|
||||
@@ -1,3 +0,0 @@
|
||||
ARG TAG
|
||||
FROM $TAG
|
||||
COPY vendor /goldpinger-vendor-sources
|
||||
@@ -24,18 +24,14 @@ if [ -z "${PKG}" ]; then
|
||||
echo "PKG must be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${ARCH}" ]; then
|
||||
echo "ARCH must be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${VERSION}" ]; then
|
||||
echo "VERSION must be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export CGO_ENABLED=0
|
||||
export GOARCH="${ARCH}"
|
||||
export GOOS=${GOOS:-}
|
||||
export GOARCH="${ARCH:-amd64}"
|
||||
export GOOS=${GOOS:-linux}
|
||||
|
||||
go build \
|
||||
-ldflags "-X 'main.Version=${VERSION}' -X 'main.Build=`date`'" \
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
docker login -u "$DOCKER_USER" -p "$DOCKER_PASSWORD" \
|
||||
&& make tag \
|
||||
&& make push \
|
||||
&& make vendor-tag \
|
||||
&& make vendor-push
|
||||
|
||||
Reference in New Issue
Block a user