[ClusterLabs] Containers as pcs resource

Ken Gaillot kgaillot at redhat.com
Wed Nov 11 15:40:55 EST 2020


On Tue, 2020-11-10 at 21:00 +0530, Amith Prakash wrote:
> Hello,
> 
> Hope you are doing well. 
> 
> I have recently started playing with pacemaker and I had couple of
> questions. 
> 
> I have an already up&running container which I want to add to
> pacemaker as a resource. 
> I also want to use the pacemaker  to enable/disable/manage/unmanage,
> etc., operations for the same container.  
> 
> I tried doing it via systemd service, by writing a script to help
> with management of the container. It did not work as expected. 

Containers can be managed as systemd services, using a custom unit
file. If you have the podman command, it can create the unit file for
you with "podman generate systemd --name <container-name> --files".

As with any systemd resource, you shouldn't enable, start, or stop the
unit with systemctl, but with Pacemaker configuration.

> Can pacemaker add a resource, when it's not involved in its creation?
> I.e. to say, can an already running container be added as a resource
> (without having to stop/start the container again)

It can be added, but Pacemaker might restart it.

> Also, the examples around having containers as a pacemaker resource
> are scarce, from my searches. Is there anything in particular I can
> refer, for better clarity? 

While a systemd unit file would work, the preferred way to manage
containers in Pacemaker is through "bundles":

https://clusterlabs.org/pacemaker/doc/en-US/Pacemaker/2.0/html-single/Pacemaker_Explained/index.html#s-resource-bundle

Bundles allow you to define a Docker, rkt, or podman container, with
any number of replicas you want, along with an IP address and/or port
mappings for each replica (if desired), disks exported from the host
(if desired), and a service monitored inside the container (if
desired).

There is a walk-through on the wiki:

https://wiki.clusterlabs.org/wiki/Bundle_Walk-Through

Hope that helps!

> Sorry for my naiveity. Please consider me a noob here.  :)
> 
> Looking forward to your guidance.
> 
> Regards,
> Amith
> 
> _______________________________________________
> Manage your subscription:
> https://lists.clusterlabs.org/mailman/listinfo/users
> 
> ClusterLabs home: https://www.clusterlabs.org/
-- 
Ken Gaillot <kgaillot at redhat.com>



More information about the Users mailing list