-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
81 changed files
with
6,680 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
capideploy | ||
sample.json | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Generic capideploy", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "debug", | ||
"cwd": "${workspaceFolder}", | ||
"program": "${workspaceFolder}/pkg/cmd/capideploy/capideploy.go", | ||
"envFile": "${env:HOME}/capideploy_aws.rc", | ||
"args": [ | ||
"delete_networking", | ||
"-p=sample.jsonnet", | ||
"-v" | ||
] | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
##!/bin/bash | ||
|
||
# Watch the progress: | ||
# cat ./deploy.log | grep elapsed | ||
# or | ||
# less -R ./deploy.log | ||
|
||
set -e # Exit on failure | ||
set -x # Print commands | ||
|
||
go build ./pkg/cmd/capideploy/capideploy.go | ||
|
||
./capideploy list_deployment_resources -p sample.jsonnet -v > deploy.log | ||
|
||
set +x | ||
SECONDS=0 | ||
export BILLED_RESOURCES=$(cat deploy.log | grep ",billed") | ||
if [ "$BILLED_RESOURCES" != "" ]; then | ||
echo "This deployment has resources that may be still/already active, please check the log" | ||
fi | ||
|
||
set -x # Print commands | ||
|
||
./capideploy create_floating_ips -p sample.jsonnet -v >> deploy.log | ||
|
||
set +x | ||
|
||
# Save reserved BASTION_IP so we can run capitoolbelt on bastion | ||
export BASTION_IP=$(cat deploy.log | grep "export BASTION_IP=" | cut -d "=" -f2) | ||
if [ "$BASTION_IP" = "" ]; then | ||
echo "Cannot retrieve BASTION_IP" | ||
exit 1 | ||
fi | ||
|
||
# Configure SSH jumphost so we can run nodetool on Cassandra hosts (requires write access to ~/.ssh/config) | ||
if ! grep -q "$BASTION_IP" ~/.ssh/config; then | ||
echo "Adding a new jumphost to ~/.ssh/config..." | ||
echo "" | tee -a ~/.ssh/config | ||
echo "Host $BASTION_IP" | tee -a ~/.ssh/config | ||
echo " User $CAPIDEPLOY_SSH_USER" | tee -a ~/.ssh/config | ||
echo " StrictHostKeyChecking=no" | tee -a ~/.ssh/config | ||
echo " UserKnownHostsFile=/dev/null" | tee -a ~/.ssh/config | ||
echo " IdentityFile $CAPIDEPLOY_SSH_PRIVATE_KEY_PATH" | tee -a ~/.ssh/config | ||
fi | ||
|
||
set -x | ||
|
||
./capideploy create_networking -p sample.jsonnet -v >> deploy.log | ||
./capideploy create_security_groups -p sample.jsonnet -v >> deploy.log | ||
./capideploy create_volumes "*" -p sample.jsonnet -v >> deploy.log | ||
./capideploy create_instances "*" -p sample.jsonnet -v >> deploy.log | ||
#./capideploy create_instances "bastion" -p sample.jsonnet -v >> deploy.log | ||
./capideploy ping_instances '*' -p sample.jsonnet -n 20 >> deploy.log | ||
#./capideploy ping_instances "bastion" -p sample.jsonnet -n 20 >> deploy.log | ||
./capideploy attach_volumes "bastion" -p sample.jsonnet -v >> deploy.log | ||
|
||
# install_services swaps sshd services, so do not use bastion as jumphost while it's in transition | ||
./capideploy install_services "bastion" -p sample.jsonnet -v >> deploy.log | ||
./capideploy install_services "rabbitmq,prometheus,daemon*,cass*" -p sample.jsonnet -v >> deploy.log | ||
|
||
# Cassandra requires special treatment: stop and config/start | ||
./capideploy stop_services "cass*" -p sample.jsonnet -v >> deploy.log | ||
./capideploy config_services "cass*" -p sample.jsonnet -v >> deploy.log | ||
|
||
./capideploy config_services "bastion,rabbitmq,prometheus,daemon*" -p sample.jsonnet -v >> deploy.log | ||
#./capideploy config_services "bastion" -p sample.jsonnet -v >> deploy.log | ||
|
||
ssh -o StrictHostKeyChecking=no -i $CAPIDEPLOY_SSH_PRIVATE_KEY_PATH -J $BASTION_IP $CAPIDEPLOY_SSH_USER@10.5.0.11 'nodetool describecluster;nodetool status' | ||
|
||
duration=$SECONDS | ||
echo "$(($duration / 60))m $(($duration % 60))s elapsed." | ||
|
||
set +x | ||
echo To run commands against this deployment, you will probably need this: | ||
echo export BASTION_IP=$BASTION_IP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
##!/bin/bash | ||
|
||
set +e # Continue on failure | ||
set -x # Print commands | ||
|
||
SECONDS=0 | ||
./capideploy stop_services "*" -p sample.jsonnet -v | ||
|
||
set -e # Exit on failure | ||
./capideploy detach_volumes "bastion" -p sample.jsonnet -v | ||
|
||
# We want to be 100% sure that cassandra has stopped | ||
#sleep 10 | ||
|
||
./capideploy create_snapshot_images "*" -p sample.jsonnet -v | ||
#./capideploy create_snapshot_images "bastion" -p sample.jsonnet -v | ||
./capideploy delete_instances "*" -p sample.jsonnet -v | ||
#./capideploy delete_instances "bastion" -p sample.jsonnet -v | ||
./capideploy list_deployment_resources -p sample.jsonnet -v | ||
duration=$SECONDS | ||
echo "$(($duration / 60))m $(($duration % 60))s elapsed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
##!/bin/bash | ||
set -e # Exit on failure | ||
set -x # Print commands | ||
|
||
SECONDS=0 | ||
|
||
./capideploy create_instances_from_snapshot_images "*" -p sample.jsonnet -v | ||
#./capideploy create_instances_from_snapshot_images "bastion" -p sample.jsonnet -v | ||
|
||
./capideploy ping_instances '*' -p sample.jsonnet -n 50 | ||
#./capideploy ping_instances 'bastion' -p sample.jsonnet -n 50 | ||
|
||
./capideploy attach_volumes "bastion" -p sample.jsonnet -v | ||
./capideploy start_services "*" -p sample.jsonnet -v | ||
#./capideploy start_services "bastion" -p sample.jsonnet -v | ||
|
||
# Cassandra requires one more cycle to embrace the fact that data/log firectories /data0,/data1 are gone | ||
./capideploy stop_services "cass*" -p sample.jsonnet -v | ||
./capideploy start_services "cass*" -p sample.jsonnet -v | ||
|
||
duration=$SECONDS | ||
echo "$(($duration / 60))m $(($duration % 60))s elapsed." | ||
|
||
./capideploy list_deployment_resources -p sample.jsonnet -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
##!/bin/bash | ||
|
||
set -e # Exit on failure | ||
set -x # Print commands | ||
|
||
./capideploy delete_snapshot_images "*" -p sample.jsonnet -v | ||
./capideploy list_deployment_resources -p sample.jsonnet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
##!/bin/bash | ||
|
||
set +e # Continue on failure | ||
set -x # Print commands | ||
|
||
./capideploy delete_snapshot_images "*" -p sample.jsonnet -v > undeploy.log | ||
|
||
./capideploy stop_services "*" -p sample.jsonnet -v >> undeploy.log | ||
|
||
set -e # Exit on failure | ||
./capideploy detach_volumes "bastion" -p sample.jsonnet -v >> undeploy.log | ||
./capideploy delete_instances "*" -p sample.jsonnet -v >> undeploy.log | ||
./capideploy delete_volumes "*" -p sample.jsonnet -v >> undeploy.log | ||
|
||
./capideploy delete_security_groups -p sample.jsonnet -v >> undeploy.log | ||
./capideploy delete_networking -p sample.jsonnet -v >> undeploy.log | ||
./capideploy delete_floating_ips -p sample.jsonnet -v >> undeploy.log | ||
|
||
./capideploy list_deployment_resources -p sample.jsonnet |
Oops, something went wrong.