Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use recommended instance label for Prometheus/Alertmanager resources #1520

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions jsonnet/kube-prometheus/components/alertmanager.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local defaults = {
},
commonLabels:: {
'app.kubernetes.io/name': 'alertmanager',
'app.kubernetes.io/instance': defaults.name,
'app.kubernetes.io/version': defaults.version,
'app.kubernetes.io/component': 'alert-router',
'app.kubernetes.io/part-of': 'kube-prometheus',
Expand Down Expand Up @@ -100,9 +101,7 @@ function(params) {
apiVersion: 'v1',
kind: 'Secret',
type: 'Opaque',
metadata: am._metadata {
labels+: { alertmanager: am._config.name },
},
metadata: am._metadata,
stringData: {
'alertmanager.yaml': if std.type(am._config.config) == 'object'
then
Expand All @@ -115,25 +114,19 @@ function(params) {
serviceAccount: {
apiVersion: 'v1',
kind: 'ServiceAccount',
metadata: am._metadata {
labels+: { alertmanager: am._config.name },
},
metadata: am._metadata,
},

service: {
apiVersion: 'v1',
kind: 'Service',
metadata: am._metadata {
labels+: { alertmanager: am._config.name },
},
metadata: am._metadata,
spec: {
ports: [
{ name: 'web', targetPort: 'web', port: 9093 },
{ name: 'reloader-web', port: am._config.reloaderPort, targetPort: 'reloader-web' },
],
selector: am._config.selectorLabels {
alertmanager: am._config.name,
},
selector: am._config.selectorLabels,
sessionAffinity: 'ClientIP',
},
},
Expand All @@ -144,9 +137,7 @@ function(params) {
metadata: am._metadata,
spec: {
selector: {
matchLabels: am._config.selectorLabels {
alertmanager: am._config.name,
},
matchLabels: am._config.selectorLabels,
},
endpoints: [
{ port: 'web', interval: '30s' },
Expand All @@ -162,9 +153,7 @@ function(params) {
spec: {
maxUnavailable: 1,
selector: {
matchLabels: am._config.selectorLabels {
alertmanager: am._config.name,
},
matchLabels: am._config.selectorLabels,
},
},
},
Expand All @@ -174,9 +163,6 @@ function(params) {
kind: 'Alertmanager',
metadata: am._metadata {
name: am._config.name,
labels+: {
alertmanager: am._config.name,
},
},
spec: {
replicas: am._config.replicas,
Expand Down
16 changes: 4 additions & 12 deletions jsonnet/kube-prometheus/components/prometheus.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ local defaults = {
ruleSelector: {},
commonLabels:: {
'app.kubernetes.io/name': 'prometheus',
'app.kubernetes.io/instance': defaults.name,
'app.kubernetes.io/version': defaults.version,
'app.kubernetes.io/component': 'prometheus',
'app.kubernetes.io/part-of': 'kube-prometheus',
Expand All @@ -27,7 +28,7 @@ local defaults = {
[labelName]: defaults.commonLabels[labelName]
for labelName in std.objectFields(defaults.commonLabels)
if !std.setMember(labelName, ['app.kubernetes.io/version'])
} + { prometheus: defaults.name },
},
mixin:: {
ruleLabels: {},
_config: {
Expand Down Expand Up @@ -95,9 +96,7 @@ function(params) {
service: {
apiVersion: 'v1',
kind: 'Service',
metadata: p._metadata {
labels+: { prometheus: p._config.name },
},
metadata: p._metadata,
spec: {
ports: [
{ name: 'web', targetPort: 'web', port: 9090 },
Expand Down Expand Up @@ -239,9 +238,7 @@ function(params) {
spec: {
minAvailable: 1,
selector: {
matchLabels: p._config.selectorLabels {
prometheus: p._config.name,
},
matchLabels: p._config.selectorLabels,
},
},
},
Expand All @@ -251,7 +248,6 @@ function(params) {
kind: 'Prometheus',
metadata: p._metadata {
name: p._config.name,
labels+: { prometheus: p._config.name },
},
spec: {
replicas: p._config.replicas,
Expand Down Expand Up @@ -327,7 +323,6 @@ function(params) {
metadata+: p._metadata {
name: p._metadata.name + '-thanos-sidecar',
labels+: {
prometheus: p._config.name,
'app.kubernetes.io/component': 'thanos-sidecar',
},
},
Expand All @@ -337,7 +332,6 @@ function(params) {
{ name: 'http', port: 10902, targetPort: 10902 },
],
selector: p._config.selectorLabels {
prometheus: p._config.name,
'app.kubernetes.io/component': 'prometheus',
},
clusterIP: 'None',
Expand All @@ -351,15 +345,13 @@ function(params) {
metadata+: p._metadata {
name: 'thanos-sidecar',
labels+: {
prometheus: p._config.name,
'app.kubernetes.io/component': 'thanos-sidecar',
},
},
spec+: {
jobLabel: 'app.kubernetes.io/component',
selector: {
matchLabels: {
prometheus: p._config.name,
'app.kubernetes.io/component': 'thanos-sidecar',
},
},
Expand Down
4 changes: 2 additions & 2 deletions manifests/alertmanager-alertmanager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: monitoring.coreos.com/v1
kind: Alertmanager
metadata:
labels:
alertmanager: main
app.kubernetes.io/component: alert-router
app.kubernetes.io/instance: main
app.kubernetes.io/name: alertmanager
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.23.0
Expand All @@ -15,8 +15,8 @@ spec:
kubernetes.io/os: linux
podMetadata:
labels:
alertmanager: main
app.kubernetes.io/component: alert-router
app.kubernetes.io/instance: main
app.kubernetes.io/name: alertmanager
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.23.0
Expand Down
3 changes: 2 additions & 1 deletion manifests/alertmanager-podDisruptionBudget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: PodDisruptionBudget
metadata:
labels:
app.kubernetes.io/component: alert-router
app.kubernetes.io/instance: main
app.kubernetes.io/name: alertmanager
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.23.0
Expand All @@ -12,7 +13,7 @@ spec:
maxUnavailable: 1
selector:
matchLabels:
alertmanager: main
app.kubernetes.io/component: alert-router
app.kubernetes.io/instance: main
app.kubernetes.io/name: alertmanager
app.kubernetes.io/part-of: kube-prometheus
1 change: 1 addition & 0 deletions manifests/alertmanager-prometheusRule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: PrometheusRule
metadata:
labels:
app.kubernetes.io/component: alert-router
app.kubernetes.io/instance: main
app.kubernetes.io/name: alertmanager
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.23.0
Expand Down
2 changes: 1 addition & 1 deletion manifests/alertmanager-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v1
kind: Secret
metadata:
labels:
alertmanager: main
app.kubernetes.io/component: alert-router
app.kubernetes.io/instance: main
app.kubernetes.io/name: alertmanager
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.23.0
Expand Down
4 changes: 2 additions & 2 deletions manifests/alertmanager-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v1
kind: Service
metadata:
labels:
alertmanager: main
app.kubernetes.io/component: alert-router
app.kubernetes.io/instance: main
app.kubernetes.io/name: alertmanager
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.23.0
Expand All @@ -18,8 +18,8 @@ spec:
port: 8080
targetPort: reloader-web
selector:
alertmanager: main
app.kubernetes.io/component: alert-router
app.kubernetes.io/instance: main
app.kubernetes.io/name: alertmanager
app.kubernetes.io/part-of: kube-prometheus
sessionAffinity: ClientIP
2 changes: 1 addition & 1 deletion manifests/alertmanager-serviceAccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v1
kind: ServiceAccount
metadata:
labels:
alertmanager: main
app.kubernetes.io/component: alert-router
app.kubernetes.io/instance: main
app.kubernetes.io/name: alertmanager
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.23.0
Expand Down
3 changes: 2 additions & 1 deletion manifests/alertmanager-serviceMonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: ServiceMonitor
metadata:
labels:
app.kubernetes.io/component: alert-router
app.kubernetes.io/instance: main
app.kubernetes.io/name: alertmanager
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.23.0
Expand All @@ -16,7 +17,7 @@ spec:
port: reloader-web
selector:
matchLabels:
alertmanager: main
app.kubernetes.io/component: alert-router
app.kubernetes.io/instance: main
app.kubernetes.io/name: alertmanager
app.kubernetes.io/part-of: kube-prometheus
1 change: 1 addition & 0 deletions manifests/prometheus-clusterRole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: ClusterRole
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
Expand Down
1 change: 1 addition & 0 deletions manifests/prometheus-clusterRoleBinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
Expand Down
3 changes: 2 additions & 1 deletion manifests/prometheus-podDisruptionBudget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: PodDisruptionBudget
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
Expand All @@ -13,6 +14,6 @@ spec:
selector:
matchLabels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
prometheus: k8s
4 changes: 2 additions & 2 deletions manifests/prometheus-prometheus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ kind: Prometheus
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
prometheus: k8s
name: k8s
namespace: monitoring
spec:
Expand All @@ -24,10 +24,10 @@ spec:
podMetadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
prometheus: k8s
podMonitorNamespaceSelector: {}
podMonitorSelector: {}
probeNamespaceSelector: {}
Expand Down
1 change: 1 addition & 0 deletions manifests/prometheus-prometheusRule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: PrometheusRule
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
Expand Down
1 change: 1 addition & 0 deletions manifests/prometheus-roleBindingConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: RoleBinding
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
Expand Down
3 changes: 3 additions & 0 deletions manifests/prometheus-roleBindingSpecificNamespaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ items:
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
Expand All @@ -23,6 +24,7 @@ items:
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
Expand All @@ -41,6 +43,7 @@ items:
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
Expand Down
1 change: 1 addition & 0 deletions manifests/prometheus-roleConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: Role
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
Expand Down
3 changes: 3 additions & 0 deletions manifests/prometheus-roleSpecificNamespaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ items:
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
Expand Down Expand Up @@ -42,6 +43,7 @@ items:
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
Expand Down Expand Up @@ -79,6 +81,7 @@ items:
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/instance: k8s
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.31.1
Expand Down
Loading