Kubernetes Redis服务部署 ----端口转发方式

Step 1: 更改Docker的镜像源下载地址

建立一个文件:/etc/docker/daemon.json

{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ],
  "registry-mirrors":["https://registry.docker-cn.com"]
}

重新加载systemctl并重启docker服务

// 重载配置文件
sudo systemctl daemon-reload   
// 重启docker  
sudo systemctl restart docker  

Ref: https://www.ucloud.cn/yun/46270.html

国内官方镜像源:
https://registry.docker-cn.com

Step 2 :下载redis部署配置文件&Redis镜像

docker pull redis[:your_desired_tag or nothing]
wget https://gitee.com/oneslideicywater/docker-utils/raw/master/config-third-party/redis-master-deployment.yaml
wget https://gitee.com/oneslideicywater/docker-utils/raw/master/config-third-party/redis-master-service.yaml

Step 3: 部署Redis

# 部署Redis
kubectl apply -f redis-master-deployment.yaml
# 添加Service 
kubectl apply -f redis-master-service.yaml
# 设置端口转发
kubectl port-forward deployment/redis-master 7000:6379
# 安装Redis Cli Ref: 
yum install epel-release
yum install -y  redis
# 连接本机端口7000,将会被转发pod 6379端口中
redis-cli -p 7000
# 可以敲redis命令

效果如下:

127.0.0.1:7000> set oneslide icywater
OK
127.0.0.1:7000> get oneslide
"icywater"

Reference List

  1. Use Port Forwarding to Access Applications in a Cluster
  2. CentOS 7安装Kubernetes
  3. centos下通过yum安装redis-cli

你可能感兴趣的:(虚拟化与自动化运维)