Bundle Walk-Through

From ClusterLabs

Jump to: navigation, search

Overview

This is a walk-through for demonstrating Pacemaker's "bundle" feature.

Prerequisites

Choose what OS (including version) you wish to use on the cluster nodes and inside the containers. The cluster nodes must have Pacemaker 1.1.17 or later; the containers must have Pacemaker 1.1.12 or later (for Pacemaker Remote support). This walk-through will use CentOS 7.3 for both (with Pacemaker 1.1.17 packages installed from RPM, for the cluster nodes); the differences for other OSes should be minor.

Configure a test cluster of at least two cluster nodes, with no Pacemaker Remote nodes.

Each cluster node should have at least 450MB free disk space.

Preparation

Repeat on every node:

# yum install docker
  • Enable docker to run at boot:
# systemctl enable --now docker
  • Pull a Docker base image for the container OS:
# docker pull centos:centos7
  • Create some infrastructure for the walk-through:
# mkdir -p /root/bundle-walk-through \
  /var/log/pacemaker/bundles/httpd-bundle-{0,1,2} \
  /var/local/containers/httpd-bundle-{0,1,2}
# for i in 0 1 2; do cat >/var/local/containers/httpd-bundle-$i/index.html <<EOF
<html>
<head><title>Bundle test</title></head>
<body>
<h1>httpd-bundle-$i @ $(hostname)</h1>
</body>
</html>
EOF
done
  • Create a Dockerfile for the walk-through (replace centos:centos7 with your base image). Here, we're using apache as an example of a service to be containerized:
# cat >/root/bundle-walk-through/Dockerfile <<EOF
FROM centos:centos7

RUN yum update -y
RUN yum install -y httpd bind-utils curl lsof wget which
RUN yum install -y pacemaker pacemaker-remote resource-agents
EOF

Build a container image

This needs to be done on every node. Once is sufficient, but you should repeat this step if you make changes to the Dockerfile.

  • Build the image:
# cd /root/bundle-walk-through
# docker rmi pcmktest:http
# docker build -t pcmktest:http .
  • If desired, verify that the image was created:
# docker images

The output should look something like:

REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
pcmktest            http                aab04ad64ab0        About a minute ago   412 MB
centos              centos7             98d35105a391        12 days ago          192 MB
  • You may encounter a docker "waiting for lo to become free" bug. Reboot the node to avoid this possibility.

Configure the cluster

  • From any one node, start the cluster, and configure a bundle using the test image. Replace the IP address with something appropriate (three sequential IPs need to be available):
# pcs cluster start --all --wait
# cibadmin --modify --allow-create --scope resources -X '<bundle id="httpd-bundle">
  <docker image="pcmktest:http" replicas="3" options="--log-driver=journald" />
  <network ip-range-start="192.168.122.131" host-interface="eth0" host-netmask="24">
    <port-mapping id="httpd-port" port="80"/>
  </network>
  <storage>
    <storage-mapping id="httpd-root"
      source-dir-root="/var/local/containers"
      target-dir="/var/www/html"
      options="rw"/>
    <storage-mapping id="httpd-logs"
      source-dir-root="/var/log/pacemaker/bundles"
      target-dir="/etc/httpd/logs"
      options="rw"/>
  </storage>
  <primitive class="ocf" id="httpd" provider="heartbeat" type="apache"/>
</bundle>'
  • Test away. Three containers should come up, and apache should be reachable at the specified IPs. This feature is experimental, and not all things you'd expect to do with a regular resource are implemented for bundles yet. You can also modify the bundle configuration to try different values. The docker instances will be named like httpd-bundle-docker-0, so you can use standard docker commands with that (e.g. docker inspect or docker exec).
Personal tools