TExcelTAD
Home › Platform Engineering: Internal Developer Platforms › Self-Service Infrastructure Patterns

Self-Service Infrastructure Patterns

"I need a database" is the request that most often turns a platform team into a ticket queue. This section is about answering it in minutes without a human in the loop, while still getting an encrypted, backed-up, tagged, monitored database every time.

Four levels of self-service

Level Developer does Platform does Wait
0. Ticket describes the need in a ticket a person clicks or writes Terraform days
1. Pull request to the infra repo copies a module block into the team's Terraform root, opens a PR reviews; CI plans and applies hours
2. Declarative request adds a small request file (or fills a portal form that writes it) CI or a controller validates and fulfils it automatically minutes
3. API / control plane applies a custom resource (kind: Database) in their namespace, or calls an API a controller (Crossplane, an operator) reconciles it continuously minutes, and drift is corrected

Levels 1 and 2 use the Terraform module catalog; level 3 is where Crossplane comes in. Most organisations run a mix: level 2 or 3 for the common things (databases, buckets, queues, namespaces), level 1 for the unusual, level 0 only for genuinely rare requests.

The request is the interface

Whatever fulfils it, a good self-service interface is a small, validated, declarative request in the team's vocabulary:

yaml
# requests/shortlinks-db.yaml in the team's repo or a central platform-requests repo
kind: Database
name: shortlinks
owner: team-growth
engine: postgres
size: s
tier: standard

The platform translates it into whatever it uses today (a module call, a Crossplane resource, a cloud API call). If it moves from Terraform to Crossplane next year, the request format doesn't change. That's the abstraction a platform sells: decisions in the developer's terms, implementation behind it.

Validating and translating a request

The session plays the CI job of a level-2 setup. It validates three requests against the platform's rules (allowed engines and sizes, name format, owner exists), then translates the valid ones into Kubernetes resources for the Crossplane composition you'll write in XRDs & Compositions:

bash · try it yourself
mkdir -p requests out
cat > teams.txt <<'EOF'
team-growth
team-links
EOF
cat > requests/shortlinks-db.yaml <<'EOF'
kind: Database
name: shortlinks
owner: team-growth
engine: postgres
size: s
EOF
cat > requests/analytics-db.yaml <<'EOF'
kind: Database
name: analytics
owner: team-growth
engine: mongodb
size: xl
EOF
cat > requests/Links_DB.yaml <<'EOF'
kind: Database
name: Links_DB
owner: team-links
engine: postgres
size: m
tier: critical
EOF
ok=0 bad=0
for req in requests/*.yaml; do
  errs=()
  name=$(yq '.name' "$req") owner=$(yq '.owner' "$req")
  [[ $name =~ ^[a-z][a-z0-9-]{1,28}[a-z0-9]$ ]] || errs+=("name '$name' must be a lowercase DNS label")
  grep -qx "$owner" teams.txt || errs+=("unknown owner '$owner'")
  yq -e '.engine == "postgres"' "$req" >/dev/null 2>&1 || errs+=("engine '$(yq '.engine' "$req")' not offered (postgres)")
  yq -e '.size | test("^(s|m|l)
quot;)' "$req" >/dev/null 2>&1 || errs+=("size '$(yq '.size' "$req")' not one of s, m, l") if [ ${#errs[@]} -gt 0 ]; then bad=$((bad + 1)); echo "REJECT $req"; printf ' - %s\n' "${errs[@]}"; continue fi ok=$((ok + 1)); echo "ACCEPT $req" # translate: the request becomes a namespaced composite resource in the team's namespace yq -n " .apiVersion = \"platform.acme.io/v1alpha1\" | .kind = \"Database\" | .metadata.name = \"$name\" | .metadata.namespace = \"$owner\" | .metadata.labels.\"acme.io/owner\" = \"$owner\" | .spec.size = \"$(yq '.size' "$req")\" | .spec.tier = \"$(yq '.tier // "standard"' "$req")\" " > "out/$name.yaml" done echo "$ok accepted, $bad rejected" cat out/shortlinks.yaml
REJECT requests/Links_DB.yaml
  - name 'Links_DB' must be a lowercase DNS label
REJECT requests/analytics-db.yaml
  - engine 'mongodb' not offered (postgres)
  - size 'xl' not one of s, m, l
ACCEPT requests/shortlinks-db.yaml
1 accepted, 2 rejected
apiVersion: platform.acme.io/v1alpha1
kind: Database
metadata:
  name: shortlinks
  namespace: team-growth
  labels:
    acme.io/owner: team-growth
spec:
  size: s
  tier: standard

The rejections are what a ticket would have produced after a day of back-and-forth: Links_DB can't be a Kubernetes name, MongoDB isn't offered (the team now knows to talk to the platform team, or to use PostgreSQL), and xl doesn't exist. The accepted request became a five-field resource. Note tier defaulting to standard with yq's // (alternative) operator.

What every self-service capability needs

  • Guardrails, not gates: validation and policy run automatically (Secrets & Policy: policy as code); no human approval for the standard case.
  • Quotas and cost visibility: a team can create databases freely up to its quota, and sees what they cost (FinOps).
  • Ownership on everything: the owner label flows from the request into every cloud resource's tags and into the catalog as a Resource entity.
  • Day 2 included: resizing, backups and restore, deletion (with protection for production), credential rotation. Creation is the easy 20%.
  • Status back to the requester: "ready, connection secret is shortlinks-db-conn in your namespace", or a clear error. A controller writes it to the resource's status; a pipeline posts it as a PR comment.

Test yourself

What is the main advantage of a declarative request (kind: Database, size: s) over letting teams call the cloud module directly?

  1. It is shorter YAML
  2. It is an abstraction in the team's terms: the platform can change the implementation (Terraform → Crossplane) without changing the interface
  3. It is faster to apply
  4. It avoids validation

Which self-service level corrects drift continuously?

  1. Ticket
  2. Pull request with Terraform applied by CI
  3. A controller reconciling a custom resource (level 3)
  4. None can

In the session, what does yq '.tier // "standard"' do?

  1. Divides tier
  2. Returns tier, or "standard" when it is missing or null
  3. Comments out tier
  4. Validates tier