Skip to content
This repository was archived by the owner on Dec 1, 2022. It is now read-only.

Commit 7cd7b7f

Browse files
committed
Initial Checkin
This adds an initial implementation. It works but has little error handling. Do not use for production. It is based on the layout from the csi-driver-host-path repo. Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
1 parent c3059dc commit 7cd7b7f

File tree

649 files changed

+510355
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

649 files changed

+510355
-0
lines changed

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM centos:centos7
2+
LABEL maintainers="Kubernetes Authors"
3+
LABEL description="Image Driver"
4+
5+
RUN \
6+
yum install -y epel-release && \
7+
yum install -y buildah && \
8+
yum clean all
9+
10+
COPY ./bin/imageplugin /imageplugin
11+
ENTRYPOINT ["/imageplugin"]
12+

Gopkg.lock

Lines changed: 196 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
# Gopkg.toml example
3+
#
4+
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
5+
# for detailed Gopkg.toml documentation.
6+
#
7+
# required = ["github.com/user/thing/cmd/thing"]
8+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
9+
#
10+
# [[constraint]]
11+
# name = "github.com/user/project"
12+
# version = "1.0.0"
13+
#
14+
# [[constraint]]
15+
# name = "github.com/user/project2"
16+
# branch = "dev"
17+
# source = "github.com/myfork/project2"
18+
#
19+
# [[override]]
20+
# name = "github.com/x/y"
21+
# version = "2.4.0"
22+
23+
[prune]
24+
go-tests = true
25+
unused-packages = true
26+
27+
[[constraint]]
28+
name = "github.com/container-storage-interface/spec"
29+
version = "1.0.0"
30+
31+
[[constraint]]
32+
branch = "master"
33+
name = "github.com/golang/glog"
34+
35+
[[override]]
36+
revision = "5db89f0ca68677abc5eefce8f2a0a772c98ba52d"
37+
name = "github.com/docker/distribution"
38+
39+
[[constraint]]
40+
name = "github.com/pborman/uuid"
41+
version = "1.1.0"
42+
43+
[[constraint]]
44+
branch = "master"
45+
name = "golang.org/x/net"
46+
47+
[[constraint]]
48+
name = "google.golang.org/grpc"
49+
version = "1.10.0"
50+
51+
[[constraint]]
52+
name = "k8s.io/kubernetes"
53+
version = "v1.12.0"
54+
55+
[[override]]
56+
version = "kubernetes-1.12.0"
57+
name = "k8s.io/api"
58+
59+
[[override]]
60+
version = "kubernetes-1.12.0"
61+
name = "k8s.io/apiserver"
62+
63+
[[override]]
64+
name = "github.com/golang/protobuf"
65+
version = "v1.1.0"
66+
67+
[[override]]
68+
name = "github.com/json-iterator/go"
69+
version = "1.1.4"
70+
71+
[[override]]
72+
name = "gopkg.in/square/go-jose.v2"
73+
version = "2.1.7"

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# TODO: add a Dockerfile and uncomment the following line
1616
# CMDS=imagepopulatorplugin
17+
CMDS=imageplugin
1718
all: build
1819

1920
include release-tools/build.make

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,62 @@ You can reach the maintainers of this project at:
1414
### Code of conduct
1515

1616
Participation in the Kubernetes community is governed by the [Kubernetes Code of Conduct](code-of-conduct.md).
17+
18+
## How it works:
19+
20+
Currently the driver makes use of buildah to download the container image if it is not already available, launch a new instance of it named after the volumeHandle, and mount it.
21+
22+
In the future, integration with CRI would be desirable so the driver could ask via CRI that the Container Runtime perform these activities in a generic way.
23+
24+
## Usage:
25+
26+
**This is a prototype driver. Do not use for production**
27+
28+
It also requires features that are still in development.
29+
30+
### Build imageplugin
31+
```
32+
$ make image
33+
```
34+
35+
### Installing into Kubernetes
36+
```
37+
deploy/deploy-image.sh
38+
```
39+
40+
### Example Usage in Kubernetes
41+
```
42+
apiVersion: v1
43+
kind: Pod
44+
metadata:
45+
name: nginx
46+
spec:
47+
containers:
48+
- name: nginx
49+
image: nginx:1.13-alpine
50+
ports:
51+
- containerPort: 80
52+
volumeMount:
53+
- name: data
54+
mountPath: /usr/share/nginx/html
55+
volumes:
56+
- name: data
57+
csi:
58+
driver: image.csi.k8s.io
59+
volumeAttributes:
60+
image: kfox1111/misc:test
61+
```
62+
63+
### Start Image driver manually
64+
```
65+
$ sudo ./bin/imageplugin --endpoint tcp://127.0.0.1:10000 --nodeid CSINode -v=5
66+
```
67+
68+
### Test using csc
69+
Get ```csc``` tool from https://github.com/rexray/gocsi/tree/master/csc
70+
71+
### Mount the image
72+
$ csc -e tcp://127.0.0.1:10000 node publish abcdefg --attrib image=kfox1111/misc:test --cap MULTI_NODE_MULTI_WRITER,block --target-path /tmp/csi
73+
74+
### Unmount the image
75+
$ csc -e tcp://127.0.0.1:10000 node unpublish abcdefg --target-path /tmp/csi

cmd/imageplugin/main.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,31 @@ limitations under the License.
1616

1717
package main
1818

19+
import (
20+
"flag"
21+
"os"
22+
23+
"github.com/kubernetes-csi/csi-driver-image-populator/pkg/image"
24+
)
25+
26+
func init() {
27+
flag.Set("logtostderr", "true")
28+
}
29+
30+
var (
31+
endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint")
32+
driverName = flag.String("drivername", "image.csi.k8s.io", "name of the driver")
33+
nodeID = flag.String("nodeid", "", "node id")
34+
)
35+
1936
func main() {
37+
flag.Parse()
38+
39+
handle()
40+
os.Exit(0)
41+
}
42+
43+
func handle() {
44+
driver := image.NewDriver(*driverName, *nodeID, *endpoint)
45+
driver.Run()
2046
}

cmd/imageplugin/main_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "testing"
4+
5+
func TestStub(t *testing.T) {
6+
7+
}

0 commit comments

Comments
 (0)