二进制部署k8s集群v1.23.9版本-19-安装redis-5.X
19.1、准备镜像
192.168.1.200操作
docker pull redis:5.0.14
docker images|grep redis
docker tag c5da061a611a harbor.qgutech.com/middleware/redis:v5.0.14
docker push harbor.qgutech.com/middleware/redis:v5.0.14
19.2、准备资源配置清单
192.168.1.200操作
mkdir -p /data/k8s-yaml/redis/
cd /data/k8s-yaml/redis/
vim dp.yaml
kind: Deployment
apiVersion: apps/v1
metadata:
labels:
name: redis-paas
name: redis-paas
namespace: middleware
spec:
replicas: 1
revisionHistoryLimit: 7
selector:
matchLabels:
name: redis-paas
template:
metadata:
labels:
app: redis-paas
name: redis-paas
spec:
nodeName: hfqg1-201.host.com
containers:
- name: redis-paas
image: harbor.qgutech.com/middleware/redis:v5.0.14
imagePullPolicy: IfNotPresent
ports:
- containerPort: 6379
hostPort: 26379
protocol: TCP
volumeMounts:
- name: redis-config
mountPath: "/usr/local/etc/redis"
- name: redis-data
mountPath: "/data"
command:
- "redis-server"
args:
- "/usr/local/etc/redis/redis.conf"
imagePullSecrets:
- name: harbor
volumes:
- nfs:
server: hfqg1-200
path: /data/nfs-volume/redis-paas
name: redis-config
- nfs:
server: hfqg1-200
path: /data/nfs-volume/redis-paas/data
name: redis-data
vim svc.yaml
apiVersion: v1
kind: Service
metadata:
name: redis-paas
namespace: middleware
spec:
ports:
- port: 26379
protocol: TCP
targetPort: 6379
selector:
app: redis-paas
19.3、准备挂载卷
192.168.1.200操作
mkdir -p /data/nfs-volume/redis-paas/data
cd /data/nfs-volume/redis-paas/
vim redis.conf
requirepass 123456
bind 0.0.0.0
save 900 1
save 300 10
save 60 10000
19.4、应用资源配置清单
192.168.1.201操作
kubectl apply -f http://k8s-yaml.qgutech.com/redis-paas/dp.yaml
kubectl apply -f http://k8s-yaml.qgutech.com/redis-paas/svc.yaml
kubectl get pods -n middleware
节点监听的是26379端口
netstat -lntp|grep 26379
至此,redis安装完成,谢谢观看。
本文来自博客园,作者:霸都运维,转载请注明原文链接:https://www.cnblogs.com/wangjie20200529/p/16672637.html