I am using a replica set to manage my pods. If my app crashes after starting I want a replica set to restart it. But I have a scenario that the replica set that should not restart my app or restart it by limit.
When my app starts successfully it will return an OK result for endpoint /health. I have this scenario: I will push some changes so that app will not be started successfully, it will be crashed on startup. And it will not return an OK result for endpoint /health. When changes are applied to Kubernetes it doesn't make sense to restart it from the replica set, because it will always fail. I know that the replica set restart policy is always. But is there any way to make it work? I am expecting: When the app starts successfully (returns an OK result for endpoint /health), the replica set should always restart if it will be crashed during the runtime.
When the app doesn't start successfully (does not return an OK result for endpoint /health), the replica set shouldn't restart it more than 3 times, because it doesn't make sense. Instead of that it should keep old version of app.
My deployment file is basic:
apiVersion: apps/v1
kind: Deployment
metadata:
name: apideployment
namespace: dilshod
spec:
selector:
matchLabels:
app: api_deploymentpod
template:
metadata:
labels:
app: api_deploymentpod
spec:
containers:
- image: komdil/app:1.0.19
imagePullPolicy: Always
name: appcontainer
ports:
- containerPort: 80