1

In GCP how can we check if the compute engines are not accessible on port 8080. Is there any API where we can check and validate this scenario

Alex Man
  • 4,746
  • 17
  • 93
  • 178

1 Answers1

1

There are many ways of doing what you want - however there are a few factors that I don't know so this answer may sound a bit generic in a few places.

  1. Scenario 1 - instances have to be accessible from the Internet
  • check if the firewall settings allow incoming traffic to your instances on port 8080 (you can use cloud console or gcloud).
  • if there isn't such a rule you have to create one - it's best to label your instances and create a proper rule.
  • now you can actually check if there's anything running on port 8080 - if this is a web app / API you can just use curl host.ip:port 2> errors.log.

You mentioned you have a lot of instances to check then some script would be handy - have a look at this SO answer how to create one that will read the addressess from the file.

If you want to do it like a pro use Ansible - here's a useful answer that will be helpful for this.

  1. Scenario 2 - instances are not available from the Internet
  • you need to run the mentioned instance checking script from within your VPC your instances are in. Create a new VM for this purpose and run the script from there. If your instances are spread across many VPC's you need to create a VM in each of them and run the script.

And you can automate this with Ansible - even create/test instances & delete VM's. This may sound like an overkill but everything on how often you need to run those tests and on the number of VM's you need to test.


Also there's a question of testing if the ports are open from inside the insances.

Wojtek_B
  • 4,245
  • 1
  • 7
  • 21