k8s部署web

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值