Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes to Makefile and metrics-service.yml.template #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
86 changes: 28 additions & 58 deletions user-metrics/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,44 @@

VERSION=v0.0.1

build-local-grafana:
echo 'Building grafana image'
docker build -t grafana:spcs-$(VERSION) . -f ./grafana/Dockerfile

build-local-prometheus:
echo 'Building prometheus image'
docker build -t prometheus:spcs-$(VERSION) . -f ./prometheus/Dockerfile

build-local-otel:
echo 'Building otel image'
docker build -t otel:spcs-$(VERSION) . -f ./otel/Dockerfile

build-local-mdservice:
echo 'Building mdservice image'
docker build -t mdservice:spcs-$(VERSION) . -f ./mdservice/Dockerfile

check-repo-is-set:
ifndef REPO
echo "REPO not set, use `REPO=SPCS_IMAGE_REPOSITORY`"
exit 1
echo "REPO not set, use `REPO=SPCS_IMAGE_REPOSITORY`"
exit 1
endif

build-upload-grafana: SERVICE_NAME=grafana
build-upload-grafana: build-upload-repo

build-upload-prometheus: SERVICE_NAME=prometheus
build-upload-prometheus: build-upload-repo

build-upload-mdservice: SERVICE_NAME=mdservice
build-upload-mdservice: build-upload-repo

build-upload-otel: SERVICE_NAME=otel
build-upload-otel: build-upload-repo

build-upload-repo: check-repo-is-set
echo 'Building and uploading $(SERVICE_NAME) image to $(REPO)/spcs/$(SERVICE_NAME):$(VERSION)'
docker build --platform=linux/amd64 . \
-f ./$(SERVICE_NAME)/Dockerfile \
--tag $(REPO)/spcs/$(SERVICE_NAME):$(VERSION) \
--push --rm


build-upload-all: build-upload-grafana build-upload-prometheus build-upload-otel build-upload-mdservice

build-spec-file: check-repo-is-set
echo 'Building spec file'
SPCS_IMAGE_REPO=$(REPO) envsubst < metrics-service.yml.template &> metrics-service.yml
echo 'Building spec file'
$(eval SNOW_REPO:=$(shell export REPO=$(REPO); echo /$${REPO#*\/}))
export SPCS_IMAGE_REPO=$(SNOW_REPO) export VERSION=$(VERSION); envsubst '$${SPCS_IMAGE_REPO} $${VERSION}' < metrics-service.yml.template > metrics-service.yml 2>&1
cat metrics-service.yml

pull-upload-grafana: SERVICE_NAME=grafana
pull-upload-grafana: pull-upload-repo
%.bli:
echo 'Building $(basename $@) image'
docker build -t $(basename $@):spcs-$(VERSION) . -f ./$(basename $@)/Dockerfile

pull-upload-prometheus: SERVICE_NAME=prometheus
pull-upload-prometheus: pull-upload-repo
%.pui: check-repo-is-set
echo 'Pulling and uploading $(basename $@) image to $(REPO)/$(basename $@):$(VERSION)'
docker pull --platform=linux/amd64 snowflakedb-oss-$(basename $@):$(VERSION)
docker tag snowflakedb-oss-$(basename $@):$(VERSION) $(REPO)/$(basename $@):$(VERSION)
docker push $(REPO)/$(basename $@):$(VERSION)

pull-upload-mdservice: SERVICE_NAME=mdservice
pull-upload-mdservice: pull-upload-repo
%.bui: check-repo-is-set
echo 'Building and uploading $(basename $@) image to $(REPO)/$(basename $@):$(VERSION)'
docker build --platform=linux/amd64 . \
-f ./$(basename $@)/Dockerfile \
--tag $(REPO)/$(basename $@):$(VERSION) \
--push --rm

pull-upload-otel: SERVICE_NAME=otel
pull-upload-otel: pull-upload-repo
images=mdservice prometheus grafana otel

pull-upload-repo: check-repo-is-set
echo 'Pulling and uploading $(SERVICE_NAME) image to $(REPO)/spcs/prometheus:$(VERSION)'
docker pull --platform=linux/amd64 snowflakedb/spcs-oss-$(SERVICE_NAME):$(VERSION)
docker tag snowflakedb/spcs-oss-$(SERVICE_NAME):$(VERSION) $(REPO)/spcs/$(SERVICE_NAME):$(VERSION)
docker push $(REPO)/spcs/$(SERVICE_NAME):$(VERSION)
build-local-images=$(addsuffix .bli, $(images))
build-local-all: $(build-local-images) build-spec-file

build-local-all: build-otel build-mdservice build-grafana build-prometheus
build-upload-images=$(addsuffix .bui, $(images))
build-upload-all: $(build-upload-images)

build-all: build-upload-all build-spec-file
pull-upload-images=$(addsuffix .pui, $(images))
pull-upload-all: $(pull-upload-images) build-spec-file

pull-upload-all: pull-upload-otel pull-upload-mdservice pull-upload-prometheus pull-upload-grafana build-spec-file
build-all: build-upload-all build-spec-file
8 changes: 4 additions & 4 deletions user-metrics/metrics-service.yml.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
spec:
container:
- name: mdservice
image: ${SPCS_IMAGE_REPO}/spcs/mdservice:v01
image: ${SPCS_IMAGE_REPO}/mdservice:${VERSION}
resources:
requests:
memory: 200M
Expand All @@ -10,7 +10,7 @@ spec:
memory: 200M
cpu: 100m
- name: otel-collector
image: ${SPCS_IMAGE_REPO}/spcs/otel:v01
image: ${SPCS_IMAGE_REPO}/otel:${VERSION}
resources:
requests:
memory: 200M
Expand All @@ -19,7 +19,7 @@ spec:
memory: 200M
cpu: 200m
- name: prometheus
image: ${SPCS_IMAGE_REPO}/spcs/prometheus:v01
image: ${SPCS_IMAGE_REPO}/prometheus:${VERSION}
resources:
requests:
memory: 500M
Expand All @@ -35,7 +35,7 @@ spec:
- --storage.tsdb.path=/data/prometheus/db
- --config.file=/etc/prometheus/prometheus.yml
- name: grafana
image: ${SPCS_IMAGE_REPO}/spcs/grafana:v01
image: ${SPCS_IMAGE_REPO}/grafana:${VERSION}
resources:
requests:
memory: 500M
Expand Down