Git Product home page Git Product logo

zfs-flex-volume's Introduction

zfs-flex-volume

Simple ZFS flexVolume driver for Kubernetes.

Status

Highly experimental. Master is probably broken. Do not use on a system that you care about the data. This is currently just a port of the lvm driver to ZFS and Go. The code is fairly rough.

Linux only.

Kubernetes FlexVolumes are still considered alpha.

Description

FlexVolumes allow one to add support for additional storage backends to Kubernetes without modifying the core Kubernetes code.

zfs-flex-volume provides a simplistic ZFS driver. It will allocate zfs filesystems from a parent dataset and mount them for usage in a container.

Building

Note: tagged releases are availible at https://github.com/bakins/zfs-flex-volume/releases

You need a go build environment. This has been tested with go 1.7.x - other versions may work.

Inside the repo, run ./script/build and you should have a Linux amd64 binary named zfs-flex-volume in the root of the repo.

Usage

Place the zfs-flex-volume binary on the target node(s). You may want to place this in your PATH to ease usage. The node must have ZFS installed and configured.

Create a "parent" dataset. All volumes created by this driver will be children of it. In my test set up, I have a zpool called rpool and I created a parent filesystem like zfs create -o mountpoint=/k8s-volumes,compression=lz4 rpool/k8s-volumes.

You should create a shell wrapper script to pass this parent volume as an argument. Under Kubernetes, there is no facility for doing this and as an administrator, you may not wish to directly expose this.

An example wrapper script:

#!/bin/bash
exec /usr/local/sbin/zfs-flex-volume -parent=rpool/k8s-volumes "$@"

Kubernetes

  • Create the directory /usr/libexec/kubernetes/kubelet-plugins/volume/exec/akins.org~zfs/
  • Create/copy the shell wrapper script from above to /usr/libexec/kubernetes/kubelet-plugins/volume/exec/akins.org~zfs/zfs

To create a ZFS, create a Kubernetes pod such as:

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx
    volumeMounts:
    - name: test
      mountPath: /data
    ports:
    - containerPort: 80
  volumes:
  - name: test
    flexVolume:
      driver: "akins.org/zfs"
      options:
        dataset: "test-volume"
        quota: "1G"

And the driver will create a volume -- rpool/k8s-volumes/test-volume in our example. The volume will be mounted under the parent - /k8s-volumes/test-volume in our example. The volume will also be mounted in the container as /data inside the container. The actual path on the host system is under /var/lib/kubelet, by default.

When the pods is deleted, the volume will be unmounted from under /var/lib/kubelet, but remained mounted under the parent dataset. zfs-flex-driver, at this time, does not destroy the filesystem.

Note: multiple pods may mount the same dataset on the same host.

The following options may be passed:

  • dataset - required - name of the dataset to create.
  • quota - required - Quota for the dataset.
  • reservation - reservation for the dataset. By default, none is set.
  • compression - compression. By default no option is set, which means inherit from parent dataset.

Note: the options are only used at initial creation. Changing the options will not change the dataset.

See Also

LICENSE

see LICENSE

zfs-flex-volume's People

Contributors

bakins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zfs-flex-volume's Issues

JSON unmarshal error with k8s 1.7 cluster

Issue Description

First call to zfs-flex-volume (init) succeeds with no extra args as expected.

Second call to zfs-flex-volume is getvolumename with the following input JSON:

{"dataset":"test-volume","kubernetes.io/fsType":"","kubernetes.io/pvOrVolumeName":"test","kubernetes.io/readwrite":"rw","quota":"1G"}

Errors with a JSON unmarshal issue:

{"status":"Failed","message":"unable to unmarshal json: invalid character 'd' looking for beginning of object key string"}

Input (to k8s) is the example within the readme;

spec:
  containers:
  - name: nginx
    image: nginx
    volumeMounts:
    - name: test
      mountPath: /data
    ports:
    - containerPort: 80
  volumes:
  - name: test
    flexVolume:
      driver: "akins.org/zfs"
      options:
        dataset: "test-volume"
        quota: "1G"

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.