Files
allmende/k8s/base/statefulset.yaml
T

126 lines
4.2 KiB
YAML

# One node, with its keys and database on a volume. Keep it at one replica: a
# second pod would be a second node with its own identity, not a copy.
#
# The identity is created on the first start, without a recovery phrase (so
# nothing secret is logged). It lasts a year; see k8s/README.md.
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: allmende
spec:
serviceName: allmende-p2p
replicas: 1
selector:
matchLabels:
app: allmende
template:
metadata:
labels:
app: allmende
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
fsGroup: 10001
seccompProfile:
type: RuntimeDefault
terminationGracePeriodSeconds: 30
containers:
- name: allmende
image: allmende
imagePullPolicy: IfNotPresent
# First start: create the identity without a recovery phrase (a
# bootstrap node has nothing to recover; its identity is its peer ID,
# which lives on the volume). Then run as a bootstrap node: --public
# serves the DHT and relays for nodes behind a NAT, --announce names
# the address the router forwards, and REGION (config.env) the regions
# to keep listings for, if any.
#
# When you edit this script: every line of the `set --` command but
# the last ends in a backslash. A missing one cuts the command short
# and silently drops the flags below it (--announce above all); the
# node then logs "--public, but this node has no public address".
command: ["/bin/sh", "-c"]
args:
- |
: "${PUBLIC_HOST:?set PUBLIC_HOST in k8s/base/config.env}"
[ -f /data/admin.token ] || allmende init --no-phrase
set -- --public \
--no-default-bootstrap \
--no-mdns \
--no-login-link \
--difficulty "${DIFFICULTY:-24}" \
--http 0.0.0.0:8080 \
--listen /ip4/0.0.0.0/tcp/4001 \
--listen /ip4/0.0.0.0/udp/4001/quic-v1 \
--announce "/dns4/${PUBLIC_HOST}/tcp/${PUBLIC_PORT}" \
--announce "/dns4/${PUBLIC_HOST}/udp/${PUBLIC_PORT}/quic-v1"
if [ -n "${REGION}" ]; then
set -f; IFS=,
for r in ${REGION}; do set -- "$@" --region "$r"; done
unset IFS; set +f
fi
exec allmende run "$@"
envFrom:
- configMapRef:
name: allmende-config
env:
- name: ALLMENDE_DATA
value: /data
ports:
- name: p2p-tcp
containerPort: 4001
protocol: TCP
- name: p2p-quic
containerPort: 4001
protocol: UDP
- name: http
containerPort: 8080
protocol: TCP
readinessProbe:
httpGet:
path: /api/v1/status
port: http
periodSeconds: 10
startupProbe:
httpGet:
path: /api/v1/status
port: http
periodSeconds: 5
failureThreshold: 60
livenessProbe:
httpGet:
path: /api/v1/status
port: http
periodSeconds: 30
failureThreshold: 3
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
memory: 512Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
volumeMounts:
- name: data
mountPath: /data
- name: tmp # the root file system is read-only; SQLite wants a scratch place
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
# storageClassName: your-class # the cluster default is used otherwise
resources:
requests:
storage: 1Gi