Hi folks, I'm just starting with kubernetes so forgive me if this is too naive. . . .

Swanand Dhole:
Hi folks,
I’m just starting with kubernetes so forgive me if this is too naive. I’ve minikube setup locally and running below sample for replicaset practice. But I’m getting CrashLoopBackOff error. I’ve checked some of the solutions for it, but couldn’t figure out the issue.

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: new-replica-set
  labels:
    app: myapp
spec:
  replicas: 4
  selector:
    matchLabels:
      tier: frontend
  template:
    metadata:
      name: pod-def
      labels:
        tier: frontend
    spec:
      containers:
        - name: busybox-1
          image: busybox

Below is the output -

admin@admin$ kubectl get pods
NAME                    READY   STATUS             RESTARTS       AGE
new-replica-set-82xnj   0/1     CrashLoopBackOff   7 (106s ago)   13m
new-replica-set-czbqm   0/1     CrashLoopBackOff   6 (46s ago)    7m34s
new-replica-set-l59dh   0/1     CrashLoopBackOff   6 (51s ago)    7m34s
new-replica-set-xbd54   0/1     CrashLoopBackOff   6 (60s ago)    7m34s

No container logs are observed when check with kubectl logs new-replica-set-xbd54 -c busybox-1

Pooja Bolla:
Please try to check the events by giving kubectl describe <pod-name>

Pooja Bolla:
the container is not running so logs cant be checked

Swanand Dhole:
there isn’t much details in the events.(refer. img)

Trung Tran:
It native behavior of busybox, add some sleep will keep it running. You’re doing right with replica set, there’s is no problem with your yaml.
containers:
- args:
- sleep
- "4800"
image: busybox
imagePullPolicy: Always
name: busybox2

Swanand Dhole:
Thanks @Trung Tran. I never thought of checking the behaviour of the image I’m using.

unnivkn:
Hi @Swanand Dhole busybox is an os image, and the purpose of k8s image is to run some process, else it may terminate immediately. Hence busybox need some long running commands like sleep or similar commands. You may try above yaml with nginx image & see how it works.