Minimal objects to expose a stateless app
mapping requirements to core objects.
a Deployment to run and self-heal replicas plus a Service to give a stable endpoint, exposed externally via type LoadBalancer or NodePort, or an Ingress.
What's really being asked
This checks whether you can translate a plain requirement into the right minimal Kubernetes objects and explain each one's purpose.
The full answer
For a stateless web server you need two things. A Deployment runs the Pods, maintains the desired replica count, and recreates Pods that die or get rescheduled, so you never manage Pods directly. A Service gives those Pods a single stable endpoint and load-balances traffic across them, which matters because Pod IPs are ephemeral and change on restart. To make it reachable from outside the cluster, choose the Service type: LoadBalancer provisions an external load balancer on a cloud provider, NodePort opens a port on every node for simpler or on-prem setups, and for HTTP you often add an Ingress plus an ingress controller to route by host or path over a single external address. A StatefulSet is unnecessary because there is no persistent per-Pod identity or storage.
The mistakes people make
Exposing a single bare Pod and pointing clients at its IP. Using a StatefulSet for a stateless workload. Forgetting the Service and trying to reach Pods directly. Assuming ClusterIP is externally reachable.
What usually comes next
What is the difference between ClusterIP, NodePort, and LoadBalancer? Why not use a Pod IP directly? When do you add an Ingress? How does the Service find its Pods?
A concrete example
You create a Deployment with three replicas of the web image. You create a Service of type LoadBalancer with a selector matching the Deployment's Pod labels; the cloud provisions an external IP that forwards to the Pods and load-balances across them. If a Pod crashes, the Deployment replaces it and the Service automatically routes only to healthy endpoints, all without clients ever knowing individual Pod IPs.
Interview question
Why is a Service needed in front of the Deployment's Pods for external access?
- a.A Service makes the image smaller
- b.Pods cannot run web servers without one
- c.Pod IPs are ephemeral, so a Service provides a stable endpoint and load-balances across themCorrect
- d.Without it, the Deployment will not create Pods
Why? this is the answer
Pods get new IPs when rescheduled; a Service gives a durable virtual IP and balances traffic across current healthy Pods. The Deployment creates Pods regardless of any Service.
Just read this? Test yourself on what you have been reading.
Read the original → kubernetes.io
- #kubernetes
- #deployment
- #service
- #networking
- #fundamentals
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.
See open roles