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

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

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: test-redis
  namespace: workredis
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 20Gi

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

apiVersion: v1
kind: PersistentVolume
metadata:
  name: test-redis
  namespace: workredis
spec:
  capacity:
    storage: 20Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  mountOptions:
    - hard
    - nfsvers=4.0
    - noresvport
  nfs:
    path: /test/redis
    server: 1xxxxx-cccccss.cn-xxx.nas.aliyuncs.com

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

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

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

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

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

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

给TA打赏
共{{data.count}}人
人已打赏
配置管理

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

2021-8-22 11:30:01

配置管理

Alpine容器镜像调整默认时区配置

2021-8-22 11:51:27

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索