apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template "cassandra-operator.fullname" . }}
  labels:
    app: {{ template "cassandra-operator.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    heritage: {{ .Release.Service }}
    operator: cassandra
    release: {{ .Release.Name }}
spec:
  replicas: 1
  selector:
    matchLabels:
      name: {{ template "cassandra-operator.name" . }}
  template:
    metadata:
      labels:
        name: {{ template "cassandra-operator.name" . }}
        app: {{ template "cassandra-operator.name" . }}
        operator: cassandra
        release: {{ .Release.Name }}
    spec:
{{- if .Values.image.imagePullSecrets.enabled }}
      imagePullSecrets:
        - name: {{ .Values.image.imagePullSecrets.name }}
{{- end }}
{{- if .Values.rbacEnable }}
      serviceAccountName: {{ template "cassandra-operator.name" . }}
{{- end }}
      securityContext:
        runAsUser: 1000
      containers:
      - name: {{ template "cassandra-operator.name" . }}
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: "{{ .Values.image.pullPolicy }}"
        ports:
        - containerPort: 60000
          name: metrics
        command:
        - cassandra-k8s-operator
        readinessProbe:
          exec:
            command:
              - /health
          initialDelaySeconds: 4
          periodSeconds: 10
          failureThreshold: 1
        resources:
{{ toYaml .Values.resources | indent 10 }}
        env:
          - name: WATCH_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: OPERATOR_NAME
            value: "cassandra-operator"
{{- if .Values.debug }}
          - name: LOG_LEVEL
            value: Debug
{{- end }}
