Skip to content

Commit d593704

Browse files
committed
Fixes, persistant storage, better script storage
1 parent 49725cc commit d593704

File tree

2 files changed

+45
-12
lines changed

2 files changed

+45
-12
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{/*
2+
Commands to setup ssh authentification for the project repo
3+
*/}}
4+
{{- define "project.ssh" }}
5+
{{- if (or $.Values.project.auth.ssh_key $.Values.project.auth.ssh_secret) }}
6+
cd ~;
7+
mkdir .ssh;
8+
cd .ssh;
9+
ssh -o StrictHostKeyChecking=no {{ regexFind "[@\\/][^:\\/]*[\\/:]" $.Values.project.projectRepo | trimPrefix "\\/" | trimPrefix "@" | trimSuffix "\\/" | trimSuffix ":"}};
10+
echo -e $PROJECT_SSH_KEY > id;
11+
chmod 400 id;
12+
eval `ssh-agent`;
13+
ssh-add id;
14+
{{- end }}
15+
{{- end }}
16+
17+
{{/*
18+
Commands to clone the project repo
19+
*/}}
20+
{{- define "project.clone" }}
21+
{{- include "project.ssh" $}}
22+
rm -rf /data/project;
23+
mkdir -p /data/project;
24+
git clone {{ .Values.project.projectRepo }} /data/project;
25+
echo Done;
26+
{{- end }}

charts/opc-router/templates/deployment.yaml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ spec:
5353
{{- end }}
5454
- name: OR_I_ACCEPT_EULA
5555
value: {{ .Values.I_do_accept_the_EULA | quote }}
56-
{{- if (or .Values.project.auth.ssh_key .Values.project.auth.ssh_secret) }}
57-
- name: PROJECT_SSH_KEY
58-
valueFrom:
59-
secretKeyRef:
60-
name: {{ .Values.project.auth.ssh_secret | default (printf "%s-%s" (include "opc-router.fullname" $) "secret" | trunc 63 | trimSuffix "-") }}
61-
key: project-ssh-key
62-
{{- end }}
6356
# Loading environment variables specified in the values file
6457
{{- range .Values.EnvVars }}
6558
- name: "{{ keys . | first }}"
@@ -71,21 +64,35 @@ spec:
7164
{{- if .Values.project.projectRepo }}
7265
# Volume mount for the project and configuration file
7366
volumeMounts:
74-
- mountPath: /project
67+
- mountPath: /data
7568
name: project-volume
7669
# Command and arguments for loading the project and configuration into the opcrouter
7770
command: ["/init", "dotnet", "/app/inray.OPCRouter.Service.dll", "import-project"]
78-
args: ["--source","/project/{{ .Values.project.projectPath }}",{{ if eq .Values.image.repository "opcrouter/runtime" }}"--configdb","OPCRouterRuntime",{{ end }}"--allow-clear-config","--start-service"{{ if .Values.project.configPath }},"--runtime-configuration-filepath","/project/{{ .Values.project.configPath }}"{{ end }}]
79-
71+
args:
72+
- "--source"
73+
- "/data/project/{{ .Values.project.projectPath }}"
74+
{{- if eq .Values.image.repository "opcrouter/runtime" }}
75+
- "--configdb"
76+
- "OPCRouterRuntime"
77+
{{- end }}
78+
- "--allow-clear-config"
79+
- "--start-service"
80+
{{- if .Values.project.configPath }}
81+
- "--runtime-configuration-filepath"
82+
- "/data/project/{{ .Values.project.configPath }}"
83+
{{- end }}
8084
# Init container for pulling the project files
8185
initContainers:
8286
- name: pull-project
8387
image: alpine/git:latest
8488
# Script for setting ssh credentials and cloning the repository onto the volume
85-
command: ['sh', '-c', "{{ if .Values.project.auth.ssh_key }}mkdir .ssh; cd .ssh; echo -e $PROJECT_SSH_KEY > id; chmod 400 id; eval `ssh-agent`; ssh-add id; ssh -o 'StrictHostKeyChecking=no' *; {{ end }}cd /project; git clone {{ .Values.project.projectRepo }} .; echo Done"]
89+
command: ["sh", "-c"]
90+
args:
91+
- >-
92+
{{- include "project.clone" $ | indent 10}}
8693
# Volume mount for the project and configuration file
8794
volumeMounts:
88-
- mountPath: /project
95+
- mountPath: /data
8996
name: project-volume
9097
{{- if (or .Values.project.auth.ssh_key .Values.project.auth.ssh_secret) }}
9198
env:

0 commit comments

Comments
 (0)