apiVersion: v1
kind: Service
metadata:
  name: launcher
  namespace: {{ .Release.Namespace }}
spec:
  type: ClusterIP
  selector:
    app: launcher
  ports:
    - name: http
      protocol: TCP
      port: {{ .Values.port }}
      targetPort: http
---
apiVersion: v1
kind: Secret
metadata:
  name: ssh-key
type: Opaque
data:
  private: {{ .Values.sshPrivateKey }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: launcher
  namespace: {{ .Release.Namespace }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: launcher
  template:
    metadata:
      labels:
        app: launcher
    spec:
      volumes:
      - name: ssh-key
        secret:
          secretName: ssh-key
      containers:
      - name: launcher
        image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
        ports:
        - name: http
          containerPort: {{ .Values.port }}
          protocol: TCP
        command:
        - pcloud-installer
        - launcher
        - --port={{ .Values.port }}
        - --logout-url={{ .Values.logoutUrl }}
        - --ssh-key=/pcloud/ssh-key/private
        - --repo-addr={{ .Values.repoAddr }}
        volumeMounts:
        - name: ssh-key
          readOnly: true
          mountPath: /pcloud/ssh-key
