How to Install Percona XtraDB Cluster using Helm?

Is there an updated guide to install Percona using Helm?

This is my configuration

OS Centos 7

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-07T21:20:10Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.8", GitCommit:"fd5d41537aee486160ad9b5356a9d82363273721", GitTreeState:"clean", BuildDate:"2021-02-17T12:33:08Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"linux/amd64"}


$ kubectl get nodes
NAME          STATUS   ROLES                      AGE    VERSION
trr-its-kd1   Ready    controlplane,etcd,worker   217d   v1.19.8
trr-its-kd2   Ready    controlplane,etcd,worker   121d   v1.19.8
trr-its-kd3   Ready    controlplane,etcd,worker   213d   v1.19.8

I am installing following this guide

When I run the command:

helm install my-op percona/pxc-operator

I get these warnings:

W0716 14:47:04.486697 12622 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0716 14:47:04.527092 12622 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0716 14:47:04.527206 12622 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0716 14:47:04.547753 12622 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0716 14:47:06.592396 12622 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0716 14:47:06.629761 12622 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0716 14:47:06.674587 12622 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0716 14:47:06.711312 12622 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition

When i run:

helm install my-db percona/pxc-db

I get these errors:

W0716 14:48:14.612676 12646 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0716 14:48:14.648976 12646 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0716 14:48:14.656417 12646 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0716 14:48:14.656622 12646 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
Error: rendered manifests contain a resource that already exists. Unable to continue with install: Secret “my-db-pxc-db” in namespace “percona” exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key “app.kubernetes.io/managed-by”: must be set to “Helm”; annotation validation error: missing key “meta.helm.sh/release-name”: must be set to “my-db”; annotation validation error: missing key “meta.helm.sh/release-namespace”: must be set to “percona”

Can you help me?

1 Like

Hello @Giancarlo74 ,

you can ignore the warnings, we will fix them in the upcoming releases.
As for the error:

Error: rendered manifests contain a resource that already exists. Unable to continue with install: Secret “my-db-pxc-db” in namespace “percona” exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key “app.kubernetes.io/managed-by”: must be set to “Helm”; annotation validation error: missing key “meta.helm.sh/release-name”: must be set to “my-db”; annotation validation error: missing key “meta.helm.sh/release-namespace”: must be set to “percona”

Do you have any secret already created? Is it a leftover from some previous deployment?

1 Like

it may be, because I have done a thousand tests
Unfortunately that helm project doesn’t work
At least by following these instructions

Today I reset the Kubernetes cluster
These are the commands I ran, where you can see that I also create non-existent namespaces

$ kubectl create namespace pxc-operator

namespace/pxc-operator created

$ helm install my-op percona/pxc-operator -n pxc-operator

W0719 10:47:19.838608 8070 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0719 10:47:19.842635 8070 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0719 10:47:19.859020 8070 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0719 10:47:19.859037 8070 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0719 10:47:21.926933 8070 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0719 10:47:21.971388 8070 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0719 10:47:22.003204 8070 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0719 10:47:22.032297 8070 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
NAME: my-op
LAST DEPLOYED: Mon Jul 19 10:47:22 2021
NAMESPACE: pxc-operator
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:

  1. pxc-operator deployed.
    If you would like to deploy an pxc-cluster set cluster.enabled to true in values.yaml
    Check the pxc-operator logs
    export POD=$(kubectl get pods -l app=my-op-pxc-operator --namespace pxc-operator --output name)
    kubectl logs $POD --namespace=pxc-operator

$ kubectl create namespace percona

namespace/percona created

$ helm install my-db percona/pxc-db --namespace percona \
>   --set pxc.volumeSpec.resources.requests.storage=2Gi \
>   --set backup.enabled=false \
>   --set cluster.enabled=true

W0719 10:48:38.510310 8136 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0719 10:48:38.546447 8136 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0719 10:48:38.556285 8136 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0719 10:48:38.556317 8136 warnings.go:70] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
NAME: my-db
LAST DEPLOYED: Mon Jul 19 10:48:38 2021
NAMESPACE: percona
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:

  1. To get a MySQL prompt inside your new cluster you can run:

    ROOT_PASSWORD=kubectl -n percona get secrets my-db-pxc-db -o jsonpath="{.data.root}" | base64 --decode
    kubectl -n percona exec -ti
    my-db-pxc-db-pxc-0 – mysql -uroot -p"$ROOT_PASSWORD"

  2. To connect an Application running in the same Kubernetes cluster you can connect with:

$ kubectl run -i --tty --rm percona-client --image=percona --restart=Never \
  -- mysql -h my-db-pxc-db-proxysql.percona.svc.cluster.local -uroot -p"$ROOT_PASSWORD"

ROOT_PASSWORD=kubectl -n percona get secrets my-db-pxc-db -o jsonpath="{.data.root}" | base64 --decode`

$ kubectl -n percona exec -ti \
>       my-db-pxc-db-pxc-0 -- mysql -uroot -p"$ROOT_PASSWORD"

Error from server (NotFound): pods “my-db-pxc-db-pxc-0” not found

the problem is in the second command,

$ helm install my-db percona/pxc-db --namespace percona \
>   --set pxc.volumeSpec.resources.requests.storage=2Gi \
>   --set backup.enabled=false \
>   --set cluster.enabled=true

which as you can see from the previous logs does not create any clusters

From the following commands I see that only secrets are created

$ kubectl -n percona get all

No resources found in percona namespace.

$ kubectl -n percona get secrets

NAME TYPE DATA AGE
default-token-dtkjr kubernetes.io/service-account-token 3 17m
my-db-pxc-db Opaque 7 17m
my-db-pxc-db-ssl kubernetes.io/tls 3 17m
my-db-pxc-db-ssl-internal kubernetes.io/tls 3 17m
sh.helm.release.v1.my-db.v1 helm.sh/release.v1 1 17m

1 Like

You are installing the operator in namespace pxc-operator and trying to create the cluster in percona namespace.

It works, but only if operator is deployed in cluster-wide mode.

In your case the custom resource object is created in percona namespace, but the operator does not know about it.

We already have the PR to add support for cluster-wide via helm: Add support for cluster wide feature by fatz · Pull Request #70 · percona/percona-helm-charts · GitHub

We need to test it first to merge it and claim that it works as expected.
We are going to test this improvement here: https://jira.percona.com/browse/K8SPXC-827

1 Like

so do i have to work on only one namespace?

1 Like

You have few options:

  1. operator per namespace
  2. install cluster-wide without helm
  3. wait for cluster-wide support in helm