Skip to content

Deploying a 3-node Weaviate cluster on Ubuntu 22.04 with TLS gRPC and anonymous access disabled

Stand up a self-hosted Weaviate cluster across three VMs with persistent volumes, raft consensus, API-key auth, and TLS on the gRPC interface.

You ship a RAG pipeline backed by a single-node Weaviate container running on the same VM as the application. It works for the proof of concept, your sales engineering team demos it to three customers, then a marketing campaign drives traffic and the container OOMs at 2am because the embedding ingestion job collided with query traffic and pushed the JVM heap past the VM’s RAM. You restart, lose the in-flight ingestion batch, and discover there is no replica anywhere — the vector store is now a single point of failure for a feature that’s already on the marketing site. The fix is the same as for any other database tier: move it off the application VM, run it on three nodes with consensus, lock down the network plane, and treat its storage as production storage.

What’s happening

Weaviate is a vector search engine that since version 1.25 ships native raft consensus for cluster metadata, replication of object data across nodes, and a gRPC interface alongside the legacy REST API. Running it as a single container is fine for development and breaks badly in production for three reasons. First, ingestion and query share the same process — a large batch upsert with vectorization on can starve query latency for minutes. Second, Weaviate stores HNSW indices in memory; an OOM kills the index and forces a reload from disk on restart, which on a non-trivial dataset is measured in minutes not seconds. Third, there is no failover — if the node goes, the vector store goes, and any feature that depends on it surfaces as a 5xx to end users. A three-node cluster with raft consensus, replication factor 3 on production classes, persistent volumes on each node, and a load balancer in front gives you the same shape of operational resilience you would expect from Postgres or Elasticsearch.

How to verify

Cluster nodes and raft state from any node:

curl -fsS -H "Authorization: Bearer ${WEAVIATE_API_KEY}" \
  https://weaviate-01.internal:8443/v1/nodes | jq '.nodes[] | {name, status, version, shards: (.shards | length)}'

You want all three nodes reporting HEALTHY and the same version. Then check the raft leader:

curl -fsS -H "Authorization: Bearer ${WEAVIATE_API_KEY}" \
  https://weaviate-01.internal:8443/v1/cluster/statistics | jq '.statistics[] | {name, isVoter, raft: .raft.state, leaderAddress: .raft.leaderAddress}'

Exactly one node should report Leader; the other two should be Follower. Verify the gRPC port is TLS-only:

openssl s_client -connect weaviate-01.internal:50051 -alpn h2 -servername weaviate-01.internal </dev/null 2>/dev/null \
  | openssl x509 -noout -subject -issuer -dates

If you get a CONNECT_ERROR or plaintext gRPC, your TLS termination isn’t wired up. Last check — confirm anonymous access is off:

# This must return 401, not 200
curl -sS -o /dev/null -w '%{http_code}\n' https://weaviate-01.internal:8443/v1/meta

If it returns 200 you have an open vector database on the public internet, which is exactly the configuration that ends up in a quarterly security report.

The fix

Save the script as /root/setup-weaviate-node.sh and run it on each of the three nodes after editing the per-node variables. It performs base hardening on Ubuntu 22.04 (UFW, fail2ban, unattended-upgrades, SSH key-only), installs Docker + the Compose plugin from Docker’s official apt repo, drops a Weaviate 1.27 docker-compose file with raft cluster bootstrap, persistent volume mounts, API-key auth, TLS-terminating nginx on both REST (8443) and gRPC (50051), persistent backups to S3-compatible object storage, and a Prometheus metrics scrape endpoint. The script is idempotent enough to re-run if something fails halfway.

#!/usr/bin/env bash
set -euo pipefail

### Ubuntu 22.04 Weaviate 1.27 3-node cluster installer
### Run on each of the 3 nodes after editing the variables below
### Assumes VM snapshots cover the data volume; backups to S3 are an
### additional layer for object-level restore

if [[ "$(id -u)" -ne 0 ]]; then
  echo "Run as root."
  exit 1
fi

# === EDIT PER NODE ===
NODE_NAME="weaviate-01"                  # weaviate-01 / weaviate-02 / weaviate-03
NODE_HOSTNAME="weaviate-01.internal"     # FQDN reachable from peers + LB
NODE_IP="10.20.0.11"                     # this node's private IP
PEER_HOSTNAMES=("weaviate-01.internal" "weaviate-02.internal" "weaviate-03.internal")
PEER_IPS=("10.20.0.11" "10.20.0.12" "10.20.0.13")
CLUSTER_NAME="vectors"
WEAVIATE_API_KEY="CHANGE_ME_API_KEY_LONG_RANDOM_STRING"
WEAVIATE_ADMIN_USER="admin@example.com"
S3_BUCKET="weaviate-backups-prod"
S3_REGION="us-east-1"
S3_ACCESS_KEY="CHANGE_ME"
S3_SECRET_KEY="CHANGE_ME"
TLS_CERT_PATH="/etc/ssl/weaviate/fullchain.pem"
TLS_KEY_PATH="/etc/ssl/weaviate/privkey.pem"
# =====================

echo
echo "========================================"
echo "Weaviate node ${NODE_NAME} (${NODE_IP})"
echo "========================================"
echo

echo "==> Base OS update"
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get -y upgrade
apt-get -y install ca-certificates curl gnupg lsb-release \
  ufw fail2ban unattended-upgrades chrony jq \
  apt-transport-https software-properties-common

systemctl enable --now chrony

echo "==> Hostname + /etc/hosts"
hostnamectl set-hostname "${NODE_HOSTNAME}"
for i in "${!PEER_HOSTNAMES[@]}"; do
  if ! grep -q "${PEER_HOSTNAMES[$i]}" /etc/hosts; then
    echo "${PEER_IPS[$i]} ${PEER_HOSTNAMES[$i]}" >> /etc/hosts
  fi
done

echo "==> SSH hardening"
sed -i 's|^[#[:space:]]*PermitRootLogin.*|PermitRootLogin prohibit-password|' /etc/ssh/sshd_config
sed -i 's|^[#[:space:]]*PasswordAuthentication.*|PasswordAuthentication no|' /etc/ssh/sshd_config
sshd -t && systemctl restart ssh

echo "==> fail2ban + unattended-upgrades"
cat > /etc/fail2ban/jail.d/sshd.local <<'FAIL2BAN'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
FAIL2BAN
systemctl enable --now fail2ban

cat > /etc/apt/apt.conf.d/52unattended-upgrades-local <<'AUTOUP'
Unattended-Upgrade::Automatic-Reboot "false";
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
AUTOUP

echo "==> UFW — allow SSH + peer raft/gossip + LB to REST/gRPC"
ufw --force reset
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp
# Peer-to-peer cluster traffic (raft + gossip + replication)
for ip in "${PEER_IPS[@]}"; do
  ufw allow from "${ip}" to any port 7100 proto tcp comment 'weaviate raft'
  ufw allow from "${ip}" to any port 7101 proto tcp comment 'weaviate raft internal'
  ufw allow from "${ip}" to any port 7946 comment 'weaviate gossip'
done
# LB-facing TLS
ufw allow 8443/tcp comment 'weaviate REST TLS via nginx'
ufw allow 50051/tcp comment 'weaviate gRPC TLS via nginx'
# Prometheus scrape from monitoring subnet only
ufw allow from 10.20.99.0/24 to any port 2112 proto tcp comment 'weaviate metrics'
ufw --force enable

echo "==> Kernel tuning for Weaviate (HNSW is memory-heavy)"
cat > /etc/sysctl.d/99-weaviate.conf <<'SYSCTL'
vm.max_map_count = 524288
vm.swappiness = 1
vm.overcommit_memory = 1
fs.file-max = 1048576
net.core.somaxconn = 4096
SYSCTL
sysctl --system

cat > /etc/security/limits.d/99-weaviate.conf <<'LIMITS'
* soft nofile 1048576
* hard nofile 1048576
* soft memlock unlimited
* hard memlock unlimited
LIMITS

echo "==> Docker CE from upstream repo"
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
  | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
  https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo $VERSION_CODENAME) stable" \
  > /etc/apt/sources.list.d/docker.list
apt-get update
apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl enable --now docker

echo "==> Persistent data volume — assumes /dev/sdb attached"
if [[ -b /dev/sdb && ! -d /var/lib/weaviate ]]; then
  if ! blkid /dev/sdb; then
    mkfs.ext4 -L weaviate /dev/sdb
  fi
  mkdir -p /var/lib/weaviate
  echo "LABEL=weaviate /var/lib/weaviate ext4 defaults,noatime 0 2" >> /etc/fstab
  mount /var/lib/weaviate
fi
mkdir -p /var/lib/weaviate/data /var/lib/weaviate/backups

echo "==> TLS material check"
if [[ ! -s "${TLS_CERT_PATH}" || ! -s "${TLS_KEY_PATH}" ]]; then
  echo "ERROR: place TLS cert at ${TLS_CERT_PATH} and key at ${TLS_KEY_PATH} before running."
  echo "  Use a wildcard *.internal cert from your internal CA, or per-node certs."
  exit 1
fi

echo "==> Weaviate compose file"
mkdir -p /opt/weaviate
JOIN=""
for h in "${PEER_HOSTNAMES[@]}"; do
  JOIN="${JOIN}${h}:7100,"
done
JOIN="${JOIN%,}"

cat > /opt/weaviate/docker-compose.yml <<EOF
services:
  weaviate:
    image: semitechnologies/weaviate:1.27.0
    restart: unless-stopped
    network_mode: host
    volumes:
      - /var/lib/weaviate/data:/var/lib/weaviate
      - /var/lib/weaviate/backups:/var/lib/weaviate/backups
    environment:
      CLUSTER_HOSTNAME: ${NODE_NAME}
      CLUSTER_GOSSIP_BIND_PORT: 7946
      CLUSTER_DATA_BIND_PORT: 7101
      RAFT_BIND_PORT: 7100
      RAFT_JOIN: ${JOIN}
      RAFT_BOOTSTRAP_EXPECT: 3
      PERSISTENCE_DATA_PATH: /var/lib/weaviate
      QUERY_DEFAULTS_LIMIT: 50
      DEFAULT_VECTORIZER_MODULE: none
      ENABLE_MODULES: backup-s3
      BACKUP_S3_BUCKET: ${S3_BUCKET}
      BACKUP_S3_USE_SSL: 'true'
      AWS_ACCESS_KEY_ID: ${S3_ACCESS_KEY}
      AWS_SECRET_ACCESS_KEY: ${S3_SECRET_KEY}
      AWS_REGION: ${S3_REGION}
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'false'
      AUTHENTICATION_APIKEY_ENABLED: 'true'
      AUTHENTICATION_APIKEY_ALLOWED_KEYS: ${WEAVIATE_API_KEY}
      AUTHENTICATION_APIKEY_USERS: ${WEAVIATE_ADMIN_USER}
      AUTHORIZATION_ADMINLIST_ENABLED: 'true'
      AUTHORIZATION_ADMINLIST_USERS: ${WEAVIATE_ADMIN_USER}
      PROMETHEUS_MONITORING_ENABLED: 'true'
      PROMETHEUS_MONITORING_PORT: 2112
      DISABLE_TELEMETRY: 'true'
      LOG_LEVEL: info
      LIMIT_RESOURCES: 'true'
EOF

echo "==> nginx for TLS termination on REST + gRPC"
apt-get -y install nginx
cat > /etc/nginx/sites-available/weaviate.conf <<EOF
server {
  listen 8443 ssl http2;
  server_name ${NODE_HOSTNAME};
  ssl_certificate ${TLS_CERT_PATH};
  ssl_certificate_key ${TLS_KEY_PATH};
  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_prefer_server_ciphers on;
  client_max_body_size 256m;
  location / {
    proxy_pass http://127.0.0.1:8080;
    proxy_http_version 1.1;
    proxy_set_header Host \$host;
    proxy_read_timeout 300s;
  }
}

server {
  listen 50051 ssl http2;
  server_name ${NODE_HOSTNAME};
  ssl_certificate ${TLS_CERT_PATH};
  ssl_certificate_key ${TLS_KEY_PATH};
  ssl_protocols TLSv1.2 TLSv1.3;
  grpc_read_timeout 300s;
  grpc_send_timeout 300s;
  location / {
    grpc_pass grpc://127.0.0.1:50050;
  }
}
EOF
ln -sf /etc/nginx/sites-available/weaviate.conf /etc/nginx/sites-enabled/weaviate.conf
rm -f /etc/nginx/sites-enabled/default
nginx -t
systemctl enable --now nginx
systemctl reload nginx

echo "==> Start Weaviate"
cd /opt/weaviate
docker compose pull
docker compose up -d

echo "==> Waiting for Weaviate REST"
for i in {1..90}; do
  if curl -fsS -H "Authorization: Bearer ${WEAVIATE_API_KEY}" \
       "http://127.0.0.1:8080/v1/.well-known/ready" >/dev/null 2>&1; then
    break
  fi
  sleep 2
done

echo
echo "========================================"
echo "DONE"
echo "========================================"
echo
echo "Listeners:"
ss -lntp | grep -E ':(8080|8443|50050|50051|7100|7101|7946|2112)\b' || true
echo
echo "Nodes:"
curl -fsS -H "Authorization: Bearer ${WEAVIATE_API_KEY}" \
  http://127.0.0.1:8080/v1/nodes | jq '.nodes[] | {name, status, version}' || true
echo
echo "Repeat on the other 2 nodes with their NODE_NAME / NODE_IP / NODE_HOSTNAME."
echo "After all 3 nodes are up, create classes with replicationConfig.factor=3."

Make it executable and run on each node:

chmod 700 /root/setup-weaviate-node.sh
/root/setup-weaviate-node.sh

Once all three nodes report HEALTHY in /v1/nodes, create production classes with replication factor 3 so a single node loss doesn’t take a tenant offline. Example schema fragment:

{
  "class": "Document",
  "vectorizer": "none",
  "replicationConfig": { "factor": 3 },
  "shardingConfig": { "desiredCount": 3 },
  "vectorIndexType": "hnsw",
  "vectorIndexConfig": { "distance": "cosine", "ef": 128, "efConstruction": 256 }
}

Schedule a nightly backup to S3 via the backup module (POST /v1/backups/s3 with include of the production classes), then restore one backup into a sandbox cluster monthly — a backup you’ve never restored is not a backup, it’s a hypothesis. Put a TCP-aware load balancer (HAProxy or your cloud’s NLB) in front of the three nodes with health checks against /v1/.well-known/ready so the application sees a single endpoint.

Stack Harbor operates Weaviate clusters under environment management with replication health, raft leadership flapping, and HNSW memory pressure all alerted into our monitoring plane. If you’d rather not be paged when a node leaves the raft quorum, start a scoping call.