apiVersion: v1
kind: Secret
metadata:
  name: ssh-key
type: Opaque
data:
  private: {{ .Values.sshPrivateKey }}
---
apiVersion: v1
kind: Service
metadata:
  name: port-allocator
  namespace: {{ .Release.Namespace }}
spec:
  type: ClusterIP
  selector:
    app: port-allocator
  ports:
  - name: http
    port: 80
    targetPort: http
    protocol: TCP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: port-allocator
  namespace: {{ .Release.Namespace }}
spec:
  selector:
    matchLabels:
      app: port-allocator
  replicas: 1
  template:
    metadata:
      labels:
        app: port-allocator
    spec:
      volumes:
      - name: ssh-key
        secret:
          secretName: ssh-key
      containers:
      - name: port-allocator
        image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        ports:
        - name: http
          containerPort: 8080
          protocol: TCP
        command:
        - server
        - --port=8080
        - --repo-addr={{ .Values.repoAddr }}
        - --ssh-key=/pcloud/ssh-key/private
        - --ingress-nginx-path={{ .Values.ingressNginxPath }}
        volumeMounts:
        - name: ssh-key
          readOnly: true
          mountPath: /pcloud/ssh-key
