Task is completed but status shows as failed

does any one have similar issue. what is wrong in my replicaset.

Deploy ReplicaSet in Kubernetes Cluster (Kubernetes Level 1: Task 7)

apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: httpd-replicaset
spec:
replicas: 4
selector:
matchLabels:
app: httpd_app
type: front-end
template:
metadata:
labels:
app: httpd_app
type: front-end
spec:
containers:
- name: httpd-container
image: httpd:latest
ports:
- containerPort: 80

Looks like the labels need to be applied at all levels: for the RS itself, for the selector, and for the pod template.

1 Like

can you please look at my kubectl get pods --show-labels command result
they are displaying the labels. looks they are mentioned correct.

Check for the RS itself. Those are different in your code. Take a look at the the metadata for the replicaset itself – it has no labels.

1 Like

Add metadata → labels section at the top (you missed it).
Final working YAML:

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: httpd-replicaset
  labels:
    app: httpd_app
    type: front-end
spec:
  replicas: 4
  selector:
    matchLabels:
      app: httpd_app
      type: front-end
  template:
    metadata:
      labels:
        app: httpd_app
        type: front-end
    spec:
      containers:
      - name: httpd-container
        image: httpd:latest
        ports:
        - containerPort: 80

Then run:

kubectl delete rs httpd-replicaset --force --grace-period=0
kubectl apply -f httpd-replicaset.yml

That will fix the “labels not set” error.

1 Like

thank you @jhonmiller0082

1 Like

Thank you @rob_kodekloud issue is resolved.