DAaaS: enhance collectd to be more configurable 58/92258/1
authorLianhao Lu <lianhao.lu@intel.com>
Tue, 30 Jul 2019 06:33:13 +0000 (06:33 +0000)
committerLianhao Lu <lianhao.lu@intel.com>
Tue, 30 Jul 2019 06:35:42 +0000 (06:35 +0000)
Enhance the collectd chart in DAaaS to be more configurable, so that it
can be launched with k8s CMK environment.

Issue-ID: ONAPARC-393
Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
Change-Id: I28698688a9977f60e89c54f32c1de73c17cb6751

vnfs/DAaaS/deploy/collection/charts/collectd/resources/collectd.conf [moved from vnfs/DAaaS/deploy/collection/charts/collectd/resources/config/collectd.conf with 92% similarity]
vnfs/DAaaS/deploy/collection/charts/collectd/templates/configmap.yaml
vnfs/DAaaS/deploy/collection/charts/collectd/templates/daemonset.yaml
vnfs/DAaaS/deploy/collection/charts/collectd/values.yaml

@@ -38,7 +38,7 @@ LoadPlugin logfile
 </Plugin>
 
 <Plugin "write_prometheus">
- Port "{{ .Values.prometheus_port }}"
+ Port "{{ .Values.collectd_prometheus.service.targetPort }}"
 </Plugin>
 
 #Last line (collectd requires ā€˜\nā€™ at the last line)
index 5f5dde0..26d0fb5 100644 (file)
@@ -23,5 +23,4 @@ metadata:
     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
     release: {{ .Release.Name }}
 data:
-  node-collectd.conf: |-
-  {{ tpl (.Files.Glob "resources/config/*").AsConfig . | indent 2 }}
+  {{- tpl (.Files.Glob "resources/*").AsConfig . | nindent 2 }}
index 29fdded..bc68638 100644 (file)
@@ -36,48 +36,49 @@ spec:
         release: {{ .Release.Name }}
     spec:
       hostNetwork: true
+      {{- if .Values.serviceAccountName }}
+      serviceAccountName: {{ .Values.serviceAccountName }}
+      {{- end }}
+{{- if .Values.tolerations }}
+      tolerations:
+{{ toYaml .Values.tolerations | trim | indent 8 }}
+{{- end }}
+{{- if .Values.nodeSelector }}
+      nodeSelector:
+{{ toYaml .Values.nodeSelector | trim | indent 8 }}
+{{- end }}
       containers:
         - name: {{ .Chart.Name }}
           image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
           imagePullPolicy: {{ .Values.image.pullPolicy }}
           securityContext:
+            allowPrivilegeEscalation: true
             privileged: true
+{{- if .Values.env }}
+          env:
+{{ toYaml .Values.env | trim | indent 10 }}
+{{- end  }}
+{{- if .Values.command }}
+          command:
+{{ toYaml .Values.command | trim | indent 10 }}
+{{- end  }}
+{{- if .Values.args }}
+          args:
+{{ toYaml .Values.args | trim | indent 10 }}
+{{- end  }}
           volumeMounts:
           - name: {{ template "fullname" . }}-config
-            mountPath: /opt/collectd/etc
-          - name: proc
-            mountPath: /mnt/proc
-            readOnly: true
-          - name: root
-            mountPath: /hostfs
-            readOnly: true
-          - name: etc
-            mountPath: /mnt/etc
-            readOnly: true
-          - name: run
-            mountPath: /var/run/docker.sock
+            mountPath: {{ .Values.configMountPath }}
+{{- if .Values.volumeMounts }}
+{{ toYaml .Values.volumeMounts | trim | indent 10 }}
+{{- end }}
           resources:
-{{ toYaml .Values.resources | indent 12 }}
-    {{- if .Values.nodeSelector }}
-      nodeSelector:
-{{ toYaml .Values.nodeSelector | indent 8 }}
-    {{- end }}
+{{- toYaml .Values.resources | trim | indent 12}}
       volumes:
       - name: {{ template "fullname" . }}-config
         configMap:
           name: {{ template "fullname" . }}-config
-          items:
-          - key: node-collectd.conf
-            path: collectd.conf
-      - name: proc
-        hostPath:
-          path: /proc
-      - name: root
-        hostPath:
-          path: /
-      - name: etc
-        hostPath:
-          path: /etc
-      - name: run
-        hostPath:
-          path: /var/run/docker.sock
+          defaultMode: 0744
+{{- if .Values.volumeMounts }}
+{{ toYaml .Values.volumes | indent 6 }}
+{{- end }}
index fdfcae7..7957b15 100644 (file)
@@ -18,6 +18,55 @@ resources: {}
   # requests:
   #  cpu: 100m
   #  memory: 128Mi
+
+
+#serviceAccountName: cmk-serviceaccount
+
+# Uncomment the following tolerations and/or nodeSelector to select the node collectd to be deployed
+#tolerations:
+#  - operator: "Exists"
+#nodeSelector:
+#  vcmts: "true"
+
+# Uncomment the following to set environment, command and args for the collectd container
+#env:
+#- name: CMK_PROC_FS
+#  value: "/host/proc"
+#command:
+#- "/bin/bash"
+#- "-c"
+#args: [ "/opt/bin/cmk isolate --conf-dir=/etc/cmk --pool=infra /script/collectd.sh" ]
+
+# all the files under the directory resource will be mount into the directory specified by 'configMountPath' inside the container.
+# Besides that, users can specify any mount by using the 'volumeMounts' and 'volumes'.
+configMountPath: /opt/collectd/etc
+volumeMounts:
+- name: proc
+  mountPath: /mnt/proc
+  readOnly: true
+- name: root
+  mountPath: /hostfs
+  readOnly: true
+- name: etc
+  mountPath: /mnt/etc
+  readOnly: true
+- name: run
+  mountPath: /var/run/docker.sock
+
+volumes:
+- name: proc
+  hostPath:
+    path: /proc
+- name: root
+  hostPath:
+    path: /
+- name: etc
+  hostPath:
+    path: /etc
+- name: run
+  hostPath:
+    path: /var/run/docker.sock
+
 collectd_prometheus:
   service:
     type: ClusterIP