Developers
Kubernetes and Helm
Plain manifests or the official Helm chart, with or without a GPU.
StatefulSet or Deployment
| Kind | When to use it |
|---|---|
| StatefulSet (recommended) | Each pod has its own volume: after restarts, upgrades or node changes it comes back as the same computer, with its models already downloaded and its reputation. |
| Deployment | Ephemeral pods without a persistent volume: each pod is a new computer that downloads its models on start and removes itself from My computers on shutdown (PIAP_REMOVE_ON_EXIT=true). Useful for temporary capacity, for example spot nodes. |
Secrets
The same token works for the Secret the container reads and for the image pull Secret (docker-registry):
kubectl create namespace piap
kubectl -n piap create secret generic piap-token --from-literal=token="$PIAP_TOKEN"
kubectl -n piap create secret docker-registry piap-registry \
--docker-server=registry.piap.io \
--docker-username=token \
--docker-password="$PIAP_TOKEN"Plain manifests
Namespace, headless Service (for metrics), StatefulSet with a 60 Gi volume on /data, restricted security context and PodDisruptionBudget:
apiVersion: v1
kind: Namespace
metadata:
name: piap
---
apiVersion: v1
kind: Service
metadata:
name: piap-node
namespace: piap
labels:
app.kubernetes.io/name: piap-node
spec:
clusterIP: None
selector:
app.kubernetes.io/name: piap-node
ports:
- name: http
port: 9090
targetPort: http
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: piap-node
namespace: piap
spec:
serviceName: piap-node
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: piap-node
template:
metadata:
labels:
app.kubernetes.io/name: piap-node
spec:
terminationGracePeriodSeconds: 90
automountServiceAccountToken: false
imagePullSecrets:
- name: piap-registry
securityContext:
runAsNonRoot: true
runAsUser: 65532
runAsGroup: 65532
fsGroup: 65532
seccompProfile:
type: RuntimeDefault
containers:
- name: node
image: registry.piap.io/piap/node:0.1.0-cpu
env:
- name: PIAP_TOKEN
valueFrom:
secretKeyRef:
name: piap-token
key: token
- name: PIAP_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: PIAP_GRACE_SECONDS
value: "60"
ports:
- name: http
containerPort: 9090
resources:
requests:
cpu: "2"
memory: 8Gi
limits:
memory: 16Gi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
livenessProbe:
httpGet:
path: /healthz
port: http
periodSeconds: 20
failureThreshold: 3
readinessProbe:
httpGet:
path: /readyz
port: http
periodSeconds: 10
failureThreshold: 3
volumeMounts:
- name: data
mountPath: /data
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 60Gi
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: piap-node
namespace: piap
spec:
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/name: piap-nodekubectl apply -f piap-node.yaml
kubectl -n piap get pods -w
kubectl -n piap logs -f piap-node-0terminationGracePeriodSeconds: 90is the container grace (PIAP_GRACE_SECONDS, 60 by default) plus 30 seconds./healthzanswers while the process is alive (liveness);/readyzonce it is connected to the network and the engine is ready (readiness).- The pod runs as user 65532, non-root, with a read-only file system, no capabilities and the
RuntimeDefaultseccomp profile. - The memory limit must leave headroom above what the model uses (
PIAP_MAX_MEMORY_PERCENTis computed on the memory the container sees).
If you prefer the token as a file instead of an environment variable, mount the Secret and use PIAP_TOKEN_FILE:
env:
- name: PIAP_TOKEN_FILE
value: /run/secrets/piap/token
volumeMounts:
- name: token
mountPath: /run/secrets/piap
readOnly: true
volumes:
- name: token
secret:
secretName: piap-token
defaultMode: 0440GPU variant
Switch the image to the cuda variant, request nvidia.com/gpu in the limits and schedule the pod on GPU nodes. The nodeSelector and tolerations are examples: use your cluster labels and taints. If your cluster uses a RuntimeClass for NVIDIA, add runtimeClassName.
spec:
nodeSelector:
nvidia.com/gpu.present: "true"
tolerations:
- key: nvidia.com/gpu
operator: Exists
effect: NoSchedule
containers:
- name: node
image: registry.piap.io/piap/node:0.1.0-cuda
resources:
requests:
cpu: "2"
memory: 8Gi
limits:
memory: 16Gi
nvidia.com/gpu: 1Official Helm chart
The chart lives in the piap registry and has the same version as the image. Sign in with a token that has the pull scope and install using the Secrets you already created:
echo "$PIAP_TOKEN" | helm registry login registry.piap.io -u token --password-stdinhelm install piap-node oci://registry.piap.io/piap/charts/node --version 0.1.0 \
-n piap --create-namespace \
--set token.existingSecret=piap-token \
--set registry.pullSecret.name=piap-registryOr let the chart create both Secrets from the token. It is simpler, but the token is stored in the Helm release values:
helm install piap-node oci://registry.piap.io/piap/charts/node --version 0.1.0 \
-n piap --create-namespace \
--set token.value="$PIAP_TOKEN"For a GPU fleet, a values file:
image:
variant: cuda
kind: StatefulSet
replicas: 2
name: gpu-pool
token:
existingSecret: piap-token
registry:
pullSecret:
create: false
name: piap-registry
policy:
models: []
maxMemoryPercent: 70
diskGB: 80
maxConcurrent: 1
dailyTokens: 0
hours: "20:00-08:00"
days: "1-5"
timezone: UTC
ownUse: true
persistence:
enabled: true
size: 120Gi
gpu:
enabled: true
count: 1
nodeSelector:
nvidia.com/gpu.present: "true"
networkPolicy:
enabled: true
metrics:
serviceMonitor:
enabled: true
interval: 30shelm upgrade --install piap-node oci://registry.piap.io/piap/charts/node --version 0.1.0 \
-n piap --create-namespace -f values-gpu.yamlTo see every value with its default:
helm show values oci://registry.piap.io/piap/charts/node --version 0.1.0Chart values
| Value | Default | What it does |
|---|---|---|
image.repository | registry.piap.io/piap/node | Image repository. |
image.tag | (empty) | Empty = chart version plus variant (for example 0.1.0-cpu). |
image.variant | cpu | cpu or cuda. |
kind | StatefulSet | StatefulSet or Deployment. |
replicas | 1 | Number of computers. |
token.value | (empty) | Server token; the chart creates the Secret. |
token.existingSecret | (empty) | Existing Secret holding the token. |
token.key | token | Key of the token inside the Secret. |
registry.pullSecret.create | true | Creates the pull Secret with the same token (only with token.value). |
registry.pullSecret.name | (empty) | Name of the pull Secret, created or existing. |
network | prod | prod or lab. |
name | (empty) | Name in My computers (PIAP_NAME); empty = pod name. |
policy.models | [] | Allowed models (PIAP_MODELS); empty = any that fits. |
policy.maxMemoryPercent | 70 | Memory (or GPU memory) a model may use, 10 to 90. |
policy.diskGB | 40 | Space for models. |
policy.maxConcurrent | 1 | Requests at a time. |
policy.dailyTokens | 0 | Daily cap on network tokens; 0 = no cap. |
policy.hours | (always) | Window HH:MM-HH:MM. |
policy.days | (always) | Days, for example 1-5 or 0,6 (0 = Sunday). |
policy.timezone | UTC | Time zone of the window. |
policy.yieldToOthers | false | Yields to other programs on the node (PIAP_YIELD). |
policy.ownUse | true | Your own requests without credits (PIAP_OWN_USE). |
policy.networks | [] | Private networks in priority order, and global. |
policy.location | country | Precision on the map: city, country or off. |
policy.region | (empty) | Declared region. |
graceSeconds | 60 | Graceful shutdown grace. |
removeOnExit | (empty) | Empty = true with Deployment and false with StatefulSet. |
persistence.enabled | true | Persistent volume for /data. |
persistence.size | 60Gi | Volume size. |
persistence.storageClass | (empty) | StorageClass; empty = the cluster default. |
resources | (see helm show values) | Container requests and limits. |
gpu.enabled | false | Requests a GPU and uses the cuda variant. |
gpu.count | 1 | GPUs per pod. |
gpu.resourceName | nvidia.com/gpu | GPU resource name. |
gpu.runtimeClassName | (empty) | NVIDIA RuntimeClass, if your cluster uses one. |
nodeSelector | {} | Node selector. |
tolerations | [] | With gpu.enabled and no tolerations, adds the nvidia.com/gpu one. |
affinity | {} | Pod affinity. |
podDisruptionBudget.enabled | true | Creates the PodDisruptionBudget. |
podDisruptionBudget.maxUnavailable | 1 | Pods that may be down at once. |
networkPolicy.enabled | false | NetworkPolicy that only allows egress on 443 and DNS. |
metrics.serviceMonitor.enabled | false | Creates a ServiceMonitor for Prometheus Operator. |
metrics.serviceMonitor.interval | 30s | Metrics scrape interval. |
extraEnv | [] | Extra environment variables. |