Blocks · Web and proxies

web/whoami

whoami test service. Answers each request with its replica number, to watch load balancing.

Overview

A built-in HTTP service that answers every request with replica-<n>, where n is the replica's index. Expanse's own load-balancer tests use it: put it behind a VIP and repeated requests show how traffic spreads. It also echoes the request's X-Forwarded-For header back as X-Seen-XFF, which shows what the L7 proxy forwarded.

Shape
Stateless replicas
Reached at
Node port, or a VIP
Node package
None

Built into Expanse: it runs on any node with no extra package.

Example

whoami.yaml
apiVersion: expanse.io/v1
kind: Block
metadata:
  name: whoami
  namespace: default
spec:
  type: web/whoami
  replicas: 3
  placement:
    antiAffinity: ANTI_AFFINITY_NODE
  resources:
    requests:
      cpu: 100m
      memory: 64Mi
  config:
    port: 8080
  network:
    ports:
      - name: http
        port: 80
        target_port: 8080
        protocol: tcp
        expose: EXPOSE_VIP
    health_check:
      readiness:
        type: PROBE_TCP
        port: 8080
        period_seconds: 2
$ expanse ctl block apply -f whoami.yaml --dry-run   # validate only
$ expanse ctl block apply -f whoami.yaml

Configuration

Keys go under spec.config and are checked against the type's JSON Schema when the block is applied. A default is what the block uses when the key is unset.

KeyDefaultMeaning
port8080TCP port whoami listens on.
greetingnoneText written before replica-<n> in every answer.

Using it

$ for i in $(seq 6); do curl -s http://<VIP>/; done
replica-0
replica-2
replica-1
replica-0
replica-1
replica-2

/healthz answers ok for an HTTP readiness probe.

When a node fails

When a node fails, its replica's answers stop appearing; the VIP keeps serving from the others, and after the unreachable grace (30 s) a replacement replica starts elsewhere.

Limits

  • A test workload: it serves nothing but its replica number.

Source

All block types · Fields every block shares