Interview's MateDocker
Interview's Mate

Docker

Compose · Networking · Security · Ops

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Docker topics
Lesson 150/ 160
08. Container Orchestration & Ecosystem

Kubernetes Services, Ingress & ConfigMaps/Secrets

Expose apps with Services/Ingress and inject config via ConfigMaps and Secrets.

IntermediateService · Ingress3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Separate internal identity, external HTTP policy and injected configuration, then verify selectors and ingress controller ownership.

Think of it like…

The Service is a stable office switchboard, Ingress is the public reception route, ConfigMap is the policy sheet and Secret is the locked access card.

Where you’ve seen it

In practice, kubectl create service clusterip api --tcp=8080:8080; kubectl apply -f ingress.yaml; kubectl get svc,ingress,endpointslice is the concrete move for this job: expose apps with Services/Ingress and inject config via ConfigMaps and Secrets. The release is not accepted until curl through the ingress host/TLS endpoint, inspect EndpointSlice Pod IPs and confirm ConfigMap/Secret hashes changed the rollout confirms the result.

Words you’ll hear

Service
The implementation control in kubectl create service clusterip api --tcp=8080:8080; kubectl apply -f ingress.yaml; kubectl get svc,ingress,endpointslice for expose apps with Services/Ingress and inject config via ConfigMaps and Secrets.
Ingress
The result to observe with curl through the ingress host/TLS endpoint, inspect EndpointSlice Pod IPs and confirm ConfigMap/Secret hashes changed the rollout, rather than infer from a successful command alone.
ConfigMaps
The production boundary exposed when declaring an Ingress before installing the controller, or base64-encoding a secret and committing it as if encryption existed.

Visual diagram

Loading interactive diagram

Theory & deep dive

Service control path

The concrete mechanism is kubectl create service clusterip api --tcp=8080:8080; kubectl apply -f ingress.yaml; kubectl get svc,ingress,endpointslice. The observable result is curl through the ingress host/TLS endpoint, inspect EndpointSlice Pod IPs and confirm ConfigMap/Secret hashes changed the rollout; if those disagree, inspect the runtime evidence before changing unrelated settings.

Expose apps with Services/Ingress and inject config via ConfigMaps and Secrets. Keep Service, Ingress and ConfigMaps in the same deployment record so the intent and the observed state cannot drift apart.

Concrete Service setup

kubectl create service clusterip api --tcp=8080:8080; kubectl apply -f ingress.yaml; kubectl get svc,ingress,endpointslice

Key takeaway: Prove Ingress with curl through the ingress host/TLS endpoint, inspect EndpointSlice Pod IPs and confirm ConfigMap/Secret hashes changed the rollout, not with command success alone.

ConfigMaps failure boundary

A Service without matching labels creates no endpoints, and an Ingress resource with no controller does nothing. Kubernetes Secrets are not encrypted merely by base64 and should not be exposed through broad RBAC or CI logs. The narrow failure to design for is declaring an Ingress before installing the controller, or base64-encoding a secret and committing it as if encryption existed.

Accept this compromise explicitly: Service/Ingress separates concerns but depends on a correctly managed controller and network policy; a cloud load balancer can simplify edge ownership. The controlled check-curl through the ingress host/TLS endpoint, inspect EndpointSlice Pod IPs and confirm ConfigMap/Secret hashes changed the rollout-also identifies the point where a different design is safer.

Deliberate failure test

Exercise this failure safely: declaring an Ingress before installing the controller, or base64-encoding a secret and committing it as if encryption existed.

Key takeaway: Service/Ingress separates concerns but depends on a correctly managed controller and network policy; a cloud load balancer can simplify edge ownership.

How it works, step by step

Step 1 of 4
Design

1. State the boundary

Write down why the workload needs this: A Service without matching labels creates no endpoints, and an Ingress resource with no controller does nothing. Kubernetes Secrets are not encrypted merely by base64 and should not be exposed through broad RBAC or CI logs.

Separate internal identity, external HTTP policy and injected configuration, then verify selectors and ingress controller ownership.
Key numbers at this step
Intent
Service

When to use it & trade-offs

What it is

A Service selects Pod endpoints and gives stable ClusterIP/DNS; an Ingress (or Gateway) describes HTTP/TLS routing handled by a controller. ConfigMaps carry non-secret configuration and Secrets carry base64-decoded sensitive bytes with access controls and ideally external encryption.

Why it matters: A Service without matching labels creates no endpoints, and an Ingress resource with no controller does nothing. Kubernetes Secrets are not encrypted merely by base64 and should not be exposed through broad RBAC or CI logs.

When to reach for it

  • The fit is strongest for this job: expose apps with Services/Ingress and inject config via ConfigMaps and Secrets. Pair it with curl through the ingress host/TLS endpoint, inspect EndpointSlice Pod IPs and confirm ConfigMap/Secret hashes changed the rollout in the runbook.
  • Production Service changes should make Ingress observable through kubectl create service clusterip api --tcp=8080:8080; kubectl apply -f ingress.yaml; kubectl get svc,ingress,endpointslice, rather than trusting the runtime default.
  • Keep a rollback example for the case where declaring an Ingress before installing the controller, or base64-encoding a secret and committing it as if encryption existed.

When to avoid or be careful

  • Do not accept command success while the system can still fail by declaring an Ingress before installing the controller, or base64-encoding a secret and committing it as if encryption existed.
  • Avoid erasing ConfigMaps protection merely to dodge this cost: “Service/Ingress separates concerns but depends on a correctly managed controller and network policy; a cloud load balancer can simplify edge ownership”.
  • Do not replace the evidence path-curl through the ingress host/TLS endpoint, inspect EndpointSlice Pod IPs and confirm ConfigMap/Secret hashes changed the rollout-with a screenshot or a mutable tag.

kubectl create service clusterip api --tcp=8080:8080; kubectl apply -f ingress.yaml; kubectl get svc,ingress,endpointslice: practical choices

Explicit Service
Best for: Expose apps with Services/Ingress and inject config via ConfigMaps and Secrets, with a reviewed runbook.

Strengths: A Service selects Pod endpoints and gives stable ClusterIP/DNS; an Ingress (or Gateway) describes HTTP/TLS routing handled by a controller. ConfigMaps carry non-secret configuration and Secrets carry base64-decoded sensitive bytes with access controls and ideally external encryption.

Watch out: Service/Ingress separates concerns but depends on a correctly managed controller and network policy; a cloud load balancer can simplify edge ownership.

Ambient default
Best for: Short-lived Ingress experiments with low blast radius.

Strengths: It can begin with kubectl create service clusterip api --tcp=8080:8080; kubectl apply -f ingress.yaml; kubectl get svc,ingress,endpointslice and fewer surrounding controls.

Watch out: It silently accepts declaring an Ingress before installing the controller, or base64-encoding a secret and committing it as if encryption existed, which makes the result hard to reproduce after promotion.

Managed ConfigMaps
Best for: Teams that centralize ConfigMaps policy across many workloads.

Strengths: A Service without matching labels creates no endpoints, and an Ingress resource with no controller does nothing. Kubernetes Secrets are not encrypted merely by base64 and should not be exposed through broad RBAC or CI logs.

Watch out: The platform adds an ownership and debugging layer; retain curl through the ingress host/TLS endpoint, inspect EndpointSlice Pod IPs and confirm ConfigMap/Secret hashes changed the rollout as the direct check.

Interview signals & numbers to know

When this topic comes up

  • kubectl create service clusterip api --tcp=8080:8080; kubectl apply -f ingress.yaml; kubectl get svc,ingress,endpointslice
  • curl through the ingress host/TLS endpoint, inspect EndpointSlice Pod IPs and confirm ConfigMap/Secret hashes changed the rollout
  • Failure signature: declaring an Ingress before installing the controller, or base64-encoding a secret and committing it as if encryption existed
  • Trade-off: Service/Ingress separates concerns but depends on a correctly managed controller and network policy; a cloud load balancer can simplify edge ownership.

Benchmarks & rules of thumb

10.96/12 -
common but not universal ClusterIP range
80→8080 -
frontend Service/Pod port mapping example
Base64 != encryption -
the key Secrets mental model

Common mistakes & follow-ups

Common interview mistakes

  • Treating a successful kubectl create service clusterip api --tcp=8080:8080; kubectl apply -f ingress.yaml; kubectl get svc,ingress,endpointslice as proof and skipping curl through the ingress host/TLS endpoint, inspect EndpointSlice Pod IPs and confirm ConfigMap/Secret hashes changed the rollout.
  • Declaring an Ingress before installing the controller, or base64-encoding a secret and committing it as if encryption existed
  • Optimizing Service without accepting that service/Ingress separates concerns but depends on a correctly managed controller and network policy; a cloud load balancer can simplify edge ownership.

Likely interviewer follow-ups

  • Why does kubectl create service clusterip api --tcp=8080:8080; kubectl apply -f ingress.yaml; kubectl get svc,ingress,endpointslice address Service here rather than through application code?
  • How would you distinguish healthy Ingress from the failure “declaring an Ingress before installing the controller, or base64-encoding a secret and committing it as if encryption existed” using curl through the ingress host/TLS endpoint, inspect EndpointSlice Pod IPs and confirm ConfigMap/Secret hashes changed the rollout?
  • When would this trade-off-“Service/Ingress separates concerns but depends on a correctly managed controller and network policy; a cloud load balancer can simplify edge ownership”-justify a different ConfigMaps design?
Interview tip: Give one concrete operation-kubectl create service clusterip api --tcp=8080:8080; kubectl apply -f ingress.yaml; kubectl get svc,ingress,endpointslice-and one proof-curl through the ingress host/TLS endpoint, inspect EndpointSlice Pod IPs and confirm ConfigMap/Secret hashes changed the rollout. Then name the boundary: declaring an Ingress before installing the controller, or base64-encoding a secret and committing it as if encryption existed.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Kubernetes Services, Ingress & ConfigMaps/Secrets with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Mapping Docker Concepts to Kubernetes (Containers → Pods, Compose → Deployments)
Next topic
Local Kubernetes Environments with Docker (Kind, Minikube, Docker Desktop K8s)