Cyclops attacks

The Cyclops has sabotaged the shop four times. For each one, work out what's wrong from the clue before opening the answer. These are exactly the kinds of breakage the exam asks you to fix.

Four little accidents. Let’s see you find them. Four little clues, Cyclops. Give me get, describe and a sharp eye for spelling.
1

The Service with nobody behind it

The shop Service exists, but every request fails. kubectl get endpointslices -l kubernetes.io/service-name=shop shows no addresses.

{{label0}}
$ kubectl describe service shop
Selector:  app=shpo
$ kubectl get pods --show-labels
shop-7d9c...-xk2pq   ...   app=shop

Why: The Cyclops slipped a typo into the selector: shpo instead of shop. No Pod wears that tag, so the Pharos shines on nobody. Fix the selector with kubectl edit service shop.

2

Connection refused

The endpoints list has three Pods, but connecting to the Service on port 80 is refused.

{{label1}}
$ kubectl describe service shop
Port:        80/TCP
TargetPort:  80/TCP      # the container listens on 8080!

Why: The Service forwards to port 80, but the shop listens on 8080. Set targetPort: 8080.

3

The Deployment that won’t be created

kubectl apply -f shop.yaml fails with: `selector` does not match template `labels`.

{{label2}}
selector:
  matchLabels:
    app: shop
template:
  metadata:
    labels:
      app: store     # ← mismatch

Why: A Deployment only manages Pods that match its selector, so Kubernetes refuses a recipe whose Pods it would never recognise. Make both say app: shop.

4

Stuck in ImagePullBackOff

The new Pods never start. kubectl get pods shows ErrImagePull, then ImagePullBackOff.

{{label3}}
$ kubectl describe pod shop-...
Events:
  Warning  Failed  kubelet  Failed to pull image "shop:1.O": ... not found

Why: The image name has a capital letter O instead of a zero: shop:1.O. The kubelet can't download what doesn't exist. Fix it with kubectl set image deployment/shop shop=shop:1.0.

A routine that finds most of these: kubectl get to spot what looks wrong, kubectl describe to read the Events, and compare labels with --show-labels.