This is an Enterprise-only feature. Please install KubeDB Enterprise Edition to try this feature.
New to KubeDB? Please start here.
KubeDB operator supports using a private Docker registry. This tutorial will show you how to use KubeDB to run ProxySQL using private Docker images.
Read concept of ProxySQLVersion Catalog to learn detail concepts of
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 have to push the required images from KubeDB’s Dockerhub account into your private registry. For proxysql, push
EXPORTER_IMAGE of following ProxySQLVersion, where
deprecated is not true, to your private registry. Currently, KubeDB includes the following ProxySQLVersion object.
$ kubectl get proxysqlversions -o=custom-columns=NAME:.metadata.name,VERSION:.spec.version,PROXYSQL_IMAGE:.spec.proxysql.image,EXPORTER_IMAGE:.spec.exporter.image,DEPRECATED:.spec.deprecated NAME VERSION PROXYSQL_IMAGE EXPORTER_IMAGE DEPRECATED 2.0.4 2.0.4 kubedb/proxysql:v2.0.4 kubedb/proxysql-exporter:v1.1.0 <none>
Docker hub repositories:
Update KubeDB catalog for private Docker registry. Ex:
apiVersion: catalog.kubedb.com/v1alpha1 kind: ProxySQLVersion metadata: name: "2.0.4" labels: app: kubedb spec: version: "2.0.4" db: image: "PRIVATE_DOCKER_REGISTRY/proxysql:v2.0.4" exporter: image: "PRIVATE_DOCKER_REGISTRY/proxysql-exporter:v1.1.0" ...
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
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 \ --docker-password=DOCKER_PASSWORD secret/myregistrykey created
If you wish to follow other ways to pull private images see official docs of kubernetes.
NB: If you are using
kubectl1.9.0, update to 1.9.1 or later to avoid this issue.
When installing KubeDB operator, set the flags
--image-pull-secret to the appropriate value. Follow the steps to install KubeDB operator properly in the cluster so that to points to the DOCKER_REGISTRY you wish to pull images from.
ProxySQL from private repository, you have to add
myregistrykey secret in
Below is the ProxySQL object we will create.
apiVersion: kubedb.com/v1alpha2 kind: ProxySQL metadata: name: proxysql-pvt-reg namespace: demo spec: version: "2.0.4" replicas: 1 mode: GroupReplication backend: ref: apiGroup: "kubedb.com" kind: MySQL name: my-group replicas: 3 podTemplate: spec: imagePullSecrets: - name: myregistrykey
Now run the command to deploy this
$ kubectl create -f https://github.com/kubedb/docs/raw/v2020.11.12/docs/examples/proxysql/private-registry.yaml proxysql.kubedb.com/proxysql-pvt-reg created
To check if the images pulled successfully from the repository, see if the
ProxySQL is in running state:
$ kubectl get pods -n demo NAME READY STATUS RESTARTS AGE proxysql-pvt-reg-0 1/1 Running 0 56s
To clean up the Kubernetes resources created by this tutorial, run:
kubectl delete -n demo proxysql/proxysql-pvt-reg kubectl delete ns demo