Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

declarative devnet deployments with kubernetes PT.3 #309

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions kubernetes/devnet/base/farmer/archival-node-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: archival-node-config
namespace: farmer
data:
NETWORK_NAME: "network-name"
EXTERNAL_IP: "external-ip"
EXTERNAL_IP_V6: "external-ip-v6"
NODE_ID: "node-id"
NODE_PEER_ID: "node-peer-id"
BOOTSTRAP_0_PEER_ID: "bootstrap-0-peer-id"
BOOTSTRAP_1_PEER_ID: "bootstrap-1-peer-id"
DOCKER_TAG: "${DOCKER_TAG}"
POT_EXTERNAL_ENTROPY: "${POT_EXTERNAL_ENTROPY}"
171 changes: 171 additions & 0 deletions kubernetes/devnet/base/farmer/archival-node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: farmer-node
namespace: farmer
spec:
serviceName: "farmer-node-service"
replicas: 1
selector:
matchLabels:
app: farmer-node
template:
metadata:
labels:
app: farmer-node
spec:
securityContext:
fsGroup: 1000
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: farmer
operator: In
values:
- "1"
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: farmer
operator: In
values:
- "1"
topologyKey: "kubernetes.io/hostname"
tolerations:
- key: "farmer"
operator: "Equal"
value: "1"
effect: "NoSchedule"
containers:
- name: archival-node
image: ghcr.io/subspace/node:${DOCKER_TAG}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
envFrom:
- configMapRef:
name: archival-node-config
ports:
- containerPort: 9944
- containerPort: 9615
volumeMounts:
- name: archival-node-data
mountPath: /var/subspace
resources:
requests:
cpu: "500m"
memory: "1Gi"
livenessProbe:
tcpSocket:
port: 9944
initialDelaySeconds: 60
periodSeconds: 60
readinessProbe:
tcpSocket:
port: 9944
initialDelaySeconds: 30
periodSeconds: 30
args:
- "run"
- "--chain"
- "$(NETWORK_NAME)"
- "--base-path"
- "/var/subspace"
- "--state-pruning"
- "archive"
- "--blocks-pruning"
- "256"
- "--pot-external-entropy"
- "$(POT_EXTERNAL_ENTROPY)"
- "--listen-on"
- "/ip4/0.0.0.0/tcp/30333"
- "--listen-on"
- "/ip6/::/tcp/30333"
- "--dsn-external-address"
- "/ip4/$(EXTERNAL_IP)/udp/30433/quic-v1"
- "--dsn-external-address"
- "/ip6/$(EXTERNAL_IP_V6)/udp/30433/quic-v1"
- "--node-key"
- "$(NODE_KEY)"
- "--farmer"
- "--timekeeper"
- "--rpc-cors"
- "all"
- "--rpc-listen-on"
- "0.0.0.0:9944"
- "--rpc-methods"
- "unsafe"
- "--prometheus-listen-on"
- "0.0.0.0:9615"
- "--reserved-nodes"
- "/dns/bootstrap-0.$(NETWORK_NAME).subspace.network/tcp/30333/p2p/$(BOOTSTRAP_0_PEER_ID)"
- "--bootstrap-nodes"
- "/dns/bootstrap-0.$(NETWORK_NAME).subspace.network/tcp/30333/p2p/$(BOOTSTRAP_0_PEER_ID)"
- "--reserved-nodes"
- "/dns/bootstrap-1.$(NETWORK_NAME).subspace.network/tcp/30333/p2p/$(BOOTSTRAP_1_PEER_ID)"
- "--bootstrap-nodes"
- "/dns/bootstrap-1.$(NETWORK_NAME).subspace.network/tcp/30333/p2p/$(BOOTSTRAP_1_PEER_ID)"

- name: farmer-node
image: ghcr.io/subspace/farmer:${DOCKER_TAG}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
envFrom:
- configMapRef:
name: farmer-node-config
ports:
- containerPort: 9944
- containerPort: 9615
volumeMounts:
- name: farmer-node-data
mountPath: /var/subspace
resources:
requests:
cpu: "500m"
memory: "1Gi"
args:
- "farm"
- "path=/var/subspace,size=$(PLOT_SIZE)"
- "--node-rpc-url"
- "ws://localhost:9944"
- "--external-address"
- "/ip4/$(EXTERNAL_IP)/udp/30533/quic-v1"
- "--external-address"
- "/ip4/$(EXTERNAL_IP)/tcp/30533"
- "--external-address"
- "/ip6/$(EXTERNAL_IP_V6)/udp/30533/quic-v1"
- "--external-address"
- "/ip6/$(EXTERNAL_IP_V6)/tcp/30533"
- "--listen-on"
- "/ip4/0.0.0.0/udp/30533/quic-v1"
- "--listen-on"
- "/ip4/0.0.0.0/tcp/30533"
- "--listen-on"
- "/ip6/::/udp/30533/quic-v1"
- "--listen-on"
- "/ip6/::/tcp/30533"
- "--reward-address"
- "$(REWARD_ADDRESS)"
- "--metrics-endpoint=0.0.0.0:9616"
- "--cache-percentage"
- "50"
volumes:
- name: archival-node-data
persistentVolumeClaim:
claimName: archival-node-pvc
- name: farmer-node-data
persistentVolumeClaim:
claimName: farmer-node-pvc
15 changes: 15 additions & 0 deletions kubernetes/devnet/base/farmer/farmer-node-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: farmer-node-config
namespace: farmer
data:
NETWORK_NAME: "network-name"
EXTERNAL_IP: "external-ip"
EXTERNAL_IP_V6: "external-ip-v6"
NODE_ID: "node-id"
NODE_PEER_ID: "node-peer-id"
BOOTSTRAP_0_PEER_ID: "bootstrap-0-peer-id"
BOOTSTRAP_1_PEER_ID: "bootstrap-1-peer-id"
DOCKER_TAG: "${DOCKER_TAG}"
PLOT_SIZE: "${PLOT_SIZE}"
25 changes: 25 additions & 0 deletions kubernetes/devnet/base/farmer/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: archival-node-pvc
namespace: farmer
spec:
accessModes:
- ReadWriteOnce
storageClassName: ebs-storageclass
resources:
requests:
storage: 100Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: farmer-node-pvc
namespace: farmer
spec:
accessModes:
- ReadWriteOnce
storageClassName: ebs-storageclass
resources:
requests:
storage: 50Gi
46 changes: 46 additions & 0 deletions kubernetes/devnet/base/farmer/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: v1
kind: Service
metadata:
name: farmer-node-service
namespace: farmer
spec:
selector:
app: farmer-node
ports:
- name: p2p
protocol: TCP
port: 30333
targetPort: 30333
- name: p2p-udp
protocol: UDP
port: 30333
targetPort: 30333
- name: dsn_port
protocol: TCP
port: 30433
targetPort: 30433
- name: dsn_port_udp
protocol: UDP
port: 30433
targetPort: 30433
- name: rpc
protocol: TCP
port: 9944
targetPort: 9944
- name: prometheus
protocol: TCP
port: 9615
targetPort: 9615
- name: farmer_dsn
protocol: TCP
port: 30533
targetPort: 30533
- name: farmer_dsn_udp
protocol: UDP
port: 30533
targetPort: 30533
- name: famer_prometheus
protocol: TCP
port: 9616
targetPort: 9616
type: ClusterIP
13 changes: 13 additions & 0 deletions kubernetes/devnet/base/farmer/storageclass-aws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ebs-storageclass
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp3
fsType: ext4
reclaimPolicy: Retain
allowVolumeExpansion: true
mountOptions:
- debug
volumeBindingMode: Immediate