Skip to content

Commit

Permalink
Merge branch 'master' into add-helm-chart
Browse files Browse the repository at this point in the history
  • Loading branch information
skamboj authored May 13, 2024
2 parents 4af6666 + a8f1a76 commit dbd1f5f
Show file tree
Hide file tree
Showing 10 changed files with 341 additions and 647 deletions.
72 changes: 51 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@ name: CI
on:
push:
branches: [ main, master ]
tags:
- v*
pull_request:
branches: [ main, master ]
workflow_dispatch:

jobs:
build:
permissions:
contents: write
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.16
go-version-file: 'go.mod'

# local build
- name: Compile the binary
Expand All @@ -28,26 +33,51 @@ jobs:
make build
docker run `make version` --help
- name: Login to DockerHub
uses: docker/login-action@v3
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# multi-arch build
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build regular image
id: docker_build
uses: docker/build-push-action@v2
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
target: simple
- name: Build vendor image
id: docker_build_vendor
uses: docker/build-push-action@v2
bake-target: docker-metadata-action
images: |
${{ github.repository_owner }}/goldpinger
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
labels: |
org.opencontainers.image.title=${{ github.repository }}
org.opencontainers.image.description=Goldpinger makes calls between its instances to monitor your networking. It runs as a DaemonSet on Kubernetes and produces Prometheus metrics that can be scraped, visualised and alerted on.
org.opencontainers.image.vendor=${{ github.repository_owner }}
- name: Build regular image
uses: docker/bake-action@v4
with:
context: .
flavor: |
suffix: -vendor,onlatest=false
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
target: vendor
targets: ci
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
# https://github.com/docker/buildx/issues/2105
- name: Create manifest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
set -xe
for image in $images; do
docker buildx imagetools create -t "${image}" "${image}-linux" "${image}-windows-ltsc2019" "${image}-windows-ltsc2022"
done
env:
images: "${{ join( steps.meta.outputs.tags, ' ') }}"
55 changes: 0 additions & 55 deletions .github/workflows/publish.yml

This file was deleted.

18 changes: 10 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
FROM golang:1.15-alpine as builder
ARG WINDOWS_BASE_IMAGE=mcr.microsoft.com/windows/nanoserver:ltcs2022

FROM --platform=$BUILDPLATFORM golang:1.22 as builder
ARG TARGETARCH
ARG TARGETOS
ENV GO111MODULE=on

# Install our build tools

RUN apk add --update git make bash

# Get dependencies

WORKDIR /w
COPY go.mod go.sum ./
RUN go mod download
Expand All @@ -20,12 +16,18 @@ RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make bin/goldpinger
RUN go mod vendor

# Build the asset container, copy over goldpinger
FROM scratch as simple
FROM gcr.io/distroless/static:nonroot as simple
COPY --from=builder /w/bin/goldpinger /goldpinger
COPY ./static /static
COPY ./config /config
ENTRYPOINT ["/goldpinger", "--static-file-path", "/static"]

FROM $WINDOWS_BASE_IMAGE AS windows
COPY --from=builder /w/bin/goldpinger /goldpinger.exe
COPY ./static /static
COPY ./config /config
ENTRYPOINT ["/goldpinger.exe", "--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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name ?= goldpinger
version ?= v3.7.0
version ?= v3.10.1
bin ?= goldpinger
pkg ?= "github.com/bloomberg/goldpinger"
tag = $(name):$(version)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: goldpinger-serviceaccount
namespace: default
---
apiVersion: apps/v1
kind: DaemonSet
Expand Down
8 changes: 7 additions & 1 deletion cmd/goldpinger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import (
"io/ioutil"
"log"
"os"
"strings"
"time"

"github.com/go-openapi/loads"
"go.uber.org/zap"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
Expand Down Expand Up @@ -131,6 +133,10 @@ func main() {
if err != nil {
logger.Fatal("Error getting config ", zap.Error(err))
}
// communicate to kube-apiserver with protobuf
config.AcceptContentTypes = strings.Join([]string{runtime.ContentTypeProtobuf, runtime.ContentTypeJSON}, ",")
config.ContentType = runtime.ContentTypeProtobuf

// create the clientset
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
Expand All @@ -156,7 +162,7 @@ func main() {
if len(goldpinger.GoldpingerConfig.IPVersions) > 1 {
logger.Warn("Multiple IP versions not supported. Will use first version specified as default", zap.Strings("IPVersions", goldpinger.GoldpingerConfig.IPVersions))
}
if goldpinger.GoldpingerConfig.IPVersions[0] != string(net.IPv4) && goldpinger.GoldpingerConfig.IPVersions[0] != net.IPv6 {
if goldpinger.GoldpingerConfig.IPVersions[0] != string(net.IPv4) && goldpinger.GoldpingerConfig.IPVersions[0] != string(net.IPv6) {
logger.Error("Unknown IP version specified: expected values are 4 or 6", zap.Strings("IPVersions", goldpinger.GoldpingerConfig.IPVersions))
}

Expand Down
52 changes: 52 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# ref: https://docs.docker.com/build/bake/reference/

# ref: https://github.com/docker/metadata-action?tab=readme-ov-file#bake-definition
target "docker-metadata-action" {
tags = ["goldpinger:latest"]
}

group "default" {
targets = ["linux-simple"]
}

group "ci" {
targets = ["linux-simple", "linux-vendor", "windows-nanoserver-ltsc2019", "windows-nanoserver-ltsc2022"]
}

target "linux-simple" {
inherits = ["docker-metadata-action"]
tags = "${formatlist("%s-linux", target.docker-metadata-action.tags)}"
platforms = ["linux/amd64", "linux/arm64"]
target = "simple"
}

target "linux-vendor" {
inherits = ["docker-metadata-action"]
tags = "${formatlist("%s-vendor", target.docker-metadata-action.tags)}"
platforms = ["linux/amd64", "linux/arm64"]
target = "vendor"
}

target "windows-nanoserver-ltsc2019" {
inherits = ["docker-metadata-action"]
tags = "${formatlist("%s-windows-ltsc2019", target.docker-metadata-action.tags)}"

platforms = ["windows/amd64"]

target = "windows"
args = {
WINDOWS_BASE_IMAGE = "mcr.microsoft.com/windows/nanoserver:ltsc2019"
}
}

target "windows-nanoserver-ltsc2022" {
inherits = ["docker-metadata-action"]
tags = "${formatlist("%s-windows-ltsc2022", target.docker-metadata-action.tags)}"

platforms = ["windows/amd64"]

target = "windows"
args = {
WINDOWS_BASE_IMAGE = "mcr.microsoft.com/windows/nanoserver:ltsc2022"
}
}
97 changes: 70 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,34 +1,77 @@
module github.com/bloomberg/goldpinger/v3

go 1.15
go 1.22

require (
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect
github.com/cespare/xxhash v1.1.0
github.com/go-openapi/errors v0.20.2
github.com/go-openapi/loads v0.19.5
github.com/go-openapi/runtime v0.19.26
github.com/go-openapi/spec v0.19.8
github.com/go-openapi/strfmt v0.20.0
github.com/go-openapi/swag v0.19.9
github.com/go-openapi/validate v0.19.10
github.com/jessevdk/go-flags v1.4.0
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/prometheus/client_golang v0.9.1
github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39 // indirect
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d // indirect
github.com/go-openapi/errors v0.22.0
github.com/go-openapi/loads v0.22.0
github.com/go-openapi/runtime v0.28.0
github.com/go-openapi/spec v0.21.0
github.com/go-openapi/strfmt v0.23.0
github.com/go-openapi/swag v0.23.0
github.com/go-openapi/validate v0.24.0
github.com/jessevdk/go-flags v1.5.0
github.com/prometheus/client_golang v1.19.0
github.com/stuartnelson3/go-rendezvous v0.2.0
go.uber.org/zap v1.14.1
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect
golang.org/x/image v0.0.0-20190802002840-cff245a6509b
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
honnef.co/go/tools v0.0.1-2020.1.3 // indirect
k8s.io/api v0.19.14
k8s.io/apimachinery v0.19.14
k8s.io/client-go v0.19.14
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a
go.uber.org/zap v1.27.0
golang.org/x/image v0.15.0
golang.org/x/net v0.24.0
k8s.io/api v0.29.3
k8s.io/apimachinery v0.29.3
k8s.io/client-go v0.29.3
k8s.io/utils v0.0.0-20240310230437-4693a0247e57
)

require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/analysis v0.23.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.3 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.mongodb.org/mongo-driver v1.15.0 // indirect
go.opentelemetry.io/otel v1.25.0 // indirect
go.opentelemetry.io/otel/metric v1.25.0 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240411171206-dc4e619f62f3 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit dbd1f5f

Please sign in to comment.