Skip to main content

Cloud Governance Tool

Project description

PyPI Latest Release Container Repository on Quay Actions StatusCoverage Status Documentation Status python License

Cloud Governance

What is it?

Cloud Governance tool provides a lightweight and flexible framework for deploying cloud management policies focusing on cost optimize and security. We have implemented several pruning policies.
When monitoring the resources, we found that most of the cost leakage is from available volumes, unused NAT gateways, and unattached Public IPv4 addresses (Starting from February 2024, public IPv4 addresses are chargeable whether they are used or not).

Providers Disks NatGateway PublicIp Snapshots InstanceIdle TagResources EC2Stop ocp_cleanup ClusterRun EmptyBucket EmptyRoles
AWS
Azure

List of Policies:

AWS Polices!
  • instance_idle
  • instance_run
  • unattached_volume
  • zombie_cluster_resource
  • ip_unattached
  • zombie_snapshots
  • unused_nat_gateway
  • s3_inactive
  • unused_access_key
  • empty_roles
  • tag_resources
  • tag_iam_user
  • cost_over_usage
  • cluster_run
Azure Polices!
  • instance_idle
  • unattached_volume
  • ip_unattached
  • unused_nat_gateway
IBM Polices!
  • tag_baremetal
  • tag_vm
  • tag_resources

Check out policy summary here!

Reference:

Table of Contents

Installation

Download cloud-governance image from quay.io

podman pull quay.io/cloud-governance/cloud-governance

Environment variables configurations:

Key Value Description
AWS_ACCESS_KEY_ID required AWS access key
AWS_SECRET_ACCESS_KEY required AWS Secret key
AWS_DEFAULT_REGION required AWS Region, default set to us-east-2
BUCKET_NAME optional Cloud bucket Name, to store data
policy required check here for policies list
dry_run optional default set to "yes", supported only two: yes/ no
log_level optional default set to INFO
LDAP_HOST_NAME optional ldap hostnames
es_host optional Elasticsearch Host
es_port optional Elasticsearch Port
es_index optional Elasticsearch Index, to push the data. default to cloud-governance-es-index
GOOGLE_APPLICATION_CREDENTIALS optional GCP creds, to access google resources. i.e Sheets, Docs
AZURE_CLIENT_SECRET required Azure Client Secret
AZURE_TENANT_ID Azure Tenant Id
AZURE_ACCOUNT_ID Azure Account Id
AZURE_CLIENT_ID Azure Client Id
GCP_DATABASE_NAME GCP BigQuery database name, used to generate cost reports
GCP_DATABASE_TABLE_NAME GCP BigQuery TableName, used to generate cost reports
IBM_API_USERNAME IBM Account Username
IBM_API_KEY IBM Account Classic Infrastructure key
IBM_CLOUD_API_KEY IBM Cloud API Key
IBM_CUSTOM_TAGS_LIST pass string with separated with comma. i.e: "cost-center: test, env: test"

AWS Configuration

Create IAM User with Read/Delete Permissions and create S3 bucket.

IBM Configuration

  • Create classic infrastructure API key
  • Create IBM CLOUD API key to use tag_resources policy

Run Policies

AWS

  • Passing environment variables
  podman run --rm --name cloud-governance \
  -e policy="zombie_cluster_resource" \
  -e AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" \
  -e AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \
  -e AWS_DEFAULT_REGION="us-east-2" \
  -e dry_run="yes"  \
   "quay.io/cloud-governance/cloud-governance"
  • Using involvement file config
  • Create env.yaml file, and mount it to /tmp/env.yaml else mount to anypath and pass env DEFAULT_CONFIG_PATH where you mounted
AWS_ACCESS_KEY_ID: ""
AWS_SECRET_ACCESS_KEY: ""
AWS_DEFAULT_REGION: "us-east-2"
policy: "zombie_cluster_resource"
dry_run: "yes"
es_host: ""
es_port: ""
es_index: ""
  podman run --rm --name cloud-governance \
  -v "env.yaml":"/tmp/env.yaml" \
  --net="host" \
   "quay.io/cloud-governance/cloud-governance"

Run Policy Using Pod

Run as a pod job via OpenShift

Job Pod: cloud-governance.yaml

Configmaps: cloud_governance_configmap.yaml

Quay.io Secret: quayio_secret.sh

AWS Secret: cloud_governance_secret.yaml

* Need to convert secret key to base64 [run_base64.py](pod_yaml/run_base64.py)

Pytest

Cloud-governance integration tests using pytest
python3 -m venv governance
source governance/bin/activate
(governance) $ python -m pip install --upgrade pip
(governance) $ pip install coverage
(governance) $ pip install pytest
(governance) $ git clone https://github.com/redhat-performance/cloud-governance
(governance) $ cd cloud-governance
(governance) $ coverage run -m pytest
(governance) $ deactivate
rm -rf *governance*

Post Installation

Delete cloud-governance image

sudo podman rmi quay.io/cloud-governance/cloud-governance

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

cloud_governance-1.1.409.tar.gz (219.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cloud_governance-1.1.409-py3-none-any.whl (318.6 kB view details)

Uploaded Python 3

File details

Details for the file cloud_governance-1.1.409.tar.gz.

File metadata

  • Download URL: cloud_governance-1.1.409.tar.gz
  • Upload date:
  • Size: 219.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for cloud_governance-1.1.409.tar.gz
Algorithm Hash digest
SHA256 f42eeaef0871a47fa94120f8884bc614c24a6411405f459d77cce13c6837e65b
MD5 06771e401da2533b9e1e5fcb5dec5ff1
BLAKE2b-256 469be318569a6dd47566b9036dd705682efa90c83a82296d93a4a5a40fde7f73

See more details on using hashes here.

File details

Details for the file cloud_governance-1.1.409-py3-none-any.whl.

File metadata

File hashes

Hashes for cloud_governance-1.1.409-py3-none-any.whl
Algorithm Hash digest
SHA256 5c1e91c0373df40698f1522ecbfd064665c1cce15459d29af5800ce6aca2c311
MD5 31154b102a83ee56fa7ef04ac5c042e8
BLAKE2b-256 732143b0589cd124e12beaf14fe0e0ed97ef31c65ce88af76b21df9d35d03f41

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page