Setting Up Qdrant with Kong for Authentication: A Step-by-Step Guide

Stéphane Busso
2 min readApr 4, 2023

--

In this post, we will walk through installing Qdrant, an open-source vector similarity search engine, using Kong, a scalable, open-source API Gateway, for authentication. This guide is intended for users familiar with Docker and who want to secure their Qdrant deployment with API keys for authentication.

Update (25/May/2023): Qdrant v1.2.0 has a built-in authentication.

Pre-requisites

1. Docker installed on your system. If you don’t have it yet, follow the instructions here.
2. Familiarity with Docker and basic knowledge of YAML files.

Step 1: Create the Kong YAML Configuration File

Create a new file named kong.yml in your working directory. This file will contain the configuration settings for Kong, including the services, routes, consumers, and plugins required to set up authentication.

Copy the following YAML content into the `kong.yml` file:

_format_version: "3.0"
_transform: true

services:
- host: qdrant
name: qdrant
port: 6333
protocol: http
routes:
- name: qdrant_route
paths:
- /
strip_path: true

consumers:
- username: qdrant

keyauth_credentials:
- consumer: qdrant
key: <api-key>

plugins:
- name: key-auth
config:
key_in_header: true
key_names:
- apikey

Replace <api-key> with a unique API key you want to use for authentication. This key will be required in subsequent API calls to Qdrant.

Step 2: Run Kong and Qdrant Docker Containers

We will now create a Docker network for Kong and Qdrant containers to communicate with each other. In your terminal, run the following command:

docker network create kong-net

Next, start the Kong container with the following command:

docker run -d --name kong \
--network=kong-net \
-v "$(pwd):/kong/declarative/" \
-e "KONG_DATABASE=off" \
-e "KONG_DECLARATIVE_CONFIG=/kong/declarative/kong.yml" \
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
-p 8000:8000 -p 8443:8443 \
-p 127.0.0.1:8001:8001 \
-p 127.0.0.1:8444:8444 \
kong:3.2.2

Finally, start the Qdrant container with the following command:

docker run -d 
--network=kong-net \
--name=qdrant \
-p 127.0.0.1:6333:6333 \
-v $(pwd)/data:/qdrant/storage \
qdrant/qdrant

Step 3: Test the Setup

curl -H 'apikey: <api-key>' http://<ip-address>:8000/telemetry

If the setup works correctly, you should receive a JSON response containing Qdrant’s telemetry data. If you receive an error message or an unauthorized response, ensure that you have entered the correct API key and that the containers are running correctly.

Conclusion

You can now use the Qdrant API to perform vector similarity searches with the added security of Kong’s authentication. For more information on Qdrant, visit the official Qdrant GitHub repository. To learn more about Kong and its various features, visit the official Kong website or the Kong GitHub repository.

--

--