Dict.CN 在线词典, 英语学习, 在线翻译 ------------- MyGitee My腾云code My51cto

Happy_EveryDay

可以平凡 不可以平庸 无爱则无忧,无欲则无求,无怒而无敌,无怨才是佛。所有烦恼,都是放不下的执著 开源技群 328035181 MyGitee

博客园 首页 管理

1、ruoyi-web端端打包dist

 

image

 

 

2、 生成镜像

image

 

2.1

dist

image

 

2.2

nginx.conf

 

image

 

image

 

 

 

2.3  DockerFile 文件内容如下

 

 

 

 

 

image

 

# 基础Nginx镜像
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/ghcr.io/u-sb/nginx:latest

# 只清理默认页面,不删除sites配置文件
RUN rm -rf /var/www/html/*

# 复制自定义配置到conf.d,Nginx会自动加载该目录下所有.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf

 

# 你想要新增的一行(本地必须有site-default.conf文件,否则build报错)

####nginx:latest镜像生成

####pod:rouyi-ng-web-648c77bbc6-fd7zc以/etc/nginx/sites-enabled/default 配置文件为主
COPY nginx.conf  /etc/nginx/sites-enabled/default

 

# 复制前端dist静态资源
COPY dist /var/www/html

# 前台运行Nginx,防止容器退出重启
CMD ["nginx", "-g", "daemon off;"]

 

 

 

 

2.4   生成镜像

docker build -t 192.168.91.164/rouyi-biz/yudao-web:20260731 .

image

 

镜像推送到harbor

image

 

 

 

2.5  镜像192.168.91.164/rouyi-biz/yudao-web:20260731   保存为tar文件

docker save -o yudao-web20260731.tar 192.168.91.164/rouyi-biz/yudao-web:20260731

 

image

 

2.6  tar 文件复制到  master(192.168.91.166),node2(192.168.91.167),node3(192.168.91.168)

yudao-web20260731.tar

 

scp yudao-web20260731.tar root@192.168.91.166:/root/

scp yudao-web20260731.tar root@192.168.91.167:/root/

scp yudao-web20260731.tar root@192.168.91.168:/root/

 

 

2.7 master(192.168.91.166),node2(192.168.91.167),node3(192.168.91.168)

     把yudao-web20260731.tar   导入镜像

     docker load -i /root/yudao-web20260731.tar 

 

image

 

 

 

 

 

3、创建Deployment、Service文件yaml

 

kubeSphere 用命令创建 namespace: biz-rouyi

image

 

   【Deployment、Service】rouyi-ng-web.yaml内容如下

apiVersion: apps/v1
kind: Deployment
metadata:
name: rouyi-ng-web
namespace: biz-rouyi
spec:
replicas: 1
selector:
matchLabels:
app: rouyi-ng-web
template:
metadata:
labels:
app: rouyi-ng-web
spec:
imagePullSecrets:
- name: harbor-auth
containers:
- name: rouyi-nginx-web
#image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/ghcr.io/u-sb/nginx:latest
image: 192.168.91.164/rouyi-biz/yudao-web:20260731
imagePullPolicy: Never
command:
- nginx
args:
- -g
- daemon off;
ports:
- containerPort: 80
---
# 新增Service片段,type直接写NodePort
apiVersion: v1
kind: Service
metadata:
name: rouyi-ng-web
namespace: biz-rouyi
spec:
type: NodePort
selector:
app: rouyi-ng-web
ports:
- port: 80
targetPort: 80
nodePort: 30080 # 固定端口30080,范围30000-32767

 

4、发布【Deployment、Service】

kubectl apply -f rouyi-ng-web.yaml -n biz-rouyi

 

查看kubectl get pods -n  biz-rouyi

image

 

  

查看kubectl  deployment日志

kubectl logs -f deployment/rouyi-ng-web -n biz-rouyi

 

image

 

 

 

 

5、kubeSphere

image

 

 

image

 

 

 

 

 

 

6、http://192.168.91.166:30080/

http://192.168.91.166:30080/login?redirect=/index

image

 

 

 

 

 

image

 

posted on 2026-07-11 22:45  2026cn  阅读(6)  评论(6)    收藏  举报