GithubHelp home page GithubHelp logo

ronakongit / hibernate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from castai/hibernate

0.0 0.0 1.0 98 KB

Rapidly shrinks cluster out of working hours

Shell 1.68% Python 55.98% Makefile 1.78% HCL 39.91% Dockerfile 0.65%

hibernate's Introduction

Hibernate shrinks and expands your cluster on schedule

This utility currently is on best effort support by @Leon Kuperman and @Augustinas Stirbis through community slack

Install hibernate

Run this command to install Hibernate CronJobs

kubectl apply -f https://raw.githubusercontent.com/castai/hibernate/main/deploy.yaml

Change API key

Create API token with Full Access permissions and encode base64

echo -n "98349587234524jh523452435kj2h4k5h2k34j5h2kj34h5k23h5k2345jhk2" | base64

use this value to update Secret

apiVersion: v1
kind: Secret
metadata:
  name: castai-Hibernate
  namespace: castai-agent
type: Opaque
data:
  API_KEY: >-
    CASTAI-API-KEY-REPLACE-ME-WITH-ABOVE==

OR for convenience use one liner

kubectl get secret castai-hibernate -n castai-agent -o json | jq --arg API_KEY "$(echo -n 9834958-CASTAI-API-KEY-REPLACE-ME-5k2345jhk2 | base64)" '.data["API_KEY"]=$API_KEY' | kubectl apply -f -

Set Cloud env variable

AKS is set by default, but requires changing in both CronJobs "Cloud" env variable to [EKS|GKE|AKS]

How it works

Hibernate-pause Job will

  • Disable Unscheduled Pod Policy (to prevent growing cluster)
  • Prepare Hibernation node (node that will stay hosting essential components)
  • Mark essential Deployments with Hibernation toleration (system critical and with NAMESPACES_TO_KEEP env var)
  • Delete all other nodes (only hibernation node should stay running)

Hibernate-resume Job will

  • Renable Unscheduled Pod Policy to allow cluster to expand to needed size

Override default hibernate-node size

  • Set the HIBERNATE_NODE environment variable to override the default node sizing selections. Make sure the size selected is appropriate for your cloud.

Override default NAMESPACES_TO_KEEP

  • Set the NAMESPACES_TO_KEEP environment variable to override, "opa,istio""

Override default "PROTECT_EVICTION_DISABLED" and set to "true" to prevent the removal of removal-disabled nodes from being removed during hibernate. This looks for the autoscaling.cast.ai/removal-disabled="true" label on a node and if it exists excludes it from being cordoned and deleted.

TODO

  • Auto detect Cloud

Development

Create [aks|eks|gke] K8s cluster

  • create file hack/aks/local.auto.tfvars from example
  • run "make aks"
  • connect to cluster / switch kubectl context

Run code locally

  • copy cluster_id from console.cast.ai to .env file (example .env.example)
  • uncomment in main.py # local_development = True
  • run end2end tests

hibernate's People

Contributors

augustinass avatar castaiphil avatar leonkuperman avatar viktorasm avatar

Forkers

ronakforgit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.