This project provides a simple Flask-based web application that displays metadata and Managed Instance Group (MIG) information from a Google Cloud VM instance. It is intended to be deployed on a VM that is part of a MIG in Google Cloud Platform.
- Retrieves and displays:
- Private IP address of the instance
- Hostname
- Current target size of the associated MIG
- Uses Google Cloud Metadata server for instance-specific data
- Uses the Compute API to query MIG size
- Simple NGINX reverse proxy configuration
- Systemd service for process management
- Python 3
- Flask
- google-api-python-client
- google-auth
- NGINX
- Systemd
- Running inside a GCP Compute Engine instance with appropriate permissions (default service account with Compute Viewer role)
webapp.py
: Main Flask applicationwebapp.conf
: NGINX configuration for reverse proxywebapp.service
: Systemd service file for managing the app
- Place the files in
/opt/webapp
(or another directory, adjustWorkingDirectory
accordingly). - Install required Python packages:
pip install flask google-api-python-client google-auth
- Set up the systemd service:
cp webapp.service /etc/systemd/system/ systemctl daemon-reexec systemctl enable webapp systemctl start webapp
- Deploy the NGINX configuration:
cp webapp.conf /etc/nginx/sites-available/webapp ln -s /etc/nginx/sites-available/webapp /etc/nginx/sites-enabled/ nginx -t systemctl reload nginx
- Ensure the VM has access to the GCP metadata server and the necessary IAM permissions.
- The application restricts access to
.git
paths via NGINX. - No authentication is implemented; access should be limited by firewall or IAM controls if necessary.
MIT License