diff --git a/blueprints/templates/infrastructure-charts/deployment-values.yaml b/blueprints/templates/infrastructure-charts/deployment-values.yaml index 8c75088..26e9ac2 100644 --- a/blueprints/templates/infrastructure-charts/deployment-values.yaml +++ b/blueprints/templates/infrastructure-charts/deployment-values.yaml @@ -30,6 +30,8 @@ deployment: ports: http: + # port: # defaults to 80 + # protocol: # defaults to TCP health: startupProbe: diff --git a/blueprints/templates/infrastructure-charts/pod-monitor-values.yaml b/blueprints/templates/infrastructure-charts/pod-monitor-values.yaml new file mode 100644 index 0000000..e6bdb73 --- /dev/null +++ b/blueprints/templates/infrastructure-charts/pod-monitor-values.yaml @@ -0,0 +1,8 @@ +podMonitor: + enabled: true + # Default values, override them if necessary + #labels: {} + #annotations: {} + #port: "metrics" + #interval: "10s" + #path: "/metrics" \ No newline at end of file diff --git a/blueprints/templates/infrastructure-charts/pod-monitor.yaml b/blueprints/templates/infrastructure-charts/pod-monitor.yaml new file mode 100644 index 0000000..e709ba6 --- /dev/null +++ b/blueprints/templates/infrastructure-charts/pod-monitor.yaml @@ -0,0 +1,23 @@ +{{- if .Values.podMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "myService.fullname" $ }} + {{- with .Values.podMonitor.labels }} + labels: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.podMonitor.annotations }} + annotations: + iits-consulting.chart-creator/version: CHART_CREATOR_VERSION + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + {{- include "myService.selectorLabels" . | nindent 6 }} + podMetricsEndpoints: + - port: {{ default "metrics" .Values.podMonitor.port }} + interval: {{ default "10s" .Values.podMonitor.interval }} + path: {{ default "/metrics" .Values.podMonitor.path }} +{{- end }} \ No newline at end of file diff --git a/blueprints/templates/infrastructure-charts/service-monitor.yaml b/blueprints/templates/infrastructure-charts/service-monitor.yaml index f13dde2..25015ce 100644 --- a/blueprints/templates/infrastructure-charts/service-monitor.yaml +++ b/blueprints/templates/infrastructure-charts/service-monitor.yaml @@ -17,7 +17,7 @@ spec: matchLabels: {{- include "myService.selectorLabels" . | nindent 6 }} endpoints: - - port: {{ default "http" .Values.serviceMonitor.portName }} + - port: {{ default "metrics" .Values.serviceMonitor.port }} interval: {{ default "10s" .Values.serviceMonitor.interval }} path: {{ default "/metrics" .Values.serviceMonitor.path }} {{- end }} \ No newline at end of file diff --git a/blueprints/values.yaml b/blueprints/values.yaml index 68f08c8..97a6c69 100644 --- a/blueprints/values.yaml +++ b/blueprints/values.yaml @@ -73,6 +73,8 @@ deployment: ports: http: + # port: # defaults to 80 + # protocol: # defaults to TCP health: liveness: @@ -105,6 +107,15 @@ serviceMonitor: # Default values, override them if necessary #labels: {} #annotations: {} - #portName: "http" + #port: "metrics" + #interval: "10s" + #path: "/metrics" + +podMonitor: + enabled: true + # Default values, override them if necessary + #labels: {} + #annotations: {} + #port: "metrics" #interval: "10s" #path: "/metrics" \ No newline at end of file diff --git a/main.go b/main.go index d1284c1..9e93f94 100644 --- a/main.go +++ b/main.go @@ -109,11 +109,25 @@ func createInfrastructureChartsCMD() *cobra.Command { }, } + var podMonitorCreateHelpers = &cobra.Command{ + Use: "pod-monitor", + Short: "Creates a pod-monitor deployment file", + Run: func(cmd *cobra.Command, args []string) { + checkAndCreateResource(cmd, DataInputForCreation{ + ManifestName: "pod-monitor.yaml", + ChartType: "infrastructure-charts", + Version: version, + ReleaseName: overrideReleaseName, + }) + }, + } + cmdInfrastructureCharts.AddCommand(cmdCreateIngress) cmdInfrastructureCharts.AddCommand(cmdCreateHelpers) cmdInfrastructureCharts.AddCommand(saCreateHelpers) cmdInfrastructureCharts.AddCommand(serviceCreateHelpers) cmdInfrastructureCharts.AddCommand(deploymentCreateHelpers) cmdInfrastructureCharts.AddCommand(serviceMonitorCreateHelpers) + cmdInfrastructureCharts.AddCommand(podMonitorCreateHelpers) return cmdInfrastructureCharts }