apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nixcr
spec:
  selector:
    matchLabels:
      app: nixcr
  serviceName: "nixcr"
  replicas: 1
  template:
    metadata:
      labels:
        app: nixcr
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: nixcr
        image: eu.gcr.io/mm-boogle/nixcr:c3ee455
        imagePullPolicy: "Always"
        securityContext:
          privileged: true
        command: ["/bin/nixcr"]
        args: [
          "--blob-root", "/nixcr-cache/blob-root",
          "--repo-root", "/nixcr-cache/repo-root",
          "--repo", "nixpkgs,https://github.com/NixOS/nixpkgs",
          "--repo", "lsexx,git@github.com:teh/lsexx.git,/secrets/deploy-key/deploy"
        ]
        env:
        - name: RUST_BACKTRACE
          value: "1"
        - name: RUST_LOG
          value: "info,actix_web=info"
        resources:
          requests:
            memory: "2Gi"
            cpu: 1
          limits:
            memory: "2Gi"
        ports:
        - containerPort: 8888
          name: web
        volumeMounts:
        - mountPath: /nixcr-cache/
          name: nixcr-cache
        - mountPath: /secrets/deploy-key
          name: deploy-key
          readOnly: true
      volumes:
      - name: deploy-key
        secret:
          secretName: deploy-key
          defaultMode: 384
      nodeSelector:
        cloud.google.com/gke-nodepool: "infra-pool"

  volumeClaimTemplates:
  - metadata:
      name: nixcr-cache
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 30Gi
