Skip to content

Commit fdc6d1d

Browse files
committed
feat: use laptop hostname in instance names and display instance info
1 parent fa5ad8d commit fdc6d1d

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

deploy-k8s-cluster.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,35 @@ deploy_cluster() {
3333
ansible-playbook -i "$INVENTORY_FILE" kubernetes-single-node.yaml
3434

3535
echo "Deployment complete!"
36-
echo "Check the instance details file for SSH access information."
36+
echo ""
37+
echo "=== Instance Information ==="
38+
39+
# Find the most recent instance details file
40+
DETAILS_FILE=$(ls -rt instance-*-details.txt | tail -1)
41+
42+
if [ -n "$DETAILS_FILE" ]; then
43+
# Extract key information from the details file
44+
INSTANCE_ID=$(grep "Instance ID:" "$DETAILS_FILE" | cut -d' ' -f3)
45+
INSTANCE_NAME=$(grep "Instance Name:" "$DETAILS_FILE" | cut -d' ' -f3)
46+
PUBLIC_IP=$(grep "Public IP:" "$DETAILS_FILE" | cut -d' ' -f3)
47+
PRIVATE_IP=$(grep "Private IP:" "$DETAILS_FILE" | cut -d' ' -f3)
48+
INSTANCE_TYPE=$(grep "Instance Type:" "$DETAILS_FILE" | cut -d' ' -f3)
49+
SSH_COMMAND=$(grep "ssh -i" "$DETAILS_FILE")
50+
51+
echo "Instance ID: $INSTANCE_ID"
52+
echo "Instance Name: $INSTANCE_NAME"
53+
echo "Instance Type: $INSTANCE_TYPE"
54+
echo "Public IP: $PUBLIC_IP"
55+
echo "Private IP: $PRIVATE_IP"
56+
echo ""
57+
echo "SSH Access:"
58+
echo "$SSH_COMMAND"
59+
echo ""
60+
echo "Full details saved to: $DETAILS_FILE"
61+
else
62+
echo "Warning: Could not find instance details file"
63+
echo "Check the instance details file for SSH access information."
64+
fi
3765
}
3866

3967
cleanup_instances() {

launch-instance.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
key_pair: router-team-us-east2
1111
security_group_id: sg-0704e6bcaa5e655b1 # k8s security group
1212
root_volume_size: 500 # GB
13-
instance_name: "GPU-Instance-{{ ansible_date_time.epoch }}"
13+
instance_name: "{{ ansible_hostname }}-{{ ansible_date_time.epoch }}"
1414

1515
tasks:
1616
- name: Ensure boto3 and botocore are installed

0 commit comments

Comments
 (0)