From 3cd2920866b5df9d94fa1a640fbb2ee725d50651 Mon Sep 17 00:00:00 2001 From: Jordan Halterman Date: Tue, 17 Mar 2020 17:14:09 -0700 Subject: [PATCH] Support configuration files in ONOS services (#45) * Add support for values-based configuration of services * Ensure configuration files generated in configmaps are parseable --- onos-config/templates/configmap.yaml | 12 ++++++++++++ onos-config/templates/deployment.yaml | 14 ++++++++++---- onos-config/values.yaml | 2 ++ onos-ric/templates/configmap.yaml | 12 ++++++++++++ onos-ric/templates/deployment.yaml | 14 ++++++++++---- onos-ric/values.yaml | 2 ++ onos-topo/templates/configmap.yaml | 12 ++++++++++++ onos-topo/templates/deployment.yaml | 14 ++++++++++---- onos-topo/values.yaml | 2 ++ 9 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 onos-config/templates/configmap.yaml create mode 100644 onos-ric/templates/configmap.yaml create mode 100644 onos-topo/templates/configmap.yaml diff --git a/onos-config/templates/configmap.yaml b/onos-config/templates/configmap.yaml new file mode 100644 index 00000000..0f10165a --- /dev/null +++ b/onos-config/templates/configmap.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "onos-config.fullname" . }}-config + labels: + app: {{ template "onos-config.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +data: + onos.yaml: |- +{{ toYaml .Values.config | indent 4 }} \ No newline at end of file diff --git a/onos-config/templates/deployment.yaml b/onos-config/templates/deployment.yaml index 12d344b2..8ef62c5b 100644 --- a/onos-config/templates/deployment.yaml +++ b/onos-config/templates/deployment.yaml @@ -60,9 +60,9 @@ spec: - name: ATOMIX_NAMESPACE value: {{ .Release.Namespace }} args: - - "-caPath=/etc/onos-config/certs/tls.cacrt" - - "-keyPath=/etc/onos-config/certs/tls.key" - - "-certPath=/etc/onos-config/certs/tls.crt" + - "-caPath=/etc/onos/certs/tls.cacrt" + - "-keyPath=/etc/onos/certs/tls.key" + - "-certPath=/etc/onos/certs/tls.crt" {{- range $key, $plugin := .Values.plugins }} {{- range $j, $v := $plugin.versions }} - {{ printf "-modelPlugin=/usr/local/lib/shared/%s.so.%s" $key $v }} @@ -91,8 +91,11 @@ spec: initialDelaySeconds: 5 periodSeconds: 10 volumeMounts: + - name: config + mountPath: /etc/onos/config + readOnly: true - name: secret - mountPath: /etc/onos-config/certs + mountPath: /etc/onos/certs readOnly: true - name: shared-data mountPath: /usr/local/lib/shared @@ -122,6 +125,9 @@ spec: {{- end }} # Mount volumes volumes: + - name: config + configMap: + name: {{ template "onos-config.fullname" . }}-config - name: secret secret: secretName: {{ template "onos-config.fullname" . }}-secret diff --git a/onos-config/values.yaml b/onos-config/values.yaml index 92f766e6..b0896632 100644 --- a/onos-config/values.yaml +++ b/onos-config/values.yaml @@ -57,3 +57,5 @@ nodeSelector: {} tolerations: [] affinity: {} + +config: {} diff --git a/onos-ric/templates/configmap.yaml b/onos-ric/templates/configmap.yaml new file mode 100644 index 00000000..76f61edb --- /dev/null +++ b/onos-ric/templates/configmap.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "onos-ric.fullname" . }}-config + labels: + app: {{ template "onos-ric.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +data: + onos.yaml: |- +{{ toYaml .Values.config | indent 4 }} \ No newline at end of file diff --git a/onos-ric/templates/deployment.yaml b/onos-ric/templates/deployment.yaml index 2d9fe4dc..182f8ddc 100644 --- a/onos-ric/templates/deployment.yaml +++ b/onos-ric/templates/deployment.yaml @@ -54,9 +54,9 @@ spec: - name: ATOMIX_NAMESPACE value: {{ .Release.Namespace }} args: - - "-caPath=/etc/onos-ric/certs/tls.cacrt" - - "-keyPath=/etc/onos-ric/certs/tls.key" - - "-certPath=/etc/onos-ric/certs/tls.crt" + - "-caPath=/etc/onos/certs/tls.cacrt" + - "-keyPath=/etc/onos/certs/tls.key" + - "-certPath=/etc/onos/certs/tls.crt" ports: - name: grpc containerPort: 5150 @@ -76,8 +76,11 @@ spec: initialDelaySeconds: 5 periodSeconds: 10 volumeMounts: + - name: config + mountPath: /etc/onos/config + readOnly: true - name: secret - mountPath: /etc/onos-ric/certs + mountPath: /etc/onos/certs readOnly: true resources: {{- toYaml .Values.resources | nindent 12 }} @@ -89,6 +92,9 @@ spec: - SYS_PTRACE {{- end }} volumes: + - name: config + configMap: + name: {{ template "onos-ric.fullname" . }}-config - name: secret secret: secretName: {{ template "onos-ric.fullname" . }}-secret diff --git a/onos-ric/values.yaml b/onos-ric/values.yaml index f77c3139..b070bd03 100644 --- a/onos-ric/values.yaml +++ b/onos-ric/values.yaml @@ -47,3 +47,5 @@ nodeSelector: {} tolerations: [] affinity: {} + +config: {} diff --git a/onos-topo/templates/configmap.yaml b/onos-topo/templates/configmap.yaml new file mode 100644 index 00000000..fada5ce5 --- /dev/null +++ b/onos-topo/templates/configmap.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "onos-topo.fullname" . }}-config + labels: + app: {{ template "onos-topo.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +data: + onos.yaml: |- +{{ toYaml .Values.config | indent 4 }} \ No newline at end of file diff --git a/onos-topo/templates/deployment.yaml b/onos-topo/templates/deployment.yaml index d28cfb69..93f6687b 100644 --- a/onos-topo/templates/deployment.yaml +++ b/onos-topo/templates/deployment.yaml @@ -57,9 +57,9 @@ spec: - name: ATOMIX_NAMESPACE value: {{ .Release.Namespace }} args: - - "-caPath=/etc/onos-topo/certs/tls.cacrt" - - "-keyPath=/etc/onos-topo/certs/tls.key" - - "-certPath=/etc/onos-topo/certs/tls.crt" + - "-caPath=/etc/onos/certs/tls.cacrt" + - "-keyPath=/etc/onos/certs/tls.key" + - "-certPath=/etc/onos/certs/tls.crt" ports: - name: grpc containerPort: 5150 @@ -79,8 +79,11 @@ spec: initialDelaySeconds: 5 periodSeconds: 10 volumeMounts: + - name: config + mountPath: /etc/onos/config + readOnly: true - name: secret - mountPath: /etc/onos-topo/certs + mountPath: /etc/onos/certs readOnly: true resources: {{- toYaml .Values.resources | nindent 12 }} @@ -92,6 +95,9 @@ spec: - SYS_PTRACE {{- end }} volumes: + - name: config + configMap: + name: {{ template "onos-topo.fullname" . }}-config - name: secret secret: secretName: {{ template "onos-topo.fullname" . }}-secret diff --git a/onos-topo/values.yaml b/onos-topo/values.yaml index 7d269c5a..171e5778 100644 --- a/onos-topo/values.yaml +++ b/onos-topo/values.yaml @@ -40,3 +40,5 @@ nodeSelector: {} tolerations: [] affinity: {} + +config: {}