在Kubernetes中运行有状态应用及自动扩缩容
1. 使用复制控制器部署Cassandra
Cassandra是一个复杂的分布式数据库,有自动分发、平衡和复制数据的机制,这些机制并非针对网络持久存储进行优化,它设计为直接使用节点上存储的数据。当节点出现故障时,可通过其他节点上的冗余数据恢复。我们可以采用复制控制器在Kubernetes集群上部署Cassandra,这样无需将现有集群升级到最新版本就能使用。
与使用有状态集不同,使用复制控制器部署Cassandra有以下特点:
- 使用复制控制器而非有状态集。
- 存储位于调度运行Pod的节点上。
- 使用自定义的Kubernetes种子提供者类。
以下是复制控制器配置文件的详细解析:
apiVersion: v1 kind: ReplicationController metadata: name: cassandra # The labels will be applied automatically # from the labels in the pod template, if not set # labels: # app: Cassandra spec: replicas: 3 # The selector will be applied automatically # from the labels in the pod template, if not set. # selector: # app: Cassandra template: met