# Percona XtraDB operator with single node detects itself as peer

**URL:** <https://forums.percona.com/t/percona-xtradb-operator-with-single-node-detects-itself-as-peer/31570>\
**Category:** Percona Operator for MySQL\
**Created:** [July 11, 2024, 1:31pm UTC](https://forums.percona.com/t/percona-xtradb-operator-with-single-node-detects-itself-as-peer/31570 "2024-07-11T13:31:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joshua\_Sierles](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/joshua_sierles/32/13225_2.png) [@Joshua\_Sierles](https://forums.percona.com/u/Joshua_Sierles)\
**Post date:** [July 11, 2024, 1:31pm UTC](https://forums.percona.com/t/percona-xtradb-operator-with-single-node-detects-itself-as-peer/31570/1 "2024-07-11T13:31:49Z")

</div>

Hello,

I’m looking into the Percona XtraDB k8s Operator bootstrap behavior when running a single node. When booting a single node, it immediately goes into ‘crash mode’.

In theory, a first time single node should not setup replication, and should bootstrap, correct?

In the pxc node entrypoint, [this section always runs](https://github.com/percona/percona-xtradb-cluster-operator/blob/main/build/pxc-entrypoint.sh#L233-L237), and the node detects itself as a peer, which switches on replication. This sets `CLUSTER_JOIN`, which instructs the node not to bootstrap [here](https://github.com/fly-apps/percona-xtradb-cluster-operator/blob/js-fks/build/pxc-entrypoint.sh#L298-L300).

Perhaps I’m misunderstanding something. Thanks.

---

<div class="post-metadata">

**Author:** ![Pep\_Pla](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/pep_pla/32/9735_2.png) [@Pep\_Pla](https://forums.percona.com/u/Pep_Pla)\
**Post date:** [July 11, 2024, 4:11pm UTC](https://forums.percona.com/t/percona-xtradb-operator-with-single-node-detects-itself-as-peer/31570/2 "2024-07-11T16:11:54Z")

</div>

Hi Joshua,

The Percona Operator for MySQL based on Percona XtraDB Cluster does not support single node mode.

I think you need to use Percona Operator for MySQL based on Percona Server for MySQL.

> **[Percona Operator for MySQL](https://docs.percona.com/percona-operator-for-mysql/ps/index.html)**
>
> Kubernetes have added a way to
> manage containerized systems, including database clusters. This management is
> achieved by controllers, declared in configuration files. These controllers
> provide automation with the ability to create objects, such as a...

I hope this helps.

Pep

---

<div class="post-metadata">

**Author:** ![Joshua\_Sierles](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/joshua_sierles/32/13225_2.png) [@Joshua\_Sierles](https://forums.percona.com/u/Joshua_Sierles)\
**Post date:** [July 12, 2024, 9:15am UTC](https://forums.percona.com/t/percona-xtradb-operator-with-single-node-detects-itself-as-peer/31570/3 "2024-07-12T09:15:23Z")

</div>

Hmm, if it doesn’t support single nodes, why is that an option in Everest, which uses the XtraDB operator?

Also, what I’ve noticed in testing is that even with multi-node setups, this happens, so the first member of the StatefulSet never initializes. Surely this is a problem with my particular environment, but I haven’t figured out why yet.

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [July 12, 2024, 9:30am UTC](https://forums.percona.com/t/percona-xtradb-operator-with-single-node-detects-itself-as-peer/31570/4 "2024-07-12T09:30:00Z")

</div>

@Joshua_Sierles I want to correct @Pep_Pla a bit. PXC supports one node. We even have [cr-minimal.yaml](https://github.com/percona/percona-xtradb-cluster-operator/blob/main/deploy/cr-minimal.yaml) as an example to deploy a single node.

And we have lots of use cases where users deploy PXC with a single node for their dev/test environments (as it is obviously not recommended to run a single node in production).

As for the issue you are facing - it needs deeper investigation. It does not happen for me in minikube or GKE (checked just now) + we have a test for this use case. Can you attach the operator logs?

---

<div class="post-metadata">

**Author:** ![Pep\_Pla](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/pep_pla/32/9735_2.png) [@Pep\_Pla](https://forums.percona.com/u/Pep_Pla)\
**Post date:** [July 13, 2024, 10:37am UTC](https://forums.percona.com/t/percona-xtradb-operator-with-single-node-detects-itself-as-peer/31570/5 "2024-07-13T10:37:25Z")

</div>

It’s true; I typed too fast. Although you can run the PXC operator with one node, it is considered unsafe.

That’s why a CR option allows you to run in unsafe mode.

Check for **allowUnsafeConfigurations** in your cr file. It should be true. If it is false and the single cluster-pxc pod is killed, it does not restart properly.

> **[Percona Operator for MySQL - Custom Resource options](https://docs.percona.com/percona-operator-for-mysql/pxc/operator.html#perconaxtradbcluster-custom-resource-options)**
>
> Percona Operator for MySQL uses Custom Resources to manage options for the various components of the cluster.

I hope this helps.

---

<div class="post-metadata">

**Author:** ![Joshua\_Sierles](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/joshua_sierles/32/13225_2.png) [@Joshua\_Sierles](https://forums.percona.com/u/Joshua_Sierles)\
**Post date:** [July 13, 2024, 12:50pm UTC](https://forums.percona.com/t/percona-xtradb-operator-with-single-node-detects-itself-as-peer/31570/6 "2024-07-13T12:50:06Z")

</div>

Thanks. The issue must be with my k8s environment. I’ll post logs later. Meanwhile, I was able to get the newer MySQL operator working with a single node.

---

<div class="post-metadata">

**Author:** ![drew\_datajoint](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/drew_datajoint/32/11355_2.png) [@drew\_datajoint](https://forums.percona.com/u/drew_datajoint)\
**Post date:** [November 22, 2024, 5:52pm UTC](https://forums.percona.com/t/percona-xtradb-operator-with-single-node-detects-itself-as-peer/31570/7 "2024-11-22T17:52:13Z")

</div>

Hi @Sergey_Pronin ,  
Hope you are doing well!  
I’m experiencing the same issue, my environment:

- kOps provisioned EC2 based generic k8s cluster
- pxc-operator helm [here](https://github.com/percona/percona-helm-charts/blob/main/charts/pxc-operator/values.yaml)
- pxc-db helm [CrVersion: 1.15.1](https://github.com/percona/percona-helm-charts/blob/main/charts/pxc-db/values.yaml)

With all the default installation config, when I enable `unsafeFlags.*`, the operator pod still shows: `Setting safe defaults, updating cluster size oldSize: 1 newSize: 3` [here](https://github.com/percona/percona-xtradb-cluster-operator/blob/b2aa8159ea6a32321549e14efd25938c2ae17ec1/pkg/apis/pxc/v1/pxc_types.go#L1233)

After I set the pxc-operator’s image to `perconalab/percona-xtradb-cluster-operator:main` [here](https://github.com/percona/percona-xtradb-cluster-operator/blob/b2aa8159ea6a32321549e14efd25938c2ae17ec1/deploy/operator.yaml#L48), then the operator pod gets an error failing to launch PXC pods:

```auto
2024-11-22T17:23:34.821Z ERROR Reconciler error {"controller": "pxc-controller", "namespace": "percona", "name": "percona-qa", "reconcileID": "6085e80c-4a9e-4d54-bb2f-87900f7266a9", "error": "wrong PXC options: check safe defaults: PXC size must be at least 3. Set spec.unsafeFlags.pxcSize to true to disable this check", "errorVerbose": "PXC size must be at least 3. Set spec.unsafeFlags.pxcSize to true to disable this check\ngithub.com/percona/percona-xtradb-cluster-operator/pkg/apis/pxc/v1.(*PerconaXtraDBCluster).checkSafeDefaults\n\t/go/src/github.com/percona/percona-xtradb-cluster-operator/pkg/apis/pxc/v1/pxc_types.go:1202\ngithub.com/percona/percona-xtradb-cluster-operator/pkg/apis/pxc/v1.(*PerconaXtraDBCluster).CheckNSetDefaults\n\t/go/src/github.com/percona/percona-xtradb-cluster-operator/pkg/apis/pxc/v1/pxc_types.go:880\ngithub.com/percona/percona-xtradb-cluster-operator/pkg/controller/pxc.(*ReconcilePerconaXtraDBCluster).Reconcile\n\t/go/src/github.com/percona/percona-xtradb-cluster-operator/pkg/controller/pxc/controller.go:214\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:224\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1695\ncheck safe defaults\ngithub.com/percona/percona-xtradb-cluster-operator/pkg/apis/pxc/v1.(*PerconaXtraDBCluster).CheckNSetDefaults\n\t/go/src/github.com/percona/percona-xtradb-cluster-operator/pkg/apis/pxc/v1/pxc_types.go:881\ngithub.com/percona/percona-xtradb-cluster-operator/pkg/controller/pxc.(*ReconcilePerconaXtraDBCluster).Reconcile\n\t/go/src/github.com/percona/percona-xtradb-cluster-operator/pkg/controller/pxc/controller.go:214\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:224\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1695\nwrong PXC options\ngithub.com/percona/percona-xtradb-cluster-operator/pkg/controller/pxc.(*ReconcilePerconaXtraDBCluster).Reconcile\n\t/go/src/github.com/percona/percona-xtradb-cluster-operator/pkg/controller/pxc/controller.go:216\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:224\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1695"}
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:316
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:263
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.1/pkg/internal/controller/controller.go:224

```

and I checked the PerconaXtraDBCluster object `kubectl -n percona describe PerconaXtraDBCluster percona-qa`, there is no `spec.allowUnsafeConfigurations` nor `spec.unsafeFlags` at all

Once I manually `kubectl -n percona edit PerconaXtraDBCluster percona-qa` and add `spec.allowUnsafeConfigurations=true`, then the PXC is able to launch and only launched with one node.

```auto
NAME READY STATUS RESTARTS AGE
percona-op-pxc-operator-67697548f5-2sfpj 1/1 Running 0 31m
percona-qa-haproxy-0 2/2 Running 0 25m
percona-qa-haproxy-1 2/2 Running 0 25m
percona-qa-haproxy-2 2/2 Running 0 24m
percona-qa-pxc-0 3/3 Running 0 25m

```

---

<div class="post-metadata">

**Author:** ![Slava\_Sarzhan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/slava_sarzhan/32/3196_2.png) [@Slava\_Sarzhan](https://forums.percona.com/u/Slava_Sarzhan)\
**Post date:** [November 27, 2024, 12:42pm UTC](https://forums.percona.com/t/percona-xtradb-operator-with-single-node-detects-itself-as-peer/31570/8 "2024-11-27T12:42:58Z")

</div>

Hi @drew_datajoint, I have tested it today with PXC 1.15.1:

```auto
> helm install my-op percona/pxc-operator --namespace pxc
❯ helm install my-db percona/pxc-db --namespace pxc --set "unsafeFlags.pxcSize=true" --set "pxc.size=1"

❯ kubectl get pods -n pxc
NAME READY STATUS RESTARTS AGE
my-db-pxc-db-haproxy-0 2/2 Running 0 3m14s
my-db-pxc-db-haproxy-1 2/2 Running 0 114s
my-db-pxc-db-haproxy-2 2/2 Running 0 83s
my-db-pxc-db-pxc-0 3/3 Running 0 3m14s
my-op-pxc-operator-6868dd7fdc-qlwcj 1/1 Running 0 6m20s

```

As you can see, only one PXC pod was created. Could you please recheck it from your end.
