apiVersion: apps/v1
kind: Deployment
metadata:
  name: nebula-controller
  namespace: {{ .Release.Namespace }}
spec:
  selector:
    matchLabels:
      app: nebula-controller
  replicas: 1
  template:
    metadata:
      labels:
        app: nebula-controller
    spec:
      containers:
      - name: controller
        image: {{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag }}
        imagePullPolicy: {{ .Values.controller.image.pullPolicy }}
        command:
        - nebula-controller
      tolerations:
      - key: "pcloud"
        operator: "Equal"
        value: "role"
        effect: "NoSchedule"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ .Release.Namespace }}-nebula-controller
  namespace: {{ .Release.Namespace }}
rules:
- apiGroups:
  - "lekva.me"
  resources:
  - nebulacas
  - nebulacas/status
  - nebulanodes
  - nebulanodes/status
  verbs:
  - list
  - get
  - create
  - update
  - watch
- apiGroups:
  - ""
  resources:
  - secrets
  verbs:
  - list
  - get
  - create
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ .Release.Namespace }}-nebula-controller
  namespace: {{ .Release.Namespace }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ .Release.Namespace }}-nebula-controller
subjects:
- kind: ServiceAccount
  name: default
  namespace: {{ .Release.Namespace }}
