1 year ago
#353464
Rakesh
Kubernetes statefulset replication
I am using kubernetes statefulset for my mongodb and influxdb.
In summary, StatefulSets provide the following advantages when compared to Deployment objects: Ordered numbers for each Pod. The first Pod can be a primary, which makes it a good choice when creating a replicated database setup, which handles both reading and writing. Other Pods act as replicas.
But while i am deploying statefulset for both mongodb and influxdb with 3 replicas, only one pod (first pod, i.e. mondodb-0 and influxdb-0) is storing the data, non of the remaining pods are cloning the data from the first pod.
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: influxdb
labels:
app: influxdb
spec:
selector:
matchLabels:
app: influxdb
serviceName: influxdb
replicas: 3
template:
metadata:
labels:
app: influxdb
spec:
terminationGracePeriodSeconds: 10
containers:
- name: influxdb
image: influxdb:1.8.10
command:
# - influx
# - --bind_ip_all
ports:
- containerPort: 8086
env:
- name: INFLUXDB_USERNAME
valueFrom:
secretKeyRef:
name: influxdb-secret
key: influxdb-username
- name: INFLUXDB_PASSWORD
valueFrom:
secretKeyRef:
name: influxdb-secret
key: influxdb-password
volumeMounts:
- name: influxdb-volume
mountPath: /data/db
volumeClaimTemplates:
- metadata:
name: influxdb-volume
spec:
accessModes: [ ReadWriteOnce ]
resources:
requests:
storage: 25Gi
I am trying with the above yaml file, but i am unable to clone the data from first pod to the remaining pods. only one pod is getting the data.
kubernetes
influxdb
kubernetes-statefulset
0 Answers
Your Answer