configure cinder volume for docker storage

these templates will now allocate a volume from cinder for each minion
and configure them volume as direct lvm docker storage.
This commit is contained in:
Lars Kellogg-Stedman 2015-01-21 16:46:36 -05:00
parent 7ae6e54204
commit 88a8bd0eef
3 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,20 @@
#!/bin/sh
. /etc/sysconfig/heat-params
DOCKER_DEV=/dev/disk/by-id/virtio-${DOCKER_VOLUME:0:20}
if ! [ -b $DOCKER_DEV ]; then
echo "ERROR: device $DOCKER_DEV does not exist" >&2
exit 1
fi
pvcreate $DOCKER_DEV
vgcreate docker $DOCKER_DEV
lvcreate --wipesignatures y -n data docker -l 95%VG
lvcreate --wipesignatures y -n metadata docker -l 5%VG
cat > /etc/sysconfig/docker-storage <<EOF
DOCKER_STORAGE_OPTIONS="--storage-opt dm.blkdiscard=false --storage-opt dm.metadatadev=/dev/docker/metadata --storage-opt dm.datadev=/dev/docker/data --storage-opt dm.fs=xfs"
EOF

View File

@ -8,4 +8,5 @@ write_files:
KUBE_ALLOW_PRIV="$KUBE_ALLOW_PRIV"
KUBE_MASTER_IP="$KUBE_MASTER_IP"
WAIT_HANDLE="$WAIT_HANDLE"
DOCKER_VOLUME="$DOCKER_VOLUME"

View File

@ -34,6 +34,13 @@ parameters:
constraints:
- allowed_values: ["true", "false"]
docker_volume_size:
type: string
description: >
size of a cinder volume to allocate to docker for container/image
storage
default: 25
# The following are all generated in the parent template.
kube_master_ip:
type: string
@ -90,6 +97,7 @@ resources:
"$KUBE_ALLOW_PRIV": {get_param: kube_allow_priv}
"$KUBE_MASTER_IP": {get_param: kube_master_ip}
"$WAIT_HANDLE": {get_resource: node_wait_handle}
"$DOCKER_VOLUME": {get_resource: docker_volume}
add_to_docker_group:
type: "OS::Heat::SoftwareConfig"
@ -97,6 +105,12 @@ resources:
group: ungrouped
config: {get_file: fragments/add-to-docker-group.sh}
configure_docker_storage:
type: "OS::Heat::SoftwareConfig"
properties:
group: ungrouped
config: {get_file: fragments/configure-docker-storage.sh}
configure_kubernetes_minion:
type: "OS::Heat::SoftwareConfig"
properties:
@ -148,6 +162,7 @@ resources:
- config: {get_resource: kube_user}
- config: {get_resource: kube_examples}
- config: {get_resource: add_to_docker_group}
- config: {get_resource: configure_docker_storage}
- config: {get_resource: configure_kubernetes_minion}
- config: {get_resource: docker_service}
- config: {get_resource: enable_services}
@ -187,6 +202,17 @@ resources:
port_id:
get_resource: kube_node_eth0
docker_volume:
type: "OS::Cinder::Volume"
properties:
size: {get_param: docker_volume_size}
docker_volume_attach:
type: "OS::Cinder::VolumeAttachment"
properties:
instance_uuid: {get_resource: kube_node}
volume_id: {get_resource: docker_volume}
outputs:
kube_node_ip: