Skip to content

Commit 514aa56

Browse files
committed
Updated helm chart
1 parent 8c48030 commit 514aa56

18 files changed

+476
-131
lines changed

README.md

Lines changed: 132 additions & 43 deletions
Large diffs are not rendered by default.

charts/opc-router/templates/NOTES.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
77
{{- end }}
88
{{- end }}
9-
{{- else if not .Values.mongodb.externalAccess.enabled }}
9+
{{- else if not .Values.service.enabled }}
1010
External access was disabled, you will not be able to reach the application from the outside.
11-
{{- else if contains "NodePort" .Values.mongodb.externalAccess.service.type }}
11+
{{- else if contains "NodePort" .Values.service.type }}
1212
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ if .Values.mongodb.deploy }}{{ .Release.Name }}-mongodb-0-external{{ else }}{{ include "opc-router.fullname" . }}{{ end }})
1313
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
1414
echo $NODE_IP:$NODE_PORT
15-
{{- else if contains "LoadBalancer" .Values.mongodb.externalAccess.service.type }}
15+
{{- else if contains "LoadBalancer" .Values.service.type }}
1616
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
1717
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "opc-router.fullname" . }}'
1818
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ if .Values.mongodb.deploy }}{{ .Release.Name }}-mongodb-0-external{{ else }}{{ include "opc-router.fullname" . }}{{ end }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
1919
echo $SERVICE_IP:{{ .Values.mongodb.externalAccess.service.port }}
20-
{{- else if contains "ClusterIP" .Values.mongodb.externalAccess.service.type }}
20+
{{- else if contains "ClusterIP" .Values.service.type }}
2121
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "opc-router.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
2222
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
2323
echo "You can now reach the configuration at 127.0.0.1 with port 27020"

charts/opc-router/templates/_helpers.tpl

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ If release name contains chart name it will be used as a full name.
2323
{{- end }}
2424
{{- end }}
2525

26+
{{- define "opc-router.redundancy.fullname" -}}
27+
{{- include "opc-router.fullname" . | cat "redundant" | replace " " "-" | trunc 63 | trimSuffix "-" }}
28+
{{- end }}
29+
2630
{{/*
2731
Create chart name and version as used by the chart label.
2832
*/}}
@@ -35,7 +39,8 @@ Common labels
3539
*/}}
3640
{{- define "opc-router.labels" -}}
3741
helm.sh/chart: {{ include "opc-router.chart" . }}
38-
{{ include "opc-router.selectorLabels" . }}
42+
app.kubernetes.io/name: {{ include "opc-router.name" . }}
43+
app.kubernetes.io/instance: {{ .Release.Name }}
3944
{{- if .Chart.AppVersion }}
4045
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
4146
{{- end }}
@@ -46,8 +51,15 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
4651
Selector labels
4752
*/}}
4853
{{- define "opc-router.selectorLabels" -}}
49-
app.kubernetes.io/name: {{ include "opc-router.name" . }}
5054
app.kubernetes.io/instance: {{ .Release.Name }}
55+
statefulset.kubernetes.io/pod-name: {{ .Release.Name }}-mongodb-0
56+
{{- end }}
57+
58+
{{/*
59+
Original selector labels
60+
*/}}
61+
{{- define "opc-router.originalSelectorLabels" -}}
62+
originForRedundency: {{ include "opc-router.redundancy.fullname" . }}
5163
{{- end }}
5264

5365
{{/*
@@ -62,16 +74,14 @@ Create the name of the service account to use
6274
{{- end }}
6375

6476
{{/*
65-
Returns a secret if it already in Kubernetes, otherwise it creates
66-
it randomly.
67-
https://github.com/helm/charts/issues/5167
77+
Create the connection string for the mongodb(s)
6878
*/}}
69-
{{- define "getOrGeneratePass" }}
70-
{{- $len := (default 16 .Length) | int -}}
71-
{{- $obj := (lookup "v1" .Kind .Namespace .Name).data -}}
72-
{{- if $obj }}
73-
{{- index (b64dec $obj) .Key -}}
74-
{{- else -}}
75-
{{- randAlphaNum $len -}}
79+
{{- define "getMongoDB" }}
80+
{{- $addresses := int .Values.mongodb.replicaCount | until }}
81+
{{- range $addresses -}}
82+
{{- if (ne . 0) -}}
83+
,
7684
{{- end -}}
85+
{{ $.Release.Name }}-mongodb-{{ . }}.{{ $.Release.Name }}-mongodb-headless
86+
{{- end }}
7787
{{- end }}

charts/opc-router/templates/_scripts.tpl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,29 @@ Commands to clone the project repo
2525
echo Done;
2626
{{- end }}
2727

28+
{{/*
29+
Commands to clone the project repo and edit config to create a redundancy server
30+
*/}}
31+
{{- define "project.redundant.clone" }}
32+
{{- include "project.clone" $}}
33+
cat <<EOF > /data/redundancyconfig.yaml
34+
35+
---
36+
37+
routeroptions:
38+
RedundancyMasterHostname: {{ include "opc-router.redundancy.fullname" . }}
39+
RedundancyPingInterval: {{ .Values.project.redundancy.pingInterval }}
40+
RedundancyReconnectCheckPeriod: {{ .Values.project.redundancy.reconnectCheckPeriod }}
41+
EOF
42+
{{ with .Values.project.configPath }}
43+
if [ "$(tail -n+2 /data/project/{{ . }} | head -n 1)" = "routeroptions:" ]; then
44+
tail -n+3 /data/project/{{ . }} >> /data/redundancyconfig.yaml
45+
else
46+
tail -n+2 /data/project/{{ . }} >> /data/redundancyconfig.yaml
47+
fi
48+
{{- end }}
49+
{{- end }}
50+
2851
{{/*
2952
Commands to continuously update the project and restart the pod on new version
3053
*/}}

charts/opc-router/templates/deletesecret.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ apiVersion: v1
55
kind: Secret
66
metadata:
77
name: {{ printf "%s-%s" (include "opc-router.fullname" $) "secret" | trunc 63 | trimSuffix "-" }}
8+
labels:
9+
{{- include "opc-router.labels" $ | nindent 4 }}
810
annotations:
911
"helm.sh/hook": post-install
1012
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed

charts/opc-router/templates/deployment.yaml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,22 @@ spec:
99
replicas: 1
1010
selector:
1111
matchLabels:
12-
{{- include "opc-router.selectorLabels" . | nindent 6 }}
12+
{{- include "opc-router.labels" . | nindent 6 }}
13+
{{- include "opc-router.originalSelectorLabels" . | nindent 6 }}
1314
template:
1415
metadata:
1516
{{- with .Values.podAnnotations }}
1617
annotations:
1718
{{- toYaml . | nindent 8 }}
1819
{{- end }}
1920
labels:
21+
{{- include "opc-router.labels" . | nindent 8 }}
22+
{{- include "opc-router.originalSelectorLabels" . | nindent 8 }}
23+
{{- if eq .Values.image.repository "opcrouter/runtime" }}
24+
{{- if not .Values.mongodb.deploy }}
2025
{{- include "opc-router.selectorLabels" . | nindent 8 }}
26+
{{- end }}
27+
{{- end }}
2128
spec:
2229
{{- with .Values.imagePullSecrets }}
2330
imagePullSecrets:
@@ -33,34 +40,44 @@ spec:
3340
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
3441
imagePullPolicy: {{ .Values.image.pullPolicy }}
3542
ports:
36-
{{- if eq .Values.image.repository "opcrouter/runtime" }}
37-
{{- if eq .Values.mongodb.deploy false }}
38-
- name: opcrouter
43+
{{- if eq .Values.image.repository "opcrouter/runtime" }}
44+
{{- if not .Values.mongodb.deploy }}
45+
- name: mongodb
3946
containerPort: 27017
4047
protocol: TCP
41-
{{- end }}
42-
{{- end }}
48+
{{- end }}
49+
{{- end }}
50+
{{- if .Values.project.redundancy.deploy }}
51+
- name: ready
52+
containerPort: 49954
53+
protocol: TCP
54+
readinessProbe:
55+
tcpSocket:
56+
port: ready
57+
initialDelaySeconds: {{ .Values.project.redundancy.readinessProbe.initialDelaySeconds }}
58+
periodSeconds: {{ .Values.project.redundancy.readinessProbe.periodSeconds }}
59+
{{- end }}
4360
# Environment variables for the opcrouter container
4461
env:
4562
# Variables for connecting a service to the mongodb if a service is specified
4663
{{- if .Values.mongodb.deploy }}
4764
- name: OR_DATABASE_HOST_ADRESS
48-
value: "{{ .Release.Name }}-mongodb-0.{{ .Release.Name }}-mongodb-headless"
65+
value: "{{ include "getMongoDB" . }}"
4966
{{- if .Values.mongodb.auth.enabled }}
5067
- name: OR_DATABASE_USERNAME
5168
value: root
5269
# Loading the password for the mongodb from secret
5370
- name: OR_DATABASE_PASSWORD
5471
valueFrom:
5572
secretKeyRef:
56-
name: {{ .Values.mongodb.auth.existingSecret }}
73+
name: {{ if .Values.mongodb.auth.existingSecret }}{{ .Values.mongodb.auth.existingSecret }}{{ else }}{{ .Release.Name }}-mongodb{{ end }}
5774
key: mongodb-root-password
5875
{{- end }}
5976
{{- end }}
6077
- name: OR_I_ACCEPT_EULA
6178
value: {{ .Values.I_do_accept_the_EULA | quote }}
6279
# Loading environment variables specified in the values file
63-
{{- range .Values.EnvVars }}
80+
{{- range .Values.envVars }}
6481
- name: "{{ keys . | first }}"
6582
value: "{{ values . | first }}"
6683
{{- end }}

charts/opc-router/templates/mongodb-secret.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

charts/opc-router/templates/opcrouter-secret.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ apiVersion: v1
44
kind: Secret
55
metadata:
66
name: {{ printf "%s-%s" (include "opc-router.fullname" $) "secret" | trunc 63 | trimSuffix "-" }}
7+
labels:
8+
{{- include "opc-router.labels" $ | nindent 4 }}
79
type: Opaque
810
data:
911
project-ssh-key: {{ . | b64enc }}
1012
{{- end }}
11-
{{- end }}
13+
{{- end }}

charts/opc-router/templates/persistantclaim renamed to charts/opc-router/templates/persistantclaim.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ apiVersion: v1
33
kind: PersistentVolumeClaim
44
metadata:
55
name: {{ include "opc-router.fullname" . }}
6+
labels:
7+
{{- include "opc-router.labels" . | nindent 4 }}
68
spec:
7-
storageClassName: manual
9+
storageClassName: standard
810
accessModes:
9-
- ReadWriteMany
11+
- ReadWriteOnce
1012
resources:
1113
requests:
1214
storage: {{ .Values.project.persistantVolume.size }}

charts/opc-router/templates/persistantstorage.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ metadata:
55
name: {{ include "opc-router.fullname" . }}
66
labels:
77
type: local
8+
{{- include "opc-router.labels" . | nindent 4 }}
89
spec:
9-
storageClassName: manual
10+
storageClassName: standard
1011
capacity:
1112
storage: {{ .Values.project.persistantVolume.size }}
1213
accessModes:
13-
- ReadWriteMany
14+
- ReadWriteOnce
1415
hostPath:
1516
path: "/volume"
1617
claimRef:

0 commit comments

Comments
 (0)