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, and the node detects itself as a peer, which switches on replication. This sets CLUSTER_JOIN, which instructs the node not to bootstrap here.
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.
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?
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.
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.
With all the default installation config, when I enable unsafeFlags.*, the operator pod still shows: Setting safe defaults, updating cluster size oldSize: 1 newSize: 3here
After I set the pxc-operator’s image to perconalab/percona-xtradb-cluster-operator:mainhere, then the operator pod gets an error failing to launch PXC pods:
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.
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