Kubernetes manifests for a public node, and --announce
k8s/base (kustomize): StatefulSet with a volume, p2p LoadBalancer for 4001 TCP+UDP, ClusterIP for the UI, optional ingress; k8s/overlays/nodeport for clusters without a load balancer. The pod waits for 'allmende init' so the recovery phrase never goes to a log. --announce makes a node that sits behind a router or in a container announce the address others can dial (e.g. /dns4/name/tcp/4001), so a bootstrap node behind a port forward works, and the DNS records it prints name the host. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
# The public name of this node: a DNS name (A record, or a dynamic-DNS name)
|
||||
# that points at your router's public IP. Nodes behind a router do not know
|
||||
# their own public address, so the node announces this name instead.
|
||||
PUBLIC_HOST=bootstrap.allmende.stinnesbeck.com
|
||||
|
||||
# The port your router forwards to the cluster, as seen from the internet
|
||||
# (TCP and UDP). Keep it 4001 unless the router cannot forward it.
|
||||
PUBLIC_PORT=4001
|
||||
@@ -0,0 +1,30 @@
|
||||
# Optional: the web UI on a public name, so people can search without running
|
||||
# their own node. Not part of the kustomization until you enable it there.
|
||||
#
|
||||
# The same port serves the owner API. It is protected by the admin token
|
||||
# (which stays on the volume, /data/admin.token), but put TLS in front of it
|
||||
# and consider limiting /api/v1/ to your own address ranges if you do not need
|
||||
# the owner screens from outside.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: allmende
|
||||
annotations:
|
||||
# cert-manager.io/cluster-issuer: letsencrypt
|
||||
nginx.ingress.kubernetes.io/proxy-read-timeout: "60"
|
||||
spec:
|
||||
# ingressClassName: nginx
|
||||
tls:
|
||||
- hosts: [allmende.example.org]
|
||||
secretName: allmende-tls
|
||||
rules:
|
||||
- host: allmende.example.org
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: allmende-http
|
||||
port:
|
||||
name: http
|
||||
@@ -0,0 +1,36 @@
|
||||
# A public Allmende node (a bootstrap node) for your own cluster.
|
||||
#
|
||||
# kubectl apply -k k8s/base (or: kustomize build k8s/base | kubectl apply -f -)
|
||||
#
|
||||
# Before you apply: set the image below and the public name in config.env.
|
||||
# See k8s/README.md for the whole setup (router, DNS, first start).
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
namespace: allmende
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- statefulset.yaml
|
||||
- service-p2p.yaml
|
||||
- service-http.yaml
|
||||
# Optional: the web UI on a public name. Read the note in ingress.yaml first.
|
||||
# - ingress.yaml
|
||||
|
||||
configMapGenerator:
|
||||
- name: allmende-config
|
||||
envs:
|
||||
- config.env
|
||||
|
||||
# Build the image from the Dockerfile in the repository root, push it to a
|
||||
# registry your cluster can pull from, and name it here.
|
||||
images:
|
||||
- name: allmende
|
||||
newName: registry.example.com/allmende
|
||||
newTag: latest
|
||||
|
||||
labels:
|
||||
- pairs:
|
||||
app.kubernetes.io/name: allmende
|
||||
app.kubernetes.io/part-of: allmende
|
||||
includeSelectors: false
|
||||
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: allmende
|
||||
@@ -0,0 +1,15 @@
|
||||
# The web UI and API, inside the cluster only. Reach it with
|
||||
# kubectl -n allmende port-forward svc/allmende-http 8080:8080
|
||||
# or publish it through ingress.yaml.
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: allmende-http
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: allmende
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
targetPort: http
|
||||
@@ -0,0 +1,28 @@
|
||||
# The libp2p port other nodes connect to, TCP and UDP (QUIC), on one address.
|
||||
#
|
||||
# Your router forwards 4001 (TCP and UDP) to this Service's address. This file
|
||||
# uses a LoadBalancer, which at home usually means MetalLB or kube-vip handing
|
||||
# out a LAN address; forward the router's port to that address. Without a load
|
||||
# balancer in the cluster use overlays/nodeport instead.
|
||||
#
|
||||
# Mixed TCP and UDP on one LoadBalancer needs Kubernetes 1.26 or later and a
|
||||
# load balancer implementation that supports it (MetalLB does).
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: allmende-p2p
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
# Keep the real client address (and skip a second hop through the cluster).
|
||||
externalTrafficPolicy: Local
|
||||
selector:
|
||||
app: allmende
|
||||
ports:
|
||||
- name: p2p-tcp
|
||||
port: 4001
|
||||
targetPort: p2p-tcp
|
||||
protocol: TCP
|
||||
- name: p2p-quic
|
||||
port: 4001
|
||||
targetPort: p2p-quic
|
||||
protocol: UDP
|
||||
@@ -0,0 +1,117 @@
|
||||
# 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 by hand, once, because it shows a recovery phrase
|
||||
# that must never end up in a log. Until you do, the pod waits:
|
||||
# kubectl -n allmende exec -it allmende-0 -- allmende init
|
||||
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
|
||||
# Wait for 'allmende init' (it writes admin.token last), then run as a
|
||||
# bootstrap node: --public serves the DHT and relays for nodes behind
|
||||
# a NAT, --announce names the address the router forwards.
|
||||
command: ["/bin/sh", "-c"]
|
||||
args:
|
||||
- |
|
||||
until [ -f /data/admin.token ]; do
|
||||
echo "not set up yet: run kubectl -n allmende exec -it allmende-0 -- allmende init"
|
||||
sleep 10
|
||||
done
|
||||
exec allmende run \
|
||||
--public \
|
||||
--no-default-bootstrap \
|
||||
--no-mdns \
|
||||
--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"
|
||||
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
|
||||
# Ready once the node answers; before 'init' it never does, which keeps
|
||||
# a half-set-up node out of the Services without restarting it.
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /api/v1/status
|
||||
port: http
|
||||
periodSeconds: 10
|
||||
# Only judge it dead after the first start succeeded (the wait for
|
||||
# 'init' may take as long as you need).
|
||||
startupProbe:
|
||||
httpGet:
|
||||
path: /api/v1/status
|
||||
port: http
|
||||
periodSeconds: 10
|
||||
failureThreshold: 360
|
||||
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
|
||||
Reference in New Issue
Block a user