kubernetes / examples

Kubernetes application example tutorials
Apache License 2.0
6.16k stars 4.52k forks source link

Should minio service be a Deployment or a Statefulset? #463

Closed tiendatiowa closed 1 year ago

tiendatiowa commented 1 year ago

In the example manifest, the service is deployed as a Deployment and a ReadWriteOnce PVC. But a Deployment with a ReadWriteOnce PVC is not recommended per K8S doc:

Even Deployments with one replica using ReadWriteOnce volume are not recommended. This is because the default Deployment strategy creates a second Pod before bringing down the first Pod on a recreate. The Deployment may fail in deadlock as the second Pod can't start because the ReadWriteOnce volume is already in use, and the first Pod won't be removed because the second Pod has not yet started. Instead, use a StatefulSet with ReadWriteOnce volumes.

So the question is: is the use of Deployment on purpose? Or should the example be updated to use Statefulset?

yrs147 commented 1 year ago

It is generally not recommended to use a Deployment with a ReadWriteOnce PVC because, as you mentioned, the default Deployment strategy involves creating a new Pod before tearing down the old one, which can lead to a deadlock if the new Pod is unable to start due to the ReadWriteOnce volume being in use.

A StatefulSet, on the other hand, is designed to handle persistent storage more gracefully and is a better choice when using ReadWriteOnce volumes. It ensures that each Pod is created and terminated in a specific order, which helps to avoid the potential deadlock scenario that can occur with Deployments.

That being said, it is possible to use a Deployment with a ReadWriteOnce PVC if you are willing to accept the risks and are prepared to handle potential failures. However, it is generally recommended to use a StatefulSet instead in order to avoid these issues.

In the example you mentioned, it is possible that the use of a Deployment with a ReadWriteOnce PVC was intentional in order to illustrate a specific scenario or to demonstrate how to handle persistent storage in a Deployment. However, if the goal of the example is to provide a recommended practice for using persistent storage with Kubernetes, it may be worth considering updating the example to use a StatefulSet instead.

k8s-triage-robot commented 1 year ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 1 year ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot commented 1 year ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-ci-robot commented 1 year ago

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to [this](https://github.com/kubernetes/examples/issues/463#issuecomment-1564805397): >The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. > >This bot triages issues according to the following rules: >- After 90d of inactivity, `lifecycle/stale` is applied >- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied >- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed > >You can: >- Reopen this issue with `/reopen` >- Mark this issue as fresh with `/remove-lifecycle rotten` >- Offer to help out with [Issue Triage][1] > >Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community). > >/close not-planned > >[1]: https://www.kubernetes.dev/docs/guide/issue-triage/ 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/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.