Root@master:~# kubectl apply -f rs-definition.yml replicaset.apps/myapp-rs creat . . .

Prasanth V:
root@master:~# kubectl apply -f rs-definition.yml
replicaset.apps/myapp-rs created
root@master:~# kubectl get rs
NAME DESIRED CURRENT READY AGE
kubeserve-deployment-57cbd5c578 2 2 2 301d
kubeserve-deployment-b8db968b7 0 0 0 301d
my-rs 2 2 2 307d
myapp-rs 2 2 2 9s
root@master:~# kubectl describe rs myapp-rs
Name: myapp-rs
Namespace: default
Selector: type=testpods
Labels: app=myapp
type=testpods
Annotations: Replicas: 2 current / 2 desired
Pods Status: 2 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
Labels: app=myapp
type=testpods
Containers:
myapp-rs-pod-cont:
Image: nginx
Port: 80/TCP
Host Port: 0/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Events:
Type Reason Age From Message


Normal SuccessfulCreate 23s replicaset-controller Created pod: myapp-rs-7vrsw
root@master:~#
root@master:~# kubectl get pods myapp-rs
Error from server (NotFound): pods “myapp-rs” not found
root@master:~# kubectl get pods | grep -i “myapp-rs”
myapp-rs-7vrsw 1/1 Running 0 73m

Mohamed Ayman:
Can you please share your yaml file?

Prasanth V:
Hi Mohamed, pls see the below content…
root@master:~# cat rs-definition.yml
apiVersion: apps/v1

kind: ReplicaSet

metadata:
name: myapp-rs
labels:
app: myapp
type: testpods

spec:
replicas: 2
template:
metadata:
name: myapp-rs-pod
labels:
app: myapp
type: testpods

spec:
  containers:
    - name: myapp-rs-pod-cont
      image: nginx
      ports:
        - containerPort: 80

selector:
matchLabels:
type: testpods

Mohamed Ayman:
I have check it from my side and the 2 pods exists already
So please try to run again
$kubectl get pods

Mohamed Ayman:

Image from iOS.jpg
Image from iOS.jpg

Prasanth V:
Hi Mohamed, thanks for the quick look. But i was getting the same error.
I realize that there are another 2 pods with label “testpods” before creating this RS.
So when I have changed my label “testpods” to other name “testrspods”, then it is behaving properly and i can see 2 rs pods are getting created now.
NAME READY STATUS RESTARTS AGE LABELS
multi-cont-pod2 2/2 Running 0 3h11m app=myapp,location=NA,type=testpods
testapp-rs-7sqmp 1/1 Running 0 83s app=testapp,type=testrspods
testapp-rs-b8fs8 1/1 Running 0 83s app=testapp,type=testrspods

Prasanth V:

Prasanth V:
Thank you for your time Mohamed, after above lable change, i can see its behaving correctly in my env.

Prasanth V:
Seems its a K8S issue… to validate, can you please replicate these 2 below steps and see the behavior.

  1. create a pod with label type as “testpod” first.
  2. after a pod creation, create RS with matchLables - type as “testpod” with 2 replicas.
    I suspect it’s misbehaving in this kind of scenario.
    Just want to mention my scenario, hence detailed it. Neverthless, issue is fixed in my env. thank you!