Skip to content

Commit

Permalink
- UPdated deploy script
Browse files Browse the repository at this point in the history
- Updated ini to specify grafana domain
- updated grafana manifest name
- Added bucket name for loki
- updated loki manifest to pull yq and eval the aws creds
  • Loading branch information
elipe17 committed Sep 20, 2024
1 parent 47fafaf commit 7ceb3d9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
5 changes: 3 additions & 2 deletions tdrs-backend/plg/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

deploy_pg_exporter() {
pushd postgres-exporter
Expand All @@ -7,7 +8,7 @@ deploy_pg_exporter() {

APP_NAME="pg-exporter-$1"

yq eval -i ".applications[0].name = $APP_NAME" $MANIFEST
yq eval -i ".applications[0].name = \"$APP_NAME\"" $MANIFEST
yq eval -i ".applications[0].env.PG_EXPORTER_METRIC_PREFIX = \"pg_$1\"" $MANIFEST
yq eval -i ".applications[0].env.DATA_SOURCE_NAME = \"$2\"" $MANIFEST
yq eval -i ".applications[0].services[0] = \"$3\"" $MANIFEST
Expand Down Expand Up @@ -61,5 +62,5 @@ pushd "$(dirname "$0")"
deploy_prometheus
deploy_loki
deploy_grafana
deploy_pg_exporter raft postgres://u9oc318z26941vlu:p2wtjxap7i30tjpg2gef0hfwv@cg-aws-broker-prodmezsouuuxrb933l.ci7nkegdizyy.us-gov-west-1.rds.amazonaws.com:5432/tdp_db_raft tdp-db-dev
deploy_pg_exporter REDACTED
popd
4 changes: 2 additions & 2 deletions tdrs-backend/plg/grafana/custom.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
app_mode = production

# instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty
instance_name = ${HOSTNAME}
instance_name = grafana

#################################### Paths ###############################
[paths]
Expand Down Expand Up @@ -38,7 +38,7 @@ http_addr =
http_port = 8080

# The public facing domain name used to access grafana from a browser
domain = localhost
domain = app.cloud.gov

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
Expand Down
2 changes: 1 addition & 1 deletion tdrs-backend/plg/grafana/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 1
applications:
- name: grafana_test
- name: grafana
memory: 512M
disk_quota: 2G
instances: 1
Expand Down
2 changes: 1 addition & 1 deletion tdrs-backend/plg/loki/loki.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ storage_config:
region: ${S3_REGION}
access_key_id: ${S3_ACCESS_KEY}
secret_access_key: ${S3_SECRET_KEY}
bucketnames: logs
bucketnames: ${S3_BUCKET}
tsdb_shipper:
active_index_directory: /home/vcap/app/loki-data/index
cache_location: /home/vcap/app/loki-data/cache
Expand Down
26 changes: 18 additions & 8 deletions tdrs-backend/plg/loki/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@ applications:
disk_quota: 7G
instances: 1
command: |
mkdir /home/vcap/app/loki-data &&
S3_URI=$(echo $VCAP_SERVICES | jq -r .s3[0].credentials.uri) &&
S3_ENDPOINT=$(echo $VCAP_SERVICES | jq -r .s3[0].credentials.endpoint) &&
S3_REGION=$(echo $VCAP_SERVICES | jq -r .s3[0].credentials.region) &&
S3_ACCESS_KEY=$(echo $VCAP_SERVICES | jq -r .s3[0].credentials.access_key_id) &&
S3_SECRET_KEY=$(echo $VCAP_SERVICES | jq -r .s3[0].credentials.secret_access_key) &&
wget https://github.com/grafana/loki/releases/download/v3.1.1/loki-linux-amd64.zip &&
unzip -a loki-linux-amd64.zip && rm -rf loki-linux-amd64.zip &&
mkdir /home/vcap/app/loki-data
S3_URI=$(echo $VCAP_SERVICES | jq -r .s3[0].credentials.uri)
S3_ENDPOINT=$(echo $VCAP_SERVICES | jq -r .s3[0].credentials.endpoint)
S3_REGION=$(echo $VCAP_SERVICES | jq -r .s3[0].credentials.region)
S3_ACCESS_KEY=$(echo $VCAP_SERVICES | jq -r .s3[0].credentials.access_key_id)
S3_SECRET_KEY=$(echo $VCAP_SERVICES | jq -r .s3[0].credentials.secret_access_key)
S3_BUCKET=$(echo $VCAP_SERVICES | jq -r .s3[0].credentials.bucket)
wget https://tdp-nexus.dev.raftlabs.tech/repository/tdp-bin/linux/bin/yq_linux_amd64.tar.gz
tar -zxvf yq_linux_amd64.tar.gz
rm yq_linux_amd64.tar.gz && rm yq.1 && rm install-man-page.sh
./yq_linux_amd64 eval -i ".storage_config.aws.s3 = \"$S3_URI\"" loki.yml
./yq_linux_amd64 eval -i ".storage_config.aws.endpoint = \"$S3_ENDPOINT\"" loki.yml
./yq_linux_amd64 eval -i ".storage_config.aws.region = \"$S3_REGION\"" loki.yml
./yq_linux_amd64 eval -i ".storage_config.aws.access_key_id = \"$S3_ACCESS_KEY\"" loki.yml
./yq_linux_amd64 eval -i ".storage_config.aws.secret_access_key = \"$S3_SECRET_KEY\"" loki.yml
./yq_linux_amd64 eval -i ".storage_config.aws.bucketnames = \"$S3_BUCKET\"" loki.yml
wget https://github.com/grafana/loki/releases/download/v3.1.1/loki-linux-amd64.zip
unzip -a loki-linux-amd64.zip && rm -rf loki-linux-amd64.zip
./loki-linux-amd64 -config.expand-env=true -config.file=/home/vcap/app/loki.yml
buildpacks:
- https://github.com/cloudfoundry/binary-buildpack
Expand Down

0 comments on commit 7ceb3d9

Please sign in to comment.