You are looking at the documentation of a prior release. To read the documentation of the latest release, please visit here.

New to KubeDB? Please start here.

Deploy Percona XtraDB from private Docker registry

KubeDB operator supports using private Docker registry. This tutorial will show you how to use KubeDB to run Percona XtraDB database using private Docker images.

Before You Begin

  • Read about PerconaXtraDBVersion to learn how it is used.

  • You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. If you do not already have a cluster, you can create one by using kind.

  • You will also need a docker private registry or private repository. In this tutorial we will use private repository of docker hub.

  • You have to push the required images from KubeDB’s Docker hub account into your private registry. For PerconaXtraDB, push DB_IMAGE, EXPORTER_IMAGE of following PerconaXtraDBVersions, where deprecated is not true, to your private registry.

    $ kubectl get perconaxtradbversions,VERSION:.spec.version,DB_IMAGE:.spec.db.image,EXPORTER_IMAGE:.spec.exporter.image,DEPRECATED:.spec.deprecated
    NAME          VERSION   DB_IMAGE                            EXPORTER_IMAGE                   DEPRECATED
    5.7           5.7       kubedb/percona:5.7                  kubedb/mysqld-exporter:v0.11.0   <none>
    5.7-private   5.7       kubedb/percona-xtradb-cluster:5.7   kubedb/mysqld-exporter:v0.11.0   <none>

    Docker hub repositories:

  • Update KubeDB catalog for private Docker registry. Ex:

    kind: PerconaXtraDBVersion
      name: 5.7-cluster
        image: PRIVATE_REGISTRY/percona-xtradb-cluster:5.7
        image: PRIVATE_REGISTRY/mysqld-exporter:v0.11.0
        image: PRIVATE_REGISTRY/busybox
        databasePolicyName: percona-xtradb-db
            name: perconaxtradb-backup-5.7
            name: perconaxtradb-restore-5.7
      version: "5.7"
  • To keep things isolated, this tutorial uses a separate namespace called demo throughout this tutorial. Run the following command to prepare your cluster for this tutorial:

    $ kubectl create ns demo
    namespace/demo created

Create ImagePullSecret

ImagePullSecrets is a type of a Kubernetes Secret whose sole purpose is to pull private images from a Docker registry. It allows you to specify the url of the docker registry, credentials for logging in and the image name of your private docker image.

Run the following command, substituting the appropriate uppercase values to create an image pull secret for your private Docker registry:

$ kubectl create secret docker-registry -n demo myregistrykey \
  --docker-server=DOCKER_REGISTRY_SERVER \
  --docker-username=DOCKER_USER \
  --docker-email=DOCKER_EMAIL \
secret/myregistrykey created

If you wish to follow other ways to pull private images see official docs of kubernetes.

NB: If you are using kubectl 1.9.0, update to 1.9.1 or later to avoid this issue.

Install KubeDB operator

When installing KubeDB operator, set the flags --docker-registry and --image-pull-secret to appropriate value. Follow the steps to install KubeDB operator properly in cluster so that it points to the Docker registry you wish to pull images from.

Deploy Percona XtraDB database from Private Registry

While deploying PerconaXtraDB from private repository, you have to add myregistrykey secret in the .spec.imagePullSecrets field of the PerconaXtraDB object. Below is the PerconaXtraDB object we will create.

kind: PerconaXtraDB
  name: px-pvt-reg
  namespace: demo
  version: "5.7-cluster"
  replicas: 3
  storageType: Durable
    storageClassName: "standard"
    - ReadWriteOnce
        storage: 50Mi
      - name: myregistrykey
  terminationPolicy: WipeOut

Now run the command to deploy this PerconaXtraDB object:

$ kubectl create -f created

To check if the images pulled successfully from the repository, see if the PerconaXtraDB is in running state:

$ kubectl get pods -n demo
px-pvt-reg-0   1/1       Running   0          56s

Cleaning up

To cleanup the Kubernetes resources created by this tutorial, run:

kubectl patch -n demo perconaxtradb/px-pvt-reg -p '{"spec":{"terminationPolicy":"WipeOut"}}' --type="merge"
kubectl delete -n demo perconaxtradb/px-pvt-reg

kubectl delete ns demo

Next Steps