Commit 77d59b12 authored by Ricardo Rocha's avatar Ricardo Rocha

initial commit

parents
Pipeline #51023 canceled with stage
verbose: true
mountpoint: '/eos'
docker-volume-eos
*swp
*swo
stages:
- build
- deploy
rpmbuild:
stage: build
image: gitlab-registry.cern.ch/cloud/ciadm
except:
- master
script:
- curl https://gitlab.cern.ch/cloud-infrastructure/cloud-dev/raw/master/gitlab/rpmbuild.sh | bash
tags:
- cci-swarm-builder
kojiscratch:
stage: build
image: gitlab-registry.cern.ch/cloud/ciadm
except:
- master
script:
- export SCRATCH=1
- curl https://gitlab.cern.ch/cloud-infrastructure/cloud-dev/raw/master/gitlab/kojibuild.sh | bash
tags:
- cci-swarm-builder
kojicheck:
stage: build
image: gitlab-registry.cern.ch/cloud/ciadm
except:
- master
script:
- curl https://gitlab.cern.ch/cloud-infrastructure/cloud-dev/raw/master/gitlab/kojicheck.sh | bash
tags:
- cci-swarm-builder
kojibuild:
stage: deploy
image: gitlab-registry.cern.ch/cloud/ciadm
only:
- master
script:
- curl https://gitlab.cern.ch/cloud-infrastructure/cloud-dev/raw/master/gitlab/kojibuild.sh | bash
tags:
- cci-swarm-builder
FROM fedora:23
MAINTAINER Ricardo Rocha <ricardo.rocha@cern.ch>
RUN yum install -y \
wget
RUN wget -q https://ecsft.cern.ch/dist/cvmfs/cvmfs-2.1.20/cvmfs-2.1.20-1.fc21.x86_64.rpm; \
wget -q https://ecsft.cern.ch/dist/cvmfs/cvmfs-config/cvmfs-config-default-latest.noarch.rpm; \
yum -y install cvmfs-2.1.20-1.fc21.x86_64.rpm cvmfs-config-default-latest.noarch.rpm
RUN echo $'\n\
CVMFS_HTTP_PROXY="http://ca-proxy.cern.ch:3128" \n\
CVMFS_CACHE_BASE=/var/cache/cvmfs \n\
CVMFS_QUOTA_LIMIT=20000 \n'\
>> /etc/cvmfs/default.local
ADD docker-volume-cvmfs /usr/sbin/docker-volume-cvmfs
RUN chmod 755 /usr/sbin/docker-volume-cvmfs
LABEL Vendor="Red Hat" License=GPLv2
LABEL Version=1.0
LABEL INSTALL="docker run --rm --privileged -v /:/host -e HOST=/host -e CONFDIR=${CONFDIR} -e DATADIR=${DATADIR} -e -e IMAGE=IMAGE -e NAME=NAME IMAGE /bin/install.sh"
LABEL UNINSTALL="docker run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=IMAGE -e NAME=NAME IMAGE /bin/uninstall.sh"
ADD root /
CMD "/usr/sbin/docker-volume-cvmfs"
This diff is collapsed.
# docker-volume-cvmfs
This package provides management of cvmfs repositories in docker and kubernetes.
It provides a nicer interface to handle cvmfs volume definitions.
## Requirements
Docker 1.9.x, Kubernetes 1.2.x.
## Installation
### CentOS 7
Package installation is available for CentOS7, just add the following repos:
```
yum install https://ecsft.cern.ch/dist/cvmfs/cvmfs-release/cvmfs-release-latest.noarch.rpm
tee /etc/yum.repos.d/cci7-utils.repo <<-'EOF'
[cci7-utils]
name=CERN Cloud Infrastructure Utils
baseurl=http://linuxsoft.cern.ch/internal/repos/cci7-utils-stable/x86_64/os/
enabled=1
gpgcheck=0
EOF
```
Install the packages and launch the service (assuming you have docker already running):
```
yum install -y docker-volume-cvmfs
systemctl restart docker-volume-cvmfs
```
Logging will be at /var/log/docker-volume-cvmfs.log.
### Other
Otherwise you'll need to compile it manually and do the install. Example for Ubuntu:
```
wget https://ecsft.cern.ch/dist/cvmfs/cvmfs-2.1.20/cvmfs_2.1.20_amd64.deb
wget https://ecsft.cern.ch/dist/cvmfs/cvmfs-config/cvmfs-config-default_latest_all.deb
sudo dpkg --install cvmfs_2.1.20_amd64.deb cvmfs-config-default_latest_all.deb
cat >/etc/cvmfs/default.local << EOF
CVMFS_HTTP_PROXY="http://ca-proxy.cern.ch:3128"
CVMFS_CACHE_BASE=/var/cache/cvmfs
CVMFS_QUOTA_LIMIT=20000
EOF
```
Build the binary (go build from this repo source) and launch it:
```
sudo docker-volume-cvmfs
docker-volume-cvmfs: registering with docker
docker-volume-cvmfs: listening on /run/docker/plugins/cvmfs.sock
```
## Usage
1. Attempt some volume creation (the plugin should output some useful info)
```
sudo docker volume ls
sudo docker volume create -d cvmfs --name=cms.cern.ch
```
The plugin should have given the following:
```
docker-volume-cvmfs: create cms.cern.ch map[]
docker-volume-cvmfs: mounting cms.cern.ch in /cvmfs/cms.cern.ch
docker-volume-cvmfs: path {cms.cern.ch map[]}
```
2. Deleting a volume
```
sudo docker volume rm cms.cern.ch
```
Plugin should give some info:
```
docker-volume-cvmfs: path {cms.cern.ch map[]}
docker-volume-cvmfs: remove {cms.cern.ch map[]}
docker-volume-cvmfs: unmounting cms.cern.ch in /cvmfs/cms.cern.ch
```
3. Attach a volume to a new container
```
sudo docker run -it --rm --volume-driver cvmfs -v cms.cern.ch:/cms centos:7 /bin/bash
[root@874cbf8199d0 /]# ls /cms/
CMS@Home bootstrap_slc5_amd64_gcc462.log cmssw.git
...
```
## Troubleshooting
%global gopath %{_tmppath}/gopath
%define debug_package %{nil}
%define _unitdir /lib/systemd/system
%global eos %{gopath}/src/gitlab.cern.ch/cloud-infrastructure/docker-volume-eos
Name: docker-volume-eos
Version: 0.1.0
Release: 1
Summary: Docker volume plugin for EOS
Source0: https://gitlab.cern.ch/cloud-infrastructure/docker-volume-eos/%{name}-%{version}.tar.gz
Group: Development/Languages
License: ASL 2.0
URL: http://gitlab.cern.ch/cloud-infrastructure/docker-volume-eos
BuildRequires: golang
BuildRequires: systemd
%description
Docker volume plugin for the EOS filesystem.
http://eos.readthedocs.io/
%prep
%setup -q -n %{name}-%{version}
rm -rf %{gopath}
mkdir -p %{gopath} %{gopath}/pkg %{gopath}/bin %{gopath}/src %{eos}
%build
cp -R * %{eos}
cd %{eos}
ln -sf `pwd`/vendor/* %{gopath}/src # we need to support go 1.4 (no vendor)
GOPATH=%{gopath} go build .
%install
cd %{eos}
# binary
GOPATH=%{gopath} go install .
install -d %{buildroot}%{_bindir}
install -m 755 %{_tmppath}/gopath/bin/%{name} %{buildroot}%{_bindir}
# default eos config
install -d %{buildroot}%{_sysconfdir}
install -d %{buildroot}%{_sysconfdir}/eos
# kubernetes plugin (symlink)
install -d %{buildroot}%{_libexecdir}/kubernetes/kubelet-plugins/volume/exec/cern~eos
ln -sf %{_bindir}/docker-volume-eos %{buildroot}%{_libexecdir}/kubernetes/kubelet-plugins/volume/exec/cern~eos/eos
%files
%doc LICENSE
%doc README.md
%{_bindir}/%{name}
%{_libexecdir}/kubernetes/kubelet-plugins/volume/exec/cern~eos/eos
%changelog
* Tue Nov 29 2016 Ricardo Rocha <ricardo.rocha@cern.ch> 0.1.0-1
- First release
// Copyright ©2016 CERN
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package main
import (
"fmt"
"log"
"github.com/docker/go-plugins-helpers/volume"
)
type eosDriver struct {
eos Eos
volumes map[string]string
}
func newEosDriver(mountPoint string) eosDriver {
log.Printf("initializing driver :: mount point: %v\n", mountPoint)
d := eosDriver{
eos: newEos(mountPoint),
volumes: make(map[string]string),
}
return d
}
func (d eosDriver) Create(r volume.Request) volume.Response {
log.Printf("create %v %v", r.Name, r.Options)
volumeName := r.Name
if _, ok := d.volumes[volumeName]; ok {
return volume.Response{}
}
// mount eos
volumePath, err := d.eos.Mount(volumeName)
if err != nil {
return volume.Response{Err: err.Error()}
}
// store in map cache for path and other later calls
d.volumes[volumeName] = volumePath
return volume.Response{}
}
func (d eosDriver) Path(r volume.Request) volume.Response {
log.Printf("path %v", r)
volumeName := r.Name
if volumePath, ok := d.volumes[volumeName]; ok {
return volume.Response{Mountpoint: volumePath}
}
return volume.Response{}
}
func (d eosDriver) Remove(r volume.Request) volume.Response {
log.Printf("remove %v", r)
volumeName := r.Name
_, err := d.eos.Umount(volumeName)
if err != nil {
return volume.Response{Err: err.Error()}
}
// remove from map cache
if _, ok := d.volumes[volumeName]; ok {
delete(d.volumes, volumeName)
}
return volume.Response{}
}
func (d eosDriver) Mount(r volume.Request) volume.Response {
log.Printf("mount %v", r)
volumeName := r.Name
if volumePath, ok := d.volumes[volumeName]; ok {
return volume.Response{Mountpoint: volumePath}
}
return volume.Response{}
}
func (d eosDriver) Unmount(r volume.Request) volume.Response {
log.Printf("unmount %v", r)
return volume.Response{}
}
func (d eosDriver) Get(r volume.Request) volume.Response {
log.Printf("get %v", r)
volumeName := r.Name
if volumePath, ok := d.volumes[volumeName]; ok {
return volume.Response{Volume: &volume.Volume{Name: volumeName, Mountpoint: volumePath}}
}
msg := fmt.Sprintf("volume %s does not exist", volumeName)
log.Printf(msg)
return volume.Response{Err: msg}
}
func (d eosDriver) List(r volume.Request) volume.Response {
log.Printf("list %v\n", r)
volumes := []*volume.Volume{}
for name, path := range d.volumes {
volumes = append(volumes, &volume.Volume{Name: name, Mountpoint: path})
}
return volume.Response{Volumes: volumes}
}
// Copyright ©2016 CERN
//
//
// Licensed under the Apache License, Version 2.0 (the "License");