groundnuty
7/14/2017 - 6:14 PM

local volumes test

local volumes test

---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: local-test
spec:
  serviceName: "local-service"
  replicas: 1
  template:
    metadata:
      labels:
        app: local-test
    spec:
      containers:
      - name: test-container
        image: gcr.io/google_containers/busybox:1.24
        command:
        - "/bin/sh"
        args:
        - "-c"
        - "count=0; count_file=\"/usr/test-pod/count\"; test_file=\"/usr/test-pod/test_file\"; if [ -e $count_file ]; then count=$(cat $count_file); fi; echo $((count+1)) > $count_file; while [ 1 ]; do date >> $test_file; echo \"This is $MY_POD_NAME, count=$(cat $count_file)\" >> $test_file; sleep 10; done"
        volumeMounts:
        - name: local-vol
          mountPath: /usr/test-pod
        env:
        - name: MY_POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
      securityContext:
        fsGroup: 1234
  volumeClaimTemplates:
  - metadata:
      name: local-vol
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: "local-storage"
      resources:
        requests:
          storage: 1Gi
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: local-test
spec:
  serviceName: "local-service"
  replicas: 1
  template:
    metadata:
      labels:
        app: local-test
    spec:
      containers:
      - name: test-container
        image: gcr.io/google_containers/busybox:1.24
        command:
        - "/bin/sh"
        args:
        - "-c"
        - "count=0; count_file=\"/usr/test-pod/count\"; test_file=\"/usr/test-pod/test_file\"; if [ -e $count_file ]; then count=$(cat $count_file); fi; echo $((count+1)) > $count_file; while [ 1 ]; do date >> $test_file; echo \"This is $MY_POD_NAME, count=$(cat $count_file)\" >> $test_file; sleep 10; done"
        volumeMounts:
        - name: local-vol
          mountPath: /usr/test-pod
        env:
        - name: MY_POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
      securityContext:
        fsGroup: 1234
  volumeClaimTemplates:
  - metadata:
      name: local-vol
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: "local-storage"
      resources:
        requests:
          storage: 1Gi
 orzech@orzechpro  ~  0 
 orzech@orzechpro  ~  0  cat /tmp/pr
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: local-volume-provisioner
spec:
  template:
    metadata:
      labels:
        app: local-volume-provisioner
    spec:
      containers:
      - name: provisioner
        image: "quay.io/external_storage/local-volume-provisioner:latest"
        imagePullPolicy: Always
        securityContext:
          privileged: true
        volumeMounts:
        - name: discovery-vol
          mountPath: "/local-disks"
        env:
        - name: MY_NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
      volumes:
      - name: discovery-vol
        hostPath:
          path: "/mnt/disks/"
      serviceAccount: local-storage-admin