Kubernetes Services, Ingress & ConfigMaps/Secrets
Expose apps with Services/Ingress and inject config via ConfigMaps and Secrets.
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,endpointslicefor 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
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.
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, 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.
Exercise this failure safely: declaring an Ingress before installing the controller, or base64-encoding a secret and committing it as if encryption existed.
How it works, step by step
Step 1 of 41. 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.
- 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 rolloutin 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
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.
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.
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,endpointsliceas proof and skippingcurl 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,endpointsliceaddress 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?
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
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.