An upgraded and improved version of the Iris automatic GCP-labeling project
In Greek mythology, Iris(Ἶρις) is the personification of the rainbow and messenger of the gods. She was the handmaiden to Hera.
See the post that presents Iris.
Iris automatically assigns labels to Google Cloud Platform resources for easier analysis, particularly of cost.
Resources of all supported types in all or some of the projects in the GCP organization will get automatically-generated labels with keys like iris_zone
(the prefix is configurable), and a value copied from the resource. For example, a Google Compute Engine instance would get labels like
[iris_name:nginx]
, [iris_region:us-central1]
and [iris_zone:us-central1-a]
. This behavior can be configured in various ways; see below.
Note that Iris is designed to serve the organization.
Iris does not add information, only copy values that already exist. For example, it can label a VM instance with its zone; but it cannot add a "business unit" label because it does not know a resource's business unit. For that, you should label all resources when creating them, e.g., in your Terraform scripts. (Indeed, iris can be made extraneous in this way.)
If you want to label the resources -- virtual machines, PubSub topics etc. -- that already exist when you deploy Iris, see section "Labeling existing resources" below.
Iris is open-source;it is not an official DoiT product. Feel free to send Pull Requests with new functionality and add new types of labels. See the TODO.md
file and Github
issues for features and fixes you might do.
Iris labels newly-created resources by listening to Google Cloud Operations Logs. You can disable this: See "Deploy" or run deploy.sh -h
.
Iris labels resources periodically on a Cloud Scheduler "cron" job. By default, only some types of resources are labeled on these Cloud Scheduler runs, while most types are not labeled on schedule, , to save the costs of relabeling with the same label every day.
You can change that in configuration. Set label_all_on_cron
to True
in the configuration file.
You can also disable the scheduled labeling. See Deployment below or run ./deploy.sh -h
label_all_on_cron: true
before deploying. Then, on the next daily Cloud Scheduler run, all resources will be labeled. However, this will increase cost, since all resources will be rescanned every day.iris_label_all_topic
, for example with gcloud pubsub topics publish iris_label_all_topic --message=does_not_matter --project $PROJECT_ID
and a full labeling will be triggered.Right now, there are plugins for the following types of resources.
To learn from the code what resources and keys are added, search for functions whose
names start _gcp_
. The part of the function name after _gcp_
is used for the label key.
The required project-level roles: Project Owner or Project Editor on the project where Iris is deployed, so that the deployment script can
actAs
the serivice account iris-msg-sender
for deploying it to allow JWT auth.Fine-granted "predefined roles" are not possible because deploying Cloud Scheduler cron requires at least Editor or Owner, per GCP docs.
Get the code with git clone https://github.com/doitintl/iris3.git
Have Python 3.9+ as your default python3
.
Make sure you have these tools
envsubst
jq
pip3
gcloud
. Make sure it is logged-in using an account with the above-mentioned roles.Set up the configuration
config.yaml.original
to config.yaml
.Now, run ./deploy.sh <PROJECT_ID>
.
deploy.sh -h
Choosing when the labeling occurs
config.yaml
).-c
switch on deploy.sh
to label using Cloud Scheduler only.-e
switch on deploy.sh
to label on-event only.-c
and -e
or neither, both types of labeling occur.Iris' config file is config*.yaml
.
config.yaml.orig
has detailed documentation of the fields.config.yaml
is read as the production configuration file
Alternatively, you can have config-test.yaml
. It takes priority if both it and config-test.yaml
are present.
app.yaml
lets you configure App Engine, for example, to set a maximum number of instances. See App Engine documentation.
Editing cron_full.yaml
lets you optionally change the timing for the Cloud Scheduler scheduled labelings, e.g. to do it more frequently. See Google App Engine documentation.
uninstall.sh
uninstall.sh
that describes what elements are uninstalled. The default is to uninstall everything, both the org-level components and the project-level components.uninstall.sh -h
for help.custom-iris-role.yaml
.deploy.sh -h
.cron_full.yaml
for config. The GCP Console view for this is in a separate App Engine tab in the Cloud Scheduler view./schedule
Cloud Scheduler handler in main.py
. (The /schedule
path is triggered by the Cloud Scheduler). This then sends out messages, where each one triggers the labeling of a given resource tyope in a given project./label_one
and /do_label
in main.py
, respectively.Please see README_for_dev_and_testing