1. 程式人生 > 其它 >|NO.Z.00255|——————————|CloudNative|——|KuberNetes&中介軟體容器化及helm.V02|------------------------------------------|中介軟體.v02|redis.v5.0.4|ratel方式部署|

|NO.Z.00255|——————————|CloudNative|——|KuberNetes&中介軟體容器化及helm.V02|------------------------------------------|中介軟體.v02|redis.v5.0.4|ratel方式部署|



[CloudNative:KuberNetes&中介軟體容器化及helm.V02]                                             [Applications.KuberNetes] [|容器化中介軟體基本說明|如何部署一個容器到k8s中|k8s下同步docker映象|部署redis-operator|redis.v5.0.4|]








一、部署Redis到k8s上:通過資源管理建立
### --- 下載官方redis.conf配置模板:
~~~     官方地址:

[root@k8s-master01 redis]#  wget -c http://download.redis.io/redis-stable/redis.conf
### --- 取消配置檔案中的空格及註釋#號

[root@k8s-master01 redis]# grep -v "#" redis.conf |grep -v "^$"
### --- 獲取到的配置檔案引數如下

[root@k8s-master01 redis]# vim redis.conf 

bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "/tmp/redis.log"        # log日誌地址
databases 16
always-show-logo no
set-proc-title yes
proc-title-template "{title} {listen-addr} {server-mode}"
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir /data                       # dir地址更改為data
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
acllog-max-len 128
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
lazyfree-lazy-user-flush no
oom-score-adj no
oom-score-adj-values 0 200 800
disable-thp yes
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
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
jemalloc-bg-thread yes
二、建立redis-configmap:
### --- 建立redis-configmap:通過資源管理平臺來建立配置檔案,通過configmap的配置來修改

~~~     ——>建立configmap:資源配置——>ConfigMap——>選擇叢集:test1
~~~     ——>namespace:ratel-test1——>configmap名稱:redis-conf——>Data名稱:redis.conf
~~~     ——>資料:redis.conf模板——>Create——>END
三、建立redis-deployment
### --- 下載一個redis的5.0.4-alpine映象

[root@k8s-master01 redis]# docker images | grep redis
redis                                                             latest         bc8d70f9ef6c   5 days ago      105MB
redis                                                             5.0.4-alpine   631bf69df08e   2 years ago     50.9MB
### --- 建立redis-deployment

~~~     # 建立deployment:deployment——>
~~~     ——>Metadata:選擇叢集:test1——>Namespace:retal-test1——>Name:redis-single-node——>重啟策略——>Always——>DNS策略:ClusterFirst——>節點故障停留時間——>副本數:1——>儘量部署在不同宿主機上——>NEXT
~~~     ——>Volumes:volumes——>名稱:redis-conf——>Voume型別:ConfigMap——>ConfigMap名稱:redis-configmap——>Next
~~~     # ——>Containers:容器名稱:redis-single-node——>映象地址:redis:5.0.4-alpine
~~~     ——>啟動命令:sh,,,-c,,,redis-server"/mnt/redis.conf"
~~~     ——>Memory Request&limit(單位:Mi):10~399
~~~     ——>LivenessProbe健康檢查:準備時間:10;檢查埠:6379;檢查方式:tcpSocket
~~~     ——>ReadinessProbe:準備時間:10;檢查埠:6379;檢查方式:tcpSocket
~~~     ——>映象下載策略:IfNotPresent——>容器埠:6379
~~~     ——>檔案掛載:Volume名稱:redis-conf;掛載目錄:/mnt;只讀:true——>Next
~~~     # ——>Init Containers:——>Next
~~~     ——>Services:新增Service——>預設——>Next
~~~     ——>Ingress:Create——>END
四、檢視建立的redis單節點pod
### --- 檢視啟動的redis的pod

[root@k8s-master01 redis]# kubectl get po -n ratel-test1 -owide
NAME                                READY   STATUS    RESTARTS   AGE   IP              NODE           NOMINATED NODE   READINESS GATES
redis-single-node-df78c5db8-jlbcn   1/1     Running   0          15m   172.25.92.115   k8s-master02   <none>           <none>
### --- 檢視啟動的svc

[root@k8s-master01 redis]# kubectl get svc -n ratel-test1 -owide
NAME                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE   SELECTOR
redis-single-node   ClusterIP   10.107.230.191   <none>        6379/TCP   41m   app=redis-single-node
### --- 檢視啟動的ep

[root@k8s-master01 redis]# kubectl get ep -n ratel-test1 -owide
NAME                ENDPOINTS            AGE
redis-single-node   172.25.92.115:6379   41m








===============================END===============================


Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart                                                                                                                                                    ——W.S.Landor



來自為知筆記(Wiz)