How does the operator know which pods form a cluster and which do not?

Description:

I am trying to deploy a Percona XtraDB cluster of 3 nodes in kubernetes, distributed in 3 zones, so that each pod located in a different zone uses a ceph backend located in that zone (achieving ceph level data isolation per zone).

The issue is that kubernetes does not allow to define multiple ceph clusters in the same StorageClass. The idea I had had to achieve this was to use 3 different pxc-db values each with a different StorageClass. However, I don’t know how to do it so that these values form the same cluster.

What values or labels does the operator use to manage the cluster and to know which pods belong to a cluster or another?

I have searched for information on this in the docs but I have not found anything relevant related to it.

Hey @dagonzalez ,

I feel that you want a good thing, but thinking about it in a wrong way.

In short, you need a single PXC object, single storage class and a properly configured CSI (Container storage interface).

  1. To distribute the PXC nodes with the Operator you need to set proper affinity configuration. Read our docs and affinity k8s docs. And create just one PXC per cluster.
  2. The result of it, will be a stateful set with affinity configuration. Kubernetes will make sure that Pods of a single cluster are put into different zones.
  3. For Ceph to support this setup, you should have a single storage class. But that storage class would be topology aware and understand the all the constraints that are enforced by the affinity configuration. That is how CSIs in the public clouds work today (check AWS CSI or GCP for example).

If you feel that I misunderstood, let’s discuss more.