Best Practices
How to run workloads on the ayedo SDP securely, reliably and observably – with examples for security context, probes, resources, PodDisruptionBudgets and logging.
This page shows how to run workloads on the ayedo Software Delivery Platform (SDP) securely, reliably and observably – each with an example. The binding rules behind these practices are summarized in Guardrails; the complete path from image to deployment is described in the Application Deployment Guide.
Security
Run Containers Without Root
Run containers without root privileges, without privilege escalation and with a read-only root filesystem. Put temporary files on an emptyDir volume. This meets the restricted profile of the Kubernetes Pod Security Standards.
spec:
template:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: api
image: registry.acme.corp/acme/api:1.4.2
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}
Create the unprivileged user in your Dockerfile already (USER 1000) so the image never starts as root, even without pod configuration.
Pinned Image Tags and Scanned Images
Use explicit version tags (e.g. 1.4.2 or the Git commit SHA) or image digests instead of :latest. This keeps deployments reproducible, Argo CD rollbacks reliable, and Harbor scan results traceable to running pods. Pull production images from your Harbor registry, mirror third-party images there, and update base images regularly.
Restrict Network Access
Without a NetworkPolicy, every pod in the cluster can talk to every other pod. Start each production namespace with a default-deny rule and allow only the connections you need, such as traffic from the ingress controller and to your database and DNS:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-all
namespace: acme-production
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
More examples of allow rules are in Networking & Ingress.
Keep Secrets Out of Git
Passwords, API tokens and certificates don't belong in Git, images or ConfigMaps. Store them in OpenBao and let the External Secrets Operator sync them into your namespace as Kubernetes secrets. Give each application its own path and rotate credentials regularly. Step 2 of the Application Deployment Guide shows how this works in practice.
Resources and Scaling
Set Requests and Limits
Define CPU and memory requests and limits for every container. Requests determine where Kubernetes schedules a pod; limits protect neighboring workloads from memory leaks and load spikes.
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
Guidelines for choosing and regularly adjusting these values are in Maintenance, Upgrades & Capacity.
Autoscale with HPA
For fluctuating load, a HorizontalPodAutoscaler adjusts the replica count to utilization. It requires resources.requests to be set and a stateless application.
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: acme-api
namespace: acme-production
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: acme-api
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
Choose minReplicas to cover baseline load and high availability, and maxReplicas to fit your ResourceQuota.
Reliability
Health Checks (Probes)
Probes let Kubernetes detect broken containers and send traffic only to pods that are ready:
startupProbe:
httpGet:
path: /healthz
port: 8080
failureThreshold: 30
periodSeconds: 5
livenessProbe:
httpGet:
path: /healthz
port: 8080
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 8080
periodSeconds: 5
- Readiness probe: decides whether a pod receives traffic – essential for zero-downtime rollouts.
- Liveness probe: restarts hung containers. Don't check external dependencies such as databases here, or every pod restarts when the database has an outage.
- Startup probe: protects slow-starting applications from being restarted too early by the liveness probe.
Spread Replicas and Protect Them with a PodDisruptionBudget
Run production applications with at least two replicas spread across different nodes. A PodDisruptionBudget ensures that planned maintenance never stops all replicas at once.
apiVersion: apps/v1
kind: Deployment
metadata:
name: acme-api
spec:
replicas: 2
template:
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app.kubernetes.io/name: acme-api
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: acme-api
spec:
minAvailable: 1
selector:
matchLabels:
app.kubernetes.io/name: acme-api
minAvailable must be lower than the number of replicas. Maintenance, Upgrades & Capacity explains why.
Rolling Updates and Graceful Shutdown
Configure rolling updates so old pods are only removed once new ones are ready:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
When a pod is stopped, your container receives SIGTERM. Stop accepting new connections and finish in-flight requests. If the default 30 seconds aren't enough, raise terminationGracePeriodSeconds. A short preStop hook (e.g. sleep 5) gives routing time to remove the pod before it shuts down.
Run Workloads Through Controllers
Don't start standalone pods (kind: Pod); use a Deployment, StatefulSet, DaemonSet, Job or CronJob instead. Give one-off jobs such as database migrations a ttlSecondsAfterFinished so finished jobs are cleaned up automatically.
Observability
Log Structured Output to stdout and stderr
Don't write logs to files inside the container; emit JSON to stdout and stderr. The SDP collects this output automatically in VictoriaLogs, searchable in Grafana.
{"timestamp":"2026-11-29T14:30:00Z","level":"info","service":"acme-api","request_id":"req-9f8e7d6c","status":200,"duration_ms":42,"message":"Request processed"}
Use consistent field names such as level, service and request_id, and never log passwords, tokens or personal data.
Expose Metrics
Expose metrics such as request rate, error rate and latency on a Prometheus-compatible /metrics endpoint and have VictoriaMetrics scrape it via a VMServiceScrape:
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMServiceScrape
metadata:
name: acme-api
namespace: acme-production
spec:
selector:
matchLabels:
app.kubernetes.io/name: acme-api
endpoints:
- port: metrics
path: /metrics
interval: 30s
Build dashboards and alert rules on these metrics in Grafana (see Observability).
GitOps and Data
Deliver Declaratively
Keep manifests and Helm values in Forgejo or GitLab and deploy with Argo CD. Separate environments by namespace (e.g. acme-staging, acme-production), use consistent labels (app.kubernetes.io/name, app.kubernetes.io/version, app.kubernetes.io/part-of), and test changes in staging before rolling them out to production.
Externalize State and Test Restores
Keep application containers stateless and store data in services built for it: databases, persistent volumes or S3-compatible object storage (Storage). Test restoring your data regularly as described in Backup & Restore.