cloud-governance


Namecloud-governance JSON
Version 1.1.326 PyPI version JSON
download
home_pagehttps://github.com/redhat-performance/cloud-governance
SummaryCloud Governance Tool
upload_time2024-11-11 07:49:11
maintainerNone
docs_urlNone
authorRed Hat
requires_pythonNone
licenseApache License 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            [![PyPI Latest Release](https://img.shields.io/pypi/v/cloud-governance.svg)](https://pypi.org/project/cloud-governance/)
[![Container Repository on Quay](https://quay.io/repository/projectquay/quay/status "Container Repository on Quay")](https://quay.io/repository/cloud-governance/cloud-governance?tab=tags)
[![Actions Status](https://github.com/redhat-performance/cloud-governance/actions/workflows/Build.yml/badge.svg)](https://github.com/redhat-performance/cloud-governance/actions)[![Coverage Status](https://coveralls.io/repos/github/redhat-performance/cloud-governance/badge.svg?branch=main)](https://coveralls.io/github/redhat-performance/cloud-governance?branch=main)
[![Documentation Status](https://readthedocs.org/projects/cloud-governance/badge/?version=latest)](https://cloud-governance.readthedocs.io/en/latest/?badge=latest)
[![python](https://img.shields.io/pypi/pyversions/cloud-governance.svg?color=%2334D058)](https://pypi.org/project/cloud-governance)
[![License](https://img.shields.io/pypi/l/cloud-governance.svg)](https://github.com/redhat-performance/cloud-governance/blob/main/LICENSE)

# Cloud Governance

![](images/cloud_governance.png)

## 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!](./POLICIES.md#aws-policies)

- instance_idle
- instance_run
- unattached_volume
- zombie_cluster_resource
- ip_unattached
- zombie_snapshots
- unused_nat_gateway
- s3_inactive
- empty_roles
- tag_resources
- tag_iam_user
- cost_over_usage
- cluster_run

##### [Azure Polices!](POLICIES.md)

- instance_idle
- unattached_volume
- ip_unattached
- unused_nat_gateway

##### [IBM Polices!](POLICIES.md)

- tag_baremetal
- tag_vm
- tag_resources

Check out policy summary [here!](POLICIES.md)

![](images/cloud_governance1.png)
![](images/demo.gif)

Reference:

* Checkout
  blog: [Optimizing cloud resource management with cloud governance](https://www.redhat.com/en/blog/optimizing-cloud-resource-management-cloud-governance)
* The cloud-governance package is placed in [PyPi](https://pypi.org/project/cloud-governance/)
* The cloud-governance container image is placed in [Quay.io](https://quay.io/repository/ebattat/cloud-governance)
* The cloud-governance readthedocs link is [ReadTheDocs](https://cloud-governance.readthedocs.io/en/latest/)

[//]: # (  ![](images/cloud_governance3.png))

_**Table of Contents**_

<!-- TOC -->

- [Installation](#installation)
- [Configuration](#environment-variables-configurations)
- [Run Policies](#run-policies)
- [Run Policy Using Pod](#run-policy-using-pod)
- [Pytest](#pytest)
- [Post Installation](#post-installation)

<!-- /TOC -->

## Installation

#### Download cloud-governance image from quay.io

```sh
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](POLICIES.md) 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.

- Follow the instructions [README.md](iam/clouds/aws/CloudGovernanceInfra/README.md).

### IBM Configuration

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

## Run Policies

## AWS

- Passing environment variables

```shell
  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

```yaml
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: ""
```

```shell
  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](pod_yaml/cloud-governance.yaml)

Configmaps: [cloud_governance_configmap.yaml](pod_yaml/cloud_governance_configmap.yaml)

Quay.io Secret: [quayio_secret.sh](pod_yaml/quayio_secret.sh)

AWS Secret: [cloud_governance_secret.yaml](pod_yaml/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

```sh
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

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/redhat-performance/cloud-governance",
    "name": "cloud-governance",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Red Hat",
    "author_email": "ebattat@redhat.com, athiruma@redhat.com",
    "download_url": "https://files.pythonhosted.org/packages/df/c0/3493d06748521368a5f8e7cf98eaa904989278d217e988b4c02e9b8a9abb/cloud_governance-1.1.326.tar.gz",
    "platform": null,
    "description": "[![PyPI Latest Release](https://img.shields.io/pypi/v/cloud-governance.svg)](https://pypi.org/project/cloud-governance/)\n[![Container Repository on Quay](https://quay.io/repository/projectquay/quay/status \"Container Repository on Quay\")](https://quay.io/repository/cloud-governance/cloud-governance?tab=tags)\n[![Actions Status](https://github.com/redhat-performance/cloud-governance/actions/workflows/Build.yml/badge.svg)](https://github.com/redhat-performance/cloud-governance/actions)[![Coverage Status](https://coveralls.io/repos/github/redhat-performance/cloud-governance/badge.svg?branch=main)](https://coveralls.io/github/redhat-performance/cloud-governance?branch=main)\n[![Documentation Status](https://readthedocs.org/projects/cloud-governance/badge/?version=latest)](https://cloud-governance.readthedocs.io/en/latest/?badge=latest)\n[![python](https://img.shields.io/pypi/pyversions/cloud-governance.svg?color=%2334D058)](https://pypi.org/project/cloud-governance)\n[![License](https://img.shields.io/pypi/l/cloud-governance.svg)](https://github.com/redhat-performance/cloud-governance/blob/main/LICENSE)\n\n# Cloud Governance\n\n![](images/cloud_governance.png)\n\n## What is it?\n\n**Cloud Governance** tool provides a lightweight and flexible framework for deploying cloud management policies focusing\non cost optimize and security.\nWe have implemented several pruning policies. \\\nWhen monitoring the resources, we found that most of the cost leakage is from available volumes, unused NAT gateways,\nand unattached Public IPv4 addresses (Starting from February 2024, public IPv4 addresses are chargeable whether they are\nused or not).\n\n| Providers | Disks   | NatGateway | PublicIp | Snapshots | InstanceIdle | TagResources | EC2Stop | ocp_cleanup | ClusterRun | EmptyBucket | EmptyRoles |\n|-----------|---------|------------|----------|-----------|--------------|--------------|---------|-------------|------------|-------------|------------|\n| AWS       | &check; | &check;    | &check;  | &check;   | &check;      | &check;      | &check; | &check;     | &check;    | &check;     | &check;    |\n| Azure     | &check; | &check;    | &check;  | &check;   | &check;      | &cross;      | &cross; | &cross;     | &check;    | &cross;     | &cross;    |\n\nList of Policies:\n\n##### [AWS Polices!](./POLICIES.md#aws-policies)\n\n- instance_idle\n- instance_run\n- unattached_volume\n- zombie_cluster_resource\n- ip_unattached\n- zombie_snapshots\n- unused_nat_gateway\n- s3_inactive\n- empty_roles\n- tag_resources\n- tag_iam_user\n- cost_over_usage\n- cluster_run\n\n##### [Azure Polices!](POLICIES.md)\n\n- instance_idle\n- unattached_volume\n- ip_unattached\n- unused_nat_gateway\n\n##### [IBM Polices!](POLICIES.md)\n\n- tag_baremetal\n- tag_vm\n- tag_resources\n\nCheck out policy summary [here!](POLICIES.md)\n\n![](images/cloud_governance1.png)\n![](images/demo.gif)\n\nReference:\n\n* Checkout\n  blog: [Optimizing cloud resource management with cloud governance](https://www.redhat.com/en/blog/optimizing-cloud-resource-management-cloud-governance)\n* The cloud-governance package is placed in [PyPi](https://pypi.org/project/cloud-governance/)\n* The cloud-governance container image is placed in [Quay.io](https://quay.io/repository/ebattat/cloud-governance)\n* The cloud-governance readthedocs link is [ReadTheDocs](https://cloud-governance.readthedocs.io/en/latest/)\n\n[//]: # (  ![]&#40;images/cloud_governance3.png&#41;)\n\n_**Table of Contents**_\n\n<!-- TOC -->\n\n- [Installation](#installation)\n- [Configuration](#environment-variables-configurations)\n- [Run Policies](#run-policies)\n- [Run Policy Using Pod](#run-policy-using-pod)\n- [Pytest](#pytest)\n- [Post Installation](#post-installation)\n\n<!-- /TOC -->\n\n## Installation\n\n#### Download cloud-governance image from quay.io\n\n```sh\npodman pull quay.io/cloud-governance/cloud-governance\n```\n\n#### Environment variables configurations:\n\n| Key                            | Value    | Description                                                                 |\n|--------------------------------|----------|:----------------------------------------------------------------------------|\n| AWS_ACCESS_KEY_ID              | required | AWS access key                                                              |\n| AWS_SECRET_ACCESS_KEY          | required | AWS Secret key                                                              |\n| AWS_DEFAULT_REGION             | required | AWS Region, default set to us-east-2                                        |\n| BUCKET_NAME                    | optional | Cloud bucket Name, to store data                                            |\n| policy                         | required | check [here](POLICIES.md) for policies list                                 |\n| dry_run                        | optional | default set to \"yes\", supported only two: yes/ no                           |\n| log_level                      | optional | default set to INFO                                                         |\n| LDAP_HOST_NAME                 | optional | ldap hostnames                                                              |\n| es_host                        | optional | Elasticsearch Host                                                          |\n| es_port                        | optional | Elasticsearch Port                                                          |\n| es_index                       | optional | Elasticsearch Index, to push the data. default to cloud-governance-es-index |\n| GOOGLE_APPLICATION_CREDENTIALS | optional | GCP creds, to access google resources. i.e Sheets, Docs                     |\n| AZURE_CLIENT_SECRET            | required | Azure Client Secret                                                         |\n| AZURE_TENANT_ID                |          | Azure Tenant Id                                                             |\n| AZURE_ACCOUNT_ID               |          | Azure Account Id                                                            |\n| AZURE_CLIENT_ID                |          | Azure Client Id                                                             |\n| GCP_DATABASE_NAME              |          | GCP BigQuery database name, used to generate cost reports                   |\n| GCP_DATABASE_TABLE_NAME        |          | GCP BigQuery TableName, used to generate cost reports                       |\n| IBM_API_USERNAME               |          | IBM Account Username                                                        |\n| IBM_API_KEY                    |          | IBM Account Classic Infrastructure key                                      |\n| IBM_CLOUD_API_KEY              |          | IBM Cloud API Key                                                           |\n| IBM_CUSTOM_TAGS_LIST           |          | pass string with separated with comma. i.e: \"cost-center: test, env: test\"  |\n\n### AWS Configuration\n\nCreate IAM User with Read/Delete Permissions and create S3 bucket.\n\n- Follow the instructions [README.md](iam/clouds/aws/CloudGovernanceInfra/README.md).\n\n### IBM Configuration\n\n* Create classic infrastructure API key\n* Create IBM CLOUD API key to use tag_resources policy\n\n## Run Policies\n\n## AWS\n\n- Passing environment variables\n\n```shell\n  podman run --rm --name cloud-governance \\\n  -e policy=\"zombie_cluster_resource\" \\\n  -e AWS_ACCESS_KEY_ID=\"$AWS_ACCESS_KEY_ID\" \\\n  -e AWS_SECRET_ACCESS_KEY=\"$AWS_SECRET_ACCESS_KEY\" \\\n  -e AWS_DEFAULT_REGION=\"us-east-2\" \\\n  -e dry_run=\"yes\"  \\\n   \"quay.io/cloud-governance/cloud-governance\"\n```\n\n- Using involvement file config\n- Create env.yaml file, and mount it to /tmp/env.yaml else mount to anypath and pass env DEFAULT_CONFIG_PATH where you\n  mounted\n\n```yaml\nAWS_ACCESS_KEY_ID: \"\"\nAWS_SECRET_ACCESS_KEY: \"\"\nAWS_DEFAULT_REGION: \"us-east-2\"\npolicy: \"zombie_cluster_resource\"\ndry_run: \"yes\"\nes_host: \"\"\nes_port: \"\"\nes_index: \"\"\n```\n\n```shell\n  podman run --rm --name cloud-governance \\\n  -v \"env.yaml\":\"/tmp/env.yaml\" \\\n  --net=\"host\" \\\n   \"quay.io/cloud-governance/cloud-governance\"\n```\n\n## Run Policy Using Pod\n\n#### Run as a pod job via OpenShift\n\nJob Pod: [cloud-governance.yaml](pod_yaml/cloud-governance.yaml)\n\nConfigmaps: [cloud_governance_configmap.yaml](pod_yaml/cloud_governance_configmap.yaml)\n\nQuay.io Secret: [quayio_secret.sh](pod_yaml/quayio_secret.sh)\n\nAWS Secret: [cloud_governance_secret.yaml](pod_yaml/cloud_governance_secret.yaml)\n\n    * Need to convert secret key to base64 [run_base64.py](pod_yaml/run_base64.py)\n\n## Pytest\n\n##### Cloud-governance integration tests using pytest\n\n```sh\npython3 -m venv governance\nsource governance/bin/activate\n(governance) $ python -m pip install --upgrade pip\n(governance) $ pip install coverage\n(governance) $ pip install pytest\n(governance) $ git clone https://github.com/redhat-performance/cloud-governance\n(governance) $ cd cloud-governance\n(governance) $ coverage run -m pytest\n(governance) $ deactivate\nrm -rf *governance*\n```\n\n## Post Installation\n\n#### Delete cloud-governance image\n\n```sh\nsudo podman rmi quay.io/cloud-governance/cloud-governance\n```\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Cloud Governance Tool",
    "version": "1.1.326",
    "project_urls": {
        "Homepage": "https://github.com/redhat-performance/cloud-governance"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c4e1e5d48e047386ffc5208306587a5df265d40abad5a5d72a8209d4ef75a653",
                "md5": "038275fb124f7c9e08c3f5dea90d3823",
                "sha256": "a4f42861cbb6e9298bd0a71b1073abec06ee2abc50c9f57ac0a8f18da5fbd411"
            },
            "downloads": -1,
            "filename": "cloud_governance-1.1.326-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "038275fb124f7c9e08c3f5dea90d3823",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 297577,
            "upload_time": "2024-11-11T07:49:09",
            "upload_time_iso_8601": "2024-11-11T07:49:09.849047Z",
            "url": "https://files.pythonhosted.org/packages/c4/e1/e5d48e047386ffc5208306587a5df265d40abad5a5d72a8209d4ef75a653/cloud_governance-1.1.326-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dfc03493d06748521368a5f8e7cf98eaa904989278d217e988b4c02e9b8a9abb",
                "md5": "e041b4a64a2c7999fdcef10e3d73e64d",
                "sha256": "b8e06c29a51918862d0a95ecfd9181a95ecb8e67fe2c6f42c0dd5e570642ea33"
            },
            "downloads": -1,
            "filename": "cloud_governance-1.1.326.tar.gz",
            "has_sig": false,
            "md5_digest": "e041b4a64a2c7999fdcef10e3d73e64d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 202912,
            "upload_time": "2024-11-11T07:49:11",
            "upload_time_iso_8601": "2024-11-11T07:49:11.771025Z",
            "url": "https://files.pythonhosted.org/packages/df/c0/3493d06748521368a5f8e7cf98eaa904989278d217e988b4c02e9b8a9abb/cloud_governance-1.1.326.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-11 07:49:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "redhat-performance",
    "github_project": "cloud-governance",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "cloud-governance"
}
        
Elapsed time: 3.53986s