# Copyright 2019 Nutanix Inc
# 
# example usage: kubectl create -f <this_file>

---
kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: csi-provisioner-ntnx-plugin
  namespace: kube-system
spec:
  serviceName: csi-provisioner-ntnx-plugin
  replicas: 1
  selector:
    matchLabels:
      app: csi-provisioner-ntnx-plugin
  template:
    metadata:
      labels:
        app: csi-provisioner-ntnx-plugin
    spec:
      serviceAccount: csi-provisioner
      containers:
      - name: csi-provisioner
        image: quay.io/k8scsi/csi-provisioner:v1.5.0
        args:
        - --csi-address=$(ADDRESS)
        - --timeout=60s
        - --v=5
        env:
        - name: ADDRESS
          value: /var/lib/csi/sockets/pluginproxy/csi.sock
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - name: socket-dir
          mountPath: /var/lib/csi/sockets/pluginproxy/
      - name: csi-resizer
        image: quay.io/k8scsi/csi-resizer:v0.3.0
        args:
        - --v=5
        - --csi-address=$(ADDRESS)
        - --leader-election=false
        env:
        - name: ADDRESS
          value: /var/lib/csi/sockets/pluginproxy/csi.sock
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - name: socket-dir
          mountPath: /var/lib/csi/sockets/pluginproxy/
      - name: csi-snapshotter
        image: quay.io/k8scsi/csi-snapshotter:v2.1.0
        args:
        - --csi-address=$(ADDRESS)
        - --leader-election=false
        - --logtostderr=true
        env:
        - name: ADDRESS
          value: /csi/csi.sock
        volumeMounts:
        - name: socket-dir
          mountPath: /csi
      - name: ntnx-csi-plugin
        image: ntnx/ntnx-csi:v2.2.0
        securityContext:
          allowPrivilegeEscalation: true
          privileged: true
        args:
        - --drivername=csi.nutanix.com
        - --endpoint=$(CSI_ENDPOINT)
        - --nodeid=$(NODE_ID)
        env:
        - name: CSI_ENDPOINT
          value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
        - name: NODE_ID
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        volumeMounts:
        - mountPath: /var/lib/csi/sockets/pluginproxy/
          name: socket-dir
        ports:
        - containerPort: 9808
          name: healthz
          protocol: TCP
        livenessProbe:
          httpGet:
            path: /healthz
            port: healthz
          initialDelaySeconds: 10
          timeoutSeconds: 3
          periodSeconds: 2
          failureThreshold: 3
      - name: liveness-probe
        volumeMounts:
          - mountPath: /csi
            name: socket-dir
        image: quay.io/k8scsi/livenessprobe:v1.1.0
        args:
        - --csi-address=/csi/csi.sock
      volumes:
      - emptyDir: {}
        name: socket-dir
