欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 手游 > k8s 部署RuoYi-Vue-Plus之redis搭建

k8s 部署RuoYi-Vue-Plus之redis搭建

2025/2/24 14:41:18 来源:https://blog.csdn.net/weimeibuqieryu/article/details/140250445  浏览:    关键词:k8s 部署RuoYi-Vue-Plus之redis搭建
1.直接部署一个pod

需要挂载存储款, 可参考 之前文章设置 https://blog.csdn.net/weimeibuqieryu/article/details/140183843

2.部署yaml

先创建命名空间ruoyi, 有就不用创建了

kubectl create namespace ruoyi

创建部署文件 redis-deploy.yaml

kind: PersistentVolume
apiVersion: v1
metadata:name: redis-pvnamespace: ruoyi #使用ns ruoyilabels:type: local
spec:storageClassName: manualcapacity:storage: 5Gi  #存储容量为 5 GiBaccessModes:- ReadWriteOncenfs:path: /nfs/redis        #使用 NFS 服务器的路径和地址, 使用自己定义的server: 139.159.140.xxx
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:name: redis-pvcnamespace: ruoyi
spec:storageClassName: manualaccessModes:- ReadWriteOnceresources:requests:storage: 5Gi
---
apiVersion: v1
kind: ConfigMap
metadata:name: redis-confignamespace: ruoyi
data:redis.conf: |-bind 0.0.0.0protected-mode noappendonly yes
---
apiVersion: v1
kind: Secret
metadata:name: redis-secretnamespace: ruoyi
type: Opaque
stringData:password: password   #明文密码, 记得改为自己的
---
apiVersion: apps/v1
kind: Deployment
metadata:name: redisnamespace: ruoyi
spec:replicas: 1  selector:matchLabels:app: redistemplate:metadata:labels:app: redisspec:nodeSelector:node-role.kubernetes.io/master: ""  # 指定 Pod 运行在 master 节点containers:- name: redisimage: redis:6.2.7ports:- containerPort: 6379args:- "--requirepass"- "$(REDIS_PASSWORD)"env:- name: REDIS_PASSWORDvalueFrom:secretKeyRef:name: redis-secretkey: passwordvolumeMounts:    # 挂载 PVC 和 ConfigMap- name: redis-datamountPath: /data- name: redis-configmountPath: /redis.confsubPath: redis.confvolumes:- name: redis-datapersistentVolumeClaim:claimName: redis-pvc- name: redis-configconfigMap:name: redis-config
---
apiVersion: v1
kind: Service
metadata:name: redis-servicenamespace: ruoyi
spec:selector:app: redisports:- port: 6379targetPort: 6379nodePort: 30379 # 节点端口 30379, 可外部访问type: NodePort   # 暴露服务为 NodePort 类型

部署该服务

kubectl apply -f redis-deploy.yaml

就可以使用节点的ip+30379 来访问了. 公网记得防火墙的端口要打开

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词