k8s搭建web界面管理rancher
rancher部署
一、准备介质
镜像v2.4.17
docker pull rancher/rancher:v2.4.17
二、使用docker安装
点击查看代码
docker run -d --restart=unless-stopped -p 80:80 -p 443:443 \
-v /home/ap/aipf/rancher_home/rancher:/var/lib/rancher \
-v /home/ap/aipf/rancher_home/auditlog:/var/log/auditlog \
--name rancher rancher/rancher:v2.4.17
访问本机ip
三、使用k8s部署rancher
3.1、创建namespace
kubectl create ns rancher
3.2、创建rancher的存储路径pv/pvc
点击查看代码
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-rancher
namespace: rancher
spec:
capacity:
storage: 20Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
local:
path: /home/ap/nas_b
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- k8s-master
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-rancher
namespace: rancher
spec:
accessModes:
- ReadWriteMany
storageClassName: local-storage
resources:
requests:
storage: 15Gi
3.3、创建rancher的配置文件
点击查看代码
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: rancher
name: rancher
namespace: rancher
spec:
replicas: 1
selector:
matchLabels:
app: rancher
template:
metadata:
labels:
app: rancher
containers:
- image: rancher/rancher:v2.4.17
imagePullPolicy: IfNotPresent
name: rancher
envFrom:
- configMapRef:
name: ai-platform-config
ports:
- containerPort: 80
volumeMounts:
- mountPath: /var/lib/rancher
name: ai-rancher-volumes
subPath: rancher_home/rancher
- mountPath: /var/log/auditlog
name: ai-rancher-volumes
subPath: rancher_home/auditlog
volumes:
- name: ai-rancher-volumes
persistentVolumeClaim:
claimName: pvc-rancher
---
apiVersion: v1
kind: Service
metadata:
name: rancher
labels:
app: rancher
namespace: rancher
spec:
type: ClusterIP
selector:
app: ai-admin-web
ports:
- port: 80
targetPort: 80
点击查看代码
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: rancher
name: rancher
namespace: rancher
spec:
replicas: 1
selector:
matchLabels:
app: rancher
template:
metadata:
labels:
app: rancher
spec:
nodeSelector:
rancherbase: "true"
containers:
- image: rancher.harbor.io/rancher/rancher:v2.4.17
imagePullPolicy: IfNotPresent
name: rancher
envFrom:
- configMapRef:
name: ai-platform-config
ports:
- containerPort: 80
volumeMounts:
- mountPath: /var/lib/rancher
name: ai-rancher-volumes
subPath: rancher_home/rancher
- mountPath: /var/log/auditlog
name: ai-rancher-volumes
subPath: rancher_home/auditlog
volumes:
- name: ai-rancher-volumes
persistentVolumeClaim:
claimName: pvc-rancher
---
apiVersion: v1
kind: Service
metadata:
name: rancher
labels:
app: rancher
namespace: rancher
spec:
type: ClusterIP
selector:
app: ai-admin-web
ports:
- port: 80
targetPort: 80
3.4、使用上面的配置文件启动rancher服务
[root@k8s-master conf]# kubectl apply -f rancher-pv.yaml
persistentvolume/pv-rancher created
persistentvolumeclaim/pvc-rancher created
[root@k8s-master conf]# kubectl get pv,pvc -A | grep rancher
persistentvolume/pv-rancher 20Gi RWX Retain Bound rancher/pvc-rancher local-storage 79s
rancher persistentvolumeclaim/pvc-rancher Bound pv-rancher 20Gi RWX local-storage 79s
3.5、启动rancher服务
[root@k8s-master conf]# kubectl apply -f rancher.yaml
deployment.apps/rancher created
service/rancher created
【推荐】2025 HarmonyOS 鸿蒙创新赛正式启动,百万大奖等你挑战
【推荐】博客园的心动:当一群程序员决定开源共建一个真诚相亲平台
【推荐】开源 Linux 服务器运维管理面板 1Panel V2 版本正式发布
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 还在手写JSON调教大模型?.NET 9有新玩法
· 复杂业务系统线上问题排查过程
· 通过抓包,深入揭秘MCP协议底层通信
· 记一次.NET MAUI项目中绑定Android库实现硬件控制的开发经历
· 糊涂啊!这个需求居然没想到用时间轮来解决
· Coze Studio:字节跳动 Coze 的开源版本来了!第一时间深度解析
· 为大模型 MCP Code Interpreter 而生:C# Runner 开源发布
· 复杂业务系统线上问题排查过程
· 独立开发:高效集成大模型,看这篇就够了
· 在SqlSugar的开发框架的Vue3+ElementPlus前端中增加对报表模块的封装处理,实现常
2019-12-20 docker制作镜像乱码问题
2019-12-20 docker使用普通用户可以启动问题
2019-12-20 keeplive 高可用nginx
2019-12-20 CDH随手记
2019-12-20 linux 配置环境变量不生效
2019-12-20 redis主从和哨兵搭建
2019-12-20 linux 清楚buff