GreenCourier is a carbon-aware Kubernetes plugin to intelligently schedule serverless functions in regions of low carbon emission using Carbon-Aware-SDK. GreenCourier optimises delivery of serverless functions across geo-spatial multi-cluster Kubernetes environment in the cloud for carbon efficiency. GreenCourier has production-ready tech stack and one-click away from integrating with existing geographically distributed clusters with Liqo.
We need a cluster with Knative enabled in management cluster and target clusters which are geographically distributed to be connected to management cluster using Liqo.
Once the cluster setup up is done, it is important for us to install metrics-collector and Carbon-Aware-SDK's WebAPI in local cluster.
# Replace $USERNAME and $PASSWORD with WattTime credentials in deployment YAML
kubectl apply -f metrics-collector/deployment/deployment.yaml
Once metrics-collector is deployed, we can deploy the plugin code using Helm using following command:
helm install GreenCourier carbon-scheduler/charts/
When metrics-collector and plugin code is deployed, we can just start deploying functions in Knative with just addition of one line in the function spec YAML.
...
spec:
schedulerName: kube-carbon-scheduler
...
Example function spec with schedulerName added.
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: hello
namespace: default
spec:
template:
metadata:
annotations:
autoscaling.knative.dev/target: "10"
spec:
schedulerName: kube-carbon-scheduler
containers:
- image: gcr.io/knative-samples/helloworld-go
ports:
- containerPort: 8080
env:
- name: TARGET
value: "GreenCourier Demo"
As shown in the system architecture, we deployed 3 clusters in different regions and load tested our solution. And the result of the evaluation is show as following:
It is very much evident that our proposed solution does impact scheduling decisions, tremendously reducing carbon footprint for function execution. We calculate efficiency value for function placement by following formula:
Similarly, Carbon efficiency was calculated by taking weighted average of carbon score divided by best possible result for execution.
GreenCourier is built using Kubernetes Scheduling Framework. It is possible to extend GreenCourier just as extending Kubernetes Scheduler for which there are numerous publicly available documentation.