Git Product home page Git Product logo

kube-gce-cleanup's Introduction

GCE cleanup scripts

Unsupported

Scripts in this directory are necessary due to bugs (as of Q1-2017) in GKE that cause network load-balancer resources to become orphaned and unused but accruing charges against the account. These charges can be substantial. Before we realized what was happening (with the help of google support) we were seeing 40-50% of the monthly bill going to these network load-balancer resources.

Usage

Configuration

Configuration is handled through environment variables:

  • PROJECT: The GCE project that we should operate on
  • REGION: The region where GCE resources should be probed
  • GKE_CLUSTER_NAME: The Kube cluster name for verifying network resources against
  • KUBE_CONTEXT: the kube context to use when running kubectl commands - not needed when running inside a cluster.

Running the script

Set the env variables and execute the script

PROJECT=myproject \
REGION=us-central1 \
GKE_CLUSTER_NAME=dev-01 \
KUBE_CONTEXT=gke_some-project_us-west1-a_dev01 \
./delete-orphaned-kube-network-load-balancers.sh

This script is derived from the similar script in the kubernetes github repo. That script deletes load-balancers that are pointing to nodes that no longer exist. This is helpful but does not cleanup all orphaned resources.

The delete-orphaned-kube-network-load-balancers.sh is written and maintained by Pantheon and offers a more complete cleanup function. It uses kubectl to get a list of public IP's assigned to active Services and then iterates through gcloud firewall-rules and forwarding-rules looking for IP's that are not in use by the cluster.

Deployment

See the deployment-example.yaml file for an example Deployment.

Development & Testing

It's just a simple shell script. All code should pass shellcheck linting (make test or make test-shell) and follow the Google Shell Style Guide.

make build-docker will build the docker container. make push will push it to quay.io. You can override the repo by setting the REGISTRY variable on the make task.

kube-gce-cleanup's People

Contributors

csdread avatar davidstrauss avatar greg-1-anderson avatar kporras07 avatar spheromak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kube-gce-cleanup's Issues

When are you experiencing orphan resources?

Hello, could you explain to me when you're orphaning these GCP resources? Are you deleting clusters without deleting services? Are you constantly deleting and creating services? How many LB services are you running? How many nodes in your cluster?

Thanks.

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.