update nginx deploy config
Some checks failed
Build NGINX on Ubuntu / build-and-deploy (push) Failing after 1m36s
Some checks failed
Build NGINX on Ubuntu / build-and-deploy (push) Failing after 1m36s
This commit is contained in:
parent
488bb8cd64
commit
3ffcf7e360
@ -261,9 +261,6 @@ cleanup() {
|
|||||||
if [[ -f "./nginx-deployment.yaml.bak" ]]; then
|
if [[ -f "./nginx-deployment.yaml.bak" ]]; then
|
||||||
mv "./nginx-deployment.yaml.bak" "./nginx-deployment.yaml"
|
mv "./nginx-deployment.yaml.bak" "./nginx-deployment.yaml"
|
||||||
fi
|
fi
|
||||||
if [[ -f "./nginx-pv.yaml.bak" ]]; then
|
|
||||||
mv "./nginx-pv.yaml.bak" "./nginx-pv.yaml"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 设置清理陷阱
|
# 设置清理陷阱
|
||||||
|
@ -226,37 +226,6 @@ spec:
|
|||||||
- name: nginx-logs
|
- name: nginx-logs
|
||||||
mountPath: /usr/local/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:
|
containers:
|
||||||
- name: nginx
|
- name: nginx
|
||||||
# 使用私有仓库中的镜像(需要根据实际情况修改)
|
# 使用私有仓库中的镜像(需要根据实际情况修改)
|
||||||
@ -326,9 +295,6 @@ spec:
|
|||||||
# 添加日志目录挂载
|
# 添加日志目录挂载
|
||||||
- name: nginx-logs
|
- name: nginx-logs
|
||||||
mountPath: /usr/local/nginx/logs
|
mountPath: /usr/local/nginx/logs
|
||||||
# 添加HTML内容挂载
|
|
||||||
- name: nginx-html-content
|
|
||||||
mountPath: /usr/local/nginx/html
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: nginx-config-volume
|
- name: nginx-config-volume
|
||||||
@ -342,10 +308,6 @@ spec:
|
|||||||
# 添加日志目录卷
|
# 添加日志目录卷
|
||||||
- name: nginx-logs
|
- name: nginx-logs
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
# 添加HTML内容卷
|
|
||||||
- name: nginx-html-content
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: nginx-html-pvc
|
|
||||||
|
|
||||||
# 节点选择器(可选)
|
# 节点选择器(可选)
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
@ -435,3 +397,9 @@ spec:
|
|||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: nginx
|
app: nginx
|
||||||
|
scaleUp:
|
||||||
|
stabilizationWindowSeconds: 60
|
||||||
|
policies:
|
||||||
|
- type: Percent
|
||||||
|
value: 100
|
||||||
|
periodSeconds: 15
|
||||||
|
Loading…
x
Reference in New Issue
Block a user