kubernet手打打前端包并更新发布

环境:centos、前端的tar.gz包、使用nginx打包成images

1、编辑dockerfile

FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
ADD *.gz /
RUN mv -f /dist/* /usr/share/nginx/html/
RUN chmod -R 755 /usr/share/nginx/html/
VOLUME ["/usr/share/nginx/html"]

2、编辑nginx.conf

复制代码
server {
    listen 80;
    server_name  localhost; 
    location /{
       root /usr/share/nginx/html;
       index index.html index.htm;
       try_files $uri $uri/ /index.html =404;
       add_header Cache-Control no-cache;
       add_header Cache-Control private;
       expires 0s;
    }
复制代码

3、编辑打包更新程序到k8s的脚本

复制代码

#!/bin/bash
#获取当前路径
dir=$(cd $(dirname $0);pwd)
#images名称
i='test-ywxtpt'
docker build -t 100.98.100.234/chinapopin-test/$i:`date +%-m`.`date +%-d` -f $dir/dockerfile $dir/
docker push 100.98.100.234/chinapopin-test/$i:`date +%-m`.`date +%-d`
docker rmi -f 100.98.100.234/chinapopin-test/$i:`date +%-m`.`date +%-d`
kubectl set image deploy `kubectl get deploy -n test-project|grep ywxtpt-manager-test|awk '{print $1}'` *=100.98.100.234/chinapopin-test/$i:`date +%-m`.`date +%-d` -n test-project
kubectl delete pod `kubectl get pods -n test-project|grep ywxtpt-manager-test|awk '{print $1}'` -n test-project

复制代码

 

posted @   苍茫宇宙  阅读(211)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示