使用helm部署 redis 集群
参考 githubhttps://github.com/ucloud/redis-cluster-operator添加repo仓库,并更新helm repo add ucloud-operator https://ucloud.github.io/redis-cluster-operator/helm repo update拉取redis-cluster配置信息helm fetch ucloud-
参考 github
https://github.com/ucloud/redis-cluster-operator
添加repo仓库,并更新
helm repo add ucloud-operator https://ucloud.github.io/redis-cluster-operator/
helm repo update
拉取redis-cluster配置信息
helm fetch ucloud-operator/redis-cluster-operator
解压
tar -zxvf redis-cluster-operator-0.1.0.tgz
查看配置文件所需镜像版本,拉取镜像信息
docker pull fishu/redis-cluster-operator
拉取镜像失败,我已经将该镜像保存在我的镜像仓库,可下载
docker pull swr.cn-north-4.myhuaweicloud.com/redis/redis-cluster-operator:v0.2.4
修改镜像tag
docker tag swr.cn-north-4.myhuaweicloud.com/redis/redis-cluster-operator:v0.2.4 fishu/redis-cluster-operator:latest
helm部署redis-cluster-operator
helm install redis .
部署redis
这些deploy放置在https://github.com/ucloud/redis-cluster-operator/tree/master/deploy/example
以如下的deploy-redis.yaml为例:
apiVersion: redis.kun/v1alpha1
kind: DistributedRedisCluster
metadata:
annotations:
# if your operator run as cluster-scoped, add this annotations
redis.kun/scope: cluster-scoped
name: redis
spec:
# Add fields here
masterSize: 3
clusterReplicas: 1
image: redis:5.0.12
resources:
limits:
cpu: 200m
memory: 200Mi
requests:
cpu: 200m
memory: 100Mi
执行:
kubectl apply -f deploy-redis.yaml
若提示如上报错 error: unable to recognize "deploy-redis.yaml": no matches for kind "Distributed RedisCluster" in version "redis.kun/v1alpha1"
则切到crds目录执行
kubectl apply -f redis.kun_distributedredisclusters_crd.yaml
kubectl apply -f redis.kun_redisclusterbackups_crd.yaml
切到上次目录,再次执行
kubectl apply -f deploy-redis.yaml
要是redis拉取不到镜像提供我仓库的镜像地址:
docker pull swr.cn-north-4.myhuaweicloud.com/redis/redis:5.0.12
修改tag
docker tag swr.cn-north-4.myhuaweicloud.com/redis/redis:5.0.12 redis:5.0.12
集群已经全部起来,pending的pod是因为资源不足导致 ,调整资源重新部署
可设置密码:创建部署 secret.yaml
apiVersion: v1
kind: Secret
metadata:
annotations:
# if your operator run as cluster-scoped, add this annotations
redis.kun/scope: cluster-scoped
name: mysecret
type: Opaque
data:
password: MTIzNDU2
# echo -n "123456" |base64
修改deploy-redis.yaml,以及添加redis 启动config配置信息
apiVersion: redis.kun/v1alpha1
kind: DistributedRedisCluster
metadata:
annotations:
# if your operator run as cluster-scoped, add this annotations
redis.kun/scope: cluster-scoped
name: redis
spec:
# Add fields here
masterSize: 3
clusterReplicas: 1
image: redis:5.0.12
resources:
limits:
cpu: 200m
memory: 200Mi
requests:
cpu: 200m
memory: 100Mi
passwordSecret:
name: mysecret
config:
appendonly: "yes"
更多推荐
所有评论(0)