apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web-sc
spec:
  serviceName: "nginx-sc"
  replicas: 2
  selector:
    matchLabels:
      app: nginx-sc
  template:
    metadata:
      labels:
        app: nginx-sc
    spec:
      containers:
        - name: nginx
          image: nginx
          ports:
            - containerPort: 80
              name: web
          volumeMounts:
            - name: www
              mountPath: /usr/share/nginx/html
        - name: tools
          image: busybox
          args:
            - sleep
            - "86400"
  volumeClaimTemplates:
    - metadata:
        name: www
      spec:
          accessModes:
            - ReadWriteOnce
          storageClassName: rook-ceph-block
          resources:
            requests:
              storage: 150Mi


# for i in 0 1; do kubectl exec web-$i -- sh -c 'echo hello $(hostname) > /usr/share/nginx/html/index.html'; done
# for i in 0 1; do kubectl exec -it web-$i -- curl localhost; done