-1

I have deployed an application in Kubernetes that prints numbers from 1-20 in Kubernetes.

While printing numbers suddenly there is an internet failure and the pod crases after printing numbers from 1-10. Now the basic pod lifecycle says that the pod will restart and numbers will print again starting from 1 but I want to print the numbers from where it failed ie 10...

So basically I am searching for a way through which I can resume the application running in pods from the point of failure without restarting again.

Is there a way to do it ?? I have read about persistent storage and volumes but they are basically used to assign volumes to pods so that they can retain data and files .....

Please help me how can I achieve this and demonstrate this in form of POC ...

Ayush
  • 91
  • 1
  • 8
  • Please consider editing your question without an opinion-based context, check [here](https://meta.stackoverflow.com/questions/417476/question-close-reasons-definitions-and-guidance/417487#417487) to understand how. – Hector Martinez Rodriguez Jul 08 '22 at 23:28
  • Your application needs to somehow remember where it is, so that when it starts up in a new pod it will resume its state. I might suggest keeping that state in some sort of database rather than local files, and demonstrating it locally pressing `^C` and restarting your process rather than anything in a container. But there's literally dozens of technology choices here and beyond the very broad "you need to save state" statement it's hard to give more specific advice. – David Maze Jul 09 '22 at 09:56

1 Answers1

1

can a statefulset be of use here? https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/

Using StatefulSets

StatefulSets are valuable for applications that require one or more of the following.

Stable, unique network identifiers.

Stable, persistent storage.

Ordered, graceful deployment and scaling.

Ordered, automated rolling updates.

In the above, stable is synonymous with persistence across Pod (re)scheduling. If an application doesn't require any stable identifiers or ordered deployment, deletion, or scaling, you should deploy your application using a workload object that provides a set of stateless replicas. Deployment or ReplicaSet may be better suited to your stateless needs.