Code Monkey home page Code Monkey logo

k8s-volume-discovery's Introduction

k8s-volume-discovery

What is k8s-volume-discovery

k8s-volume-discovery is a Kubernetes operator that discovers EBS volumes in AWS tagged with the cluster identifiers and attaches them to the cluster in the form of PersistentVolume and PersistentVolumeClaim.

Why k8s-volume-discovery?

When rebuilding a Kubernetes cluster (e.g. in case of disaster), we might want to reattach the volumes that were attached to the previous cluster. This operator allows for an easy and automatic volume recovery. The cluster will automatically rediscover the volumes and attach them.

Deployment

The operator deployment files are expressed in dhall for type safety and customizability. To apply it to your cluster you need to install the dhall-to-yaml tool (inside dhall-json). See https://github.com/dhall-lang/dhall-haskell#pre-built-binaries for more information on installing it.

Once you have dhall-to-yaml installed, you can apply the files to your cluster by doing

export AWS_CLUSTER_NAME=example #set it to your cluster name
make deploy

IAM Role

By default, the operator tries to assume a IAM role called App-k8s-volume-discovery using kube2iam or kiam. You can rename the role by changing k8s/config.dhall. The role needs to have the ec2:DescribeVolumes permission.

Tags

k8s-volume-discovery operates by retrieving the AWS EBS volumes and using the information that Kubernetes puts in the tags. k8s-volume-discovery will only consider volumes with the kubernetes.io/cluster/{clusterName} tag that are in the available state.

The following tags are required for k8s-volume-discovery to add the EBS volume to Kubernetes:

  • kubernetes.io/created-for/pv/name
  • kubernetes.io/created-for/pvc/name
  • kubernetes.io/created-for/pvc/namespace These tags are usually automatically created by Kubernetes when creating PersistentVolumes/PersistentVolumeClaims.

If any of these tags is missing, the volume is not added to the cluster.

Optionally, users can add the tag kubernetes.io/created-for/sc/name to signal which storage class should be assigned to the volume. To add the storage class tag, we recommend using k8s-metadata-injector.

Development

The application is developed in Haskell. To build the project you need stack. Run make build to build the project locally. Run make test to test the project locally.

You can deploy a dry run version of the project by adding the --dry-run flag to the deployment.

To build a new docker image, run make build-docker-image.

Maintainers

The project is actively maintained but it's in alpha stage, expect breaking changes.

k8s-volume-discovery's People

Contributors

amarrella avatar michael-zucchetta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

Forkers

amarrella

k8s-volume-discovery's Issues

Accept --default-storage-class parameter

There are cases where we want to pass an optional default storage class name to the operator and that should be attached to persistentvolumes and persistentvolumeclaims if the storage class is not specified in the tags.

Support discovery with other tags besides clusterName

Currently we are basing discovery on the kubernetes.io/cluster/{clusterName} tag.
We should probably:

  • support wildcards in cluster names
  • support discovery via other tags other than cluster name (clusters can be renamed)

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.