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

refactor: prometheus apis #43

Merged
merged 1 commit into from
Oct 13, 2022
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
id: apps/v1:Deployment:prometheus-example-app:prometheus-example-appprod
type: Kubernetes
dependsOn:
- v1:Namespace:prometheus-example-app
attributes:
apiVersion: apps/v1
kind: Deployment
Expand All @@ -8,15 +12,15 @@ attributes:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: prometheus-example-app
app.kubernetes.io/env: prod
app.kubernetes.io/instance: prometheus-example-app-prod
app.kubernetes.io/name: prometheus-example-app
template:
metadata:
labels:
app.kubernetes.io/name: prometheus-example-app
app.kubernetes.io/env: prod
app.kubernetes.io/instance: prometheus-example-app-prod
app.kubernetes.io/name: prometheus-example-app
spec:
containers:
- image: quay.io/brancz/prometheus-example-app:v0.3.0
Expand All @@ -34,36 +38,32 @@ attributes:
cpu: 100m
memory: 100Mi
ephemeral-storage: 1Gi
dependsOn:
- v1:Namespace:prometheus-example-app
id: apps/v1:Deployment:prometheus-example-app:prometheus-example-appprod
type: Kubernetes
---
id: v1:Namespace:prometheus-example-app
type: Kubernetes
attributes:
apiVersion: v1
kind: Namespace
metadata:
name: prometheus-example-app
id: v1:Namespace:prometheus-example-app
type: Kubernetes
---
id: monitoring.coreos.com/v1:PodMonitor:prometheus-example-app:prometheus-example-appprod
type: Kubernetes
attributes:
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
labels:
app.kubernetes.io/name: prometheus-example-app
app.kubernetes.io/env: prod
app.kubernetes.io/instance: prometheus-example-app-prod
app.kubernetes.io/name: prometheus-example-app
name: prometheus-example-appprod
namespace: prometheus-example-app
spec:
podMetricsEndpoints:
- port: web
selector:
matchLabels:
app.kubernetes.io/name: prometheus-example-app
app.kubernetes.io/env: prod
app.kubernetes.io/instance: prometheus-example-app-prod
app.kubernetes.io/name: prometheus-example-app
id: monitoring.coreos.com/v1:PodMonitor:prometheus-example-app:prometheus-example-appprod
type: Kubernetes
4 changes: 2 additions & 2 deletions base/pkg/kusion_prometheus/mixins/pod_monitor_mixin.k
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import base.pkg.kusion_models.kube.protocol
import base.pkg.kusion_prometheus.monitoring
import base.pkg.kusion_prometheus.monitoring.v1 as monitoringv1
import base.pkg.kusion_models.kube.resource

mixin PodMonitorMixin for protocol.ServerProtocol:
if config.enableMonitoring:
kubernetes: resource.ResourceMapping {
PodMonitor = [
monitoring.PodMonitor {
monitoringv1.PodMonitor {
metadata = workloadAttributes.metadata
metadata.labels: workloadAttributes.spec.template.metadata.labels
spec.selector.matchLabels = workloadAttributes.spec.selector.matchLabels
Expand Down
Loading