front_re.sh
2.49 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# 切换到您的自定义前端镜像
kubectl patch deployment -n ecommerce frontend -p '{
"spec": {
"template": {
"spec": {
"containers": [{
"name": "frontend",
"image": "319998871902.dkr.ecr.us-east-1.amazonaws.com/ecommerce-frontend:1.1.2",
"command": null,
"args": null,
"env": [
{
"name": "NODE_ENV",
"value": "production"
},
{
"name": "PORT",
"value": "80"
},
{
"name": "API_BASE_URL",
"value": "https://api.awsmpc.asia"
},
{
"name": "REACT_APP_API_URL",
"value": "https://api.awsmpc.asia"
}
],
"volumeMounts": [
{
"name": "nginx-config",
"mountPath": "/etc/nginx/conf.d/default.conf",
"subPath": "nginx.conf"
},
{
"name": "environment-config",
"mountPath": "/usr/share/nginx/html/env.js",
"subPath": "environment.js"
}
],
# 使用 /health 端点进行健康检查(您的镜像应该有这个端点)
"livenessProbe": {
"httpGet": {
"path": "/health",
"port": 80
},
"initialDelaySeconds": 30,
"periodSeconds": 10,
"timeoutSeconds": 5,
"failureThreshold": 3
},
"readinessProbe": {
"httpGet": {
"path": "/health",
"port": 80
},
"initialDelaySeconds": 5,
"periodSeconds": 5,
"timeoutSeconds": 3,
"failureThreshold": 3
},
"startupProbe": {
"httpGet": {
"path": "/health",
"port": 80
},
"initialDelaySeconds": 10,
"periodSeconds": 10,
"failureThreshold": 30
}
}]
}
}
}
}'
# 添加 volumes
kubectl patch deployment -n ecommerce frontend -p '{
"spec": {
"template": {
"spec": {
"volumes": [
{
"name": "nginx-config",
"configMap": {
"name": "frontend-config"
}
},
{
"name": "environment-config",
"configMap": {
"name": "frontend-config"
}
}
]
}
}
}
}'