Chaos Toolkit Extension for Google Cloud Platform
Project description
Chaos Toolkit Extension for Google Cloud Platform
This project is a collection of actions and probes, gathered as an extension to the Chaos Toolkit. It targets the Google Cloud Platform platform.
Install
This package requires Python 3.5+
To be used from your experiment, this package must be installed in the Python environment where chaostoolkit already lives.
$ pip install -U chaostoolkit-google-cloud-platform
Usage
To use the probes and actions from this package, add the following to your experiment file:
{
"type": "action",
"name": "swap-nodepool-for-a-new-one",
"provider": {
"type": "python",
"module": "chaosgcp.gke.nodepool.actions",
"func": "swap_nodepool",
"secrets": ["gcp"],
"arguments": {
"body": {
"nodePool": {
"config": {
"oauthScopes": [
"gke-version-default",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/service.management.readonly",
"https://www.googleapis.com/auth/servicecontrol",
"https://www.googleapis.com/auth/trace.append"
]
},
"initialNodeCount": 3,
"name": "new-default-pool"
}
}
}
}
}
That's it!
Please explore the code to see existing probes and actions.
Configuration
Project and Cluster Information
You can pass the context via the configuration
section of your experiment:
{
"configuration": {
"gcp_project_id": "...",
"gcp_gke_cluster_name": "...",
"gcp_region": "...",
"gcp_zone": "..."
}
}
Note that most functions exposed in this package also take those values directly when you want specific values for them.
Credentials
This extension expects a service account with enough permissions to perform its operations. Please create such a service account manually (do not use the default one for your cluster if you can, so you'll be able to delete that service account if need be).
Once you have created your service account, either keep the file on the same
machine where you will be running the experiment from. Or, pass its content
as part of the secrets
section, although this is not recommended because your
sensitive data will be quite visible.
Here is the first way:
{
"secrets": {
"gcp": {
"service_account_file": "/path/to/sa.json"
}
}
}
While the embedded way looks like this:
{
"secrets": {
"gcp": {
"service_account_info": {
"type": "service_account",
"project_id": "...",
"private_key_id": "...",
"private_key": "...",
"client_email": "...",
"client_id": "...",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/...."
}
}
}
}
Putting it all together
Here is a full example:
{
"version": "1.0.0",
"title": "...",
"description": "...",
"configuration": {
"gcp_project_id": "...",
"gcp_gke_cluster_name": "...",
"gcp_region": "...",
"gcp_zone": "..."
},
"secrets": {
"gcp": {
"service_account_file": "/path/to/sa.json"
}
},
"method": [
{
"type": "action",
"name": "swap-nodepool-for-a-new-one",
"provider": {
"type": "python",
"module": "chaosgcp.gke.nodepool.actions",
"func": "swap_nodepool",
"secrets": ["gcp"],
"arguments": {
"body": {
"nodePool": {
"config": {
"oauthScopes": [
"gke-version-default",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/service.management.readonly",
"https://www.googleapis.com/auth/servicecontrol",
"https://www.googleapis.com/auth/trace.append"
]
},
"initialNodeCount": 3,
"name": "new-default-pool"
}
}
}
}
}
]
}
Migrate from GCE extension
If you previously used the deprecated GCE extension, here is a quick recap of changes you'll need to go through to update your experiments.
- The module
chaosgce.nodepool.actions
has been replaced bychaosgcp.gke.nodepool.actions
. You will need to update themodule
key for the python providers. - The configuration keys in the
configuration
section have been renamed accordingly:- "gce_project_id" -> "gcp_project_id"
- "gce_region" -> "gcp_region"
- "gce_zone" -> "gcp_zone"
- "gce_cluster_name" -> "gcp_gke_cluster_name"
Contribute
If you wish to contribute more functions to this package, you are more than welcome to do so. Please, fork this project, make your changes following the usual PEP 8 code style, sprinkling with tests and submit a PR for review.
The Chaos Toolkit projects require all contributors must sign a Developer Certificate of Origin on each commit they would like to merge into the master branch of the repository. Please, make sure you can abide by the rules of the DCO before submitting a PR.
If you wish to add a new function to this extension, that is related to a Google Cloud product that is not available yet in this package, please use the product short name or acronym as a first level subpackage (eg. iam, gke, sql, storage, ...). See the list of [GCP products and services][gcp_products].
[gcp_products] https://cloud.google.com/products/
Develop
If you wish to develop on this project, make sure to install the development dependencies. But first, create a virtual environment and then install those dependencies.
$ pip install -r requirements-dev.txt -r requirements.txt
Then, point your environment to this directory:
$ python setup.py develop
Now, you can edit the files and they will be automatically be seen by your
environment, even when running from the chaos
command locally.
Test
To run the tests for the project execute the following:
$ pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for chaostoolkit-google-cloud-platform-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 303937f115c649d53e9f36cf4d533a18660840a7ebeebc1e3f4109970df64614 |
|
MD5 | 09a772b40431deabd4a7bf69184adcd5 |
|
BLAKE2b-256 | 7a6ba741e2c81256ffbb8c9875b81479d589c16e08559756ea08869baa76fa5f |
Hashes for chaostoolkit_google_cloud_platform-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d10dc3b9c979483b69865255f3a2e00f41229dd7b1cf25bd206540d989d71b8c |
|
MD5 | 764670156ba641ca2804b51908b886a2 |
|
BLAKE2b-256 | 43a1c90e6b6351a6b3c5b9082c4ad3a73c5300dfa3ead156e8f7c6d57f0f67fa |