Option to use Instance Private IPs
neilgroat opened this issue · 7 comments
This isn't necessarily an issue but adding a flag or environment variable to choose if the script will collect gru and the minion's private IPs vs public would be useful.
For example, my environment is entirely in Amazon including where lucy would run from. Having the instances within a vpc and security group that is locked down so the systems can only talk to each other and reach the internet allows for better overall security versus opening up port 22 to the entire world, along with the other necessary ports.
I modified the script and rebuilt lucy to give this a try and it worked just fine:
# Step 7 - Get private IP addresses from Gru and Minions
GRU_HOST=$(aws ec2 describe-instances --instance-ids $GRU_INSTANCE_ID \
--query 'Reservations[*].Instances[*].[PrivateIpAddress]' --output text | tr -d '\n')
echo "Gru at $GRU_HOST"
MINION_HOSTS=$(aws ec2 describe-instances --instance-ids $MINION_INSTANCE_IDS \
--query 'Reservations[*].Instances[*].[PrivateIpAddress]' --output text | tr '\n' ',')
echo "Minions at at $MINION_HOSTS"
Again not necessarily an issue as the package currently works as is, but would be a nice feature.
Great suggestion. I am wondering if there is a way that Lucy could be smart enough to auto-detect if it was running in the VPC? I remember seeing an AWS whitepaper showing how an instance can discover its environment within AWS, but I am not sure how it world work if Lucy would run outside the VPC.
Possibly use the AWS API like the entrypoint.sh script for the jmeter container does?
# AWS Public HOSTNAME API
echo "Detecting an AWS Environment"
PUBLIC_HOSTNAME=$(curl -s --max-time 5 http://169.254.169.254/latest/meta-data/public-hostname)
if [ "$PUBLIC_HOSTNAME" = '' ]; then
echo "Not running in AWS. Using Gru HOSTNAME $HOSTNAME"
else
HOSTNAME=$PUBLIC_HOSTNAME
echo "Using Gru AWS Public HOSTNAME $HOSTNAME"
fi
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
Possibly have lucy check what her ami-id is?
curl -s --max-time 5 http://169.254.169.254/latest/meta-data/public-hostname
Assuming a value is returned she is in AWS if nothing is returned she is not.
Sent from my Samsung SM-G920W8 using FastHub
That should work.
@neilgroat - I started looking at this issue today as I am also working on feature #10. It occurred to me that we always runs Gru and the minions in the same VPC, so we can always use the private IPs for the Minions. We do need to auto-detect if Lucy is in running in AWS as you suggested. Take a look at the issue-10 branch and test it out. I have a test Lucy here:
docker pull smithmicro/lucy:2.0b1
I decided on a simpler approach and not try to have Lucy auto-detect her settings. This allows user to run Lucy in a different VPC, or the same. To tell Lucy to use Gru's Private IP, pass"
--env GRU_PRIVATE_IP=true
To test:
docker pull smithmicro/lucy:2.0b2
I have taken down the beta Docker images. You can now test with:
smithmicro/lucy:2.0 or smithmicro/lucy:latest