Kubernetes stateful apps with bare metal

1/19/2019

I am pretty new on Kubernetes and cloud computing. I am working with bare metal servers on my home (actually virtual servers on vbox) and trying to run a stateful app with StatefulSet. I have 1 master and 2 worker nodes and I am trying to run a database application on this cluster. So each node has 1 pod and I am very confused about volumes. I use hostpath volume(code below) but volumes working separately(actually they are not synchronizing). So my 2 pods are working different(same apps but they run like 2 different servers) when I reach them.

How can I run that app in 2 synchronized pods?

I've tried to synchronized volume files between 2 slaves. I also tried to synchronize volume files with deployment. I've tried to do this with volume provisioning (persistent volume and persistent volume provisioning).

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: cloud
spec:
  selector:
    matchLabels:
      app: cloud
  serviceName: "cloud"
  replicas: 2
  template:
    metadata:
      labels:
        app: cloud
    spec:
      containers:
      - name: cloud
        image: owncloud:v2
        imagePullPolicy: Never
        ports:
        - containerPort: 80
          name: web
        volumeMounts:
        - name: cloud-volume
          mountPath: /var/www/html/
      volumes:
      - name: cloud-volume
        hostPath:
          path: /volumes/cloud/
---
kind: Service
apiVersion: v1
metadata:
  name: cloud
spec:
  selector:
    app: cloud
  type: LoadBalancer
  ports:
  - protocol: TCP
    port: 80
-- Adi Soyadi
docker
kubernetes

0 Answers