54.sh
944 Bytes
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
#!/bin/bash
echo "=== 修复 nginx 配置文件路径 ==="
echo "问题: 前端 Pod 使用错误的 nginx 配置文件路径"
echo "当前: /etc/nginx/nginx.conf (错误的)"
echo "应该: /etc/nginx/conf.d/default.conf (正确的)"
echo ""
echo "检查当前的 volumeMounts 配置:"
kubectl get deployment frontend -n ecommerce -o yaml | grep -A 10 -B 10 "volumeMounts\|volumes"
echo ""
echo "修复 volumeMounts 配置:"
kubectl patch deployment frontend -n ecommerce -p '{
  "spec": {
    "template": {
      "spec": {
        "containers": [
          {
            "name": "frontend",
            "volumeMounts": [
              {
                "name": "nginx-config",
                "mountPath": "/etc/nginx/conf.d/default.conf",
                "subPath": "nginx.conf"
              }
            ]
          }
        ]
      }
    }
  }
}'
echo ""
echo "重启前端:"
kubectl rollout restart deployment frontend -n ecommerce