Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bonzofenix committed Aug 21, 2024
1 parent ef8ebd0 commit 51a7445
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/autoscaler/metricsforwarder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions src/autoscaler/metricsforwarder/config.sh
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}'

0 comments on commit 51a7445

Please sign in to comment.