Git Product home page Git Product logo

flexvolume-git-live's Introduction

Live Git Flexvolume for Kubernetes

Flexvolume driver for Git repos that should track updates to the mounted repo.

Installing

This Flexvolume driver is a bash script that makes use of binaries installed on the Kubernetes nodes.

Installing the script itself is done simply as;

VOLUME_PLUGIN_DIR="/usr/libexec/kubernetes/kubelet-plugins/volume/exec"
mkdir -p "$VOLUME_PLUGIN_DIR/ananace~git-live"
cd "$VOLUME_PLUGIN_DIR/ananace~git-live"
curl -L -O https://raw.githubusercontent.com/ananace/flexvolume-git-live/master/git-live
chmod 755 git-live

The git-live script requires a couple of tools to be installed on all the nodes where it's to be used, additionally it currently requires systemd for launching the background updates;

  • awk
  • base64
  • git
  • grep
  • jq
  • realpath
  • sha256sum

Running

Once the Flexvolume plugin has been installed on all relevant nodes, running it is as simple as creating a Kubernetes pod that will use it for a volume;

apiVersion: v1
kind: Pod
metadata:
  name: git-example
spec:
  containers:
  - name: busybox
    image: busybox
    command:
      - sh
      - -c
      - |
        ls -l /data
        tail -f /data/README.md
    volumeMounts:
    - name: data
      mountPath: /data
  volumes:
  - name: data
    flexVolume:
      driver: ananace/git-live
      options:
        repo: https://github.com/ananace/flexvolume-git-live
        interval: 5d
      readOnly: true

This example pod will check out the flexvolume sources and then actively print any new lines as they are added to the README file and pushed.

The interval argument is handled in the same manner as systemd.time timespans. The default interval - if not specified - can be set in the git-live script as DEFAULT_INTERVAL_SEC, and is by default set to 15 minutes.

Caveats

Due to the fact that checkouts are done as root on the underlying system, the git index has been moved away from the repository itself. This unfortunately means that tools inside the running pod will not be able to retrieve any data from the index of the git mount.

Currently, there's no way to differentiate read-only and read-write, the background updates will always override any user changes on every interval.

If you only require a static git checkout that doesn't follow any new commits, the Kubernetes documentation provides a better route.

flexvolume-git-live's People

Contributors

ananace avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flexvolume-git-live's Issues

Make systemd features fully optional

Should be possible to instead auto-configure/deconfigure it by handling a file in /etc/cron.d, or perhaps skip the automated handling and instead use another manual step for the recurring update executions.

Handle errors / back-off for failing repos

Currently, any errors in git updates after the original clone are silently lost, and updates will keep running at the same interval for failing repos, potentially hammering the hosting server.

Scale automated update checks based on required intervals

Currently, lots of unnecessary updates are executed, as the update loop runs on a tight schedule.
Adding dynamic reconfiguration of the service interval, to a lowest common denominator of all the checked out repositories, should help to avoid excessive check executions.

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.