From 51a744589b84f476b36af43284970b404f546d70 Mon Sep 17 00:00:00 2001 From: Alan Moran Date: Wed, 21 Aug 2024 11:49:20 +0200 Subject: [PATCH] WIP --- src/autoscaler/metricsforwarder/Makefile | 7 +++- src/autoscaler/metricsforwarder/config.sh | 51 +++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100755 src/autoscaler/metricsforwarder/config.sh diff --git a/src/autoscaler/metricsforwarder/Makefile b/src/autoscaler/metricsforwarder/Makefile index 5b69047ef2..5a16eae187 100644 --- a/src/autoscaler/metricsforwarder/Makefile +++ b/src/autoscaler/metricsforwarder/Makefile @@ -3,18 +3,21 @@ DEPLOYMENT_NAME ?= autoscaler-$(PR_NUMBER) SYSTEM_DOMAIN ?=autoscaler.app-runtime-interfaces.ci.cloudfoundry.org METIRCSFORWARDER_VM := $(shell bosh -d $(DEPLOYMENT_NAME) vms --json | jq '.Tables | .[] | .Rows | .[] | select(.instance|test("metricsforwarder")) | .instance') POSTGRES_ADDRESS := $(DEPLOYMENT_NAME)-postgres.tcp.$(SYSTEM_DOMAIN) -LOG_CACHE_IP := $(shell bosh -d cf vms --json | jq -r '.Tables | .[] | .Rows | .[] | select(.instance|test("log-cache")) | .ips' ) MAKEFILE_DIR := $(dir $(lastword $(MAKEFILE_LIST))) POSTGRES_EXTERNAL_PORT := $(or $(PR_NUMBER),5432) +.PHONY: create-config-user-provided-service +create-config-user-provided-service: + #cf cups config -p "$(./config.sh)" + ./config.sh + .PHONY: fetch-config fetch-config: start-metricsforwarder-vm # how to define variables in deployment name mkdir -p build/assets/certs/policy_db build/assets/certs/storedprocedure_db build/assets/certs/syslog_client echo "POSTGRES ADDRESS: $(POSTGRES_ADDRESS)" - echo "LOG_CACHE IP: $(LOG_CACHE_IP)" @echo "Pulling metricforwarder config from $(METIRCSFORWARDER_VM)..." bosh -d $(DEPLOYMENT_NAME) scp $(METIRCSFORWARDER_VM):/var/vcap/jobs/metricsforwarder/config/metricsforwarder.yml build/assets/metricsforwarder.yml diff --git a/src/autoscaler/metricsforwarder/config.sh b/src/autoscaler/metricsforwarder/config.sh new file mode 100755 index 0000000000..380978be33 --- /dev/null +++ b/src/autoscaler/metricsforwarder/config.sh @@ -0,0 +1,51 @@ +export PR_NUMBER="$(gh pr view --json number --jq '.number')" +export DEPLOYMENT_NAME="autoscaler-${PR_NUMBER}" +export SYSTEM_DOMAIN="autoscaler.app-runtime-interfaces.ci.cloudfoundry.org" +export POSTGRES_ADDRESS="${DEPLOYMENT_NAME}-postgres.tcp.${SYSTEM_DOMAIN}" +export POLICY_DB_PASSWORD="$(credhub get -n /bosh-autoscaler/${DEPLOYMENT_NAME}/database_password --quiet)" +export STOREPROCEDURE_DB_PASSWORD="$(credhub get -n /bosh-autoscaler/${DEPLOYMENT_NAME}/database_password --quiet)" +export METRICSFORWARDER_HEALTH_PASSWORD="$(credhub get -n /bosh-autoscaler/${DEPLOYMENT_NAME}/autoscaler_metricsforwarder_health_password --quiet)" +export POSTGRES_EXTERNAL_PORT="${PR_NUMBER:-5432}" + +echo '{ + "metricsforwarder": { + "cache_cleanup_interval": "6h", + "cache_ttl": "900s", + "cred_helper_impl": "default", + "health": { + "password": "'"${METRICSFORWARDER_HEALTH_PASSWORD}"'", + "username": "metricsforwarder" + }, + "logging": { + "level": "debug" + }, + "syslog": { + "server_address": "log-cache.service.cf.internal", + "port": 6067, + "tls": { + "ca_file": "/home/vcap/app/assets/certs/syslog_client/ca.crt", + "cert_file": "/home/vcap/app/assets/certs/syslog_client/client.crt", + "key_file": "/home/vcap/app/assets/certs/syslog_client/client.key" + } + "db": { + "policy_db": { + "url": "postgres://postgres:'"${POLICY_DB_PASSWORD}@${POSTGRES_ADDRESS}:${POSTGRES_EXTERNAL_PORT}"'/autoscaler?application_name=metricsforwarder&sslmode=verify-full&sslrootcert=/home/vcap/app/assets/certs/policy_db/ca.crt&sslcert=/home/vcap/app/assets/certs/policy_db/crt&sslkey=/home/vcap/app/assets/certs/policy_db/key", + "max_open_connections": 100, + "max_idle_connections": 10, + "connection_max_lifetime": "60s" + }, + "storedprocedure_db": { + "url": "postgres://postgres:'"${STOREPROCEDURE_DB_PASSWORD}@${POSTGRES_ADDRESS}:${POSTGRES_EXTERNAL_PORT}"'/autoscaler?application_name=metricsforwarder&sslmode=verify-full&sslrootcert=/home/vcap/app/assets/certs/storedprocedure_db/ca.crt&sslcert=/home/vcap/app/assets/certs/storedprocedure_db/crt&sslkey=/home/vcap/app/assets/certs/storedprocedure_db/key", + "max_open_connections": 20, + "max_idle_connections": 10, + "connection_max_lifetime": "60s" + } + }, + "policy_poller_interval": "60s", + "rate_limit": { + "valid_duration": "1s", + "max_amount": 10 + } + } + } +}'