Skip to content

Commit

Permalink
Merge pull request #2 from jsafrane/add-connect
Browse files Browse the repository at this point in the history
Add CSI connection
  • Loading branch information
jsafrane committed Oct 30, 2017
2 parents c7ab437 + 29e3bde commit d05f352
Show file tree
Hide file tree
Showing 489 changed files with 202,324 additions and 67 deletions.
261 changes: 261 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"


[[constraint]]
branch = "master"
name = "github.com/container-storage-interface/spec"

[[constraint]]
branch = "master"
name = "github.com/golang/glog"

[[constraint]]
name = "github.com/golang/mock"
version = "1.0.0"

[[constraint]]
branch = "master"
name = "github.com/kubernetes-csi/csi-test"

[[constraint]]
name = "google.golang.org/grpc"
version = "1.7.1"

[[constraint]]
branch = "master"
name = "k8s.io/api"

[[constraint]]
branch = "master"
name = "k8s.io/apimachinery"

[[constraint]]
name = "k8s.io/client-go"
version = "5.0.1"
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,55 @@

The csi-attacher is part of Kubernetes implementation of [Container Storage Interface (CSI)](https://github.com/container-storage-interface/spec).

## Design
## Overview

In short, it's an external controller that monitors `VolumeAttachment` objects and attaches/detaches volumes to/from nodes. Full design can be found at Kubernetes proposal at https://github.com/kubernetes/community/pull/1258. TODO: update the link after merge.

There is no plan to implement a generic external attacher library, csi-attacher is the only external attacher that exists. If this proves false in future, splitting a generic external-attacher library should be possible with some effort.

## Design

External attacher follows [controller](https://github.com/kubernetes/community/blob/master/contributors/devel/controllers.md) pattern and uses informers to watch for `VolumeAttachment` and `PersistentVolume` create/update/delete events. It filters out `VolumeAttachment` instances with `Attacher==<CSI driver name>` and processes these events in workqueues with exponential backoff. Real handling is deferred to `Handler` interface.

`Handler` interface has two implementations, trivial and real one.

### Trivial handler

Trivial handler will be used for CSI drivers that don't support `ControllerPublish` calls and marks all `VolumeAttachment` as attached. It does not use any finalizers. This attacher can also be used for testing.

### Real attacher

"Real" attacher talks to CSI over socket (`/run/csi/socket` by default, configurable by `-csi-address`). The attacher tries to connect for `-connection-timeout` (1 minute by default), allowing CSI driver to start and create its server socket a bit later.

The attacher then:

* Discovers the supported attacher name by `GetPluginInfo` calls. The attacher only processes `VolumeAttachment` instances that have `Attacher==GetPluginInfoResponse.Name`.
* Uses `ControllerGetCapabilities` to find out if CSI driver supports `ControllerPublish` calls. It degrades to trivial mode if not.
* Processes `VolumeAttach` instances and attaches/detaches volumes. TBD: details + VolumeAttachment finalizers.
* TBD: PV finalizers.
* TBD: async operations - we can't block worker queue for 20 minutes (= current AWS attach timeout).

## Usage

TBD
### Dummy mode

Dummy attacher watches for `VolumeAttachment` instances with `Attacher=="csi/dummy"` and marks them attached. It does not use any finalizers and is useful for testing.

To run dummy attacher in `hack/local-up-cluster.sh` environment:

```sh
$ csi-attacher -dummy -kubeconfig=~/kube/config -v 5
```

TBD: running as a pod

### Real attacher

```sh
$ csi-attacher -kubeconfig=~/kube/config -v 5 -csi-address /run/csi/socket
```

TBD: running as a pod

## Vendoring

Expand Down

0 comments on commit d05f352

Please sign in to comment.