apiVersion: apps/v1
kind: Deployment
metadata:
  name: rybbit-clickhouse
  labels:
    app.kubernetes.io/controller: clickhouse
    app.kubernetes.io/instance: rybbit
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: rybbit
    helm.sh/chart: rybbit-5.0.1
  namespace: rybbit
spec:
  revisionHistoryLimit: 3
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/controller: clickhouse
      app.kubernetes.io/name: rybbit
      app.kubernetes.io/instance: rybbit
  template:
    metadata:
      annotations:
        checksum/configMaps: ba4b6ef840b78e95c76ebd6d10e0cc8536bd139037769a25c40c76f1eceb029d
      labels:
        app.kubernetes.io/controller: clickhouse
        app.kubernetes.io/instance: rybbit
        app.kubernetes.io/name: rybbit
    spec:
      enableServiceLinks: false
      serviceAccountName: rybbit
      automountServiceAccountToken: false
      hostIPC: false
      hostNetwork: false
      hostPID: false
      dnsPolicy: ClusterFirst
      containers:
        - env:
            - name: CLICKHOUSE_DB
              value: analytics
            - name: CLICKHOUSE_USER
              valueFrom:
                secretKeyRef:
                  key: clickhouse-user
                  name: rybbit-clickhouse-config
            - name: CLICKHOUSE_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: clickhouse-password
                  name: rybbit-clickhouse-config
          image: clickhouse/clickhouse-server:26.5.1@sha256:07afc18d8a9706eb9d85c5c5d2752e5270f91bbc2894caeaecb73e4d0f603bf5
          livenessProbe:
            failureThreshold: 5
            httpGet:
              path: /ping
              port: 8123
            initialDelaySeconds: 10
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 5
          name: main
          resources:
            requests:
              cpu: 40m
              memory: 300Mi
          volumeMounts:
            - mountPath: /var/lib/clickhouse
              name: clickhouse
            - mountPath: /etc/clickhouse-server/config.d/network.xml
              mountPropagation: None
              name: clickhouse-config
              readOnly: true
              subPath: network.xml
            - mountPath: /etc/clickhouse-server/config.d/enable_json.xml
              mountPropagation: None
              name: clickhouse-config
              readOnly: true
              subPath: enable_json.xml
            - mountPath: /etc/clickhouse-server/config.d/logging_rules.xml
              mountPropagation: None
              name: clickhouse-config
              readOnly: true
              subPath: logging_rules.xml
            - mountPath: /etc/clickhouse-server/config.d/user_logging.xml
              mountPropagation: None
              name: clickhouse-config
              readOnly: true
              subPath: user_logging.xml
            - mountPath: /etc/clickhouse-server/config.d/metrics.xml
              mountPropagation: None
              name: clickhouse-config
              readOnly: true
              subPath: metrics.xml
      volumes:
        - name: clickhouse
          persistentVolumeClaim:
            claimName: clickhouse-data
        - configMap:
            name: clickhouse-config
          name: clickhouse-config
