mirror of
				https://github.com/carlosedp/cluster-monitoring.git
				synced 2025-10-26 10:23:04 +01:00 
			
		
		
		
	Add SMTP relay as optional. Adjust formatting.
This commit is contained in:
		
							parent
							
								
									860d80f5e6
								
							
						
					
					
						commit
						10b82768c2
					
				@ -19,7 +19,7 @@ Components included in this package:
 | 
				
			|||||||
* kube-state-metrics
 | 
					* kube-state-metrics
 | 
				
			||||||
* CoreDNS
 | 
					* CoreDNS
 | 
				
			||||||
* Grafana
 | 
					* Grafana
 | 
				
			||||||
* SMTP relay to Gmail for Grafana notifications
 | 
					* SMTP relay to Gmail for Grafana notifications (optional)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
There are additional modules (disabled by default) to monitor other components of the infra-structure. These can be disabled on `vars.jsonnet` file by setting the module in `installModules` to `false`.
 | 
					There are additional modules (disabled by default) to monitor other components of the infra-structure. These can be disabled on `vars.jsonnet` file by setting the module in `installModules` to `false`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -46,6 +46,7 @@ For the ingresses, edit `suffixDomain` to have your cluster URL suffix. This wil
 | 
				
			|||||||
To deploy the stack, run:
 | 
					To deploy the stack, run:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
 | 
					$ make vendor
 | 
				
			||||||
$ make deploy
 | 
					$ make deploy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Or manually:
 | 
					# Or manually:
 | 
				
			||||||
@ -57,7 +58,7 @@ $ kubectl apply -f manifests/
 | 
				
			|||||||
$ until kubectl get customresourcedefinitions servicemonitors.monitoring.coreos.com ; do date; sleep 1; echo ""; done
 | 
					$ until kubectl get customresourcedefinitions servicemonitors.monitoring.coreos.com ; do date; sleep 1; echo ""; done
 | 
				
			||||||
$ until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done
 | 
					$ until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$ kubectl apply -f manifests/ # This command sometimes may need to be done twice (to workaround a race condition).
 | 
					$ kubectl apply -f manifests/ # This command sometimes may need to be done twice (to workaround a race condition)
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
If you get an error from applying the manifests, run the `make deploy` or `kubectl apply -f manifests/` again. Sometimes the resources required to apply the CRDs are not deployed yet.
 | 
					If you get an error from applying the manifests, run the `make deploy` or `kubectl apply -f manifests/` again. Sometimes the resources required to apply the CRDs are not deployed yet.
 | 
				
			||||||
@ -90,6 +91,8 @@ $ kubectl apply -f manifests/ # This command sometimes may need to be done twice
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
If you get an error from applying the manifests, run the `make deploy` or `kubectl apply -f manifests/` again. Sometimes the resources required to apply the CRDs are not deployed yet.
 | 
					If you get an error from applying the manifests, run the `make deploy` or `kubectl apply -f manifests/` again. Sometimes the resources required to apply the CRDs are not deployed yet.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					If you enable the SMTP relay for Gmail in `vars.jsonnet`, the pod will be in an error state after deployed since it would not find the user and password on the "smtp-account" secret. To generate, run the `scripts/create_gmail_auth.sh` script.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Ingress
 | 
					## Ingress
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Now you can open the applications:
 | 
					Now you can open the applications:
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										13
									
								
								main.jsonnet
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								main.jsonnet
									
									
									
									
									
								
							@ -1,13 +1,12 @@
 | 
				
			|||||||
local vars = import 'vars.jsonnet';
 | 
					 | 
				
			||||||
local utils = import 'utils.libsonnet';
 | 
					local utils = import 'utils.libsonnet';
 | 
				
			||||||
 | 
					local vars = import 'vars.jsonnet';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
 | 
					local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
 | 
				
			||||||
           + (import 'kube-prometheus/kube-prometheus-anti-affinity.libsonnet')
 | 
					           + (import 'kube-prometheus/kube-prometheus-anti-affinity.libsonnet')
 | 
				
			||||||
           + (import 'kube-prometheus/kube-prometheus-kops-coredns.libsonnet')
 | 
					           + (import 'kube-prometheus/kube-prometheus-kops-coredns.libsonnet')
 | 
				
			||||||
           + (import 'kube-prometheus/kube-prometheus-kubeadm.libsonnet')
 | 
					           + (import 'kube-prometheus/kube-prometheus-kubeadm.libsonnet')
 | 
				
			||||||
           // Use http Kubelet targets. Comment to revert to https
 | 
					           // Use http Kubelet targets. Comment to revert to https
 | 
				
			||||||
           + (import 'kube-prometheus/kube-prometheus-insecure-kubelet.libsonnet')
 | 
					           //  + (import 'kube-prometheus/kube-prometheus-insecure-kubelet.libsonnet')
 | 
				
			||||||
           + (import 'smtp_server.jsonnet')
 | 
					 | 
				
			||||||
           // Additional modules are loaded dynamically from vars.jsonnet
 | 
					           // Additional modules are loaded dynamically from vars.jsonnet
 | 
				
			||||||
           + utils.join_objects([module.file for module in vars.modules if module.enabled])
 | 
					           + utils.join_objects([module.file for module in vars.modules if module.enabled])
 | 
				
			||||||
           // Load K3s customized modules
 | 
					           // Load K3s customized modules
 | 
				
			||||||
@ -20,7 +19,12 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Generate core modules
 | 
					// Generate core modules
 | 
				
			||||||
{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) }
 | 
					{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) }
 | 
				
			||||||
{ ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) }
 | 
					{
 | 
				
			||||||
 | 
					  ['0prometheus-operator-' + name]: kp.prometheusOperator[name]
 | 
				
			||||||
 | 
					  for name in std.filter((function(name) name != 'serviceMonitor'), std.objectFields(kp.prometheusOperator))
 | 
				
			||||||
 | 
					} +
 | 
				
			||||||
 | 
					// serviceMonitor is separated so that it can be created after the CRDs are ready
 | 
				
			||||||
 | 
					{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
 | 
				
			||||||
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }
 | 
					{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) }
 | 
				
			||||||
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) }
 | 
					{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) }
 | 
				
			||||||
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) }
 | 
					{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) }
 | 
				
			||||||
@ -28,7 +32,6 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet')
 | 
				
			|||||||
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) }
 | 
					{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) }
 | 
				
			||||||
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
 | 
					{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
 | 
				
			||||||
{ ['ingress-' + name]: kp.ingress[name] for name in std.objectFields(kp.ingress) }
 | 
					{ ['ingress-' + name]: kp.ingress[name] for name in std.objectFields(kp.ingress) }
 | 
				
			||||||
{ ['smtp-server-' + name]: kp.smtpServer[name] for name in std.objectFields(kp.smtpServer) }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
{  // Dynamically generate additional modules from vars.jsonnet
 | 
					{  // Dynamically generate additional modules from vars.jsonnet
 | 
				
			||||||
  [std.asciiLower(module.name) + '-' + name]: kp[module.name][name]
 | 
					  [std.asciiLower(module.name) + '-' + name]: kp[module.name][name]
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										18
									
								
								vars.jsonnet
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								vars.jsonnet
									
									
									
									
									
								
							@ -1,9 +1,15 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  _config+:: {
 | 
					  _config+:: {
 | 
				
			||||||
    namespace: 'monitoring'
 | 
					    namespace: 'monitoring',
 | 
				
			||||||
    },
 | 
					  },
 | 
				
			||||||
  // Enable or disable additional modules
 | 
					  // Enable or disable additional modules
 | 
				
			||||||
  modules: [
 | 
					  modules: [
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      // After deployment, run the create_gmail_auth.sh script from scripts dir.
 | 
				
			||||||
 | 
					      name: 'smtpRelay',
 | 
				
			||||||
 | 
					      enabled: false,
 | 
				
			||||||
 | 
					      file: import 'smtp_relay.jsonnet',
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      name: 'armExporter',
 | 
					      name: 'armExporter',
 | 
				
			||||||
      enabled: false,
 | 
					      enabled: false,
 | 
				
			||||||
@ -33,15 +39,15 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  k3s: {
 | 
					  k3s: {
 | 
				
			||||||
    enabled: false,
 | 
					    enabled: false,
 | 
				
			||||||
    master_ip: ['192.168.164.120']
 | 
					    master_ip: ['192.168.15.15'],
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Domain suffix for the ingresses
 | 
					  // Domain suffix for the ingresses
 | 
				
			||||||
  suffixDomain: '192.168.99.100.nip.io',
 | 
					  suffixDomain: '192.168.15.15.nip.io',
 | 
				
			||||||
  // If TLSingress is true, a self-signed HTTPS ingress with redirect will be created
 | 
					  // If TLSingress is true, a self-signed HTTPS ingress with redirect will be created
 | 
				
			||||||
  TLSingress: true,
 | 
					  TLSingress: true,
 | 
				
			||||||
  # If UseProvidedCerts is true, provided files will be used on created HTTPS ingresses.
 | 
					  // If UseProvidedCerts is true, provided files will be used on created HTTPS ingresses.
 | 
				
			||||||
  # Use a wildcard certificate for the domain like ex. "*.192.168.99.100.nip.io"
 | 
					  // Use a wildcard certificate for the domain like ex. "*.192.168.99.100.nip.io"
 | 
				
			||||||
  UseProvidedCerts: false,
 | 
					  UseProvidedCerts: false,
 | 
				
			||||||
  TLSCertificate: importstr 'server.crt',
 | 
					  TLSCertificate: importstr 'server.crt',
 | 
				
			||||||
  TLSKey: importstr 'server.key',
 | 
					  TLSKey: importstr 'server.key',
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user