根据需求搭建一个不需要数据持久化,需要密码登录的 Redis
mkdir /iba/qa_ibaboss_elk -p
cd /iba/qa_ibaboss_elk
# 创建一个专用的 namespace
cat namespace.yaml
---
apiVersion: v1
kind: Namespace
metadata:
name: qa-ibaboss-elk
kubectl apply -f namespace.yaml
# 查看 namespace
kubectl get namespace
创建一个 configmap
mkdir config && cd config
cat redis.conf
#daemonize yes
pidfile /data/redis.pid
port 6379
tcp-backlog 30000
timeout 0
tcp-keepalive 10
loglevel notice
logfile /data/redis.log
databases 16
#save 900 1
#save 300 10
#save 60 10000
stop-writes-on-bgsave-error no
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /data
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
requirepass ibalife
maxclients 30000
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events KEA
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 1000
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
# 在 qa-ibaboss-elk namespace 中创建 configmap
kubectl create configmap qa-ibaboss-elk-redis-conf --from-file=redis.conf -n qa-ibaboss-elk
创建 redis 容器
cat qa_ibaboss_elk_redis.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: qa-ibaboss-elk-redis
namespace: qa-ibaboss-elk
spec:
replicas: 1
template:
metadata:
labels:
name: qa-ibaboss-elk-redis
spec:
containers:
- name: qa-ibaboss-elk-redis
image: redis
volumeMounts:
- name: foo
mountPath: "/usr/local/etc"
command:
- "redis-server"
args:
- "/usr/local/etc/redis/redis.conf"
volumes:
- name: foo
configMap:
name: qa-ibaboss-elk-redis-conf
items:
- key: redis.conf
path: redis/redis.conf
# 创建和查看 pod
kubectl apply -f qa_ibaboss_elk_redis.yaml
kubectl get pods -n qa-ibaboss-elk
# 注意:configMap 会挂在 /usr/local/etc/redis/redis.conf 上。与 mountPath 和 configMap 下的 path 一同指定
可以创建一个 busybox 容器进去测试
kubectl run busybox --image=busybox -n qa-ibaboss-elk --command -- ping baidu.com
所有评论(0)