Photon OS on vCloud Director 8.10 with Docker volume driver for vSphere

photon_vcloudair

Today my colleague and I had a discussion if it would be possible to build a Docker cluster at our service provider running vCloud Director 8.10. We gave it a try and were successful. So how could this be achieved.

Photon OS Installation on vCloud Director 8.10

First thing you need to do is to download the OVA File for Photon OS. The OVA File (Photon OS, Version 1.0 — OVA with virtual hardware v11) could be obtained here : https://vmware.github.io/photon/

Please be sure to run vCloud Director 8.10 to use hardware version 11 otherwise download hardware version 10.

Afterwards login to your vCloud Director Instance and use the “Add vApp from OVF” function under “My Cloud”.

vapp001

Follow the dialog and choose your VDC, your storage policy and a network with DHCP or a vCloud Director backed static IP-Pool network. Choose 2 vCPUs because this is the minimum requirement for Photon OS and for our test 2 GB RAM should also be enough. The disk size does not matter for our test so you could choose any size here.

Wait until the import was successful.  Now start the vApp.

vapp002

Under Virtual Machines find the allocated IP-Address and connect to it via any SSH client. Username is root and initial password is “changeme”. First thing that needs to be done is to change the password. Please take care that no dictionary word is being used.

Docker is not initially started and enabled. To do this we have to run the following commands:

systemctl start docker
systemctl enable docker

The detailed procedure could be found here:
https://github.com/vmware/photon/wiki/Running-Photon-OS-on-vSphere

Docker Volume Driver for vSphere/vCloud Installation

The Docker Volume Driver consists of two parts. The driver inside the Photon OS Instance and the VIB driver on the vCloud Director ESXi Hosts. Only when both components are installed we will be able to provide persistent storage for our docker containers.

To install the docker driver in the Photon OS machine login to the machine via ssh and just run the following command:

rpm -Uvh https://github.com/vmware/docker-volume-vsphere/releases/download/0.7/docker-volume-vsphere-0.7-1.x86_64.rpm

The output should look like this:

vapp003

If you run the docker volume ls the output should be empty. With this we installed the volume driver on the Photon OS.

The second part is to install the driver for the vCloud Director ESXi Hosts. This part could be a bit tricky if you depend on a provider like we do. But after a short discussion and explanation the provider was ready to help us out with this. The installation is quite easy.

First you need to download the VIB File. The file could be obtained here:
https://github.com/vmware/docker-volume-vsphere/releases

Second step is to upload the VIB file to your ESXi Host TMP directory.
scp vmware-esx-vmdkops-0.7.vib root@esxi01.local:/tmp
You can use SCP or any other method to copy the file to you ESXi host.

Afterwards you need to install the VIB to the host. No reboot is required for this operation. Connect via SSH to your ESXi host and run the following command:
esxcli software vib install --no-sig-check -v /tmp/vmware-esx-vmdkops-0.7.vib

The output should look like this:

vapp004

Now we are able to see which disks have already been created via docker volume driver. Just run this command:
/usr/lib/vmware/vmdkops/bin/vmdkops_admin.py ls

In the beginning the output will be empty. But if we have created some docker volumes the output should look similar to this:

vapp005

The installation could also be done via “Offline Depot” or “vSphere Update Manager”. Detailed information about the process could be found here:
https://vmware.github.io/docker-volume-vsphere/user-guide/install/

Now that we prepared the infrastructure we should be able to create shared docker volumes.

Docker Volume creation

So let us create our first vSphere/vCloud backed Docker volume.

docker volume create --driver=vmdk --name=torben.hamburg.volume -o size=10gb

A lot more parameters are possible here like: policy, diskformat, access, fstype you will find a lot of examples on this page:
https://vmware.github.io/docker-volume-vsphere/user-guide/docker-volume-cli/

With docker volume ls we are now able to see our newly created volume.

vapp006

On the vSphere / vCloud site the VMDK will be created on the same datastore the Photon OS is running. You could also adjust this by setting the policy parameter when creating the disk. The VMDK is stored underneath the folder /dockvols

vapp008

We created our first volume which we would like to attach to a docker instance.

Docker Volume usage

Now let us start a docker instance and mount the newly created volume into it. We can simply doing this by running the following command:

docker run --rm -it -v torben.hamburg.volume:/mnt/myvol busybox

This will start a busybox docker image and mount the volume. Afterwards we are able to consume the volume we created. The output for the docker run command should look like this:

vapp009

The magic that happens in the background is that the Photon OS VM is mounting the VMDK to its virtual machine.

vapp010

If you are able to logon with SSH to the ESXi Host and run the previously described vmdkops admin python script you are also able to see the mount status on the ESXi Host.

vapp011

Conclusion

With those techniques described above you are now be able to setup a highly available docker cluster based on vSphere/vCloud. For vCloud you need to be able to install the VIB to your hosts. Our provider was very helpful with this. I will dive deeper into the setup of the cluster in my next article.

5 responses to “Photon OS on vCloud Director 8.10 with Docker volume driver for vSphere”

  1. great article

    Liked by 1 person

  2. Hi Torben,
    Great article. Maybe you could assist me with the following.
    We are a vcloud service provider, currently considering implementing this functionality. But two concerns comes to our mind:

    1) If two Dockers VMs from a different tenant are coexisting in the same datastore, do they have visibility to each others docker volumes, or just to their own?
    2) Is billing time: Tenant “A” has a Docker VM that deployed 3 docker volumes, but only one is mounted. How do you bill them? Do you have any visibility in vcloud or vcenter to be able to identify the owner of these volumes?

    Thanks in advance.

    Liked by 1 person

    1. Hello Andres,
      I am trying to answer your questions. Hopefully that helps you. Otherwise please let me know and we can have a phone call.

      1.) VMware has put a lot of time into the product since I created this article. There is a Multi-tenancy support available now. There you are able to create separate access to volumes.
      Please read the following link:

      http://vmware.github.io/docker-volume-vsphere/documentation/tenancy.html
      I guess this should do the trick.

      But VMware is also planning to implement a vSphere Plugin. I am not sure when this will be released.

      https://github.com/vmware/docker-volume-vsphere/blob/master/docs/misc/docker-volume-auth-proposal.v1_2.md

      2.)
      Here I only have two solutions .The first one is ESXi hosed based. You are able to run the following command to get ALL created volumes and not only the ATTACHED ones.
      /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py volume ls
      This command has changed since I created the article.

      The second solution is to export all VMDKs that have been created into the /dockvols folder and try to match those to the customers.

      Greetings
      Torben

      Like

  3. Hi Torben.

    Great article. We are using vsphere driver at our company, but run into resizing problem.

    Is there any procedure or any solution for resizing volumes?

    Like

    1. Actually there is no resize command available. The only supported way is to attach the volume to a Linux system that is able to read the filesystem and use vSphere mechanism to enlarge the disk and remount it with the volume driver. Another way would be to create a new volume with larger size and copy data over. In this case the docker container does not need to be shut down. Hope that helps

      Like

Leave a comment

Blog at WordPress.com.