apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    app.kubernetes.io/component: csi-driver
    app.kubernetes.io/name: bonree-operator
    app.kubernetes.io/version: 1.1.0
  name: bonree-smartagent-csi-driver
  namespace: bonree-agent
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  labels:
    app.kubernetes.io/component: csi-driver
    app.kubernetes.io/name: bonree-operator
    app.kubernetes.io/version: 1.1.0
  name: bonree-smartagent-csi-driver
  namespace: bonree-agent
rules:
- apiGroups:
  - ""
  resources:
  - endpoints
  verbs:
  - get
  - watch
  - list
  - delete
  - update
  - create
- apiGroups:
  - coordination.k8s.io
  resources:
  - leases
  verbs:
  - get
  - watch
  - list
  - delete
  - update
  - create
- apiGroups:
  - bonree.com
  resources:
  - smartkubes
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - ""
  resources:
  - secrets
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    app.kubernetes.io/component: csi-driver
    app.kubernetes.io/name: bonree-operator
    app.kubernetes.io/version: 1.1.0
  name: bonree-smartagent-csi-driver
rules:
- apiGroups:
  - ""
  resources:
  - namespaces
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - ""
  resources:
  - events
  verbs:
  - list
  - watch
  - create
  - update
  - patch
- apiGroups:
  - storage.k8s.io
  resources:
  - csinodes
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - ""
  resources:
  - nodes
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  labels:
    app.kubernetes.io/component: csi-driver
    app.kubernetes.io/name: bonree-operator
    app.kubernetes.io/version: 1.1.0
  name: bonree-smartagent-csi-driver
  namespace: bonree-agent
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: bonree-smartagent-csi-driver
subjects:
- kind: ServiceAccount
  name: bonree-smartagent-csi-driver
  namespace: bonree-agent
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    app.kubernetes.io/component: csi-driver
    app.kubernetes.io/name: bonree-operator
    app.kubernetes.io/version: 1.1.0
  name: bonree-smartagent-csi-driver
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: bonree-smartagent-csi-driver
subjects:
- kind: ServiceAccount
  name: bonree-smartagent-csi-driver
  namespace: bonree-agent
---
apiVersion: scheduling.k8s.io/v1
description: This priority class is used for Bonree Components in order to make sure
  they are not evicted in favor of other pods
globalDefault: false
kind: PriorityClass
metadata:
  name: bonree-high-priority
value: 1000000
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app.kubernetes.io/component: csi-driver
    app.kubernetes.io/name: bonree-operator
    app.kubernetes.io/version: 1.1.0
  name: bonree-smartagent-csi-driver
  namespace: bonree-agent
spec:
  selector:
    matchLabels:
      internal.smartagent.bonree.com/app: csi-driver
      internal.smartagent.bonree.com/component: csi-driver
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-logs-container: driver
      labels:
        app.kubernetes.io/component: csi-driver
        app.kubernetes.io/name: bonree-operator
        app.kubernetes.io/version: 1.1.0
        internal.smartagent.bonree.com/app: csi-driver
        internal.smartagent.bonree.com/component: csi-driver
    spec:
      containers:
      - args:
        - --endpoint=unix://csi/csi.sock
        - --node-id=$(KUBE_NODE_NAME)
        - --health-probe-bind-address=:10080
        command:
        - csi-driver
        env:
        - name: GC_INTERVAL_MINUTES
          value: "60"
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
        - name: KUBE_NODE_NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: spec.nodeName
        image: docker.bonree.com/agent/smartagent-operator:1.1.1
        imagePullPolicy: Always
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /livez
            port: livez
            scheme: HTTP
          initialDelaySeconds: 5
          periodSeconds: 5
          successThreshold: 1
          timeoutSeconds: 1
        name: bonree-driver
        ports:
        - containerPort: 10080
          name: livez
          protocol: TCP
        resources:
          limits:
            cpu: 300m
            memory: 100Mi
          requests:
            cpu: 300m
            memory: 100Mi
        securityContext:
          allowPrivilegeEscalation: true
          privileged: true
          readOnlyRootFilesystem: false
          runAsNonRoot: false
          runAsUser: 0
          seLinuxOptions:
            level: s0
          seccompProfile:
            type: RuntimeDefault
        volumeMounts:
        - mountPath: /csi
          name: plugin-dir
        - mountPath: /var/lib/kubelet/plugins
          mountPropagation: Bidirectional
          name: plugins-dir
        - mountPath: /var/lib/kubelet/pods
          mountPropagation: Bidirectional
          name: mountpoint-dir
        - mountPath: /data
          mountPropagation: Bidirectional
          name: bonree-smartagent-data-dir
      - args:
        - --csi-address=/csi/csi.sock
        - --kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)
        command:
        - csi-node-driver-registrar
        env:
        - name: DRIVER_REG_SOCK_PATH
          value: /var/lib/kubelet/plugins/csi.smartagent.bonree.com/csi.sock
        image: docker.bonree.com/agent/smartagent-operator:1.1.1
        imagePullPolicy: Always
        livenessProbe:
          exec:
            command:
            - csi-node-driver-registrar
            - --kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)
            - --mode=kubelet-registration-probe
          failureThreshold: 3
          initialDelaySeconds: 30
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 15
        name: bonree-registrar
        resources:
          limits:
            cpu: 100m
            memory: 100Mi
          requests:
            cpu: 10m
            memory: 20Mi
        securityContext:
          runAsUser: 0
        volumeMounts:
        - mountPath: /csi
          name: plugin-dir
        - mountPath: /registration
          name: registration-dir
      - args:
        - --csi-address=/csi/csi.sock
        - --health-port=9898
        command:
        - livenessprobe
        image: docker.bonree.com/agent/smartagent-operator:1.1.1
        imagePullPolicy: Always
        name: bonree-liveness-probe
        volumeMounts:
        - mountPath: /csi
          name: plugin-dir
      dnsPolicy: ClusterFirst
      priorityClassName: bonree-high-priority
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccountName: bonree-smartagent-csi-driver
      terminationGracePeriodSeconds: 30
      tolerations:
      - effect: NoSchedule
        key: node-role.kubernetes.io/master
        operator: Exists
      - effect: NoSchedule
        key: node-role.kubernetes.io/control-plane
        operator: Exists
      - effect: NoSchedule
        key: kubernetes.io/arch
        value: arm64
      - effect: NoSchedule
        key: kubernetes.io/arch
        value: amd64
      - effect: NoSchedule
        key: ToBeDeletedByClusterAutoscaler
        operator: Exists
      volumes:
      - hostPath:
          path: /var/lib/kubelet/plugins_registry/
          type: Directory
        name: registration-dir
      - hostPath:
          path: /var/lib/kubelet/plugins/csi.smartagent.bonree.com
          type: DirectoryOrCreate
        name: plugin-dir
      - hostPath:
          path: /var/lib/kubelet/plugins
          type: Directory
        name: plugins-dir
      - hostPath:
          path: /var/lib/kubelet/pods
          type: DirectoryOrCreate
        name: mountpoint-dir
      - hostPath:
          path: /var/lib/kubelet/plugins/csi.smartagent.bonree.com/data
          type: DirectoryOrCreate
        name: bonree-smartagent-data-dir
  updateStrategy:
    rollingUpdate:
      maxUnavailable: 1
    type: RollingUpdate
---
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
  labels:
    app.kubernetes.io/component: csi-driver
    app.kubernetes.io/name: bonree-operator
    app.kubernetes.io/version: 1.1.0
  name: csi.smartagent.bonree.com
spec:
  attachRequired: false
  podInfoOnMount: true
  volumeLifecycleModes:
  - Ephemeral
