re-deploy_ng.sh 1.31 KB
# 创建更新文件
cat > frontend-update.yaml << 'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend
  namespace: ecommerce
spec:
  template:
    spec:
      containers:
      - name: frontend
        image: 319998871902.dkr.ecr.us-east-1.amazonaws.com/ecommerce-frontend:1.1.2
        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
        livenessProbe:
          httpGet:
            path: /health
            port: 80
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /health
            port: 80
          initialDelaySeconds: 5
          periodSeconds: 5
      volumes:
      - name: nginx-config
        configMap:
          name: frontend-config
      - name: environment-config
        configMap:
          name: frontend-config
EOF

# 应用更新
kubectl apply -f frontend-update.yaml