Can't set up 1 node pxc on kubernetes cluster

I’m a newbie of percona xtradb cluster. When i set up the size of pxc to 1 to deploy mysql server to kubernetes cluster the result is 3 pxc node. This is my code:

apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
name: cluster1
spec:
crVersion: 1.13.0
pxc:
size: 1
image: perconalab/percona-xtradb-cluster:8.0.32-24.2
resources:
requests:
memory: 500M
cpu: 300m
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 10G

and this is my result:
cluster1-pxc-0 2/2 Running 0 2d16h
cluster1-pxc-1 2/2 Running 1 (2d16h ago) 2d16h
cluster1-pxc-2 2/2 Running 0 2d16h
Can anyone explain this to me?

Hello @Tu_n_Nguy_n_Thuc
Is there any specific reason for using a 1 node PXC cluster?

The size of the Percona XtraDB cluster must be 3 or 5 for High Availability. other values are allowed if the spec.allowUnsafeConfigurations key is set to true
Ref: Custom Resource options - Percona Operator for MySQL based on Percona XtraDB Cluster

Example:

  allowUnsafeConfigurations: true

  pxc:
    size: 1
    image: percona/percona-xtradb-cluster:8.0.32-24.2
kubectl apply -f deploy/cr.yaml -n pxc

$ kubectl get pods -n pxc
NAME                                               READY   STATUS    RESTARTS   AGE
percona-xtradb-cluster-operator-77c67b5dfc-ckjf8   1/1     Running   0          21m
cluster1-pxc-0                                     3/3     Running   0          56s
cluster1-haproxy-0                                 2/2     Running   0          21m
cluster1-haproxy-1                                 2/2     Running   0          18m
cluster1-haproxy-2                                 2/2     Running   0          17m

If you are looking for single primary setup , you might check Percona Operator for MySQL
Note: It is a tech preview release and it is not recommended for production environments . As of today, we recommend using Percona Operator for MySQL based on Percona XtraDB Cluster, which is production-ready and contains everything you need to quickly and consistently deploy and scale MySQL clusters in a Kubernetes-based environment, on-premises or in the cloud.

1 Like

Thank you for your answer, I have read the document about percona XtraDB cluster and it say that I can create 1 node PXC cluster so I just want to test this case.