1

我正在尝试在 Kubernetes 上运行 Redis 集群。我不打算将任何 Redis 数据保存到磁盘。是否可以将 Redis 集群作为 Kubernetes 部署而不是作为有状态集运行?

4

2 回答 2

1

是的,尽管我可能仍会专门使用 StatefulSet 来确保一次只启动一个 pod。

于 2020-04-06T06:11:08.180 回答
1

是的,可以使用有状态集在 PVC 中持久化数据,但是在 HA redis 集群的掌舵图中,它们仅使用有状态集:

apiVersion: v1
kind: Service
metadata:
  name: redis
spec:
  ports:
    - port: 6379
      name: redis
  clusterIP: None
  selector:
    app: redis
---
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: redis
spec:
  selector:
    matchLabels:
      app: redis  
  serviceName: redis
  replicas: 1
  template:
    metadata:
      labels:
        app: redis 
    spec:
      containers:
        - name: redis
          image: redislabs/redis
          args: ["--requirepass", "admin", "--appendonly", "yes", "--save", "900", "1", "--save", "30", "2"]
          ports:
            - containerPort: 6379
              name: redis
          resources:
            limits:
              cpu: .50
              memory: 1500Mi
            requests:
              cpu: .25
              memory: 1024Mi
          volumeMounts:
            - name: redis-volume
              mountPath: /data
  volumeClaimTemplates:
  - metadata:
      name: redis-volume
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 20Gi
于 2020-04-06T06:23:33.573 回答