gcloud-resize
is tool that can automatically resize persistent disks on Google Cloud Platform.
This tool supports the next filesystems: ext4, xfs.
Set next labels for VM instance.
Label | Description |
---|---|
environment |
Environment definition. For example value can be development, production, stage. |
Add next permissions to Cloud API access scopes for VM instance.
Cloud API | Permissions |
---|---|
Compute Engine | Read Write |
gcloud-resize
tool need installed python 3 and run with root permissions.
# Install python
sudo apt-get install -y python3-pip
# For XFS support
sudo apt-get -y install xfsprogs
# Clone repo
git clone https://github.com/gutsul/gcloud-resize.git
# Go to repo folder
cd gcloud-resize/
# Install
sudo python3 setup.py install
General configuration file located in ~/.gcloud-resize/gcloud-resize.conf
.
It consist from 3 general parts: GCloud Settings
, Resize Settings
, Slack Settings
.
Key | Value | Type | Description |
---|---|---|---|
ProjectId |
project-id | Required | Google project id. More detail see here. |
Key | Value | Type | Description |
---|---|---|---|
ResizeMode |
fixed | Required | Available resize modes: fixed, percent |
FixedFreeSize |
1 | Required | Fixed resize mode setting only. Resize disk when there is less or equal than FixedFreeSize GB. |
FixedIncreaseSize |
1 | Required | Add to disk additional FixedIncreaseSize GB. |
UsagePercent |
95 | Required | Resize disk when disk usage more or equal UsagePercent value. The value should be greater than zero. |
ResizePercent |
10 | Required | Determines how much in percentage you should increase the disk when low disk space amount is detected. The minimum disk space you can add is 1 GB. |
Key | Value | Type | Description |
---|---|---|---|
SlackWebhook |
https://hooks.slack.com | Optional | Slack incoming webhook url. |
SlackUsers |
username1,username2 | Optional | Users who will be notified about the resize message. |
To configure how often need to check disks, edit you root crontab.
# Edit root crontab:
sudo crontab -e
# Add lines below to end of file:
# Check persistent disks
0 * * * * /usr/local/bin/gcloud-resize
To calculate frequency (f) use next formula:
f = (T * r) / (2 * w )
Where:
- T Total disk size in MB.
- r Resize percent value. (5% = 0.05)
- w Write rate in MB per minute
The result of the calculation means to run crontab job at least every f minutes.
Log file located in ~/.gcloud-resize/logs/gcloud-resize.log
To completely remove gcloud-resize tool run those commands in terminal:
sudo pip3 uninstall gcloud-resize
sudo rm /usr/local/bin/gcloud-resize
sudo rm -rf ~/.gcloud-resize/