Skip to content

Commit

Permalink
PMM-10900: custom image and option to run pmm with external clickhouse (
Browse files Browse the repository at this point in the history
  • Loading branch information
ritbl authored Oct 19, 2022
1 parent 815adfa commit 4e5131b
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Percona PMM dev container
#PMM_CONTAINER=perconalab/pmm-server:dev-container

# Native ARM image
#PMM_CONTAINER=ritbl/pmm-x:v2.31.0

CH_IMAGE=clickhouse/clickhouse-server:22.6.9.11-alpine
CH_PORT=9000
CH_HOSTNAME=ch
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ pmm-agent-dev.yaml

# ViM temporary files
*.sw[o,p]

.env
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,40 @@

include Makefile.include

ifeq ($(PROFILES),)
PROFILES := 'pmm'
endif

env-up: ## Start devcontainer.
COMPOSE_PROFILES=$(PROFILES) \
docker-compose up -d

env-up-rebuild: env-update-image ## Rebuild and start devcontainer. Useful for custom $PMM_SERVER_IMAGE
COMPOSE_PROFILES=$(PROFILES) \
docker-compose up --build -d

env-update-image: ## Pull latest dev image
COMPOSE_PROFILES=$(PROFILES) \
docker-compose pull

env-compose-up: env-update-image
COMPOSE_PROFILES=$(PROFILES) \
docker-compose up --detach --renew-anon-volumes --remove-orphans

env-devcontainer:
COMPOSE_PROFILES=$(PROFILES) \
docker exec -it --workdir=/root/go/src/github.com/percona/pmm pmm-managed-server .devcontainer/setup.py

env-down: ## Stop devcontainer.
COMPOSE_PROFILES=$(PROFILES) \
docker-compose down --remove-orphans

env-remove:
COMPOSE_PROFILES=$(PROFILES) \
docker-compose down --volumes --remove-orphans

TARGET ?= _bash

env: ## Run `make TARGET` in devcontainer (`make env TARGET=help`); TARGET defaults to bash.
COMPOSE_PROFILES=$(PROFILES) \
docker exec -it --workdir=/root/go/src/github.com/percona/pmm pmm-managed-server make $(TARGET)
84 changes: 79 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
version: '3.7'
services:
pmm-managed-server:
image: perconalab/pmm-server:dev-container
profiles:
- pmm
image: ${PMM_CONTAINER:-perconalab/pmm-server:dev-container}
# build:
# context: .
# args:
Expand All @@ -19,15 +21,86 @@ services:
- AWS_ACCESS_KEY=${AWS_ACCESS_KEY}
- AWS_SECRET_KEY=${AWS_SECRET_KEY}
- ENABLE_BACKUP_MANAGEMENT=1
# - PERCONA_TEST_PLATFORM_ADDRESS=https://check.localhost
# - PERCONA_TEST_PLATFORM_INSECURE=1
# - PERCONA_TEST_PLATFORM_PUBLIC_KEY=<public key>
# - PERCONA_TEST_TELEMETRY_INTERVAL=10s
# - PERCONA_TEST_TELEMETRY_RETRY_BACKOFF=10s
# - PERCONA_TEST_PMM_CLICKHOUSE_ADDR=127.0.0.1:9000
# - PERCONA_TEST_PMM_CLICKHOUSE_DATABASE=pmm
# - PERCONA_TEST_PMM_CLICKHOUSE_BLOCK_SIZE=10000
# - PERCONA_TEST_PMM_CLICKHOUSE_POOL_SIZE=2
# - PMM_DEBUG=1

extra_hosts:
- host.docker.internal:host-gateway
# - portal.localhost:${PORTAL_HOST:-host-gateway}
# - check.localhost:${PORTAL_CHECK_HOST:-host-gateway}
# - pmm.localhost:${PORTAL_PMM_HOST:-host-gateway}
# - check-dev.percona.com:${PORTAL_PMM_HOST:-host-gateway}

# for delve
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined

# see https://github.com/golang/go/wiki/LinuxKernelSignalVectorBug#what-to-do
ulimits:
memlock: 67108864

ports:
- ${PMM_PORT_HTTP:-80}:80
- ${PMM_PORT_HTTPS:-443}:443
# For headless delve
- ${PMM_PORT_DELVE:-2345}:2345
# PG
- ${PMM_PORT_PG:-15432}:5432
# CH
- ${PMM_PORT_CH_TCP:-11000}:9000
- ${PMM_PORT_CH_HTTP:-11123}:8123
volumes:
- ./:/root/go/src/github.com/percona/pmm
- ./Makefile.devcontainer:/root/go/src/github.com/percona/pmm/Makefile:ro # change Makefile in devcontainer
# caching
- go-modules:/root/go/pkg/mod
- root-cache:/root/.cache

# PMM with external ClickHouse DB
ch:
profiles:
- pmm-ch
image: ${CH_IMAGE:-clickhouse/clickhouse-server:22.6.9.11-alpine}
platform: linux/amd64
hostname: ${CH_HOSTNAME:-ch}
ports:
- ${CH_PORT:-9000}:9000
pmm-managed-server-ch:
profiles:
- pmm-ch
depends_on:
- ch
image: ${PMM_CONTAINER:-perconalab/pmm-server:dev-container}
container_name: pmm-managed-server
hostname: pmm-managed-server
networks:
- ${NETWORK:-default}
environment:
- PMM_RELEASE_PATH=/root/go/bin
- REVIEWDOG_GITHUB_API_TOKEN=${REVIEWDOG_GITHUB_API_TOKEN}
- ENABLE_DBAAS=${ENABLE_DBAAS:-0}
- AWS_ACCESS_KEY=${AWS_ACCESS_KEY}
- AWS_SECRET_KEY=${AWS_SECRET_KEY}
- ENABLE_BACKUP_MANAGEMENT=1
# - PERCONA_TEST_PLATFORM_ADDRESS=https://check.localhost
# - PERCONA_TEST_PLATFORM_INSECURE=1
# - PERCONA_TEST_PLATFORM_PUBLIC_KEY=<public key>
# - PERCONA_TEST_TELEMETRY_INTERVAL=10s
# - PERCONA_TEST_TELEMETRY_RETRY_BACKOFF=10s
# - PERCONA_TEST_PMM_CLICKHOUSE_ADDR=127.0.0.1:9000
# - PERCONA_TEST_PMM_CLICKHOUSE_DATABASE=pmm
# - PERCONA_TEST_PMM_CLICKHOUSE_BLOCK_SIZE=10000
# - PERCONA_TEST_PMM_CLICKHOUSE_POOL_SIZE=2
- PERCONA_TEST_PMM_CLICKHOUSE_ADDR=${CH_HOSTNAME:-ch}:9000
- PERCONA_TEST_PMM_CLICKHOUSE_DATABASE=pmm
- PERCONA_TEST_PMM_CLICKHOUSE_BLOCK_SIZE=10000
- PERCONA_TEST_PMM_CLICKHOUSE_POOL_SIZE=2
# - PMM_DEBUG=1

extra_hosts:
Expand Down Expand Up @@ -59,6 +132,7 @@ services:
- ${PMM_PORT_CH_HTTP:-11123}:8123
volumes:
- ./:/root/go/src/github.com/percona/pmm
# - "../grafana/public:/usr/share/grafana/public"
- ./Makefile.devcontainer:/root/go/src/github.com/percona/pmm/Makefile:ro # change Makefile in devcontainer
# caching
- go-modules:/root/go/pkg/mod
Expand Down
7 changes: 6 additions & 1 deletion managed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ release: ## Build pmm-managed release binaries.
env CGO_ENABLED=0 go build -v $(PMM_LD_FLAGS) -o $(PMM_RELEASE_PATH)/ ./cmd/...
$(PMM_RELEASE_PATH)/pmm-managed --version

ARCH=$(shell uname -m)
release-dev:
go build -race -gcflags="all=-N -l" -v $(PMM_LD_FLAGS) -o $(PMM_RELEASE_PATH)/ ./cmd/...
@if [ $(ARCH) = "aarch64" ]; then\
go build -gcflags="all=-N -l" -v $(PMM_LD_FLAGS) -o $(PMM_RELEASE_PATH)/ ./cmd/...
else \
go build -race -gcflags="all=-N -l" -v $(PMM_LD_FLAGS) -o $(PMM_RELEASE_PATH)/ ./cmd/...
fi

PMM_TEST_FLAGS ?= -timeout=90s
PMM_TEST_RUN_UPDATE ?= 0
Expand Down

0 comments on commit 4e5131b

Please sign in to comment.