Project: KubeDB by AppsCode (App Definition and Development / Database)
File: using-private-registry.md

title: Run Redis using Private Registry menu: docs_{{ .version }}: identifier: rd-using-private-registry-private-registry name: Quickstart parent: rd-private-registry-redis weight: 10 menuname: docs{{ .version }} sectionmenuid: guides New to KubeDB? Please start . KubeDB operator supports using private Docker registry. This tutorial will show you how to use KubeDB to run Redis server using private Docker images. Read to learn detail concepts of `RedisVersion` object. 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 . 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: ```bash $ kubectl create ns demo namespace/demo created ``` You will also need a docker private or . In this tutorial we will use private repository of . You have to push the required images from KubeDB's into your private registry. For redis, push `DBIMAGE`, `TOOLSIMAGE`, `EXPORTER_IMAGE` of following RedisVersions, where `deprecated` is not true, to your private registry. ```bash $ kubectl get redisversions -n kube-system -o=custom-columns=NAME:.metadata.name,VERSION:.spec.version,INITCONTAINERIMAGE:.spec.initContainer.image,DBIMAGE:.spec.db.image,EXPORTER_IMAGE:.spec.exporter.image NAME VERSION INITCONTAINERIMAGE DBIMAGE EXPORTER_IMAGE 4.0.11 4.0.11 kubedb/redis-init:0.7.0 kubedb/redis:4.0.11 kubedb/redis_exporter:v0.21.1 4.0.6-v2 4.0.6 kubedb/redis-init:0.7.0 kubedb/redis:4.0.6-v2 kubedb/redis_exporter:v0.21.1 5.0.14 5.0.14 kubedb/redis-init:0.7.0 redis:5.0.14 kubedb/redis_exporter:1.9.0 6.2.14 5.0.3 kubedb/redis-init:0.7.0 kubedb/redis:6.2.14 kubedb/redis_exporter:v0.21.1 6.0.20 6.0.20 kubedb/redis-init:0.7.0 kubedb/redis:6.0.20 kubedb/redis_exporter:1.9.0 6.2.14 6.2.14 kubedb/redis-init:0.7.0 redis:6.2.14 kubedb/redis_exporter:1.9.0 6.2.14 6.2.14 kubedb/redis-init:0.7.0 redis:6.2.14 kubedb/redis_exporter:1.9.0 6.2.14 6.2.14 kubedb/redis-init:0.7.0 redis:6.2.14 kubedb/redis_exporter:1.9.0 7.0.4 7.0.4 kubedb/redis-init:0.7.0 redis:7.0.4 kubedb/redis_exporter:1.9.0 7.0.14 7.0.14 kubedb/redis-init:0.7.0 redis:7.0.14 kubedb/redis_exporter:1.9.0 7.0.6 7.0.6 kubedb/redis-init:0.7.0 redis:7.0.6 kubedb/redis_exporter:1.9.0 ``` Docker hub repositories: - Update KubeDB catalog for private Docker registry. Ex: ```yaml apiVersion: catalog.kubedb.com/v1alpha1 kind: RedisVersion metadata: name: 6.2.14 spec: db: image: PRIVATEDOCKERREGISTRY:6.0.20 exporter: image: PRIVATEDOCKERREGISTRY:1.9.0 podSecurityPolicies: databasePolicyName: redis-db version: 6.0.20 ``` ImagePullSecrets is a type of 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

Run the following command, substituting the appropriate uppercase values to create an image pull secret for your private Docker registry: ```bash $ kubectl create secret docker-registry -n demo myregistrykey \ --docker-server=DOCKERREGISTRYSERVER \ --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 of Kubernetes. NB: If you are using `kubectl` 1.9.0, update to 1.9.1 or later to avoid this . When installing KubeDB operator, set the flags `--docker-registry` and `--image-pull-secret` to appropriate value. Follow the steps to properly in cluster so that to points to the DOCKER_REGISTRY you wish to pull images from. While deploying `Redis` from private repository, you have to add `myregistrykey` secret in `Redis` `spec.imagePullSecrets`. Below is the Redis CRD object we will create. ```yaml apiVersion: kubedb.com/v1alpha2 kind: Redis metadata: name: redis-pvt-reg namespace: demo spec: version: 6.2.14 storage: storageClassName: "standard" accessModes: ReadWriteOnce resources: requests: storage: 1Gi podTemplate: spec: imagePullSecrets: name: myregistrykey ``` Now run the command to deploy this `Redis` object: ```bash $ kubectl create -f https://github.com/kubedb/docs/raw/{{< param "info.version" >}}/docs/examples/redis/private-registry/demo-2.yaml redis.kubedb.com/redis-pvt-reg created ``` To check if the images pulled successfully from the repository, see if the `Redis` is in running state: ```bash $ kubectl get pods -n demo -w NAME READY STATUS RESTARTS AGE redis-pvt-reg-0 0/1 Pending 0 0s redis-pvt-reg-0 0/1 Pending 0 0s redis-pvt-reg-0 0/1 ContainerCreating 0 0s redis-pvt-reg-0 1/1 Running 0 2m $ kubectl get rd -n demo NAME VERSION STATUS AGE redis-pvt-reg 6.2.14 Running 40s ``` To clean up the Kubernetes resources created by this tutorial, run: ```bash kubectl patch -n demo rd/redis-pvt-reg -p '{"spec":{"terminationPolicy":"WipeOut"}}' --type="merge" kubectl delete -n demo rd/redis-pvt-reg kubectl patch -n demo drmn/redis-pvt-reg -p '{"spec":{"wipeOut":true}}' --type="merge" kubectl delete -n demo drmn/redis-pvt-reg kubectl delete ns demo ``` ```bash $ kubectl patch -n demo rd/redis-pvt-reg -p '{"spec":{"terminationPolicy":"WipeOut"}}' --type="merge" redis.kubedb.com/redis-pvt-reg patched $ kubectl delete -n demo rd/redis-pvt-reg redis.kubedb.com "redis-pvt-reg" deleted $ kubectl delete -n demo secret myregistrykey secret "myregistrykey" deleted $ kubectl delete ns demo namespace "demo" deleted ``` Monitor your Redis server with KubeDB using . Monitor your Redis server with KubeDB using . Detail concepts of . Detail concepts of . Want to hack on KubeDB? Check our .