nbdkit-gcs-plugin - Man Page
expose data in Google Cloud Storage (GCS) buckets as block device
Synopsis
nbdkit gcs [json-credentials=FILE] [size=NN object-size=NN] bucket=BUCKET key=STRING
Description
nbdkit-gcs-plugin
is a plugin for nbdkit(1) which lets you open objects stored in Google Cloud Storage (GCS) as disk images.
This plugin uses the Python Google Cloud Storage client library (google-cloud-storage). It requires Python ≥ 3.7.
Examples
nbdkit gcs json-credentials=/path/to-my-json-credentials.json \ bucket=MY-BUCKET key=disk.img
Provides a read only block device holding the data contained in the disk.img object.
nbdkit gcs json-credentials=/path/to-my-json-credentials.json \ size=50G object-size=128k \ bucket=MY-BUCKET key=disk
Provides a read-write block device with size 50G, whose contents are stored across multiple in objects of size 128k, prefixed with disk/
Parameters
- json-credentials=FILE
Path to a JSON file with Google Service account keys. Application Default Credentials will be used if
json-credentials
is not specified (see "Credentials" below).- bucket=BUCKET
The bucket containing the object(s). This parameter is required.
- key=STRING
The object name (if
size
is not specified) or object prefix (ifsize
is specified) to use within the bucket. This parameter is required.- size=SIZE
- object-size=SIZE
These two parameters must always be specified together. If set, data will be split into blocks of
object-size
and stored as separate objects. The block device will report a total size ofsize
and be writeable and trim-able.Object names will have the form key/%16x, where
%16x
is the 16-digit hexadecimal block number. If there are existing objects under the prefix that do not have the expected size, the plugin will crash.
Performance Considerations
It is highly recommended that clients do their utmost to issue requests that exactly match the object size: Smaller write requests will incur a performance penalty due to the need for read-modify-write cycles (thus also incurring latency from two network round-trips). Larger read and write requests will incur a performance penalty because of sequential execution.
The nbdkit-blocksize-filter(1) can be used to alleviate the impact of requests larger than the object size, but does not help if the client issues requests smaller than the block size.
The nbdkit-stats-filter(1) can be used to investigate what block sizes and alignments are used by the client.
When connecting through the Linux kernel's NBD module, consider setting /sys/block/nbd<X>/queue/max_sectors_kb
to match the object size.
Credentials
Refer to the following web pages:
- Google Service account keys
https://developers.google.com/workspace/guides/create-credentials#service-account
- Application Default Credentials
https://cloud.google.com/docs/authentication/application-default-credentials
Files
- $plugindir/nbdkit-gcs-plugin
The plugin.
Use
nbdkit --dump-config
to find the location of$plugindir
.- $HOME/.config/gcloud/application_default_credentials.json
Application Default Credentials.
Environment Variables
- GOOGLE_APPLICATION_CREDENTIALS
You can use the
GOOGLE_APPLICATION_CREDENTIALS
environment variable to provide the location of a credential JSON file.
Comparison to S3 Plugin
You can use the S3
plugin to access Google Cloud Storage in interoperability mode. read
and write
work perfectly fine, while trim
and zero
operations don't work in the general case: trimmed or zeroed-out blocks cannot be deleted from the storage using the S3
plugin.
Version
nbdkit-gcs-plugin
first appeared in nbdkit 1.38.
See Also
nbdkit(1), nbdkit-plugin(3), nbdkit-python-plugin(3), nbdkit-S3-plugin(3), https://pypi.org/project/google-cloud-storage/, https://developers.google.com/workspace/guides/create-credentials#service-account, https://cloud.google.com/docs/authentication/application-default-credentials.
Authors
Mykola Ivanets
Copyright
Copyright Infrascale Inc.
License
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Red Hat nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Referenced By
nbdkit(1), nbdkit-plugin(3), nbdkit-release-notes-1.38(1), nbdkit-S3-plugin(1).