• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created over 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kubernetes controller that can shift nodes from one node pool to another, to favour for example preemptibles over regular VMs

estafette-gke-node-pool-shifter

This controller shifts nodes from one node pool to another, in order to favour preemptibles over a 'safety net' node pool of regular vms.

License

Usage

You can either use environment variables or flags to configure the following settings:

Environment variable Flag Default Description
INTERVAL --interval (-i) 300 Time in second to wait between each shift check
KUBECONFIG --kubeconfig Provide the path to the kube config path, usually located in ~/.kube/config. For out of cluster execution
METRICS_LISTEN_ADDRESS --metrics-listen-address :9001 The address to listen on for Prometheus metrics requests
METRICS_PATH --metrics-path /metrics The path to listen for Prometheus metrics requests
NODE_POOL_FROM --node-pool-from Name of the node pool to shift from
NODE_POOL_FROM_MIN_NODE --node-pool-from-min-node 0 Minimum amount of node to keep on the from node pool
NODE_POOL_TO --node-pool-to Name of the node pool to shift to

Before deploying, you first need to create a service account via the GCloud dashboard with role set to Compute Instance Admin and Kubernetes Engine Admin. This key is going to be used to authenticate from the application to the GCloud API. See documentation.

Deploy with Helm

# Prepare Helm/Tiller
$ kubectl create sa tiller -n kube-system
$ helm init --service-account tiller
$ kubectl create clusterrolebinding tiller \
    --clusterrole=cluster-admin \
    --serviceaccount=kube-system:tiller

# Install
$ helm upgrade estafette-gke-node-pool-shifter \
    --namespace estafette \
    --install \
    --set rbac.create=true \
    --set-file googleServiceAccount=./google_service_account.json \
    --set nodePool.from=default-pool \
    --set nodePool.to=preemptible-pool \
    chart/estafette-gke-node-pool-shifter

Deploy without Helm

export NAMESPACE=estafette
export APP_NAME=estafette-gke-node-pool-shifter
export TEAM_NAME=tooling
export VERSION=1.0.11
export GO_PIPELINE_LABEL=1.0.11
export GOOGLE_SERVICE_ACCOUNT=$(cat google-service-account.json | base64)
export INTERVAL=300
export NODE_POOL_FROM=default-pool
export NODE_POOL_TO=preemptible-pool
export NODE_POOL_FROM_MIN_NODE=0
export CPU_REQUEST=10m
export MEMORY_REQUEST=16Mi
export CPU_LIMIT=50m
export MEMORY_LIMIT=128Mi

# Setup RBAC
curl https://raw.githubusercontent.com/estafette/estafette-gke-node-pool-shifter/master/rbac.yaml | envsubst | kubectl apply -n ${NAMESPACE} -f -

# Run application
curl https://raw.githubusercontent.com/estafette/estafette-gke-node-pool-shifter/master/kubernetes.yaml | envsubst | kubectl apply -n ${NAMESPACE} -f -

Local development

For development purpose, you can create a new cluster with 2 autoscaled node pools, 1 preemptible and 1 regular VM.

Create the cluster with appropriate node pools

export CLUSTER_NAME=node-shifter
export CLUSTER_VERSION=1.7.3
export PROJECT=my-project
export ZONE=europe-west1-c

# Create cluster with regular VMs
gcloud beta container clusters create $CLUSTER_NAME \
  --project=$PROJECT \
  --zone=$ZONE \
  --cluster-version=$CLUSTER_VERSION \
  --num-nodes=1 \
  --enable-autoscaling \
  --min-nodes=0 \
  --max-nodes=3

# Add preemptible VMs node pool
gcloud beta container node-pools create preemptible-pool \
  --project=$PROJECT \
  --zone=$ZONE \
  --cluster=$CLUSTER_NAME \
  --num-nodes=1  \
  --enable-autoscaling \
  --min-nodes=1 \
  --max-nodes=3 \
  --preemptible

Deploy an application

kubectl run nginx --image=nginx:alpine --replicas=5 --limits='cpu=200m,memory=512Mi'

Start the node pool shifter

# proxy master
kubectl proxy

# in another shell
go build && ./estafette-gke-node-pool-shifter --node-pool-from=default-pool --node-pool-to=preemptible-pool

Note: KUBECONFIG=~/.kube/config as environment variable can also be used if you don't want to use the kubectl proxy command.

If necessary, you can resize the node pool size:

gcloud container clusters resize $CLUSTER_NAME
  --project=$PROJECT \
  --zone=$ZONE \
  --size=1 \
  --node-pool=default-pool

More Repositories

1

estafette-gke-preemptible-killer

Kubernetes controller to spread preemption for preemtible VMs in GKE to avoid mass deletion after 24 hours
Go
449
star
2

estafette-vulnerability-scanner

An application that regularly scans all containers in a Kubernetes cluster for vulnerabilities
Go
51
star
3

estafette-cloudflare-dns

Kubernetes controller to set and update dns records in Cloudflare for annotated services and ingresses
Go
39
star
4

estafette-k8s-node-compactor

Kubernetes controller to remove underutilized nodes to improve resource utilization.
Go
25
star
5

estafette-ci-builder

Component of Estafette CI that executes build steps
Go
15
star
6

estafette-ci-api

The API of the CI system that handles all incoming webhooks, bot request, UI requests, etc
Go
14
star
7

estafette-ci

The overarching project for Estafette CI; used for tracking issues
Smarty
11
star
8

estafette-letsencrypt-certificate

Kubernetes controller to retrieve and renews tls certificates from Letsencrypt for annotated Kubernetes secrets
Go
10
star
9

estafette-k8s-hpa-scaler

Kubernetes controller to set minimum replicas from a Prometheus query on annotated HorizontalPodAutoscalers to avoid collapsing deployments in case of errors
Go
10
star
10

estafette-extension-gke

This extension provides a base container to run commands against Kubernetes Engine
Go
8
star
11

estafette-ci-web

The web interface of Estafette CI
Vue
7
star
12

estafette-google-cloud-dns

Kubernetes controller to update dns record in a Google Cloud DNS zone for annotated services and ingresses
Go
4
star
13

estafette.io

Resilient and cloud-native CI/CD
HTML
4
star
14

estafette-gcloud-mig-scaler

Controller to scale a Google Cloud managed instance groups based on request rate retrieved from Prometheus
Go
4
star
15

estafette-foundation

Handles common logic like graceful shutdown, reloads on configmap or secret updates, etc
Go
4
star
16

estafette-ci-manifest

A library with the logic to deserialize the Estafette manifest, so it can be used from both the api and the builder
Go
3
star
17

nginx-sidecar

A sidecar container to take care of TLS termination
Lua
3
star
18

estafette-extension-docker

This extension allows you to build, push and tag docker images
Go
3
star
19

estafette-gcloud-quota-exporter

Prometheus exporter to turn Google Cloud quota into Prometheus timeline series
Go
3
star
20

estafette-extension-github-status

This Estafette extension updates the build status in Github
Go
2
star
21

k8s-node-termination-handler

Helm chart for GoogleCloudPlatform/k8s-node-termination-handler
HTML
2
star
22

estafette-gcp-service-account

Kubernetes controller to fetch GCP service account keyfiles for annotated secrets
Go
2
star
23

estafette-extension-bitbucket-status

This Estafette extension updates the build status in Bitbucket
Go
2
star
24

helm-charts

Repository for the official Estafette helm charts
2
star
25

estafette-extension-git-clone

This Estafette extension clones the git repository to build
Go
2
star
26

estafette-ci-crypt

This library has encryption/decryption helpers for Estafette secrets stored in plain sight
Go
2
star
27

estafette-extension-github-release

This Estafette extension assists in creating a release with resolved issues from a milestone if it exists
Go
2
star
28

estafette-extension-git-trigger

This extension can be used to trigger another pipeline by committing and empty commit to a repository
Go
1
star
29

estafette-docker-cache-heater

Runs as a sidecar to the pull through cache in order to warmup new pods with frequently used container images
Go
1
star
30

estafette-ci-hanging-job-cleaner

This cronjob checks for jobs that have been running for too long and cleans them up
Go
1
star
31

estafette-extension-slack-build-status

This Estafette extension makes it easy to send a build status message to a Slack channel
Go
1
star
32

estafette-extension-dotnet

This extension allows you to build and publish ASP.NET Core application and libraries
Go
1
star
33

estafette-extension-cloud-function

This extension can be used to create and deploy a cloud function
Go
1
star
34

estafette-extension-envvars

This Estafette extension logs all Estafette envvars available to your pipeline build
Go
1
star
35

prometheus-bigquery-adapter

Adapter for using BigQuery as remote storage for Prometheus
Go
1
star
36

estafette-promote-container

This repository provides just a manifest that can tag a specific image with another tag in order to promote a dev version to beta or stable
1
star
37

openresty-sidecar

A sidecar container to take care of TLS termination
Lua
1
star
38

estafette-ci-builder-cached-extensions

Estafette-ci-builder image with extensions pre-cached
Dockerfile
1
star
39

estafette-google-cloud-catalog-extractor

A job that extracts information from your Google Cloud Platform and stores in in Estafette's catalog
Go
1
star
40

estafette

The CLI for Estafette
Go
1
star
41

istio-helm-chart

Turns the helm chart bundled in the istio repository into a hosted helm chart
1
star
42

estafette-cloudflare-loadbalancer

Kubernetes controller to create a Cloudflare load balancer with all GKE nodes as a backend pool
Go
1
star
43

estafette-gke-node-recycler

This Kubernetes controller cycles vms on an interval to prevent hosts from filling up too early with containers or logs
Go
1
star
44

estafette-extension-helm

This extension helps with linting, packaging, testing and adding Helm charts to repositories
Go
1
star