当前位置: 首页 > news >正文

十堰响应式网站想学做网站从哪里入手

十堰响应式网站,想学做网站从哪里入手,公司网址制作,可以做婚礼鲜花布置的网站k8s 部署nginx 实现集群统一配置#xff0c;自动更新nginx.conf配置文件 总结 大纲 1 nginx镜像选择2 创建configmap保存nginx配置文件3 使用inotify监控配置文件变化4 Dockerfile创建5 调整镜像原地址使用阿里云6 创建deploy部署文件部署nginx7 测试使用nginx配置文件同步自动更新nginx.conf配置文件 总结 大纲 1 nginx镜像选择2 创建configmap保存nginx配置文件3 使用inotify监控配置文件变化4 Dockerfile创建5 调整镜像原地址使用阿里云6 创建deploy部署文件部署nginx7 测试使用nginx配置文件同步nginx自动重启 直接使用https://hub.docker.com/_/nginx nginx镜像有几个问题 1 集群环境下需要手动的配置多个nginx.conf文件2 集群环境下配置文件修改后需要 kubectl exec -it 到多个pod重启nginx 使用k8s configmap统一配置集群下所有nginx的配置并使用inotify监听配置文件变化后自动重启 nginx镜像选择 nginx镜像地址 https://hub.docker.com/_/nginx 使用 nginx:1.23.3 作为基础镜像 此镜像的配置文件为 /etc/nginx/nginx.conf 可以看到配置文件会include /etc/nginx/conf.d 文件夹下的配置 只需把此文件夹与configmap挂载就可以使用自己的配置信息了 创建configmap 创建一个configmap 用来保存nginx的配置文件 apiVersion: v1 kind: ConfigMap metadata:name: nginx-config data:nginx.conf: |server {listen 8080;charset utf-8;server_name localhost; location / {root /usr/share/nginx/html;index index.html index.htm;}}使用inotify监控配置文件变化 可以使用inotify 实现对配置文件夹的监控当文件夹内有.conf文件创建修改删除后重新启动nginx 可以创建一个脚本此脚本监控 /etc/nginx/conf.d 下文件的变化 #!/bin/bash configfile.conf$#监听文件夹修改删除事件 inotifywait -e modify,delete -mr --timefmt %Y-%m-%d %H:%M:%S --format %T %w %f %e /etc/nginx/conf.d | while read day time folder file event; do#判断变化的文件是否是.conf结尾的文件 注意正则判断需要使用[[]]if [[ $file ~ $configfile ]]; thennginx -t# $?返回上一个命令的结束状态 0表示正常if [ $? 0 ]; thennginx -s reloadfifi done 再准备一个启动start.sh脚本用于启动nginx以及inotify监控 echo start nginx # 启动nginx nginx # 启动监控 需要保持一个前台运行的程序 否则容器运行后就退出 ./auto_reload.shinotify的使用可以参考 《linux-inotify工具监控文件状态变化总结》 Dockerfile创建 Dockerfile 内容如下可以调整linux镜像源使用阿里云的镜像源 FROM nginx:1.23.3 VOLUME [/data/service/logs,/docker/tmp,/data/service/store] WORKDIR /data/service LABEL base.namenginx-auto-reload LABEL base.descnginx-auto-reload #修改操作系统源地址 使用阿里云 可以不修改但是由于网络原因会比较满 #注意 nginx:1.23.3 镜像使用的是debian 11.x (bullseye) #需要使用对应的阿里云 镜像源 https://developer.aliyun.com/mirror/debian?spma2c6h.13651102.0.0.3e221b11W40Fzd RUN echo deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib /etc/apt/sources.list RUN echo deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib /etc/apt/sources.list RUN echo deb https://mirrors.aliyun.com/debian-security/ bullseye-security main /etc/apt/sources.list RUN echo deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main /etc/apt/sources.list RUN echo deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib /etc/apt/sources.list RUN echo deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib /etc/apt/sources.list RUN echo deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib /etc/apt/sources.list RUN echo deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib /etc/apt/sources.list RUN apt-get update RUN apt-get install inotify-tools -y ADD auto_reload.sh auto_reload.sh RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime echo Asia/Shanghai /etc/timezone COPY [auto_reload.sh,start.sh,./] RUN chmod 711 auto_reload.sh chmod 711 start.sh CMD [./start.sh]需要使用对应的阿里云 镜像源 https://developer.aliyun.com/mirror/debian?spma2c6h.13651102.0.0.3e221b11W40Fzd 创建镜像后推送到阿里云私库用于后续的使用 docker build -t nginx-auto-reload . docker tag nginx-auto-reload registry.cn-hangzhou.aliyuncs.com/jimliu/nginx-auto-reload docker push registry.cn-hangzhou.aliyuncs.com/jimliu/nginx-auto-reload创建deploy部署文件部署nginx 部署deploy.yaml 内容如下 apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec:replicas: 1selector:matchLabels:app: nginx-auto-reloadtemplate:metadata:labels:app: nginx-auto-reloadspec:# 容器配置 imagePullSecrets:- name: myaliyunsecrethostname: nginx-hostsubdomain: nginx-inner-domaincontainers:- image: registry.cn-hangzhou.aliyuncs.com/jimliu/nginx-auto-reload:latestname: nginx-containers# 挂载文件夹volumeMounts:- mountPath: /etc/nginx/conf.d/name: config-volumevolumes:- name: config-volumeconfigMap:name: nginx-config--- # 外部访问的接口 apiVersion: v1 kind: Service metadata: name: nginx-auto-reload-service spec:ports:- protocol: TCPport: 18080targetPort: 8080nodePort: 18080name: http8080#暴露两个接口用于测试 nginx重启- protocol: TCPport: 18081targetPort: 8081nodePort: 18081 name: http8081selector: app: nginx-auto-reload部署nginx并测试 创建configmap 部署nginx kubectl apply -f n-deployment.yaml 此步 nginx部署完成 service创建成功 测试nginx 8080端口访问成功 8081端口还无法访问 修改configmap中nginx配置文件 开放8081端口 等待configmap同步更新nginx pod中的配置文件
http://www.w-s-a.com/news/86949/

相关文章:

  • 深圳市专注网站建设全网营销网络推广
  • 如何快速建设网站虚拟空间软件
  • 一个虚拟主机可以做几个网站免费软件下载中心
  • 美工培训网站中国建筑网官网手机版
  • 创建网站花钱吗谁能给个网址免费的
  • 宁波教育学会网站建设网站建设价格由什么决定
  • 北京定制网站价格wordpress上传pdf文档
  • 网站建设费税率dz论坛seo设置
  • 推销网站话术商业网站开发与设计
  • 金华网站建设哪个网站做欧洲旅行比较好
  • 东莞市住房和城乡建设局网站trswcm网站建设
  • 郑州做网站企业h5编辑器免费版
  • 加强公司窗口网站建设陕西省外省入陕建筑信息平台
  • 成都网站优化实战大连企业网站建设模板
  • 服务器硬件影响网站速度seo网站推广价格
  • 学院网站开发竞争对手分析买网站送域名
  • 手机网站 jsp个人网页制作成品代码五个页面
  • ppt做长图网站wordpress文章页面图片自动适应
  • 做泌尿科网站价格京东商城网站建设教程
  • 像网站的ppt怎么做的移动app与网站建设的区别
  • 怎么建个人网站网站收录有什么用
  • 广州市医院网站建设广州头条新闻最近一周
  • 广州移动 网站设计中国交通建设监理协网站
  • 甘肃省第八建设集团公司网站wordpress topnews
  • 公司网站建设维保协议wordpress会员可看
  • 合肥百度网站排名优化深圳集团网站开发公司
  • 可以直接打开网站的方法手机回收站
  • 山西免费网站制作中天建设集团有限公司第九建设公司
  • 好的网站有哪些企业微信开发者工具
  • 网站通栏代码老外做的中国汉字网站