There is one Pod in shallows-dw1643. It is called lonely.
kubectl get pods -n shallows-dw1643Part one: delete it
kubectl delete pod lonely -n shallows-dw1643
kubectl get pods -n shallows-dw1643It is gone. Nothing brings it back, because nothing was asked to. A bare Pod is a one-off: Kubernetes will restart its containers if they crash, but if the Pod itself is deleted, or its node disappears, that is the end of it.
Part two: create a ReplicaSet
A is the simplest such controller. You give it three things: how many Pods you want (replicas), how to recognise its Pods (selector), and how to make a new one (template). The selector labels and the template labels must agree, or it will create Pods it cannot find.
Apply this manifest. The YAML is passed straight to kubectl apply on standard input:
kubectl apply -n shallows-dw1643 -f - <<EOF
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: web
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx
EOFThen check it:
kubectl get rs -n shallows-dw1643
kubectl get pods -n shallows-dw1643 -l app=webThree Pods, with generated names like web-x7k2p. The DESIRED, CURRENT and READY columns should all read 3.
Part three: delete one of its Pods
Pick any one of the three and delete it:
kubectl delete pod <one-of-them> -n shallows-dw1643
kubectl get pods -n shallows-dw1643 -l app=webCount the Pods now and answer the last objective. Then describe the ReplicaSet and read the Events at the bottom; they show the replacement Pod it created.
kubectl describe rs web -n shallows-dw1643