Skip to content

Latest commit

 

History

History
100 lines (81 loc) · 6.58 KB

carbon.md

File metadata and controls

100 lines (81 loc) · 6.58 KB

Carbon Dioxide Emission Estimation

SusQL supports three primary CO2 emission calculation methods.

"Out-of-the-box" SusQL reports an estimated CO2 emission value for all measured workloads using the static method:

The behavior of SusQL carbon calculation can be tuned by modifying the susql-config ConfigMap in the same namespace that the SusQL operator is running in. A sample file is provided in samples/susql-config.yaml.

static Method

  • This static method uses a static "carbon intensity value" as a coefficient to calculate grams of CO2 emitted. This calculation method is used when the CARBON-METHOD ConfigMap value is set to static.

static Method ConfigMap Configurable Items

  • CARBON-METHOD - The static method is enabled when this is set to static.
  • CARBON-INTENSITY - Carbon intensity value. A coefficient used to convert Joules to grams of CO2 per Joule. The unit definition is grams of CO2 per Joule. (If you have a custom grams per KWH carbon intensity value, you can multiple it times 0.0000002777777778 to get grams CO2 per Joule.) The default carbon intensity value is based on US EPA data.

simpledynamic Method

  • The simpledynamic method periodically queries the carbon intensity value for a user specified location to provide a more accurate estimation of CO2 emission. This calculation method is used when the CARBON-METHOD ConfigMap value is set to simpledynamic.

simpledynamic Method ConfigMap Configurable Items

  • CARBON-METHOD - The simpledynamic method is enabled when this is set to simpledynamic.
  • CARBON-INTENSITY - This value is set automatically with the simpledynamic method. User specified values will be overwritten. The unit definition is grams of CO2 per Joule.
  • CARBON-INTENSITY-URL - Specifies a web API that returns carbon intensity. (The default value works as of the date of this writing, but may need to be modified in the future.)
  • CARBON-LOCATION - The location identifiers are defined by the API provider, but can be selected by the user. (The default value works as of the date of this writing.)
  • CARBON-QUERY-RATE - Interval in seconds at which the carbon intensity is queried. The data available from the source is updated less than hourly, so an interval of greater than 3600 seconds is recommended.
  • CARBON-QUERY-FILTER - When the return value is embedded in a JSON object, this specification enables the extraction of the data. The default value matches the default provider.
  • CARBON-QUERY-CONV-2J - If the carbon data provider does not provide data in the standard "grams of CO2 per Joule" then this factor can be specified to normalize the units displayed. The default value ensures that the default provider data is in the correct unit.

casdk Method

  • The casdk offers integration with the Green Software Foundation's Carbon Aware SDK. This calculation method is used when the CARBON-METHOD ConfigMap value is set to casdk. The user is required to first prepare a local instance of the Carbon Aware SDK that is configured to support carbon intensity queries.

Configuring and installing Carbon Aware SDK

git clone [email protected]:Green-Software-Foundation/carbon-aware-sdk.git
vi helm-chart/values.yaml
  • Preparation: required software and permission
    • Ensure that helm, and kubectl (or oc) are installed
    • Ensure that the CLI user is logged in to the cluster with sufficient permissions
  • Perform installation: (The example installs into namespace gsf. However, other namespaces may be used.)
cd carbon-aware-sdk
helm upgrade --install --wait carbon-aware-sdk helm-chart --create-namespace gsf
oc expose svc/webapi -n gsf
oc get routes

Note the value reported for "HOST/PORT". This will be used in the next configuration step.

  • Update susql-config.yaml: Update the following items in the susql-config.yaml file:
  CARBON-METHOD: "casdk"
  CARBON-INTENSITY-URL: "http://<HOST/PORT>/emissions/bylocation?location=%s"
  CARBON-LOCATION: "<WORKLOAD-LOCATION>"
  CARBON-QUERY-FILTER: "rating"

Tip: try this command to verify sdk container functionality and also view available locations: curl -s "http:<HOST/PORT>/locations"

Apply the updated susql-config.yaml file:

oc apply -f susql-config.yaml -n <SUSQL-OPERATOR-NAMESPACE>

You are now ready to install and use the SusQL operator. If the SusQL Operator is already installed, then restart the control pod to enable new susql-config values.

casdk Method ConfigMap Configurable Items

  • CARBON-METHOD - The casdk method is enabled when this is set to casdk.
  • CARBON-INTENSITY - This value is set automatically with the casdk method. User specified values will be overwritten. The unit definition is grams of CO2 per Joule.
  • CARBON-INTENSITY-URL - Specifies the web API that returns carbon intensity. This is assumed to be a GSF Carbon Aware SDK prepared and configured by the user.
  • CARBON-LOCATION - The location identifiers are defined by the API provider, and should be specified by the user.
  • CARBON-QUERY-RATE - Interval in seconds at which the carbon intensity is queried.
  • CARBON-QUERY-FILTER - When the return value is embedded in a JSON object, this specification enables the extraction of the data.
  • CARBON-QUERY-CONV-2J - The default values converts "grams of CO2 per KWH" (Carbon Aware SDK standard) to "grams of CO2 per Joule".

License

Copyright 2024.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.