AppManager: Add API endpoint to install dodo app

Refactors cue definitions.

Next steps:
* Needs some cleanup, namespace is hard coded ...
* Maybe merge with regular install API
* Support exposing ports across clusters

Change-Id: Ibfc3c3f742b61f2c5874012fe6c77b958eae81d9
diff --git a/charts/app-runner/templates/install.yaml b/charts/app-runner/templates/install.yaml
index 5ba1aac..8cdd1a9 100644
--- a/charts/app-runner/templates/install.yaml
+++ b/charts/app-runner/templates/install.yaml
@@ -1,17 +1,19 @@
 {{ $runCfg := .Values.runCfg | b64dec }}
 ---
+{{- if .Values.sshPrivateKey }}
 apiVersion: v1
 kind: Secret
 metadata:
-  name: app-ssh-key
+  name: {{ .Values.name }}-ssh-key
 type: Opaque
 data:
   private: {{ .Values.sshPrivateKey }}
+{{- end }}
 ---
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  name: app-run-cfg
+  name: {{ .Values.name }}-run-cfg
 data:
   run: |
 {{ indent 4 $runCfg }}
@@ -20,12 +22,12 @@
 apiVersion: v1
 kind: Service
 metadata:
-  name: app-app
+  name: {{ .Values.name }}-app
   namespace: {{ .Release.Namespace }}
 spec:
   type: ClusterIP
   selector:
-    app: app-app
+    app: {{ .Values.name }}-app
   ports:
   {{- range .Values.appPorts }}
   - name: {{ .name }}
@@ -38,12 +40,12 @@
 apiVersion: v1
 kind: Service
 metadata:
-  name: app-api
+  name: {{ .Values.name }}-api
   namespace: {{ .Release.Namespace }}
 spec:
   type: ClusterIP
   selector:
-    app: app-app
+    app: {{ .Values.name }}-app
   ports:
   - name: api
     port: 80
@@ -53,30 +55,32 @@
 apiVersion: apps/v1
 kind: Deployment
 metadata:
-  name: app-app
+  name: {{ .Values.name }}-app
   namespace: {{ .Release.Namespace }}
   annotations:
     dodo.cloud/config-checksum: {{ sha256sum .Values.runCfg }}
 spec:
   selector:
     matchLabels:
-      app: app-app
+      app: {{ .Values.name }}-app
   replicas: 1
   template:
     metadata:
       labels:
-        app: app-app
+        app: {{ .Values.name }}-app
       annotations:
         dodo.cloud/config-checksum: {{ sha256sum .Values.runCfg }}
     spec:
       runtimeClassName: {{ .Values.runtimeClassName }}
       volumes:
+      {{- if .Values.sshPrivateKey }}
       - name: ssh-key
         secret:
-          secretName: app-ssh-key
+          secretName: {{ .Values.name }}-ssh-key
+      {{- end }}
       - name: run-cfg
         configMap:
-          name: app-run-cfg
+          name: {{ .Values.name }}-run-cfg
       {{- range .Values.volumes }}
       - name: volume-{{ .name }}
         persistentVolumeClaim:
@@ -105,13 +109,18 @@
         - --app-dir={{ .Values.appDir }}
         - --repo-addr={{ .Values.repoAddr }}
         - --branch={{ .Values.branch }}
+        - --root-dir={{ .Values.rootDir }}
+        {{- if .Values.sshPrivateKey }}
         - --ssh-key=/pcloud/ssh-key/private
+        {{- end }}
         - --run-cfg=/pcloud/config/run
         - --manager-addr={{ .Values.managerAddr }}
         volumeMounts:
+        {{- if .Values.sshPrivateKey }}
         - name: ssh-key
           readOnly: true
           mountPath: /pcloud/ssh-key
+        {{- end }}
         - name: run-cfg
           readOnly: true
           mountPath: /pcloud/config
diff --git a/charts/app-runner/values.yaml b/charts/app-runner/values.yaml
index aaf8592..db623a9 100644
--- a/charts/app-runner/values.yaml
+++ b/charts/app-runner/values.yaml
@@ -4,7 +4,8 @@
   pullPolicy: Always
 repoAddr: 192.168.0.11
 branch: "master"
-sshPrivateKey: key
+rootDir: "/"
+sshPrivateKey: ""
 appId: ""
 runCfg: ""
 appDir: /dodo-app
@@ -14,3 +15,4 @@
 runtimeClassName: ""
 extraContainers: []
 apiPort: 3000
+name: "app"