Azure Blob Support

We are using Azure File Storage as a persistent solution. It’s not as clean as I’d like it to be. There’s no convoy support, so Rancher won’t make volumes for you on stack/service start. You will need to create the volumes as a prerequisite step before starting the container that’s going to use it.


First we install the docker azurefile volume driver on each of the rancher agent hosts. There are a number of ways to do it. We bootstrap this with puppet.

You can get the driver here: https://github.com/Azure/azurefile-dockervolumedriver


Next we run a very simple “run-once” rancher-catalog entry to initialize the volumes. This runs globally on each of our agent hosts in an environment.

All this does is run the docker volume create command with the right options for you on each host. If you use this image, the share is the VOLUME_NAME prefixed with the Rancher environment name.

docker-compose.yml

volume:
  image: leankit/rancher-azurefile-volume
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  environment:
    VOLUME_NAME: ${name}
    VOLUME_GID: 'x${gid}'
    VOLUME_UID: 'x${uid}'
    VOLUME_FILEMODE: 'x${filemode}'
    VOLUME_DIRMODE: 'x${dirmode}'
    VOLUME_NOLOCK: '${nolock}'
  labels:
    io.rancher.scheduler.global: 'true'
    io.rancher.container.start_once: 'true'
    io.rancher.container.hostname_override: container_name
    io.rancher.container.pull_image: always

rancher-compose.yml

.catalog:
  name: "AzureFile Volume"
  version: "v0.0.1"
  description: Create an Azure File Share Volume.
  uuid: azurefile-volume:v0.0.1
  questions:
    - variable: name
      label: Volume Name
      type: string
      required: true
      default: rabbitmq
    - variable: uid
      label: UID
      type: string
      description: UID for owner of mounted files.
      required: true
      default: '0'
    - variable: gid
      label: GID
      type: string
      description: GID for owner of mounted files.
      required: true
      default: '0'
    - variable: filemode
      label: File Mode
      type: string
      description: Mode for mounted files.
      required: true
      default: '0600'
    - variable: dirmode
      label: Directory Mode
      type: string
      description: Mode for directories (executable is important).
      required: true
      default: '0755'
    - variable: nolock
      label: nolock
      type: boolean
      label: nolock mount option
      required: true
      default: true

Once the volume is created globally, we can run the service that’s going to use it
An example docker-compose.yml for a rabbitmq service

rabbit:
  image: rabbitmq:3.6.5
  ports:
    - 5672:5672/tcp
    - 15672:15672/tcp
    - 25672:25672/tcp
  volumes:
  - rabbitmq:/var/lib/rabbitmq
  volume_driver: azurefile
  environment:
    RABBITMQ_DEFAULT_USER: "${username}"
    RABBITMQ_DEFAULT_PASS: "${password}"
    RABBITMQ_DEFAULT_VHOST: "/${username}"
  labels:
    io.rancher.container.hostname_override: container_name
    io.rancher.container.pull_image: always
2 Likes