---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: kadalustorages.kadalu-operator.storage
spec:
  group: kadalu-operator.storage
  names:
    kind: KadaluStorage
    listKind: KadaluStorageList
    plural: kadalustorages
    singular: kadalustorage
    shortNames:
      - kadalu
      - kds
  scope: Namespaced
  versions:
    - name: v1alpha1
      storage: true
      served: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              x-kubernetes-preserve-unknown-fields: true
              type: object
              properties:
                disperse:
                  type: object
                  properties:
                    data:
                      type: integer
                    redundancy:
                      type: integer
                type:
                  type: string
                pvReclaimPolicy:
                  type: string
                  default: delete
                volume_id:
                  type: string
                kadalu_format:
                  type: string
                single_pv_per_pool:
                  type: boolean
                  default: false
                # Refer https://github.com/kubernetes-client/python/blob/da6076/kubernetes/docs/V1Toleration.md
                tolerations:
                  type: array
                  items:
                    type: object
                    properties:
                      effect:
                        type: string
                      key:
                        type: string
                      operator:
                        type: string
                      tolerationSeconds:
                        format: int64
                        type: integer
                      value:
                        type: string
                options:
                  type: array
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                      value:
                        type: string
                storage:
                  type: array
                  items:
                    type: object
                    properties:
                      node:
                        type: string
                      device:
                        type: string
                      path:
                        type: string
                      pvc:
                        type: string
                      decommissioned:
                        type: string
                tiebreaker:
                  type: object
                  properties:
                    deployment:
                      type: string
                    node:
                      type: string
                    path:
                      type: string
                    port:
                      type: integer
                details:
                  type: object
                  properties:
                    gluster_host:
                      type: string
                    gluster_hosts:
                      type: array
                      items:
                        type: string
                    gluster_volname:
                      type: string
                    gluster_options:
                      type: string

---
# Source: kadalu/charts/operator/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: kadalu-operator
  namespace: kadalu
---
# Source: kadalu/charts/operator/templates/serviceaccount.yaml
kind: ServiceAccount
apiVersion: v1
metadata:
  name: kadalu-csi-nodeplugin
  namespace: kadalu
---
# Source: kadalu/charts/operator/templates/serviceaccount.yaml
kind: ServiceAccount
apiVersion: v1
metadata:
  name: kadalu-csi-provisioner
  namespace: kadalu
---
# Source: kadalu/charts/operator/templates/serviceaccount.yaml
kind: ServiceAccount
apiVersion: v1
metadata:
  name: kadalu-server-sa
  namespace: kadalu
---
# Source: kadalu/charts/operator/templates/rbac.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: kadalu-operator
rules:
  - apiGroups:
      - storage.k8s.io
      - csi.storage.k8s.io
    resources:
      - csidrivers
      - storageclasses
    verbs:
      - create
      - delete
      - get
      - list
      - update
  - apiGroups:
      - kadalu-operator.storage
    resources:
      - kadalustorages
    verbs:
      - watch
  - apiGroups:
      - ""
    resources:
      - persistentvolumes
    verbs:
      - get
      - list
---
# Source: kadalu/charts/operator/templates/rbac.yaml
# CSI External Attacher
# https://github.com/kubernetes-csi/external-attacher/blob/master/deploy/kubernetes/rbac.yaml
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: kadalu-csi-external-attacher
rules:
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "patch"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["csinodes"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["volumeattachments"]
    verbs: ["get", "list", "watch", "patch"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["volumeattachments/status"]
    verbs: ["patch"]
---
# Source: kadalu/charts/operator/templates/rbac.yaml
# CSI External Provisioner
# https://github.com/kubernetes-csi/external-provisioner/blob/master/deploy/kubernetes/rbac.yaml
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: kadalu-csi-external-provisioner
rules:
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "create", "delete"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["storageclasses"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["list", "watch", "create", "update", "patch"]
  - apiGroups: ["snapshot.storage.k8s.io"]
    resources: ["volumesnapshots"]
    verbs: ["get", "list"]
  - apiGroups: ["snapshot.storage.k8s.io"]
    resources: ["volumesnapshotcontents"]
    verbs: ["get", "list"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["csinodes"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["get", "list", "watch"]
  # PUBLISH_UNPUBLISH_VOLUME capability
  - apiGroups: ["storage.k8s.io"]
    resources: ["volumeattachments"]
    verbs: ["get", "list", "watch"]
---
# Source: kadalu/charts/operator/templates/rbac.yaml
# CSI External Resizer
# https://github.com/kubernetes-csi/external-resizer/blob/master/deploy/kubernetes/rbac.yaml
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: kadalu-csi-external-resizer
rules:
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "patch"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["pods"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims/status"]
    verbs: ["patch"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["list", "watch", "create", "update", "patch"]
---
# Source: kadalu/charts/operator/templates/rbac.yaml
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: kadalu-operator
subjects:
  - kind: ServiceAccount
    name: kadalu-operator
    namespace: kadalu
roleRef:
  kind: ClusterRole
  name: kadalu-operator
  apiGroup: rbac.authorization.k8s.io
---
# Source: kadalu/charts/operator/templates/rbac.yaml
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: kadalu-csi-external-attacher
subjects:
  - kind: ServiceAccount
    name: kadalu-csi-provisioner
    namespace: kadalu
roleRef:
  kind: ClusterRole
  name: kadalu-csi-external-attacher
  apiGroup: rbac.authorization.k8s.io
---
# Source: kadalu/charts/operator/templates/rbac.yaml
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: kadalu-csi-external-provisioner
subjects:
  - kind: ServiceAccount
    name: kadalu-csi-provisioner
    namespace: kadalu
roleRef:
  kind: ClusterRole
  name: kadalu-csi-external-provisioner
  apiGroup: rbac.authorization.k8s.io
---
# Source: kadalu/charts/operator/templates/rbac.yaml
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: kadalu-csi-external-resizer
subjects:
  - kind: ServiceAccount
    name: kadalu-csi-provisioner
    namespace: kadalu
roleRef:
  kind: ClusterRole
  name: kadalu-csi-external-resizer
  apiGroup: rbac.authorization.k8s.io
---
# Source: kadalu/charts/operator/templates/rbac.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: kadalu-operator
  namespace: kadalu
rules:
  - apiGroups: [""]
    resources:
      - configmaps
      - persistentvolumes
      - pods
      - pods/exec
      - services
    verbs:
      - create
      - delete
      - get
      - list
      - patch
  - apiGroups:
      - ""
      - apiextensions.k8s.io
    resources:
      - customresourcedefinitions
    verbs:
      - create
      - update
  - apiGroups:
      - apps
    resources:
      - daemonsets
      - statefulsets
    verbs:
      - create
      - delete
      - get
      - patch
---
# Source: kadalu/charts/operator/templates/rbac.yaml
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: kadalu-operator
  namespace: kadalu
subjects:
  - kind: ServiceAccount
    name: kadalu-operator
    namespace: kadalu
roleRef:
  kind: Role
  name: kadalu-operator
  apiGroup: rbac.authorization.k8s.io
---
# Source: kadalu/charts/operator/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: operator
  namespace: kadalu
  labels:
    app.kubernetes.io/part-of: kadalu
    app.kubernetes.io/name: kadalu-operator
    app.kubernetes.io/component: operator
spec:
  replicas: 1
  selector:
    matchLabels:
      name: kadalu
  template:
    metadata:
      labels:
        name: kadalu
        app.kubernetes.io/part-of: kadalu
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "8050"
    spec:
      serviceAccountName: kadalu-operator
      containers:
        - name: kadalu-operator
          securityContext:
            capabilities: {}
            privileged: true
          image: registry.mopaas.com/ai/kadalu-operator:1.2.0
          imagePullPolicy: IfNotPresent
          env:
            - name: WATCH_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: OPERATOR_NAME
              value: "kadalu-operator"
            - name: IMAGES_HUB
              value: "registry.mopaas.com"
            - name: DOCKER_USER
              value: "ai"
            - name: KADALU_VERSION
              value: "1.2.0"
            - name: KADALU_NAMESPACE
              value: "kadalu"
            - name: KUBELET_DIR
              value: "/var/lib/kubelet"
            - name: K8S_DIST
              value: "kubernetes"
            - name: VERBOSE
              value: "no"
