首页 > 其他分享 >K8S配置vue

K8S配置vue

时间:2023-03-16 11:36:34浏览次数:37  
标签:index vue log 配置 nginx html template K8S

1、编写Dockerfile

1)、Dockerfile 文件

FROM nginx:1.22.1
COPY dist /etc/nginx/vueTemplate
EXPOSE 30098
CMD ["nginx", "-g", "daemon off;"]

2)、制作镜像

docker build -t vue-template:latest .
docker tag vue-template:latest 172.171.2.148:5000/vue-template:latest
docker push 172.171.2.148:5000/vue-template:latest

2、配置configmap

1)、nginx.conf文件


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       30098;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /etc/nginx/vueTemplate;
	    try_files $uri $uri/ @router;
            index  index.html index.htm;
        }

	location @router {
      	    rewrite ^.*$ /index.html last;
   	}

	location /api/{

	    proxy_pass http://gateway-demo.dev:8081/api/;
	}

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
       # error_page   500 502 503 504  /50x.html;
       # location = /50x.html {
        #    root   html;
        #}

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

2)、应用nginx.conf 文件 到 configmap

kubectl create configmap nginx-vue-template --from-file=./nginx.conf -n dev

3、配置yaml文件


apiVersion: v1
kind: Service
metadata:
  name: vue-template
  namespace: dev
  labels:
    app: vue-template
spec:
  type: NodePort
  ports:
    - port: 5174
      targetPort: 30098 #service对外开放端口
      nodePort: 30098
  selector:
    app: vue-template
---
apiVersion: apps/v1
kind: Deployment #对象类型
metadata:
  name: vue-template #名称
  namespace: dev
  labels:
    app: vue-template #标注
spec:
  replicas: 1 #运行容器的副本数,修改这里可以快速修改分布式节点数量
  selector:
    matchLabels:
      app: vue-template
  template:
    metadata:
      labels:
        app: vue-template
    spec:
      containers: #docker容器的配置
        - name: vue-template
          image: 172.171.2.148:5000/vue-template:latest  # pull镜像的地址 ip:prot/dir/images:tag
          imagePullPolicy: Always   #pull镜像时机,
          ports:
            - containerPort: 5174  #容器对外开放端口,需与springboot配置文件一致
          volumeMounts:
          - name: vueconf
            mountPath: /etc/nginx/nginx.conf
            subPath: nginx.conf
            readOnly: true
      volumes:
      - name: vueconf
        configMap:
          name: nginx-vue-template
          items:
            - key: nginx.conf
              path: nginx.conf

标签:index,vue,log,配置,nginx,html,template,K8S
From: https://www.cnblogs.com/llds/p/17221668.html

相关文章

  • springboot中配置elasticSearch
    1.1.1 在build.gradle中添加需要的jar包   我创建的gradle工程,对应的maven工程也是一样,添加对应的jar包即可//添加SpringDataElasticsearch的依赖comp......
  • nacos 配置
    nacos:#注册命名空间discovery:namespace:6c50904a-66a9-435a-9475-34a9671f4bd0#lxnconfig:#配置命名空间namespace:bf494ccf-5419-4eb3-94f5-906d......
  • Vue利用slice()方法实现分页操作
    Vue利用slice()方法实现分页操作https://blog.csdn.net/pleaseprintf/article/details/129187584系列文章目录提示:这里可以添加系列文章的所有文章的目录,目录需要......
  • K8S配置文件详解
    apiVersion:v1#【必须】版本号kind:Pod#【必选】Podmetadata:#【必选-Object】元数据name:String#【必选】Pod的名称namespace:String#【必选】Po......
  • R4900G3,配置Raid,并通过HDM安装esxi系统
    ​一、配置raid文章链接:新华三R4900G3Raid配置«久酷新华三服务器感觉还是非常符合咱们国人习惯的。非常人性化的标签设计以及hdm管理功能;开机启动后会默认进入配置......
  • IDEA 配置
    IDEA配置import导入优化配置,将Preferences->Editor->CodeStyle->java->importsclasscounttouseimportwith"*"将默认5调整为99,避免出现import*情况......
  • 4、单个Master配置
    1、初始化Master1.1、初始化命令kubeadminit--kubernetes-version=1.25.7\--apiserver-advertise-address=192.168.10.26\--service-cidr=10.96.0.0/12\--pod-n......
  • 配配配配配配配配配配配配配配配配置
    可能是我换机的时候要考虑的配置我中意的一款台式的配置我有积蓄之后可能就会换这个配置这是我很久之前在贴吧复制的东西了抽到名额,老板就问了我一连串问题!问题一:电脑......
  • shell脚本 续签K8S证书 -续签至10年
    背景,适配kubeadm生成证书集群脚本主题main#!/usr/bin/envbashset-oerrexitset-opipefail#set-oxtrace#setoutputcolorNC='\033[0m'RED='\033[31m'......
  • 前后端分离项目(vue+springboot)集成pageoffice实现在线编辑office文件
    前后端分离项目下使用PageOffice原理图集成步骤前端vue项目在您Vue项目的根目录下index.html中引用后端项目根目录下pageoffice.js文件。例如:<scripttype="te......