k8s快速部署Redis单机

1.创建Redis配置

apiVersion: v1
data:
  redis.conf: |-
    bind 0.0.0.0
    port 6379
    requirepass System@123
    pidfile /var/run/redis_6379.pid
    save 900 1
    save 300 10
    save 60 10000
    rdbcompression yes
    rdbchecksum yes
    dbfilename dump.rdb
    appendonly yes
    appendfilename "appendonly.aof"
    appendfsync everysec
    dir /data
    logfile "/data/redis-6379.log"
kind: ConfigMap
metadata:
  name: redis-config
  namespace: ops-share

2.创建PV/PVC

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: redis-data
  namespace: ops-share
spec:
  storageClassName: nfs-client #使用存储类自行替换,不是根据时间情况创建
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10G

3.创建redis deployment文件

apiVersion: apps/v1
kind: Deployment
metadata:
  name: t1-redis
  namespace: ops-share
spec:
  replicas: 1
  selector:
    matchLabels:
      app: t1-redis
  template:
    metadata:
      labels:
        app: t1-redis
    spec:
      containers:
      - image: redis:6.0.9
        command: ["redis-server","/etc/redis/redis.conf"]
        name: t1-redis
        ports:
        - containerPort: 6379        
        volumeMounts:
        - name: redis-config
          mountPath: /etc/redis/redis.conf
          subPath: redis.conf
        - name: redis-data
          mountPath: /data
      volumes:
      - name: redis-config
        configMap:
          name: redis-config
      - name: redis-data
        persistentVolumeClaim:
          claimName: redis-data

4.创建Redis svc文件

apiVersion: v1
kind: Service
metadata:
  labels:
    app: t1-redis-svc
  name: t1-redis-svc
  namespace: ops-share
spec:
  ports:
  - name: tcp-redis-6379
    port: 6379
    protocol: TCP
    targetPort: 6379
  selector:
    app: t1-redis

 

 

posted @ 2023-05-19 14:17  百衲本  阅读(863)  评论(1编辑  收藏  举报
cnblogs_post_body { color: black; font: 0.875em/1.5em "微软雅黑" , "PTSans" , "Arial" ,sans-serif; font-size: 15px; } cnblogs_post_body h1 { text-align:center; background: #333366; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 23px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } cnblogs_post_body h2 { text-align:center; background: #006699; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 20px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } cnblogs_post_body h3 { background: #2B6695; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 18px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } 回到顶部 博客侧边栏 回到顶部 页首代码 回到顶部 页脚代码