update nginx deploy config
Some checks failed
Build NGINX on Ubuntu / build-and-deploy (push) Failing after 1m36s

This commit is contained in:
huangzhiqiang 2025-06-10 15:55:24 +08:00
parent 488bb8cd64
commit 3ffcf7e360
2 changed files with 6 additions and 41 deletions

View File

@ -261,9 +261,6 @@ cleanup() {
if [[ -f "./nginx-deployment.yaml.bak" ]]; then
mv "./nginx-deployment.yaml.bak" "./nginx-deployment.yaml"
fi
if [[ -f "./nginx-pv.yaml.bak" ]]; then
mv "./nginx-pv.yaml.bak" "./nginx-pv.yaml"
fi
}
# 设置清理陷阱

View File

@ -226,37 +226,6 @@ spec:
- name: nginx-logs
mountPath: /usr/local/nginx/logs
# 添加初始化容器检查HTML目录权限
- name: init-html-permissions
image: busybox
command: ["/bin/sh", "-c"]
args:
- |
echo "检查HTML目录权限...";
if [ ! -r /usr/local/nginx/html ]; then
echo "警告: HTML目录不可读";
chmod -R 755 /usr/local/nginx/html;
fi;
# 保留已存在的前端文件,不覆盖
if [ -f /usr/local/nginx/html/index.html ]; then
echo "找到现有index.html文件将保留这些文件";
else
echo "警告: 没有找到index文件创建默认页面";
cat > /usr/local/nginx/html/index.html << 'EOF'
<!DOCTYPE html>
<html><head><title>Welcome to Nginx</title></head>
<body><h1>Welcome to Nginx on Kubernetes!</h1>
<p>If you see this page, the persistent volume is mounted but no HTML files were found.</p>
</body></html>
EOF
fi;
echo "设置目录权限...";
chown -R 65534:65534 /usr/local/nginx/html || true;
chmod -R 755 /usr/local/nginx/html || true;
echo "HTML目录权限设置完成";
containers:
- name: nginx
# 使用私有仓库中的镜像(需要根据实际情况修改)
@ -326,9 +295,6 @@ spec:
# 添加日志目录挂载
- name: nginx-logs
mountPath: /usr/local/nginx/logs
# 添加HTML内容挂载
- name: nginx-html-content
mountPath: /usr/local/nginx/html
volumes:
- name: nginx-config-volume
@ -342,10 +308,6 @@ spec:
# 添加日志目录卷
- name: nginx-logs
emptyDir: {}
# 添加HTML内容卷
- name: nginx-html-content
persistentVolumeClaim:
claimName: nginx-html-pvc
# 节点选择器(可选)
nodeSelector:
@ -435,3 +397,9 @@ spec:
selector:
matchLabels:
app: nginx
scaleUp:
stabilizationWindowSeconds: 60
policies:
- type: Percent
value: 100
periodSeconds: 15