Skip to content

Tool that can resize persistent disks on Google Cloud Platform.

Notifications You must be signed in to change notification settings

gutsul/gcloud-resize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GCloud resize tool v1.0.0

gcloud-resize is tool that can automatically resize persistent disks on Google Cloud Platform.
This tool supports the next filesystems: ext4, xfs.

Requirements

Compute Engine

Labels

Set next labels for VM instance.

Label Description
environment Environment definition.
For example value can be development, production, stage.

Cloud API access scopes

Add next permissions to Cloud API access scopes for VM instance.

Cloud API Permissions
Compute Engine Read Write

Installation

gcloud-resize tool need installed python 3 and run with root permissions.

Install dependencies

# Install python
sudo apt-get install -y python3-pip

# For XFS support
sudo apt-get -y install xfsprogs

Install gcloud-resize tool

# Clone repo
git clone https://github.com/gutsul/gcloud-resize.git

# Go to repo folder
cd gcloud-resize/

# Install
sudo python3 setup.py install

Configuration

General configuration file located in ~/.gcloud-resize/gcloud-resize.conf. It consist from 3 general parts: GCloud Settings, Resize Settings, Slack Settings.

GCloud Settings

Key Value Type Description
ProjectId project-id Required Google project id. More detail see here.

Resize Settings

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.

Slack Settings

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.

Crontab

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

Calculate crontab job frequency

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.

Logs

Log file located in ~/.gcloud-resize/logs/gcloud-resize.log

Uninstall

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/

About

Tool that can resize persistent disks on Google Cloud Platform.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages