当前位置: 首页 > news >正文

k8s部署单节点redis

一、configmap

# cat redis-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:name: redis-single-confignamespace: redis
data:redis.conf: |daemonize nobind 0.0.0.0port 6379tcp-backlog 511timeout 0tcp-keepalive 300pidfile /data/redis-server.pidlogfile /data/redis.logloglevel noticedatabases 16always-show-logo yessave 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir /dataslave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100appendonly yesappendfilename "appendonly.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yesrequirepass redis#s

# kubectl create namespace redis

# kubectl apply -f redis-configmap.yaml

二、deployment编写

# cat redis-deployment.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:name: redis-singlenamespace: redis
spec:replicas: 1selector:matchLabels:app: redis-singletemplate:metadata:labels:app: redis-singlespec:initContainers:- name: init-0image: busyboximagePullPolicy: IfNotPresentterminationMessagePath: /dev/termination-logterminationMessagePolicy: Filecommand: [ "sysctl", "-w", "net.core.somaxconn=511" ]securityContext:privileged: true- name: init-1image: busyboximagePullPolicy: IfNotPresentterminationMessagePath: /dev/termination-logterminationMessagePolicy: Filecommand: [ "sh", "-c", "echo never > /sys/kernel/mm/transparent_hugepage/enabled" ]securityContext:privileged: truecontainers:- name: redis-singleimage: redis:6.0.8imagePullPolicy: IfNotPresentterminationMessagePath: /dev/termination-logterminationMessagePolicy: FilevolumeMounts:- name: redis-datamountPath: /data- name: redis-configmountPath: /usr/local/etc/redis/redis.confsubPath: redis.confcommand: [ "redis-server" ,"/usr/local/etc/redis/redis.conf" ]env:- name: TZvalue: "Asia/Shanghai"volumes:- name: timezonehostPath:path: /usr/share/zoneinfo/Asia/Shanghai- name: redis-datanfs:path: /nfs/redisserver: 192.168.110.38- name: redis-configconfigMap:name: redis-single-configitems:- key: redis.confpath: redis.conf

# kubectl apply -f redis-deployment.yaml

三、service编写

# cat redis-service.yaml
apiVersion: v1
kind: Service
metadata:name: service-redis-singlenamespace: redislabels:app: redis-single
spec:selector:app: redis-singleports:- name: redis-singleport: 6379targetPort: 6379nodePort: 30000type: NodePort# kubectl apply -f redis-service.yaml
service/service-redis-single created

四、测试

http://www.lryc.cn/news/389788.html

相关文章:

  • 云微客矩阵系统:如何利用智能策略引领营销新时代?
  • 嵌入式Linux系统编程 — 6.3 kill、raise、alarm、pause函数向进程发送信号
  • Swoole实践:如何使用协程构建高性能爬虫
  • 基于人脸68特征点识别的美颜算法(一) 大眼算法 C++
  • 算法金 | 欧氏距离算法、余弦相似度、汉明、曼哈顿、切比雪夫、闵可夫斯基、雅卡尔指数、半正矢、Sørensen-Dice
  • 项目实战--Spring Boot大数据量报表Excel优化
  • C#编程技术指南:从入门到精通的全面教程
  • Redis+定式任务实现简易版消息队列
  • 学习在 C# 中使用 Lambda 运算符
  • 数据结构和算法,单链表的实现(kotlin版)
  • Jdk17是否有可能代替 Jdk8
  • oca和 ocp有什么区别
  • 煤矿安全大模型:微调internlm2模型实现针对煤矿事故和煤矿安全知识的智能问答
  • C++中的C++中的虚析构函数的作用和重要性
  • 机器学习 - 文本特征处理之 TF 和 IDF
  • 因为自己淋过雨所以想给嵌入式撑把伞
  • 《C++20设计模式》中单例模式
  • 前端技术(说明篇)
  • 带电池监控功能的恒流直流负载组
  • 关于Disruptor监听策略
  • 大数据面试题之HBase(3)
  • c#中赋值、浅拷贝和深拷贝
  • 旧版st7789屏幕模块 没有CS引脚的天坑 已解决!!!
  • 激光粒度分析仪校准步骤详解:提升测量精度的秘诀
  • 独一无二的设计模式——单例模式(python实现)
  • 第二证券:可转债基础知识?想玩可转债一定要搞懂的交易规则!
  • 原型模式的实现
  • 【第二套】华为 2024 年校招-硬件电源岗
  • Xilinx FPGA:vivado利用单端RAM/串口传输数据实现自定义私有协议
  • Spark on k8s 源码解析执行流程