High Availability#
To gain a higher level of availability for your Instance, you can
- create more Kubernetes Cluster Nodes
- create more replicas of the nscale and nplus components
- distribute those replicas across multiple nodes using anti-affinities
This is how:
helm install \
--values samples/ha/values.yaml \
--values samples/environment/demo.yaml \
sample-ha nplus/nplus-instanceHow many nodes you need#
The charts set a hard pod anti-affinity: two pods of the same component of an instance never run on the
same Kubernetes node. For the storage layer the rule applies to the type, so nstla and nstlb always run on
different nodes as well. Therefore:
- a component needs one node per replica. With two replicas you need at least two nodes. If a node is
missing, the second pod stays
Pendingwithdidn't match pod anti-affinity rules. That is intended: two replicas on one node would not protect you against the failure of that node. - this sample needs at least two nodes; with nscale AI you need three for real high availability (see below).
- An upgrade of a running Deployment can block. With
replicaCount: 1(and also with 2) the rolling update starts the new pod before it removes the old one. If every node already runs a pod of that component, for example one replica on a single node or two replicas on two nodes, the new pod finds no node and staysPending. You see two ReplicaSets, the old one still running. A fresh installation is not affected. Ways out: setupdateStrategy: Recreatefor the component (Deployments only, not StatefulSets), scale it to zero before the upgrade (kubectl scale --replicas=0), or provide one more node.
The license and the storage layer server ids#
A nscale Server Storage Layer runs with a server id, and in a high availability
setup each node needs its own. The sample therefore sets them explicitly, 4711 for
nstla and 4712 for nstlb:
nstla:
serverID: 4711
nstlb:
serverID: 4712For that to work, the license must not carry a server id of its own. If it does, the storage layer refuses to start and says so clearly:
Server-ID 4711 in config is different from Server-ID 1514574720 from license
Start aborted due to configuration errorsA license with a ServerId property pins the storage layer to exactly that one id
and makes a multi node setup impossible — in that case, ask Ceyoniq for a license
without it, rather than bending the server ids to match the license.
The essents of the values file is this:
- We use three (3) nscale Server Application Layer, two dedicated to user access, one dedicated to jobs
- if the jobs node fails, the user nodes take the jobs (handled by priority)
- if one of the user nodes fail, the other one handles the load
- Kubernetes takes care of restarting nodes should that happen
web,rs,ilm,cmis,webdav,erpproxy,erpcmis, the usernappland the AI components (see below) run with two replicas;nappljobs,administrator,pam,monand the database run with one, the storage layer is made redundant by the two storage layersnstlaandnstlb- Pod anti-affinities handle the distribution
- any administration component only connects to the jobs nappl, leaving the user nodes to the users
- PodDisruptionBudgets are defined for the crutial components. These are set via
minReplicaCountfor the components that can support multiple replicas, andminReplicaCountTypefor the first replicaSet of the components that do not support replicas, in this case nstla.
web:
replicaCount: 2
minReplicaCount: 1
rs:
replicaCount: 2
minReplicaCount: 1
ilm:
replicaCount: 2
minReplicaCount: 1
cmis:
replicaCount: 2
minReplicaCount: 1
erpproxy:
replicaCount: 2
minReplicaCount: 1
erpcmis:
replicaCount: 2
minReplicaCount: 1
webdav:
replicaCount: 2
minReplicaCount: 1
nstla:
minReplicaCountType: 1
administrator:
nappl:
host: "{{ .component.prefix }}nappljobs.{{ .Release.Namespace }}"
waitFor:
- "-service {{ .component.prefix }}nappljobs.{{ .Release.Namespace }}.svc.cluster.local:{{ .this.nappl.port }} -timeout 600"
pam:
nappl:
host: "{{ .component.prefix }}nappljobs.{{ .Release.Namespace }}"
waitFor:
- "-service {{ .component.prefix }}nappljobs.{{ .Release.Namespace }}.svc.cluster.local:{{ .this.nappl.port }} -timeout 600"
nappl:
replicaCount: 2
minReplicaCount: 1
jobs: false
waitFor:
- "-service {{ .component.prefix }}nappljobs.{{ .Release.Namespace }}.svc.cluster.local:{{ .this.nappl.port }} -timeout 600"
nappljobs:
replicaCount: 1
jobs: true
disableSessionReplication: true
ingress:
enabled: false
snc:
enabled: true
waitFor:
- "-service {{ .component.prefix }}database.{{ .Release.Namespace }}.svc.cluster.local:5432 -timeout 600"
application:
nstl:
host: "{{ .component.prefix }}nstl-cluster.{{ .Release.Namespace }}"
nappl:
host: "{{ .component.prefix }}nappljobs.{{ .Release.Namespace }}"nscale AI in a high availability setup#
If you add nscale AI to this sample (stack ../ai/values.yaml behind the values of the sample, see ../ai/README.md), the values of this sample already take care of the AI components: the stateless ones run with two replicas, and Elasticsearch runs with three nodes. A single node would be a single point of failure for the whole AI feature: chat history, summaries and the vector index live there. The AI sample on its own sets no replicas, like the other samples.
aichat:
replicaCount: 2
minReplicaCount: 1
aiauth:
replicaCount: 2
minReplicaCount: 1
aibackend:
replicaCount: 2
minReplicaCount: 1
aimcp:
replicaCount: 2
minReplicaCount: 1
mcp:
protocol: STATELESS
aisearch:
elasticsearch:
count: 3- Why three: all three nodes are master eligible, so the cluster keeps its quorum when one node fails. With one or two nodes a failure can stop the cluster, three tolerate the loss of one.
- Spread across the nodes: the Elasticsearch pods prefer different Kubernetes nodes (a soft pod anti-affinity,
“best effort”), unlike the other components, which require it. With fewer Kubernetes nodes than Elasticsearch
nodes, for example on two sites, all three pods still start and two of them share a node. Then the failure of
that node takes two Elasticsearch nodes with it and the cluster loses its quorum: for real high availability you
need three Kubernetes nodes (or zones) for the three Elasticsearch nodes. Check where the pods run with
kubectl get pods -o wide. - Health: Elasticsearch creates every index with one replica shard. With three nodes the cluster is
green, with a single node it isyellowbecause the replicas have nowhere to go. That is expected for one node, not a fault.kubectl get elasticsearchshows it. - Storage: each node gets its own volume of 40 Gi (
aisearch.mounts.data.size,aisearch.mounts.data.classfor the storage class), so three volumes. Choose a fast storage class, preferably local or block storage. - ECK operator:
aisearchrenders anElasticsearchresource that the ECK operator runs. Install the operator (elastic/eck-operator) before the instance, its custom resources must exist in the cluster. - The other AI components:
aichat,aiauth,aibackendandaimcpare stateless and run withreplicaCount: 2here.aimcpneedsmcp.protocol: STATELESSfor that: by default the MCP server keeps the session of a client in the memory of one pod, and a request that reaches the other pod fails with404 Session not found. On a fresh installation startaibackendwith one replica and scale up afterwards (see the AI sample): when several backends start at the same time, they all try to create the indices. - Pull secrets: the AI images come from
registry.source.ceyoniq.com/ceyoniq-public/nscale/container/nscale-aiand need the pull secretnscale-ai-cr, the helper image from the nplus registry needsnplus-cr, just like in every other component.
We run exactly this setup in our test environment (three nodes, high availability sample with nscale AI, three Elasticsearch nodes), deployed with Helm as well as with Argo CD.
Files#
Download all files of this sample
build.sh#
#!/bin/bash
#
# This sample script builds the example as described. It is also used to build the test environment in our lab,
# so it should be well tested.
#
# Make sure it fails immediately, if anything goes wrong
set -e
# -- ENVironment variables:
# CHARTS: The path to the source code
# DEST: The path to the build destination
# SAMPLE: The directory of the sample
# NAME: The name of the sample, used as the .Release.Name
# KUBE_CONTEXT: The name of the kube context, used to build this sample depending on where you run it against. You might have different Environments such as lab, dev, qa, prod, demo, local, ...
# Check, if we have the source code available
if [ ! -d "$CHARTS" ]; then
echo "ERROR Building $SAMPLE example: The Charts Sources folder is not set. Please make sure to run this script with the full Source Code available"
exit 1
fi
if [ ! -d "$DEST" ]; then
echo "ERROR Building $SAMPLE example: DEST folder not found."
exit 1
fi
if [ ! -d "$CHARTS/instance" ]; then
echo "ERROR Building $SAMPLE example: Chart Sources in $CHARTS/instance not found. Are you running this script as a subscriber?"
exit 1
fi
# Set the Variables
SAMPLE="ha"
NAME="sample-$SAMPLE"
# Output what is happening
echo "Building $NAME"
# Create the manifest
mkdir -p $DEST/instance
helm template --debug \
--values $SAMPLES/ha/values.yaml \
--values $SAMPLES/hid/values.yaml \
--values $SAMPLES/application/empty.yaml \
--values $SAMPLES/environment/$KUBE_CONTEXT.yaml \
--values $SAMPLES/resources/$KUBE_CONTEXT.yaml \
$NAME $CHARTS/instance > $DEST/instance/$SAMPLE.yaml
# creating the Argo manifest
mkdir -p $DEST/instance-argo
helm template --debug \
--values $SAMPLES/ha/values.yaml \
--values $SAMPLES/hid/values.yaml \
--values $SAMPLES/application/empty.yaml \
--values $SAMPLES/environment/$KUBE_CONTEXT.yaml \
--values $SAMPLES/resources/$KUBE_CONTEXT.yaml \
$NAME-argo $CHARTS/instance-argo > $DEST/instance-argo/$SAMPLE-argo.yamlvalues.yaml#
components:
nappl: true
nappljobs: true
web: true
mon: true
rs: true
ilm: true
erpproxy: true
erpcmis: true
cmis: true
database: true
nstl: false
nstla: true
nstlb: true
pipeliner: true
application: true
administrator: true
webdav: true
rms: false
pam: true
web:
replicaCount: 2
minReplicaCount: 1
rs:
replicaCount: 2
minReplicaCount: 1
ilm:
replicaCount: 2
minReplicaCount: 1
erpproxy:
replicaCount: 2
minReplicaCount: 1
erpcmis:
replicaCount: 2
minReplicaCount: 1
cmis:
replicaCount: 2
minReplicaCount: 1
webdav:
replicaCount: 2
minReplicaCount: 1
# nscale AI (stack ../ai/values.yaml behind this file): the stateless components run twice, Elasticsearch
# with three nodes. They are only rendered if the AI components are switched on.
aichat:
replicaCount: 2
minReplicaCount: 1
aiauth:
replicaCount: 2
minReplicaCount: 1
aibackend:
replicaCount: 2
minReplicaCount: 1
aimcp:
replicaCount: 2
minReplicaCount: 1
mcp:
# the MCP sessions would live in one pod, with two replicas every pod has to answer every request
protocol: STATELESS
aisearch:
elasticsearch:
count: 3
administrator:
nappl:
host: "{{ .component.prefix }}nappljobs.{{ .Release.Namespace }}"
waitFor:
- "-service {{ .component.prefix }}nappljobs.{{ .Release.Namespace }}.svc.cluster.local:{{ .this.nappl.port }} -timeout 600"
pam:
nappl:
host: "{{ .component.prefix }}nappljobs.{{ .Release.Namespace }}"
waitFor:
- "-service {{ .component.prefix }}nappljobs.{{ .Release.Namespace }}.svc.cluster.local:{{ .this.nappl.port }} -timeout 600"
nappl:
replicaCount: 2
minReplicaCount: 1
jobs: false
waitFor:
- "-service {{ .component.prefix }}nappljobs.{{ .Release.Namespace }}.svc.cluster.local:{{ .this.nappl.port }} -timeout 600"
nappljobs:
replicaCount: 1
jobs: true
disableSessionReplication: true
ingress:
enabled: false
snc:
enabled: true
waitFor:
- "-service {{ .component.prefix }}database.{{ .Release.Namespace }}.svc.cluster.local:5432 -timeout 600"
application:
nstl:
host: "{{ .component.prefix }}nstl-cluster.{{ .Release.Namespace }}"
nappl:
host: "{{ .component.prefix }}nappljobs.{{ .Release.Namespace }}"
waitFor:
- "-service {{ .component.prefix }}nappljobs.{{ .Release.Namespace }}.svc.cluster.local:{{ .this.nappl.port }} -timeout 1800"
nstla:
minReplicaCountType: 1
accounting: true
logForwarder:
- name: Accounting
path: "/opt/ceyoniq/nscale-server/storage-layer/accounting/*.csv"
serverID: 4711
env:
NSTL_REMOTESERVER_MAINTAINCONNECTION: 1
NSTL_REMOTESERVER_SERVERID: 4712
NSTL_REMOTESERVER_ADDRESS: "nstlb"
NSTL_REMOTESERVER_NAME: "nstla"
NSTL_REMOTESERVER_USERNAME: "admin"
NSTL_REMOTESERVER_PASSWORD: "admin"
NSTL_REMOTESERVER_MAXCONNECTIONS: 10
NSTL_REMOTESERVER_MAXARCCONNECTIONS: 1
NSTL_REMOTESERVER_FORWARDDELETEJOBS: 0
NSTL_REMOTESERVER_ACCEPTRETRIEVAL: 1
NSTL_REMOTESERVER_ACCEPTDOCS: 1
NSTL_REMOTESERVER_ACCEPTDOCSWITHTHISSERVERID: 1
NSTL_REMOTESERVER_PERMANENTMIGRATION: 1
nstlb:
accounting: true
logForwarder:
- name: Accounting
path: "/opt/ceyoniq/nscale-server/storage-layer/accounting/*.csv"
serverID: 4712
env:
NSTL_REMOTESERVER_MAINTAINCONNECTION: 1
NSTL_REMOTESERVER_SERVERID: 4711
NSTL_REMOTESERVER_ADDRESS: "nstla"
NSTL_REMOTESERVER_NAME: "nstla"
NSTL_REMOTESERVER_USERNAME: "admin"
NSTL_REMOTESERVER_PASSWORD: "admin"
NSTL_REMOTESERVER_MAXCONNECTIONS: 10
NSTL_REMOTESERVER_MAXARCCONNECTIONS: 1
NSTL_REMOTESERVER_FORWARDDELETEJOBS: 0
NSTL_REMOTESERVER_ACCEPTRETRIEVAL: 1
NSTL_REMOTESERVER_ACCEPTDOCS: 1
NSTL_REMOTESERVER_ACCEPTDOCSWITHTHISSERVERID: 1
NSTL_REMOTESERVER_PERMANENTMIGRATION: 1
global:
revisionHistoryLimit: 2