k8s部署redis单实例数据存节点配置

k8s部署redis单实例数据存节点配置configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: redis-conf
  namespace: workredis
data:
  redis.conf: |
        bind 0.0.0.0
        port 6379
        requirepass test2021aaa
        pidfile .pid
        appendonly yes
        cluster-config-file nodes-6379.conf
        pidfile /data/testdata/redis/log/redis-6379.pid
        cluster-config-file /data/testdata/redis/conf/redis.conf
        dir /data/testdata/redis/data/
        logfile "/data/testdata/redis/log/redis-6379.log"
        cluster-node-timeout 5000
        protected-mode no

k8s部署redis单实例配置StatefulSet.yaml

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: redis
  namespace: workredis
spec:
  replicas: 1
  serviceName: redis
  selector:
    matchLabels:
      name: redis
  template:
    metadata:
      labels:
        name: redis
    spec:
      initContainers:
      - name: init-redis
        image: busybox
        command: ['sh', '-c', 'mkdir -p /data/testdata/redis/log/;mkdir -p /data/testdata/redis/conf/;mkdir -p /data/testdata/redis/data/']
        volumeMounts:
        - name: data
          mountPath: /data/testdata/redis/
      containers:
      - name: redis
        image: redis:6.2.5-alpine3.14
        imagePullPolicy: IfNotPresent
        command:
        - sh
        - -c
        - "exec redis-server /data/testdata/redis/conf/redis.conf"
        ports:
        - containerPort: 6379
          name: redis
          protocol: TCP
        volumeMounts:
        - name: redis-config
          mountPath: /data/testdata/redis/conf/
        - name: data
          mountPath: /data/testdata/redis/
      volumes:
      - name: redis-config
        configMap:
          name: redis-conf
      - name: data
        hostPath:
          path: /data/testdata/redis/
      nodeSelector:
        type5: test2-node

k8s部署redis单实例配置StatefulSet.yaml

kind: Service
apiVersion: v1
metadata:
  labels:
    name: redis
  name: redis
  namespace: workredis
spec:
  type: NodePort
  ports:
  - name: redis
    port: 6379
    targetPort: 6379
    nodePort: 36366
  selector:
    name: redis

给TA买糖
共{{data.count}}人
人已赞赏
配置管理

Nginx后端应用超时配置

2021-8-22 11:24:44

配置管理

k8s部署redis单实例数据存PVC配置

2021-8-22 11:35:55

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
今日签到
有新私信 私信列表
搜索