apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: questdb-pvc
  namespace: foxhunt
  labels:
    app.kubernetes.io/name: questdb
    app.kubernetes.io/part-of: foxhunt
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: questdb
  namespace: foxhunt
  labels:
    app.kubernetes.io/name: questdb
    app.kubernetes.io/part-of: foxhunt
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: questdb
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: questdb
        app.kubernetes.io/part-of: foxhunt
    spec:
      nodeSelector:
        k8s.scaleway.com/pool-name: platform
      containers:
        - name: questdb
          image: questdb/questdb:8.2.3
          ports:
            - containerPort: 9009
              name: ilp
            - containerPort: 8812
              name: pg
            - containerPort: 9003
              name: metrics
          env:
            - name: QDB_PG_ENABLED
              value: "true"
            - name: QDB_METRICS_ENABLED
              value: "TRUE"
          volumeMounts:
            - name: questdb-data
              mountPath: /var/lib/questdb
          readinessProbe:
            httpGet:
              path: /exec?query=SELECT%201
              port: 9003
            initialDelaySeconds: 10
            periodSeconds: 10
          resources:
            requests:
              cpu: 200m
              memory: 512Mi
            limits:
              cpu: 500m
              memory: 1Gi
      volumes:
        - name: questdb-data
          persistentVolumeClaim:
            claimName: questdb-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: questdb
  namespace: foxhunt
  labels:
    app.kubernetes.io/name: questdb
    app.kubernetes.io/part-of: foxhunt
spec:
  selector:
    app.kubernetes.io/name: questdb
  ports:
    - port: 9009
      targetPort: 9009
      name: ilp
    - port: 8812
      targetPort: 8812
      name: pg
    - port: 9003
      targetPort: 9003
      name: metrics
