Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Blue turns green! Approaches and technologies for sustainable K8s clusters. #KCDMunich

Blue turns green! Approaches and technologies for sustainable K8s clusters. #KCDMunich

The cloud already has a larger CO2 footprint than the worldwide aviation industry. With increasing digitalization and cloudification this trend will continue if we don't do anything about it. Many Kubernetes installations are greatly oversized in terms of the resources actually required and thus contribute unnecessarily to global warming. What is the energy balance of your cluster and its workloads?

In this session we will discuss approaches and technologies that help to make K8s clusters green(er). First of all, transparency is needed: what is the energy balance of the cluster and its workloads? Only then we can start to optimize for better energy efficiency. And it's not that difficult, so let's get started!

M.-Leander Reimer

July 18, 2023
Tweet

More Decks by M.-Leander Reimer

Other Decks in Technology

Transcript

  1. SPONSORS
    Speaker: Mario-Leander Reimer
    Company: QAware GmbH
    Blue turns green!
    Approaches and technologies for
    sustainable K8s clusters.

    View full-size slide

  2. 2
    Mario-Leander Reimer
    Managing Director | CTO
    @LeanderReimer
    #cloudnativenerd #qaware
    #gernperDude

    View full-size slide

  3. 3
    Mario-Leander Reimer
    Managing Director | CTO
    @LeanderReimer
    #cloudnativenerd #qaware
    #gernperDude

    View full-size slide

  4. CO2 Emissions Worldwide
    QAware | 5
    Aerospace: 2%
    Buildings: 18% Stockbreeding: 6%
    Concrete: 2%
    IT: 4%

    View full-size slide

  5. Energy Sources and CO2 Emissions Worldwide
    QAware | 6
    Coal
    Oil
    Gas
    Nuclear
    Water
    Wind, Solar
    https://app.electricitymaps.com/map

    View full-size slide

  6. 7
    IT
    Sustainability Impact on other Industries
    Own consumption of resources

    View full-size slide

  7. 8
    QAware
    Sustainable Software
    Design, Implementation and Operation
    of software limited energy consumption
    and minimal impact on the environment
    https://www.greenmanifesto.de/
    https://www.meetup.com/de-DE/green-software-development-manifesto/

    View full-size slide

  8. 10
    QAware
    Notebook Fridge
    Usage
    Manufacturing
    Disposal
    Energy Consumption
    75%
    25%
    96%

    View full-size slide

  9. 11
    QAware 11
    https://www.circable.de/
    https://www.anderwerk.de/gewerke/recycling/

    View full-size slide

  10. sustainable
    kubernetes

    View full-size slide

  11. cncf/tag-env-sustainability
    TAG Environmental Sustainability
    🌳🌍♻

    View full-size slide

  12. Current Sustainable Cloud Computing Landscape
    QAware | 14

    View full-size slide

  13. Sustainability Engineering to optimize the CO2 footprint of
    your K8s clusters and workloads
    15
    QAware
    Monitoring
    What is the CO2
    footprint of my
    cluster and
    workloads?
    Measure,
    Measure,
    Measure,
    Act.
    Elasticity
    Oversized or
    underutilized
    resources?
    Infrastructure and
    workloads should
    be proportionate
    to actual demand.
    Architecture
    Where is the
    cluster running?
    On which
    hardware?
    Take sustainability
    into account when
    building the
    infrastructure.
    Waste
    Shutdown or
    deplete the
    wasted
    resources.
    Not required,
    redundant or
    forgotten
    environments or
    workloads?

    View full-size slide

  14. 16
    QAware
    Optimize by costs?
    Costs are not necessarily
    proportional to CO2 emissions

    View full-size slide

  15. 17
    QAware
    ELECTRICITYMAPS.COM

    View full-size slide

  16. Business requirements and sustainability goals need to be
    aligned and reconciled.
    The choice of region for the cluster and workloads has a significant impact on their KPIs,
    including performance, cost, and carbon footprint.
    ■ Ensure that the region meets the required legal regulations (e.g. GDPR)
    ■ Ensure that the region supports the required services and features.
    – Which hardware classes are supported?
    – Databases? Storage? …
    ■ Calculate costs for the cluster and workloads for the selected region.
    ■ Test network latency between your end user locations and region!
    18
    QAware
    https://docs.aws.amazon.com/wellarchitected/latest/sustainability-pillar/sus_sus_region_a2.html
    AWS Graviton 2 can save up to 65%
    on energy consumption
    AWS Graviton 2 can save up to 15%
    on costs

    View full-size slide

  17. Cluster Rightsizing with Cluster-Autoscaler and Karpenter
    19
    QAware
    Node 1 Node 2 Node 3
    X
    Node 4

    View full-size slide

  18. Workload Rightsizing with VPA and Goldilocks
    20
    QAware
    https://github.com/FairwindsOps/goldilocks
    apiVersion: "autoscaling.k8s.io/v1"
    kind: VerticalPodAutoscaler
    metadata:
    name: hamster-vpa
    spec:
    targetRef:
    apiVersion: "apps/v1"
    kind: Deployment
    name: hamster
    updatePolicy:
    # updateMode: "Auto"
    updateMode: "Off"
    resourcePolicy
    :
    containerPolicies
    :
    - containerName: '*'
    minAllowed:
    cpu: 100m
    memory: 50Mi
    maxAllowed:
    cpu: 1
    memory: 500Mi
    controlledResources
    : ["cpu", "memory"]
    defined and tune requests and
    limits for CPU and RAM
    perform realistic
    performance tests
    analyse measurements of
    resource consumption
    https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler

    View full-size slide

  19. kube-green
    An operator to reduce CO2 footprint of your clusters
    21
    QAware
    apiVersion: kube-green.com/v1alpha1
    kind: SleepInfo
    metadata:
    name: non-working-hours
    spec:
    weekdays: "1-5"
    sleepAt: "18:00"
    wakeUpAt: "08:00"
    timeZone: "Europe/Rome"
    suspendCronJobs : true
    excludeRef:
    - apiVersion: "apps/v1"
    kind: Deployment
    name: no-sleep-deployment
    - matchLabels :
    kube-green.dev/exclude : "true" https://kube-green.dev/docs/FAQ/#how-many-co2-is-produced-by-pod

    View full-size slide

  20. Carbon-aware Scheduling with KEDA
    ■ https://keda.sh
    ■ KEDA is a Kubernetes-based event-driven and purpose
    oriented workload autoscaler
    ■ Support for 50+ different scaler out-of-the-box, e.g.
    Cron, RabbitMQ, …
    ■ Carbon Aware Scheduling
    - Kubernetes Carbon Intensity Exporter
    - Carbon Aware KEDA Operator
    22
    QAware

    View full-size slide

  21. Sustainable Computing Projects
    ■ Kepler (Kubernetes-based Efficient Power Level Exporter) uses eBPF to probe energy
    related system stats and exports as Prometheus metrics.
    ■ PEAKS (Power Efficiency Aware Kubernetes Scheduler) uses metrics exported by
    Kepler to help Kubernetes schedule to improve energy efficiency by placing Pods on
    optimal nodes.
    ■ CLEVER (Container Level Energy-efficient VPA Recommender) uses metrics exported
    by Kepler to recommend Vertical Pod Autoscaler the resource profiles to improve
    energy efficiency by running workloads.
    23
    QAware
    https://www.sustainable-computing.io

    View full-size slide

  22. Monitor and Measure the Energy Consumption of Nodes and
    Pods using Kepler
    24
    QAware

    View full-size slide

  23. lreimer/green-kubernetes

    View full-size slide

  24. qaware.de
    QAware GmbH
    Aschauer Straße 32
    81549 München
    Tel. +49 89 232315-0
    [email protected]
    twitter.com/qaware
    linkedin.com/company/qaware-gmbh
    xing.com/companies/qawaregmbh
    slideshare.net/qaware
    github.com/qaware

    View full-size slide