apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    dyskComponent: kernel-flexvol-installer
  name: dysk-flexvol-installer
  namespace: kube-system
spec:
  template:
    metadata:
      labels:
        dyskComponent: dysk-kubernetes-installer
    spec:
      containers:
        #this image installs the flex vol driver and its deps
        # mount your flex vols directory to this container 
        # and set TARGET_DIR env var. 
        # * for acs-engine 0.12 and later the directory is /etc/kubernetes/volumeplugins
        # * for acs-engine <0.12 you will need to set vol directory follow https://github.com/khenidak/dysk/tree/master/kubernetes for details
        # * if you have used flex before on your cluster, use same directory
        # set TARGET_DIR env var and mount the same directory to to the container
      - name: flexvol-driver-installer
        image: "andyzhangx/dysk-flexvol-installer:0.7"
        env:
        #forces the container not to exit 
        # to solve for this https://github.com/kubernetes/kubernetes/issues/17182
        # until it is fixed
        - name: TARGET_DIR
          value: "/etc/kubernetes/volumeplugins"
        volumeMounts:
        - mountPath: "/etc/kubernetes/volumeplugins"
          name: volplugins
        # this image installs kernel module according to 
        # to the kernel loaded on host. currently it downloads
        # the entire github repo, as we move to beta code will 
        # be part of the image
      - name: kernel-module-installer
        image: "khenidak/dysk-installer:0.6"
        env:
        #forces the container not to exit 
        # to solve for this https://github.com/kubernetes/kubernetes/issues/17182
        # until it is fixed
        - name: INSTALL_MODE
          value: "kubernetes"
        #use this to control which version of dysk module 
        # do you want to install
        - name: DYSK_TAG
          value: f02fbe61750fc050d759366b9647e7ea6c159e16
        resources:
          requests:
            cpu: 100m
        securityContext:
          privileged: true
        volumeMounts:
        - mountPath: "/usr/src"
          name: src
        - mountPath: "/lib/modules"
          name: modules
          readOnly: true
      # Todo: flex vol installer container
      volumes:
      - hostPath:
          path: "/usr/src"
        name: src
      - hostPath:
          path: "/lib/modules"
        name: modules
      - hostPath:
          path: "/etc/kubernetes/volumeplugins" #Modify this directory if your nodes are using a different one
        name: volplugins
      nodeSelector:
        beta.kubernetes.io/os: linux
