Skip to content

Commit

Permalink
Merge pull request #20 from VictoriaMetrics/config-updater-multiple-t…
Browse files Browse the repository at this point in the history
…argets-support

vmagent-config-updater: support multiple targets
  • Loading branch information
AndrewChubatiuk authored Dec 9, 2024
2 parents 4d42f5d + c223eff commit c72553f
Show file tree
Hide file tree
Showing 30 changed files with 2,797 additions and 1,191 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include services/vmagent-config-updater/Makefile
include services/Makefile

# k8s namespace for installing the chart
# It can be overriden via NAMESPACE environment variable
Expand Down
5 changes: 0 additions & 5 deletions go.mod

This file was deleted.

62 changes: 62 additions & 0 deletions services/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# All these commands must run from repository root.

SERVICES_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

DOCKER_NAMESPACE := victoriametrics
GO_BUILDER_IMAGE := golang:1.23.4-alpine

BUILDINFO_TAG ?= $(shell echo $$(git describe --long --all | tr '/' '-')$$( \
git diff-index --quiet HEAD -- || echo '-dirty-'$$(git diff-index -u HEAD | openssl sha1 | cut -c 10-17)))

PKG_TAG ?= $(shell git tag -l --points-at HEAD)
ifeq ($(PKG_TAG),)
PKG_TAG := $(BUILDINFO_TAG)
endif

%-exists:
$(eval SERVICE := $*)
if [ ! -d $(SERVICES_DIR)/$(SERVICE) ]; then \
echo "Service $(SERVICE) does not exist"; \
exit 1; \
fi

%-go-build: %-exists
$(eval SERVICE := $*)
mkdir -p gocache-for-docker
docker run --rm \
--user $(shell id -u):$(shell id -g) \
--mount type=bind,src="$(SERVICES_DIR)/$(SERVICE)",dst=/config-updater \
-w /config-updater \
--mount type=bind,src="$(SERVICES_DIR)/$(SERVICE)/gocache-for-docker",dst=/gocache \
--env GOCACHE=/gocache \
--env GO111MODULE=on \
--env CGO_ENABLED=0 \
--env GOOS=linux \
--env GOARCH=amd64 \
$(GO_BUILDER_IMAGE) \
go build -mod=vendor -trimpath -buildvcs=false \
-ldflags "-s -w -extldflags '-static'" \
-tags 'netgo osusergo nethttpomithttp2' \
-o bin/config-updater .

%-go-package: %-go-build
$(eval SERVICE := $*)
(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q '$(DOCKER_NAMESPACE)/$(SERVICE):$(PKG_TAG)$$') || (\
docker build \
--tag $(DOCKER_NAMESPACE)/$(SERVICE):$(PKG_TAG) \
$(SERVICES_DIR)/$(SERVICE))

%-go-publish: %-go-package
$(eval SERVICE := $*)
docker push $(DOCKER_NAMESPACE)/$(SERVICE):$(PKG_TAG)

%-go-package-run: %-go-package
$(eval SERVICE := $*)
docker run -it --rm \
--user $(shell id -u):$(shell id -g) \
--net host \
$(DOCKER_NAMESPACE)/$(SERVICE):$(PKG_TAG)

%-go-run: %-exists
$(eval SERVICE := $*)
cd $(SERVICES_DIR)/$(SERVICE) && go run .
5 changes: 2 additions & 3 deletions services/vmagent-config-updater/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ FROM scratch

EXPOSE 8436

ENTRYPOINT ["/vmagent-config-update-prod"]
ARG src_binary
COPY $src_binary ./vmagent-config-update-prod
ENTRYPOINT ["/config-updater"]
COPY bin/config-updater ./config-updater
50 changes: 0 additions & 50 deletions services/vmagent-config-updater/Makefile

This file was deleted.

5 changes: 5 additions & 0 deletions services/vmagent-config-updater/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module vmagent-config-updater

go 1.23.4

require gopkg.in/yaml.v3 v3.0.1
4 changes: 2 additions & 2 deletions go.sum → services/vmagent-config-updater/go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit c72553f

Please sign in to comment.