一、准备
y1的kubeconfig(脱敏)
yaml
apiVersion: v1
kind: Config
clusters:
- name: "yumc1-middleware"
cluster:
server: "https://ksrancher.hwwt2.com/k8s/clusters/c-4nmx8"
- name: "yumc1-middleware-172.25.148.232"
cluster:
server: "https://172.25.148.232:6443"
certificate-authority-data: "xxx"
- name: "yumc1-middleware-172.25.148.231"
cluster:
server: "https://172.25.148.231:6443"
certificate-authority-data: "xxx"
- name: "yumc1-middleware-172.25.148.233"
cluster:
server: "https://172.25.148.233:6443"
certificate-authority-data: "xxx"
users:
- name: "yumc1-middleware"
user:
token: "xxx"
contexts:
- name: "yumc1-middleware"
context:
user: "yumc1-middleware"
cluster: "yumc1-middleware"
- name: "yumc1-middleware-172.25.148.232"
context:
user: "yumc1-middleware"
cluster: "yumc1-middleware-172.25.148.232"
- name: "yumc1-middleware-172.25.148.231"
context:
user: "yumc1-middleware"
cluster: "yumc1-middleware-172.25.148.231"
- name: "yumc1-middleware-172.25.148.233"
context:
user: "yumc1-middleware"
cluster: "yumc1-middleware-172.25.148.233"
current-context: "yumc1-middleware"
-
redis yaml文件
cluster模式的redis yaml文件
yaml
apiVersion: cache.tongdun.net/v1alpha1
kind: RedisCluster
metadata:
name: redis-cluster-cpos-01
namespace: redis
spec:
app: cluster-cpos-01 # 取name中redis-* 后的值, pod之间共享资源根据该标签
capacity: 8192
dc: sh
env: production
image: harbor.hwwt2.com/ops/redis-cluster:latest
monitorimage: harbor.hwwt2.com/ops/redis-exporter:latest
netmode: ClusterIP
proxyimage: "" # 原项目代理密码 废弃
proxysecret: "" # 原项目代理密码 废弃
realname: dba
secret: 'TKYdUe7pfT' # redis密码设置 可以为空
size: 3 # 初始redis集群主节点 也是slot分段数量 单台节点最高容量32GB 所以如128GB,就是至少为4
storageclass: "" # 目前都是本地盘
vip: "" # 暂时废弃
labels:
plt: cpos
sid: "1115"
srv: cpos-redis-cluster-gray
注意:
Image 和 monitorimage ,y0和y1不是一样,需要注意。
HA模式的redis yaml文件
yaml
apiVersion: cache.tongdun.net/v1alpha1
kind: RedisStandby
metadata:
name: redis-standby-kfc-storeinfo
namespace: redis
spec:
app: standby-kfc-storeinfo
capacity: 8192 # redis容量
dc: sh
env: production
image: harbor.hwwt2.com/ops/op-redis-5.0.9:v2
monitorimage: harbor.hwwt2.com/ops/redis-exporter:paas1.0
netmode: ClusterIP
realname: dba
secret: '2ghlmvl_AP'
sentinelimage: harbor.hwwt2.com/ops/sentinel-standby:v1
storageclass: ''
vip: ''
labels: # 百胜云监控需要的标签
plt: ecselection
sid: "1005"
srv: ecselection-redis-kfc-storeinfo
---
-
git信息
redis的yaml文件记录在git中
rancher地址
ksrancher.hwwt2.com/p/c-4nmx8:p...
二、操作
查询已有的redis
ini
#
kubectl --kubeconfig=yumc1_k8s get RedisCluster -n redis
-
创建 redis(apply)
ini
# cpos 是redis yaml文件
kubectl --kubeconfig=yumc1_k8s apply -f cpos
-
验证
ini
# 查看创建的 redis-cluster-cpos-01 资源
kubectl --kubeconfig=yumc1_k8s get RedisCluster -n redis
在rancher上验证


三、补充
- 最小规格
分片:8G,三分片。
- 规格套餐
- 白皮书
- 删除操作
ini
# 删除redis-cluster-cpos01 资源
kubectl --kubeconfig=yumc1_k8s delete RedisCluster redis-cluster-cpos01 -n redis