---
kind: Namespace
apiVersion: v1
metadata:
  name: kadalu
---
# Source: kadalu/charts/csi-nodeplugin/templates/clusterrole.yaml
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: kadalu-csi-nodeplugin
rules:
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["get", "list", "watch", "create", "update", "patch"]
---
# Source: kadalu/charts/csi-nodeplugin/templates/clusterrolebinding.yaml
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: kadalu-csi-nodeplugin
  namespace: kadalu
subjects:
  - kind: ServiceAccount
    name: kadalu-csi-nodeplugin
    namespace: kadalu
roleRef:
  kind: ClusterRole
  name: kadalu-csi-nodeplugin
  apiGroup: rbac.authorization.k8s.io
---
# Source: kadalu/charts/csi-nodeplugin/templates/daemonset.yaml
kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: kadalu-csi-nodeplugin
  namespace: kadalu
  labels:
    app.kubernetes.io/part-of: kadalu
    app.kubernetes.io/name: kadalu-csi-nodeplugin
    app.kubernetes.io/component: csi-driver
spec:
  selector:
    matchLabels:
      app.kubernetes.io/part-of: kadalu
      app.kubernetes.io/name: kadalu-csi-nodeplugin
      app.kubernetes.io/component: csi-driver
  template:
    metadata:
      labels:
        app.kubernetes.io/part-of: kadalu
        app.kubernetes.io/name: kadalu-csi-nodeplugin
        app.kubernetes.io/component: csi-driver
      namespace: kadalu
    spec:
      serviceAccountName: kadalu-csi-nodeplugin
      containers:
        - name: csi-node-driver-registrar
          image: registry.mopaas.com/ai-deployer/csi-node-driver-registrar:2.0.1
          args:
            - "--v=5"
            - "--csi-address=$(ADDRESS)"
            - "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "rm -rf /registration/kadalu /registration/kadalu-reg.sock"]
          env:
            - name: ADDRESS
              value: /plugin/csi.sock
            - name: DRIVER_REG_SOCK_PATH
              value: /var/lib/kubelet/plugins/kadalu/csi.sock
            - name: KUBE_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          volumeMounts:
            - name: plugin-dir
              mountPath: /plugin
            - name: registration-dir
              mountPath: /registration
        - name: kadalu-nodeplugin
          securityContext:
            privileged: true
            capabilities:
              add: ["SYS_ADMIN"]
            allowPrivilegeEscalation: true
          image: registry.mopaas.com/ai-deployer/kadalu-csi:1.2.0
          env:
            - name: NODE_ID
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: CSI_ENDPOINT
              value: unix://plugin/csi.sock
            - name: KADALU_VERSION
              value: "1.2.0"
            - name: K8S_DIST
              value: "kubernetes"
            - name: VERBOSE
              value: "no"
            - name: CSI_ROLE
              value: "nodeplugin"
          volumeMounts:
            - name: plugin-dir
              mountPath: /plugin
            - name: pods-mount-dir
              mountPath: /var/lib/kubelet/pods
              mountPropagation: "Bidirectional"
            - name: glusterfsd-volfilesdir
              mountPath: "/var/lib/gluster"
            - name: gluster-dev
              mountPath: "/dev"
            - name: varlog
              mountPath: /var/log/gluster
            - name: csi-dir
              mountPath: /var/lib/kubelet/plugins/kubernetes.io/csi
              mountPropagation: "Bidirectional"
        - name: kadalu-logging
          image: registry.mopaas.com/ai-deployer/busybox
          imagePullPolicy: IfNotPresent
          command: ["/bin/sh"]
          args: ["-c", "while true; do logcnt=$(/bin/ls /var/log/gluster/ | wc -l); if [ ${logcnt} -gt 0 ]; then break; fi; sleep 5; done; tail -F /var/log/gluster/*.log"]
          volumeMounts:
            - name: varlog
              mountPath: "/var/log/gluster"
      volumes:
        - name: plugin-dir
          hostPath:
            path: /var/lib/kubelet/plugins/kadalu
            type: DirectoryOrCreate
        - name: pods-mount-dir
          hostPath:
            path: /var/lib/kubelet/pods
            type: Directory
        - name: registration-dir
          hostPath:
            path: /var/lib/kubelet/plugins_registry/
            type: Directory
        - name: glusterfsd-volfilesdir
          configMap:
            name: "kadalu-info"
        - name: gluster-dev
          hostPath:
            path: "/dev"
        - name: varlog
          emptyDir: {}
        - name: csi-dir
          hostPath:
            path: /var/lib/kubelet/plugins/kubernetes.io/csi/
            type: DirectoryOrCreate
