Skip to content

Commit

Permalink
Merge pull request #48 from GSA/fix-deploy-and-key-issues
Browse files Browse the repository at this point in the history
fixed deploy and key issues
  • Loading branch information
FuhuXia authored Jan 16, 2024
2 parents 6665503 + 79de2b7 commit 0deed77
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 38 deletions.
81 changes: 64 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,50 +93,97 @@ jobs:
sleep 150 # Logstash is very slow to start up
[ "401" = "$(curl -w '%{http_code}' --output /dev/null --silent https://logstash-stage-datagov.app.cloud.gov)" ]
drain-apps-in-management-staging:
name: drain apps in management-staging space
environment: management-staging
runs-on: ubuntu-latest
needs:
- deploy-management-staging
steps:
- name: checkout
uses: actions/checkout@v2
- name: drain-management-staging-space
uses: cloud-gov/cg-cli-tools@37d58fc10abf00a45926e8886879c81a498f7ea8
with:
command: |
./create-space-drain.sh management-staging
cf_org: gsa-datagov
cf_space: management-staging
cf_username: ${{secrets.CF_SERVICE_USER}}
cf_password: ${{secrets.CF_SERVICE_AUTH}}

drain-apps-in-staging:
name: drain everything in staging space
environment: management
name: drain apps in staging space
environment: staging
runs-on: ubuntu-latest
needs:
- deploy-management
- deploy-management-staging
steps:
- name: checkout
uses: actions/checkout@v2
- name: drain-staging-space
uses: cloud-gov/cg-cli-tools@main
uses: cloud-gov/cg-cli-tools@37d58fc10abf00a45926e8886879c81a498f7ea8
with:
command: |
apt-get install -y jq &&
curl -L -o drain-plugin https://github.com/cloudfoundry/cf-drain-cli/releases/download/v2.0.0/cf-drain-cli-linux &&
cf install-plugin -f -r drain-plugin &&
rm -f drain-plugin &&
mkdir -p /root/.cf/ && touch /root/.cf/config.json &&
./create-space-drain.sh management-staging
cf_org: gsa-datagov
cf_space: staging
cf_username: ${{secrets.CF_SERVICE_USER}}
cf_password: ${{secrets.CF_SERVICE_AUTH}}

drain-apps-in-prod:
name: drain everything in prod space
drain-apps-in-management:
name: drain apps in management space
environment: management
runs-on: ubuntu-latest
needs:
- deploy-management
steps:
- name: checkout
uses: actions/checkout@v2
- name: drain-management-space
uses: cloud-gov/cg-cli-tools@37d58fc10abf00a45926e8886879c81a498f7ea8
with:
command: |
./create-space-drain.sh management
cf_org: gsa-datagov
cf_space: management
cf_username: ${{secrets.CF_SERVICE_USER}}
cf_password: ${{secrets.CF_SERVICE_AUTH}}

drain-apps-in-prod:
name: drain apps in prod space
environment: prod
runs-on: ubuntu-latest
needs:
- deploy-management
steps:
- name: checkout
uses: actions/checkout@v2
- name: drain-prod-space
uses: cloud-gov/cg-cli-tools@main
uses: cloud-gov/cg-cli-tools@37d58fc10abf00a45926e8886879c81a498f7ea8
with:
command: |
apt-get install -y jq &&
curl -L -o drain-plugin https://github.com/cloudfoundry/cf-drain-cli/releases/download/v2.0.0/cf-drain-cli-linux &&
cf install-plugin -f -r drain-plugin &&
rm -f drain-plugin &&
mkdir -p /root/.cf/ && touch /root/.cf/config.json &&
./create-space-drain.sh management
cf_org: gsa-datagov
cf_space: prod
cf_username: ${{secrets.CF_SERVICE_USER}}
cf_password: ${{secrets.CF_SERVICE_AUTH}}

drain-apps-in-prod-egress:
name: drain apps in prod-egress space
environment: prod-egress
runs-on: ubuntu-latest
needs:
- deploy-management
steps:
- name: checkout
uses: actions/checkout@v2
- name: drain-prod-egress-space
uses: cloud-gov/cg-cli-tools@37d58fc10abf00a45926e8886879c81a498f7ea8
with:
command: |
./create-space-drain.sh management
cf_org: gsa-datagov
cf_space: prod-egress
cf_username: ${{secrets.CF_SERVICE_USER}}
cf_password: ${{secrets.CF_SERVICE_AUTH}}
30 changes: 22 additions & 8 deletions .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,38 @@ jobs:
sleep 150 # Logstash is very slow to start up
[ "401" = "$(curl -w '%{http_code}' --output /dev/null --silent https://logstash-development-datagov.app.cloud.gov)" ]
drain-apps-in-development:
name: drain everything in development space
drain-apps-in-development-ssb:
name: drain apps in development-ssb space
environment: development-ssb
runs-on: ubuntu-latest
needs:
- deploy-development-ssb
steps:
- name: checkout
uses: actions/checkout@v2
- name: drain-development-ssb-space
uses: cloud-gov/cg-cli-tools@37d58fc10abf00a45926e8886879c81a498f7ea8
with:
command: |
./create-space-drain.sh development-ssb
cf_org: gsa-datagov
cf_space: development-ssb
cf_username: ${{secrets.CF_SERVICE_USER}}
cf_password: ${{secrets.CF_SERVICE_AUTH}}

drain-apps-in-development:
name: drain apps in development space
environment: development
runs-on: ubuntu-latest
needs:
- deploy-development-ssb
steps:
- name: checkout
uses: actions/checkout@v2
- name: drain-development-space
uses: cloud-gov/cg-cli-tools@main
uses: cloud-gov/cg-cli-tools@37d58fc10abf00a45926e8886879c81a498f7ea8
with:
command: |
apt-get install -y jq &&
curl -L -o drain-plugin https://github.com/cloudfoundry/cf-drain-cli/releases/download/v2.0.0/cf-drain-cli-linux &&
cf install-plugin -f -r drain-plugin &&
rm -f drain-plugin &&
mkdir -p /root/.cf/ && touch /root/.cf/config.json &&
./create-space-drain.sh development-ssb
cf_org: gsa-datagov
cf_space: development
Expand Down
16 changes: 13 additions & 3 deletions create-space-drain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ prefix=${3:-logstack}
# If the app already exists, exit early/successfully
cf app "${prefix}-space-drain" > /dev/null 2>&1 && echo "Drain already exists." && exit 0

# If the drain plugin isn't already installed, we can't proceed!
cf drains --help > /dev/null 2>&1 || ( printf "cf_drain_cli plugin not found!\nInstall it with:\n cf install-plugin -r CF-Community drains\n\n" && exit 1 )
# install drain plugin if it isn't installed
if ! cf plugins | grep -q drain; then
echo "cf-drain-cli plugin not found. Installing..."
apt install jq curl -y &&
curl -L -o drain-plugin https://github.com/cloudfoundry/cf-drain-cli/releases/download/v2.0.0/cf-drain-cli-linux --insecure &&
cf install-plugin -f drain-plugin &&
rm -f drain-plugin &&
mkdir -p /root/.cf/ && touch /root/.cf/config.json &&
echo "cf-drain-cli plugin installed successfully."
else
echo "cf-drain-cli plugin already exists."
fi

space=$(cf target | grep space: | cut -d : -f 2 | sed s/\ //g)

Expand All @@ -39,7 +49,7 @@ cat > manifest.yml << EOF
---
applications:
- name: ${prefix}-space-drain
instances: 0
instances: 1
memory: 64M
no-route: true
EOF
Expand Down
2 changes: 1 addition & 1 deletion logstash/logstash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ filter{
if (
([log_data] and [log_data] =~ /^NginxLog/)
or
([hostname] and [http_status] and [hostname] =~ /^logstash-/ and [http_status] == "200")
([hostname] and [status] and [hostname] =~ /^logstash-/ and [status] == "200")
) {
drop { }
}
Expand Down
2 changes: 0 additions & 2 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ applications:
APP_NAME: ((app_name))
LS_JAVA_OPTS: ((logstash_java_options))
https_proxy: ((https_proxy))
NEWRELIC_LICENSE_KEY: ((logstash_newrelic_license_key))
NEWRELIC_LOG_URI: ((logstash_newrelic_log_uri))
buildpacks:
- binary_buildpack
health-check-type: process
Expand Down
4 changes: 2 additions & 2 deletions vars.development-ssb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ https_proxy:

# Optional license key for delivering logs to New Relic
# See https://github.com/newrelic/logstash-output-plugin
logstash_newrelic_license_key:
logstash_newrelic_log_uri: https://gov-log-api.newrelic.com/log/v1
# logstash_newrelic_license_key:
# logstash_newrelic_log_uri: https://gov-log-api.newrelic.com/log/v1
2 changes: 1 addition & 1 deletion vars.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ https_proxy:

# Optional license key for delivering logs to New Relic
# See https://github.com/newrelic/logstash-output-plugin
logstash_newrelic_license_key:
# logstash_newrelic_license_key:
4 changes: 2 additions & 2 deletions vars.management-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ https_proxy:

# Optional license key for delivering logs to New Relic
# See https://github.com/newrelic/logstash-output-plugin
logstash_newrelic_license_key:
logstash_newrelic_log_uri: https://gov-log-api.newrelic.com/log/v1
# logstash_newrelic_license_key:
# logstash_newrelic_log_uri: https://gov-log-api.newrelic.com/log/v1
4 changes: 2 additions & 2 deletions vars.management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ https_proxy:

# Optional license key for delivering logs to New Relic
# See https://github.com/newrelic/logstash-output-plugin
logstash_newrelic_license_key:
logstash_newrelic_log_uri: https://gov-log-api.newrelic.com/log/v1
# logstash_newrelic_license_key:
# logstash_newrelic_log_uri: https://gov-log-api.newrelic.com/log/v1

0 comments on commit 0deed77

Please sign in to comment.