-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprolonged-downtime-Issue.yml
60 lines (49 loc) · 1.72 KB
/
prolonged-downtime-Issue.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#Kubernetes-Issue-2
#Issue
#Your backend-service application is experiencing downtime because
#it is not configured to automatically restart when it crashes.
#This is causing prolonged downtime until the issue is manually addressed.
#Solution
#To resolve this issue, you will add a restartPolicy and
#livenessProbe to the backend-service deployment YAML file to ensure that the service
#is automatically restarted if it crashes and regularly checked for its health.
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-service
spec:
replicas: 3
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- name: backend
image: backend-service:latest
ports:
- containerPort: 8080
resources:
requests:
memory: "256Mi"
cpu: "500m"
limits:
memory: "512Mi"
cpu: "1"
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 60
periodSeconds: 30
restartPolicy: Always
#Explanation
#restartPolicy: The restartPolicy: Always ensures that the container is always restarted if it crashes.
#This is the default policy for Deployments and ensures high availability.
#livenessProbe: The livenessProbe checks the health of the container by sending HTTP GET requests to the specified path and port.
#If the probe fails, Kubernetes will restart the container.
#By adding a restartPolicy and livenessProbe, you can ensure that your backend-service automatically recovers from crashes and
#is regularly checked for its health, improving the overall reliability of your application.