Hanzo

Kubernetes Deployments

Create Deployments, StatefulSets, and CronJobs on Kubernetes clusters with resource limits, health checks, and rolling updates.

Kubernetes is the default orchestrator for production workloads. The platform maps its container abstraction directly to native K8s resources — Deployments, StatefulSets, and CronJobs.

Creating a Container

Choose the Container Type

Select one of three types based on your workload:

TypeK8s ResourceUse Case
deploymentDeployment + ReplicaSetStateless services, APIs, web apps
statefulsetStatefulSetDatabases, caches, ordered pods
cronjobCronJobScheduled batch jobs, cleanups

Configure the Source

Pick either Git Repository (build from source) or Container Registry (pre-built image).

For a registry source, provide the image name and tag:

sourceType: registry
registryConfig:
  registryId: "reg-abc123"      # optional — links to a saved registry
  imageName: "ghcr.io/org/app"
  imageTag: "v1.2.0"

Set Resource Limits

Every container requires CPU and memory requests/limits. These map directly to K8s resource specifications.

podConfig:
  cpuRequest: 100        # millicores (10-1000m) or cores (0.1-4)
  cpuRequestType: millicores
  cpuLimit: 1
  cpuLimitType: cores
  memoryRequest: 128     # mebibytes (10-1024Mi) or gibibytes (0.1-16Gi)
  memoryRequestType: mebibyte
  memoryLimit: 1
  memoryLimitType: gibibyte
  restartPolicy: Always  # Always | OnFailure | Never

CPU request must be less than or equal to CPU limit. Same for memory. The platform validates this before deploying.

Configure Networking

Expose your container with a port, optional ingress, custom domain, or raw TCP proxy:

networking:
  containerPort: 8080
  ingress:
    enabled: true
    type: subdomain       # "path" or "subdomain"
  customDomain:
    enabled: true
    domain: "api.example.com"
  tcpProxy:
    enabled: false
    publicPort: 5432

Add Environment Variables

Pass configuration as key-value pairs. These become K8s env entries on the pod spec.

variables:
  - name: DATABASE_URL
    value: "postgres://user:pass@db:5432/app"
  - name: NODE_ENV
    value: "production"

Deploy

The platform creates the namespace (idempotent), applies the K8s manifest, and begins tracking status.

Deployments (Replicas & Autoscaling)

Static Replicas

Set a fixed replica count (1-100):

deploymentConfig:
  replicas: 3
  strategy: RollingUpdate

Horizontal Pod Autoscaling

Enable CPU or memory-based autoscaling by setting min/max replicas and a metric target:

deploymentConfig:
  minReplicas: 2
  maxReplicas: 10
  strategy: RollingUpdate
  cpuMetric:
    enabled: true
    metricType: AverageUtilization
    metricValue: 70
  memoryMetric:
    enabled: false

Available metric types:

ResourceMetric Types
CPUAverageUtilization, AverageValueMillicores, AverageValueCores
MemoryAverageValueMebibyte, AverageValueGibibyte

When autoscaling is enabled, minReplicas and maxReplicas are required. minReplicas must be less than or equal to maxReplicas.

Rolling Updates

Control how pods are replaced during a deployment:

deploymentConfig:
  strategy: RollingUpdate
  rollingUpdate:
    maxSurge: 1              # or "25%"
    maxSurgeType: number     # "number" or "percentage"
    maxUnavailable: 0
    maxUnavailableType: number

For downtime-tolerant workloads, use Recreate — all old pods are terminated before new ones start.

StatefulSets

StatefulSets provide stable network identities and persistent storage:

statefulSetConfig:
  desiredReplicas: 3
  strategy: RollingUpdate
  podManagementPolicy: OrderedReady  # or "Parallel"
  rollingUpdate:
    maxUnavailable: 1
    partition: 0
  persistentVolumeClaimRetentionPolicy:
    whenDeleted: Retain
    whenScaled: Retain

Persistent Volumes

Attach a PVC to any StatefulSet:

storageConfig:
  enabled: true
  mountPath: /data
  size: 10
  sizeType: gibibyte           # "mebibyte" (10-1024) or "gibibyte" (0.1-5000)
  accessModes:
    - ReadWriteOnce            # ReadWriteOnce | ReadOnlyMany | ReadWriteMany

CronJobs

Schedule recurring tasks using standard cron expressions:

cronJobConfig:
  schedule: "0 */6 * * *"       # every 6 hours
  timeZone: "America/New_York"
  concurrencyPolicy: Forbid     # Allow | Forbid | Replace
  suspend: false
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1

Health Checks (Probes)

Configure startup, readiness, and liveness probes with three check mechanisms:

probes:
  readiness:
    enabled: true
    checkMechanism: httpGet
    httpPath: /healthz
    httpPort: 8080
    initialDelaySeconds: 5
    periodSeconds: 10
    timeoutSeconds: 3
    failureThreshold: 3
  liveness:
    enabled: true
    checkMechanism: httpGet
    httpPath: /healthz
    httpPort: 8080
    initialDelaySeconds: 15
    periodSeconds: 20
    timeoutSeconds: 5
    failureThreshold: 3
  startup:
    enabled: false
probes:
  readiness:
    enabled: true
    checkMechanism: tcpSocket
    tcpPort: 5432
    initialDelaySeconds: 5
    periodSeconds: 10
    timeoutSeconds: 3
    failureThreshold: 3
probes:
  liveness:
    enabled: true
    checkMechanism: exec
    execCommand: "pg_isready -U postgres"
    initialDelaySeconds: 30
    periodSeconds: 10
    timeoutSeconds: 5
    failureThreshold: 3

Scaling

Scale a running container to a specific replica count (0 to scale down, up to 100):

# Via the platform UI: Container → Scale → set replica count
# Via API:
container.scale({ containerId: "ctr-abc", replicas: 5 })

Scaling to 0 removes all pods but keeps the container definition intact.

Container Status

The platform polls the orchestrator for live status:

StatusMeaning
CreatingK8s resources are being applied
RunningAll desired replicas are ready
UpdatingRolling update in progress
PendingPods are scheduled but not yet running
FailedOne or more pods failed to start
TerminatingContainer is being deleted

Templates

Deploy pre-configured database and service templates with a single click:

TemplateTypeCategory
PostgreSQLStatefulSetDatabase
MySQLStatefulSetDatabase
MariaDBStatefulSetDatabase
MongoDBStatefulSetDatabase
RedisStatefulSetKV Store
MemcachedStatefulSetKV Store
MinIOStatefulSetObject Storage

Templates pre-fill resource limits, storage mounts, probes, and default environment variables (credentials are auto-generated).

How is this guide?

Last updated on

On this page