kubernetes / website

Kubernetes website and documentation repo:
https://kubernetes.io
Creative Commons Attribution 4.0 International
4.44k stars 14.28k forks source link

Kubernetes documentation for Sidecar Containers #47219

Closed roshanauthankar closed 1 month ago

roshanauthankar commented 1 month ago

I think the example provided is incorrect. In the example, the sidecar container is listed under initContainers -

spec:
  containers:
    - name: myapp
      image: alpine:latest
      command: ['sh', '-c', 'while true; do echo "logging" >> /opt/logs.txt; sleep 1; done']
      volumeMounts:
        - name: data
          mountPath: /opt
  initContainers:
    - name: logshipper
      image: alpine:latest
      restartPolicy: Always
      command: ['sh', '-c', 'tail -F /opt/logs.txt']
      volumeMounts:
        - name: data
          mountPath: /opt

Documentation link: https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/#sidecar-example

k8s-ci-robot commented 1 month ago

This issue is currently awaiting triage.

SIG Docs takes a lead on issue triage for this website, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
dipesh-rawat commented 1 month ago

I think the existing example provided is correct. Kubernetes plans to use the initContainers field for specifying init containers and sidecars, but it's worth noting that this feature is currently in beta.

/language en /sig node

dipesh-rawat commented 1 month ago

Additionally, I see we have an existing issue https://github.com/kubernetes/website/issues/45406, which is addressing documenting the legacy method for defining sidecar containers in the same page.

dipesh-rawat commented 1 month ago

/triage duplicate

Marking this as duplicate in favor of existing issue https://github.com/kubernetes/website/issues/45406 (Feel free to remove the label if this is incorrect.)

stmcginnis commented 1 month ago

If you read the paragraph at the beginning of that section, it further explains how this is the correct way:

Kubernetes implements sidecar containers as a special case of init containers; sidecar containers remain running after Pod startup. This document uses the term regular init containers to clearly refer to containers that only run during Pod startup.

iam-veeramalla commented 1 month ago

@stmcginnis I think a line mentioning how a sidecar container can be defined in the InitContainer section would help.

I think by mentioning lifecycle, livenessProbe, readinessProbe, or startupProbe fields in the InitContainer, Kubernetes understands it as a special case - sidecar container.

May be this can be documented.

sftim commented 1 month ago

Please follow up on the original issue - https://github.com/kubernetes/website/issues/45406. I recommend closing this duplicate issue as not planned (because it is a duplicate, and we are tracking the work via the earlier report).

Help is welcome; Kubernetes documentation is largely maintained by volunteers.

sftim commented 1 month ago

/close not-planned

We'll track work via the original issue. Help is welcome.

k8s-ci-robot commented 1 month ago

@sftim: Closing this issue, marking it as "Not Planned".

In response to [this](https://github.com/kubernetes/website/issues/47219#issuecomment-2260242005): >/close not-planned > >We'll track work via the original issue. Help is welcome. Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.