Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pods with init container with restartPolicy: Always stay in Init status #2520

Closed
Shohou opened this issue Feb 1, 2024 · 5 comments
Closed
Labels
norepro question Further information is requested

Comments

@Shohou
Copy link

Shohou commented Feb 1, 2024




Describe the bug
I'm using kubernetes 1.29 and created a pod with normal container and init container which has restartPolicy: Always. In k9s pod always stays in Init:1/2 state, while kubectl get po <name> shows state Running

To Reproduce
Steps to reproduce the behavior:

  1. Create a pod with init container with restartPolicy: Always
  2. Check pod status in k9s
  3. Status will be Init:1/2

Expected behavior
Status should be Running

Versions (please complete the following information):

  • K9s: [e.g. 0.31.7]
  • K8s: [e.g. 1.29.0]
@derailed
Copy link
Owner

derailed commented Feb 3, 2024

@Shohou Can't seem to repro this ;( showing 1/1 Running.

What am I missing?

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      restartPolicy: Always
      initContainers:
        - name: init-1
          image: busybox
          command: ['ls', '/']
      containers:
        - name: nginx
          image: nginx
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
              name: web

@derailed derailed added question Further information is requested norepro labels Feb 3, 2024
@Shohou
Copy link
Author

Shohou commented Feb 5, 2024

@derailed try this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: k9s-test
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      initContainers:
        - name: init-1
          image: busybox
          command: ['sleep', '1000000']
          restartPolicy: Always
      containers:
        - name: nginx
          image: nginx
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
              name: web

@derailed
Copy link
Owner

derailed commented Feb 6, 2024

@Shohou Did I miss the memo??
Isn't restartPolicy an attribute of pods and not containers?
This manifest crocks on k8s 1.27 clusters ;(

@Shohou
Copy link
Author

Shohou commented Feb 6, 2024

This is new feature of kubernetes 1.29 - https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/
makes sidecar container out of init container

@derailed
Copy link
Owner

derailed commented Feb 6, 2024

@Shohou Thank you for the correction Dmitry!
I was just spinning up a 1.29 cluster. I'll take a peek...

derailed added a commit that referenced this issue Feb 7, 2024
derailed added a commit that referenced this issue Feb 7, 2024
placintaalexandru pushed a commit to placintaalexandru/k9s that referenced this issue Apr 3, 2024
* [Maint] Fix race condition issue

* [Bug] Fix derailed#2501

* [Maint] Allow reference to resource aliases for plugins

* [Feat] Intro cp namespace command + misc cleanup

* [Maint] Rev k8s v0.29.1

* [Bug] Fix derailed#1033, derailed#1558

* [Bug] Fix derailed#2527

* [Bug] Fix derailed#2520

* rel v0.31.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
norepro question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants