// Copyright (c) 2023 Volvo Car Corporation
// SPDX-License-Identifier: Apache-2.0

// Code generated by lingon. EDIT AS MUCH AS YOU LIKE.

package promstack

import (
	appsv1 "k8s.io/api/apps/v1"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/util/intstr"
)

var KubePromtheusStackPrometheusNodeExporterDS = &appsv1.DaemonSet{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app.kubernetes.io/component":  "metrics",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/name":       "prometheus-node-exporter",
			"app.kubernetes.io/part-of":    "prometheus-node-exporter",
			"app.kubernetes.io/version":    "1.5.0",
			"helm.sh/chart":                "prometheus-node-exporter-4.17.5",
			"jobLabel":                     "node-exporter",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-prometheus-node-exporter",
		Namespace: "monitoring",
	},
	Spec: appsv1.DaemonSetSpec{
		Selector: &metav1.LabelSelector{
			MatchLabels: map[string]string{
				"app.kubernetes.io/instance": "kube-promtheus-stack",
				"app.kubernetes.io/name":     "prometheus-node-exporter",
			},
		},
		Template: corev1.PodTemplateSpec{
			ObjectMeta: metav1.ObjectMeta{
				Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"},
				Labels: map[string]string{
					"app.kubernetes.io/component":  "metrics",
					"app.kubernetes.io/instance":   "kube-promtheus-stack",
					"app.kubernetes.io/managed-by": "Helm",
					"app.kubernetes.io/name":       "prometheus-node-exporter",
					"app.kubernetes.io/part-of":    "prometheus-node-exporter",
					"app.kubernetes.io/version":    "1.5.0",
					"helm.sh/chart":                "prometheus-node-exporter-4.17.5",
					"jobLabel":                     "node-exporter",
					"release":                      "kube-promtheus-stack",
				},
			},
			Spec: corev1.PodSpec{
				Containers: []corev1.Container{
					{
						Args: []string{
							"--path.procfs=/host/proc",
							"--path.sysfs=/host/sys",
							"--path.rootfs=/host/root",
							"--path.udev.data=/host/root/run/udev/data",
							"--web.listen-address=[$(HOST_IP)]:9100",
							"--collector.filesystem.mount-points-exclude=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/.+)($|/)",
							"--collector.filesystem.fs-types-exclude=^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$",
						},
						Env: []corev1.EnvVar{
							{
								Name:  "HOST_IP",
								Value: "0.0.0.0",
							},
						},
						Image:           "quay.io/prometheus/node-exporter:v1.5.0",
						ImagePullPolicy: corev1.PullPolicy("IfNotPresent"),
						LivenessProbe: &corev1.Probe{
							FailureThreshold: int32(3),
							PeriodSeconds:    int32(10),
							ProbeHandler: corev1.ProbeHandler{
								HTTPGet: &corev1.HTTPGetAction{
									Path:   "/",
									Port:   intstr.IntOrString{IntVal: int32(9100)},
									Scheme: corev1.URIScheme("HTTP"),
								},
							},
							SuccessThreshold: int32(1),
							TimeoutSeconds:   int32(1),
						},
						Name: "node-exporter",
						Ports: []corev1.ContainerPort{
							{
								ContainerPort: int32(9100),
								Name:          "http-metrics",
								Protocol:      corev1.Protocol("TCP"),
							},
						},
						ReadinessProbe: &corev1.Probe{
							FailureThreshold: int32(3),
							PeriodSeconds:    int32(10),
							ProbeHandler: corev1.ProbeHandler{
								HTTPGet: &corev1.HTTPGetAction{
									Path:   "/",
									Port:   intstr.IntOrString{IntVal: int32(9100)},
									Scheme: corev1.URIScheme("HTTP"),
								},
							},
							SuccessThreshold: int32(1),
							TimeoutSeconds:   int32(1),
						},
						SecurityContext: &corev1.SecurityContext{ReadOnlyRootFilesystem: P(true)},
						VolumeMounts: []corev1.VolumeMount{
							{
								MountPath: "/host/proc",
								Name:      "proc",
								ReadOnly:  true,
							}, {
								MountPath: "/host/sys",
								Name:      "sys",
								ReadOnly:  true,
							}, {
								MountPath:        "/host/root",
								MountPropagation: P(corev1.MountPropagationMode("HostToContainer")),
								Name:             "root",
								ReadOnly:         true,
							},
						},
					},
				},
				HostNetwork:  true,
				HostPID:      true,
				NodeSelector: map[string]string{"kubernetes.io/os": "linux"},
				SecurityContext: &corev1.PodSecurityContext{
					FSGroup:      P(int64(65534)),
					RunAsGroup:   P(int64(65534)),
					RunAsNonRoot: P(true),
					RunAsUser:    P(int64(65534)),
				},
				ServiceAccountName: "kube-promtheus-stack-prometheus-node-exporter",
				Tolerations: []corev1.Toleration{
					{
						Effect:   corev1.TaintEffect("NoSchedule"),
						Operator: corev1.TolerationOperator("Exists"),
					},
				},
				Volumes: []corev1.Volume{
					{
						Name:         "proc",
						VolumeSource: corev1.VolumeSource{HostPath: &corev1.HostPathVolumeSource{Path: "/proc"}},
					}, {
						Name:         "sys",
						VolumeSource: corev1.VolumeSource{HostPath: &corev1.HostPathVolumeSource{Path: "/sys"}},
					}, {
						Name:         "root",
						VolumeSource: corev1.VolumeSource{HostPath: &corev1.HostPathVolumeSource{Path: "/"}},
					},
				},
			},
		},
		UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
			RollingUpdate: &appsv1.RollingUpdateDaemonSet{MaxUnavailable: &intstr.IntOrString{IntVal: int32(1)}},
			Type:          appsv1.DaemonSetUpdateStrategyType("RollingUpdate"),
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "apps/v1",
		Kind:       "DaemonSet",
	},
}
