Skip to content

Commit 96750fc

Browse files
authored
Merge pull request #12 from rafaprata/feature/enable-air-gapped
Enable rmt chart run on air-gapped environments
2 parents e5f2937 + 22ba07a commit 96750fc

File tree

4 files changed

+88
-2
lines changed

4 files changed

+88
-2
lines changed

rmt-helm/templates/20-app-configmap.yaml

+69-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,72 @@ data:
1212
products_disable: |-
1313
{{- range .Values.app.scc.products_disable}}
1414
{{ . }}
15-
{{- end }}
15+
{{- end }}
16+
---
17+
{{- $component := "app" -}}
18+
{{- $sccSync := .Values.app.scc -}}
19+
{{- if not $sccSync.enabled }}
20+
apiVersion: v1
21+
kind: ConfigMap
22+
metadata:
23+
name: {{ include "rmt.fullname" . }}-{{ $component }}-config
24+
data:
25+
entrypoint.sh: |
26+
#!/bin/sh
27+
set -e
28+
29+
# PV could be empty, make sure the directories exist
30+
mkdir -p /var/lib/rmt/public/repo
31+
mkdir -p /var/lib/rmt/public/suma
32+
mkdir -p /var/lib/rmt/regsharing
33+
mkdir -p /var/lib/rmt/tmp
34+
# Set permissions
35+
chown -R _rmt:nginx /var/lib/rmt
36+
37+
if [ -z "${MYSQL_HOST}" ]; then
38+
echo "MYSQL_HOST not set!"
39+
exit 1
40+
fi
41+
if [ -z "${MYSQL_PASSWORD}" ]; then
42+
echo "MYSQL_PASSWORD not set!"
43+
exit 1
44+
fi
45+
46+
MYSQL_DATABASE="${MYSQL_DATABASE:-rmt}"
47+
MYSQL_USER="${MYSQL_USER:-rmt}"
48+
49+
# Create adjusted /etc/rmt.conf
50+
echo -e "database:\n host: ${MYSQL_HOST}\n database: ${MYSQL_DATABASE}\n username: ${MYSQL_USER}\n password: ${MYSQL_PASSWORD}" > /etc/rmt.conf
51+
echo -e " adapter: mysql2\n encoding: utf8\n timeout: 5000\n pool: 5\n" >> /etc/rmt.conf
52+
echo -e "scc:\n username: ${SCC_USERNAME}\n password: ${SCC_PASSWORD}\n sync_systems: ${SCC_SYNC}\n" >> /etc/rmt.conf
53+
echo -e "log_level:\n rails: debug" >> /etc/rmt.conf
54+
55+
if [ $# -eq 0 ]; then
56+
set -- /usr/share/rmt/bin/rails server -e production
57+
fi
58+
59+
if [ "$1" == "/usr/share/rmt/bin/rails" -a "$2" == "server" ]; then
60+
echo "Create/migrate SUSE RMT database"
61+
pushd /usr/share/rmt > /dev/null
62+
/usr/share/rmt/bin/rails db:create db:migrate RAILS_ENV=production
63+
popd > /dev/null
64+
if [ ${SCC_SYNC} != "false" ]; then
65+
echo "Syncing product list"
66+
rmt-cli sync
67+
for PRODUCT in $SCC_PRODUCT_ENABLE
68+
do
69+
rmt-cli products enable $PRODUCT
70+
done
71+
for PRODUCT in $SCC_PRODUCT_DISABLE
72+
do
73+
rmt-cli products disable $PRODUCT
74+
done
75+
rmt-cli repos clean
76+
fi
77+
echo "Executing: catatonit -- $@"
78+
exec catatonit -- "$@"
79+
else
80+
echo "Executing: $@"
81+
exec "$@"
82+
fi
83+
{{- end }}

rmt-helm/templates/20-app-cronjob.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.app.scc.enabled }}
12
---
23
{{- $component := "app" -}}
34
{{- $task := "sync" -}}
@@ -107,4 +108,5 @@ spec:
107108
volumes:
108109
- name: {{ include "rmt.fullname" . }}-{{ $component }}
109110
persistentVolumeClaim:
110-
claimName: {{ include "rmt.fullname" . }}-{{ $component }}
111+
claimName: {{ include "rmt.fullname" . }}-{{ $component }}
112+
{{- end }}

rmt-helm/templates/20-app-deployment.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{{- $initImage := .Values.app.init.image -}}
55
{{- $autoscaling := .Values.app.autoscaling -}}
66
{{- $replicaCount := .Values.app.replicaCount -}}
7+
{{- $sccSync := .Values.app.scc -}}
78
apiVersion: apps/v1
89
kind: Deployment
910
metadata:
@@ -59,6 +60,10 @@ spec:
5960
secretKeyRef:
6061
name: "{{ include "rmt.fullname" . }}-db"
6162
key: password
63+
{{- if not $sccSync.enabled }}
64+
- name: SCC_SYNC
65+
value: {{ $sccSync.enabled | toString }}
66+
{{- end }}
6267
- name: SCC_USERNAME
6368
valueFrom:
6469
secretKeyRef:
@@ -96,10 +101,19 @@ spec:
96101
volumeMounts:
97102
- name: {{ include "rmt.fullname" . }}-{{ $component }}-pv
98103
mountPath: /var/lib/rmt
104+
{{- if not $sccSync.enabled }}
105+
- name: {{ include "rmt.fullname" . }}-{{ $component }}-entrypoint
106+
mountPath: /usr/local/bin
107+
{{- end }}
99108
volumes:
100109
- name: {{ include "rmt.fullname" . }}-{{ $component }}-pv
101110
persistentVolumeClaim:
102111
claimName: {{ include "rmt.fullname" . }}-{{ $component }}
112+
{{- if not $sccSync.enabled }}
113+
- name: {{ include "rmt.fullname" . }}-{{ $component }}-entrypoint
114+
configMap:
115+
name: {{ include "rmt.fullname" . }}-{{ $component }}-config
116+
{{- end }}
103117
initContainers:
104118
- name: "{{ .Chart.Name }}-{{ $component }}-init"
105119
image: "{{ $initImage.repository }}:{{ $initImage.tag | default .Chart.AppVersion }}"

rmt-helm/values.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ app:
5252
# -- RMT server storage volume requirements. This can vary greatly depending on the number of modules to mirror.
5353
size: 300Mi
5454
scc:
55+
# -- Enable or Disable the sync with SCC
56+
enabled: true
5557
# -- SCC username
5658
username:
5759
# -- SCC password

0 commit comments

Comments
 (0)