Add the container volume integration document

Add the help document to let users know how to
use the container volume integration in kubernetes and mesos.

Change-Id: If2ae2a2f5ca49b92925a8862eb71b29cf6f7c679
Partially-Implements: blueprint magnum-integrate-with-cinder
This commit is contained in:
wangqun 2016-03-03 08:29:48 +00:00
parent 503af17a2e
commit d207488c5b
2 changed files with 210 additions and 0 deletions

View File

@ -0,0 +1,209 @@
===============================================
Using Container Volume Integration Feature
===============================================
For Magnum user, we use Container Volume Integration in Kubernetes, Swarm
and Mesos. This document details instructions how to use the container volume
integration in Kubernetes, Swarm and Mesos.
Using container volume integration in Kubernetes
------------------------------------------------
1. Create the baymodel.
The new attribute volume-driver for a baymodel specifies the volume backend
driver to use when deploying a bay. The volume-driver value needs to be
specified as 'cinder' for kubernetes::
magnum baymodel-create --name k8sbaymodel \
--image-id fedora-21-atomic-5 \
--keypair-id testkey \
--external-network-id public \
--dns-nameserver 8.8.8.8 \
--flavor-id m1.small \
--docker-volume-size 5 \
--network-driver flannel \
--coe kubernetes \
--volume-driver cinder
2. Create the bay::
magnum bay-create --name k8sbay --baymodel k8sbaymodel --node-count 1
To enable the container volume integration in kubernetes, log into each minion
node of your bay and perform the following step 3, step 4, step 5 and step 6:
3. Configure kubelet::
sudo vi /etc/kubernetes/kubelet
Comment out the line::
#KUBELET_ARGS=--config=/etc/kubernetes/manifests --cadvisor-port=4194
Uncomment the line::
#KUBELET_ARGS="--config=/etc/kubernetes/manifests --cadvisor-port=4194 --cloud-provider=openstack --cloud-config=/etc/kubernetes/cloud_config"
**NOTE:** This is a temporary workaround, and Magnum team is working
on a long term solution to automate this step.
4. Enter OpenStack user credential::
sudo vi /etc/kubernetes/cloud_config
The username, tenant-name and region entries have been filled in with the
Keystone values of the user who created the bay. Enter the password
of this user on the entry for password::
password=ChangeMe
5. Restart Kubernetes services::
sudo systemctl restart kubelet
6. Run the docker container::
sudo docker run -v /usr/local/bin:/target jpetazzo/nsenter
Kubernetes container volume integration has configured by the above steps,
And you can use the kubernetes container volume now. The following steps is
an example for container volume integration with kubernetes bay..
1. Create the cinder volume::
cinder create --display-name=test-repo 1
ID=$(cinder create --display-name=test-repo 1 | awk -F'|' '$2~/^[[:space:]]*id/ {print $3}')
The command will generate the volume with a ID. The volume ID will be specified in
Step 2.
2. Create a container in this bay.
The following example illustrates how to mount an cinder volume for a pod.
Create a file (e.g nginx-cinder.yaml) describing a pod::
cat > nginx-cinder.yaml << END
apiVersion: v1
kind: Pod
metadata:
name: aws-web
spec:
containers:
- name: web
image: nginx
ports:
- name: web
containerPort: 80
hostPort: 8081
protocol: TCP
volumeMounts:
- name: html-volume
mountPath: "/usr/share/nginx/html"
volumes:
- name: html-volume
cinder:
# Enter the volume ID below
volumeID: $ID
fsType: ext4
END
**NOTE:** The cinder volume ID needs to be configured into the yaml file
so that an existing Cinder volume can be mounted in a pod by specifying
the volume ID in the pod manifest as follows::
volumes:
- name: html-volume
cinder:
volumeID: $ID
fsType: ext4
3. Create a pod with container::
magnum pod-create --manifest ./nginx-cinder.yaml --bay k8sbay
You can log in the container to check if existing the mountPath, and check
if your cinder volume status is 'in-use' by running the command 'cinder list'.
Using container volume integration in Swarm
-------------------------------------------
*To be filled in*
Using container volume integration in Mesos
-------------------------------------------
1. Create the baymodel.
One of the new attributes volume-driver for a baymodel specifies the volume
backend driver to use when deploying a bay. The volume-driver value needs to
be specified as rexray for Mesos.
The other new attributes rexray_preempt for a baymodel is an optional
parameter here which enables any host to take control of a volume
irrespective of whether other hosts are using the volume. If this is set to
false then mostly plugins ensure safety first for locking the volume::
magnum baymodel-create --name mesosbaymodel \
--image-id ubuntu-mesos \
--keypair-id testkey \
--external-network-id public \
--dns-nameserver 8.8.8.8 \
--master-flavor-id m1.magnum \
--docker-volume-size 4 \
--tls-disabled \
--flavor-id m1.magnum \
--coe mesos \
--volume-driver rexray \
--labels rexray-preempt=true
2. Create the mesos bay::
magnum bay-create --name mesosbay --baymodel mesosbaymodel --node-count 1
3. Create the cinder volume and a container in this bay::
cinder create --display-name=redisdata 1
Create the following mesos.json file::
cat > mesos.json << END
{
"id": "redis",
"container": {
"docker": {
"image": "redis",
"network": "BRIDGE",
"portMappings": [
{ "containerPort": 80, "hostPort": 0, "protocol": "tcp"}
],
"parameters": [
{ "key": "volume-driver", "value": "rexray" },
{ "key": "volume", "value": "redisdata:/data" }
]
}
},
"cpus": 0.2,
"mem": 32.0,
"instances": 1
}
END
**NOTE:** When the mesos bay is created using this baymodel, the mesos bay
will be configured so that an existing cinder volume can be mounted in a
container by configuring the parameters to mount the cinder volume in the
json file::
"parameters": [
{ "key": "volume-driver", "value": "rexray" },
{ "key": "volume", "value": "redisdata:/data" }
]
4. Using the REST API of Marathon::
MASTER_IP=$(magnum bay-show mesosbay | awk '/ api_address /{print $4}')
curl -X POST -H "Content-Type: application/json" \
http://${MASTER_IP}:8080/v2/apps -d@mesos.json
You can log in the container to check if existing the mountPath, and check
if your cinder volume status is 'in-use' by running the command 'cinder list'.

View File

@ -79,6 +79,7 @@ Developer Info
dev/bay-template-example.rst
dev/build-atomic-image.rst
dev/kubernetes-load-balancer.rst
dev/container-volume-integration.rst
dev/tls.rst
dev/mesos.rst
dev/functional-test.rst