apiVersion: v1
kind: ConfigMap
metadata:
name: web-root
namespace: test
data:
nginx.conf: |
server {
listen 80 default_server;
index index.html index.htm index.nginx-debian.html;
server_name _;
client_max_body_size 100m;
gzip on;
gzip_min_length 1k;
gzip_comp_level 9;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png video/mp4;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
location /index.html {
add_header "Cache-Control" "no-cache";
}
location / {
root /data/;
try_files $uri $uri/ /index.html;
index index.htm index.html;
if ($request_filename ~* ^.*?.(doc|pdf|docx)$){
add_header Content-Disposition attachment;
}
if ($request_filename ~* ^.*?.(txt)$){
add_header Content-Type text/plain;
}
}
location /web/ {
root /data/;
try_files $uri $uri/ /engine-sar/index.html;
index index.htm index.html;
}
location /vector/tiles {
alias /data/tiles;
add_header 'Access-Control-Allow-Origin' '*';
}
}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-root
namespace: test
spec:
replicas: 1
selector:
matchLabels:
name: web-root
engine.piesat.cn/service.type: web.portal
engine.piesat.cn/service.class: primary
template:
metadata:
annotations:
engine.piesat.cn/service.title: 服务结果展示
engine.piesat.cn/service.name: web-root
engine.piesat.cn/endpoint.healthz: ""
engine.piesat.cn/techstack: Nginx
labels:
name: web-root
engine.piesat.cn/service.type: web.portal
engine.piesat.cn/service.class: primary
spec:
imagePullSecrets:
- name: default-secret
nodeSelector:
engine.node.sar: "true"
containers:
- name: web-root
image: nginx
imagePullPolicy: Always
ports:
- containerPort: 80
volumeMounts:
- name: configmap-volume
mountPath: /etc/nginx/conf.d/nginx.conf
subPath: nginx.conf
- name: webhtml
mountPath: /data
volumes:
- name: configmap-volume
configMap:
name: web-root
items:
- key: nginx.conf
path: nginx.conf
- name: webhtml
hostPath:
path: /data/test
---
apiVersion: v1
kind: Service
metadata:
name: web-root
namespace: test
labels:
name: web-root
spec:
ports:
- port: 80
targetPort: 80
name: web-root
selector:
name: web-root
k8s部署web
最新推荐文章于 2024-08-28 22:43:48 发布