Kubernetes Deployments and Services

MODULE 32 · LESSON 32.3

Deploy a stateless API with health probes and resource boundaries, then decide honestly whether orchestration is warranted.

Practice-firstBeginner-friendlyProduction-aware

Use the concept at the correct boundary

The difficult part of Kubernetes Deployments and Services is deciding where the responsibility belongs and how you will know it works. This lesson controls how a working change survives machines, environments, traffic and failure after it leaves a developer laptop.

Here, that decision supports a specific checkpoint: Package CourseFlow for a second CI platform, deploy it behind a reverse proxy, and write the evidence needed to operate or roll it back. A reviewable result should include a command transcript, CI result, deployment check and rollback note rather than a claim that the feature simply works.

Kubernetes Deployments and Services workflowA four-step visual showing pods, deployments, services, health probes.Kubernetes Deployments and Services workflow1Pods2Deployments3Services4Health Probes

Kubernetes Deployments and Services workflow

  1. 1Pods
  2. 2Deployments
  3. 3Services
  4. 4Health Probes
Kubernetes Deployments and Services workflow: a practical sequence used in this lesson.

A practical model for kubernetes deployments and services

Deploy a stateless API with health probes and resource boundaries, then decide honestly whether orchestration is warranted. The useful unit of understanding is the boundary: who owns the decision, which input crosses it, what result is visible and how a failure is reported.

  • Pods: Explain the concept without framework jargon, then point to it in the working example.
  • Deployments: Decide what belongs in code, configuration, data or documentation and explain why.
  • Services: Name its input, observable result and most likely failure in this lesson.
  • Health Probes: Locate this responsibility in CourseFlow and defend the boundary you chose.

Engineering decisions for Kubernetes Deployments and Services

These are the details that separate a working demonstration from a maintainable production decision.

  • Kubernetes solves orchestration problems; it does not make an application stateless, secure or observable automatically.
  • Pin immutable image versions, set requests and limits, and keep secrets outside manifests committed to Git.
  • Separate liveness from readiness so a temporary dependency problem does not create a restart storm.

What the example proves

Use the sample to answer one question: does the implementation make pods easier to verify or merely harder to see?

YAML
apiVersion: apps/v1
kind: Deployment
metadata: { name: courseflow-api }
spec:
  replicas: 2
  selector: { matchLabels: { app: courseflow-api } }
  template:
    metadata: { labels: { app: courseflow-api } }
    spec:
      containers:
        - name: api
          image: registry.example/courseflow-api:1.0.0
          ports: [{ containerPort: 3000 }]
          readinessProbe:
            httpGet: { path: /ready, port: 3000 }
          resources:
            requests: { cpu: 100m, memory: 128Mi }
            limits: { memory: 256Mi }
Test the claim, not your memory

Change one input connected to pods, predict the result, then run the successful path and one failure path.

Implement and verify one behavior

  1. 1
    Pods

    Add this responsibility at the narrowest sensible boundary; do not pull an unrelated layer into the change.

  2. 2
    Deployments

    Run the focused example and save the output, trace, query or screenshot that confirms the result.

  3. 3
    Services

    Break one assumption on purpose, make recovery clear and record the trade-off you accepted.

  4. 4
    Health Probes

    Name the caller and the owner of this behavior before changing the implementation.

Common design traps

  • Treating pods as vocabulary instead of defining the behavior it must produce.
  • Testing the expected path while ignoring an empty, invalid, repeated or unauthorized case around deployments.
  • Allowing services to cross a boundary without an explicit contract or useful error.
  • Changing several layers before capturing the first piece of evidence, which makes the original cause harder to see.

Diagnose before changing code

  1. Reduce the problem to the smallest failing Kubernetes Deployments and Services case.
  2. Capture the actual input and output at the pods boundary.
  3. Read the first relevant error, request, trace or query rather than the loudest downstream symptom.
  4. Test one explanation for the failure in deployments; avoid changing two variables together.
  5. Keep a regression check that would expose the same defect if it returned.

Security decision

Use least privilege, protected secrets, reviewed dependencies and reversible changes. A deployment shortcut must never weaken the application boundary.

Performance decision

Establish a baseline, observe resource use and latency, and keep a rollback signal. Capacity changes without measurement are guesses.

PRACTICE

Build something you can inspect

Apply the deployment to a local cluster, make readiness fail, and observe how traffic differs from a crashed container.

Stretch challenge

Replace one happy-path assumption about deployments with explicit validation and show the before-and-after behavior.

Definition of done

  • The behavior around pods works with realistic input.
  • A failure involving deployments is handled clearly and without leaking sensitive detail.
  • The implementation remains keyboard-usable when it produces an interface.
  • Your evidence directly supports the claim made in the exercise.
  • The README records the important trade-off without pretending the solution is universal.

Check your reasoning

Why must a readiness endpoint test whether the instance can serve traffic without becoming an expensive dependency audit?

Answer by naming the expected pods behavior, the layer responsible for it and the evidence that would confirm your explanation.

Where would you investigate the first failure?

Start where deployments crosses a boundary. Compare the actual input and output there before following downstream symptoms.

What would make this work reviewable?

Show the focused change, repeatable steps, the result of your check and one honest trade-off connected to services.

What to carry into the next lesson

  • Deploy a stateless API with health probes and resource boundaries, then decide honestly whether orchestration is warranted.
  • Keep pods visible at the boundary where it can be tested.
  • Use evidence from deployments before widening the implementation.

References and related reading

Progress is stored only in this browser.

Share this page

Share this page with the people who will use it next.

X Facebook LinkedIn WhatsApp Email

Discussion

No comments yet. Add the first useful question or observation.