Selected implementation

Code

Not a GitHub mirror. This page highlights small pieces of code that demonstrate engineering patterns and trade-offs.

TERRAFORM

Dynamic NLB subnet mapping

Create one public address per subnet while keeping the load balancer declaration compact.

network.tf
dynamic "subnet_mapping" {
  for_each = toset(local.public_subnets)

  content {
    subnet_id = subnet_mapping.value
    allocation_id = aws_eip.nlb[
      subnet_mapping.value
    ].id
  }
}
PYTHON

Explicit service actions

A small action dispatcher keeps scheduled and manual entry points identical.

handler.py
def handler(event, context):
    action = event.get("action", "status")

    actions = {
        "status": status,
        "start": start,
        "stop": stop,
    }

    return actions[action]()
KUBERNETES

Dedicated architecture workload

A taint isolates workloads that require a specific CPU architecture.

nodepool.yaml
taints:
  - key: workload
    value: x86
    effect: NoSchedule

requirements:
  - key: kubernetes.io/arch
    operator: In
    values: [amd64]
GO / API DESIGN

Fan-out service pattern

Use a service endpoint as a control plane while requests are executed directly against selected pods.

proxy.go
for _, pod := range pods {
    go func(addr string) {
        err := callPod(addr, request)
        results <- Result{Addr: addr, Err: err}
    }(pod.Status.PodIP)
}