54.sh 944 Bytes
#!/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