docker vsphere volume.note

参考文档

docker volume create 详解:
https://docs.docker.com/engine/reference/commandline/volume_create/#description

Give a service access to volumes or bind mounts
https://docs.docker.com/engine/swarm/services/#give-a-service-access-to-volumes-or-bind-mounts

1. 在docker中安装存储插件

$docker plugin install --grant-all-permissions --alias vsphere store/vmware/docker-volume-vsphere
0.12: Pulling from store/vmware/docker-volume-vsphere
27de4a000433: Download complete
Digest: sha256:696017e620fe8d29c883f36b5676135eaa2c2b3c3810f82931efb8027369a186
Status: Downloaded newer image for store/vmware/docker-volume-vsphere:0.12
Installed plugin store/vmware/docker-volume-vsphere:0.12

2. 查看安装是否成功

# docker plugin ls
ID                  NAME                DESCRIPTION                           ENABLED
2f833dcd59bc        vsphere:latest      VMWare vSphere Docker Volume plugin   true

3.远程到esxi主机,并将下载好的“vDVS驱动程序.VIB”安装(现已经将vib文件放到了/tmp文件夹下)

# esxcli software vib install -v /tmp/vmware-esx-vmdkops-0.12.ccfc38f.vib --no-sig-check
Installation Result
   Message: Operation finished successfully.
   Reboot Required: false
   VIBs Installed: VMWare_bootbank_esx-vmdkops-service_0.12.ccfc38f-0.0.1
   VIBs Removed:
   VIBs Skipped:

4.创建一个默认的数据卷,(默认为100M)

# docker volume create --driver=vsphere --name=MyVolume1
MyVolume1

查看volume

# docker volume ls
DRIVER              VOLUME NAME
vsphere:latest      MyVolume1@TestDatastore
# docker volume inspect MyVolume1
[
    {
        "Driver": "vsphere:latest",
        "Labels": {},
        "Mountpoint": "/mnt/vmdk/MyVolume1",
        "Name": "MyVolume1",
        "Options": {},
        "Scope": "global",
        "Status": {
            "access": "read-write",
            "attach-as": "independent_persistent",
            "capacity": {
                "allocated": "13MB",
                "size": "100MB"
            },
            "clone-from": "None",
            "created": "Fri Mar 24 07:46:36 2017",
            "created by VM": "ubuntu1",
            "datastore": "TestDatastore",
            "diskformat": "thin",
            "fstype": "ext4",
            "status": "detached"
        }
    }
]

5、创建一个10gb的存储卷(自定义大小)

$docker volume create --driver=vsphere --name=defaultDsVolume -o size=10gb
defaultDsVolume

6、在esxi主机上面也能对存储卷进行操作(权限控制,存储模式<厚置备零…>,调整大小,增删改查等)

官方参考文档:http://vmware.github.io/docker-volume-vsphere/documentation/admin-cli.html

6.1、多个数据存储支持

数据卷允许创建在任何地方,多主机之间能够互相访问。

6.2、在ESXi主机上,管理数据卷

[root@localhost:~]/usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup create --name=vmgroup1 --default-datastore=_VM_DS
vmgroup 'vmgroup1' is created. Do not forget to run 'vmgroup vm add' to add vm to vmgroup.
[root@localhost:~]/usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup ls
Uuid                                  Name      Description                Default_datastore  VM_list  
------------------------------------  --------  -------------------------  -----------------  -------  
11111111-1111-1111-1111-111111111111  _DEFAULT  This is a default vmgroup  _VM_DS                      
c821fcce-7f84-4e60-9773-1a94765f80de  vmgroup1                             _VM_DS
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup access ls --name=vmgroup1
Datastore  Allow_create  Max_volume_size  Total_size  
---------  ------------  ---------------  ----------  
_VM_DS     True          Unset            Unset    
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup ls
Uuid                                  Name      Description                Default_datastore  VM_list  
------------------------------------  --------  -------------------------  -----------------  -------  
11111111-1111-1111-1111-111111111111  _DEFAULT  This is a default vmgroup  _VM_DS                      
c821fcce-7f84-4e60-9773-1a94765f80de  vmgroup1                             _VM_DS 
create
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup create --name=vmgroup2 --default-datastore=_ALL_DS
Cannot use _ALL_DS as default datastore. Please use specific datastore name or _VM_DS special datastore
[root@localhost:~]  /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup access ls --name=vmgroup1
Datastore  Allow_create  Max_volume_size  Total_size  
---------  ------------  ---------------  ----------  
_VM_DS     True          Unset            Unset       
update
[root@localhost:~]  /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup update --name=vmgroup1 --description=New --new-name=new-vmgroup1 --default-datastore=_ALL_DS
Datastore datastore2 does not exist
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup update --name=vmgroup1 --description=New --new-name=new-vmgroup1 --default-datastore=_VM_DS
vmgroup modify succeeded
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup ls
Uuid                                  Name          Description                Default_datastore  VM_list  
------------------------------------  ------------  -------------------------  -----------------  -------  
11111111-1111-1111-1111-111111111111  _DEFAULT      This is a default vmgroup  _VM_DS                      
c821fcce-7f84-4e60-9773-1a94765f80de  new-vmgroup1  New                        _VM_DS  
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup access ls --name=new-vmgroup1
Datastore  Allow_create  Max_volume_size  Total_size  
---------  ------------  ---------------  ----------  
_VM_DS     True          Unset            Unset  

remove

删除vmgrop1,并删除下面所有的卷

[root@localhost:~]  /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup rm --name=vmgroup1 --remove-volumes

11111111-1111-1111-1111-111111111111 是默认卷,不允许被删除

[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup ls
Uuid                                  Name          Description                Default_datastore  VM_list  
------------------------------------  ------------  -------------------------  -----------------  -------  
11111111-1111-1111-1111-111111111111  _DEFAULT      This is a default vmgroup  _VM_DS                      
c821fcce-7f84-4e60-9773-1a94765f80de  new-vmgroup1  New                        _VM_DS     

访问控制:

[root@localhost:~]  /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup access -h
usage: vmdkops_admin.py vmgroup access [-h] {rm,add,set,ls} ...
optional arguments:
  -h, --help       show this help message and exit

Add or remove Datastore access and quotas for a vmgroup:

  {rm,add,set,ls}  action
    rm             Remove all access to a datastore for a vmgroup
    add            Add a datastore access for a vmgroup
    set            Modify datastore access for a vmgroup
    ls             List all access info for a vmgroup
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup update --name=new-vmgroup1 --description= --new-name=vmgroup1 --default-datastore=_VM_DS
vmgroup modify succeeded

你可能感兴趣的:(Docker,Vshere)