apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: connect-server
  labels:
    app.kubernetes.io/component: connect-server
spec:
  replicas: 2
  selector:
    matchLabels:
      app.kubernetes.io/component: connect-server
  serviceName: connect-server
  template:
    metadata:
      labels:
        app.kubernetes.io/component: connect-server
    spec:
      imagePullSecrets:
        - name: "cr.seqera.io"
      nodeSelector:
        kubernetes.io/arch: amd64
      containers:
        - name: server
          image: cr.seqera.io/enterprise/studios/server:0.11.0
          ports:
            - containerPort: 7070
              name: server
            - containerPort: 7777
              name: entrypoint
          env:
            - name: CONNECT_HOST_DOMAIN
              value: connect-server
            - name: CONNECT_TUNNEL_PORT
              value: "7070"
            - name: CONNECT_LISTENER_PORT
              value: "7777"
            - name: CONNECT_REDIS_ADDRESS
              value: <REDIS_ADDRESS>
            - name: CONNECT_REDIS_PREFIX
              value: connect:session
            - name: CONNECT_REDIS_TLS_ENABLE
              value: "false"
            - name: CONNECT_REDIS_DB
              value: "1"
            - name: CONNECT_LOG_LEVEL
              value: info  # one of: trace, debug, info, warn, error, fatal
          securityContext:
            capabilities:
              add:
                - NET_BIND_SERVICE
              drop:
                - ALL
            runAsNonRoot: true
            runAsUser: 65532
            runAsGroup: 65532
      securityContext:
        fsGroup: 65532
---
apiVersion: v1
kind: Service
metadata:
  name: connect-server
  labels:
    app.kubernetes.io/component: connect-server
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - port: 8080
      targetPort: server
      name: server
    - port: 7777
      targetPort: entrypoint
      name: entrypoint
  selector:
    app.kubernetes.io/component: connect-server
