apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    description: Serves the frontend of Sourcegraph via HTTP(S).
  labels:
    deploy: sourcegraph
  name: sourcegraph-frontend
spec:
  minReadySeconds: 10
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: sourcegraph-frontend
  strategy:
    rollingUpdate:
      maxSurge: 2
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: sourcegraph-frontend
    spec:
      containers:
      - args:
        - serve
        env:
        # TODO(slimsag): After 3.0 (NOT 3.0-preview), we can remove this. It is
        # left here now so that users upgrading to 3.0 will leave it here so
        # that the DB will be populated with their old site config file
        # (i.e. for migration). This means that for now we have two sources of
        # truth for the 'default' cluster configuration: The config-map in this
        # repository and the confdefaults.Cluster variable in our main repo.
        - name: SOURCEGRAPH_CONFIG_FILE
          value: /etc/sourcegraph/config.json
        - name: PGDATABASE
          value: sg
        - name: PGHOST
          value: pgsql
        - name: PGPORT
          value: "5432"
        - name: PGSSLMODE
          value: disable
        - name: PGUSER
          value: sg
        - name: SRC_GIT_SERVERS
          value: gitserver-0.gitserver:3178
        # POD_NAME is used by CACHE_DIR
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        # CACHE_DIR stores larger items we cache. Majority of it is zip
        # archives of repositories at a commit.
        - name: CACHE_DIR
          value: /mnt/cache/$(POD_NAME)
        image: sourcegraph/frontend:3.0.0-beta.3@sha256:e1ea82a3e0706206a5a9479d957ff0eabedb4832247ec850272be7a50c251013
        livenessProbe:
          httpGet:
            path: /healthz
            port: http
            scheme: HTTP
          initialDelaySeconds: 60
          timeoutSeconds: 5
        readinessProbe:
          httpGet:
            path: /healthz
            port: http
            scheme: HTTP
          periodSeconds: 5
          timeoutSeconds: 5
        name: frontend
        ports:
        - containerPort: 3080
          name: http
        - containerPort: 3090
          name: http-internal
        resources:
          limits:
            cpu: "2"
            memory: 4G
          requests:
            cpu: "2"
            memory: 2G
        volumeMounts:
        - mountPath: /etc/sourcegraph
          name: sg-config
        - mountPath: /mnt/cache
          name: cache-ssd
      securityContext:
        runAsUser: 0
      serviceAccountName: sourcegraph-frontend
      volumes:
      - configMap:
          defaultMode: 464
          name: config-file
        name: sg-config
      - emptyDir: {}
        name: cache-ssd
