-
-
Notifications
You must be signed in to change notification settings - Fork 44
feat: metrics support for llmaz #316
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8902311
fix miss metrics endpoint bind
googs1025 c594f5c
fix metrics-monitor.yaml
googs1025 7eba587
Update the prometheus config
kerthcet 9b5dc6c
add miss port in chart/templates/deployment.yaml
googs1025 b6cd36a
fix ClusterRoleBinding roleRef name, llmaz -> prometheus
googs1025 5b20676
add prometheus operator install docs
googs1025 f7436d3
Fix prometheus could not fetch metrics
kerthcet 1358a66
Update
kerthcet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -285,6 +285,14 @@ envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. | |
| $(ENVTEST): $(LOCALBIN) | ||
| test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest | ||
|
|
||
| .PHONY: install-prometheus | ||
| install-prometheus: | ||
| kubectl apply --server-side -k config/prometheus | ||
|
|
||
| .PHONY: uninstall-prometheus | ||
| uninstall-prometheus: | ||
| kubectl delete -k config/prometheus | ||
|
|
||
| ##@Release | ||
|
|
||
| .PHONY: artifacts | ||
|
|
@@ -300,7 +308,7 @@ HELMIFY ?= $(LOCALBIN)/helmify | |
| .PHONY: helmify | ||
| helmify: $(HELMIFY) ## Download helmify locally if necessary. | ||
| $(HELMIFY): $(LOCALBIN) | ||
| test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/[email protected].17 | ||
| test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/[email protected].18 | ||
|
|
||
| .PHONY: helm | ||
| helm: manifests kustomize helmify | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| {{- if .Values.prometheus.enable }} | ||
| {{- if not (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1/ServiceMonitor") }} | ||
| {{- fail "The cluster does not support the required API resource `monitoring.coreos.com/v1/ServiceMonitor`." }} | ||
| {{- end }} | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: Prometheus | ||
| metadata: | ||
| name: {{ include "chart.fullname" . }}-prometheus | ||
| spec: | ||
| serviceAccountName: {{ include "chart.fullname" . }}-prometheus | ||
| # Associated ServiceMonitor selector | ||
| serviceMonitorSelector: | ||
| # Need to match the label in ServiceMonitor | ||
| # https://github.com/kubernetes-sigs/jobset/blob/main/config/components/prometheus/monitor.yaml#L7 | ||
| matchLabels: | ||
| control-plane: controller-manager | ||
| {{- include "chart.selectorLabels" . | nindent 4 }} | ||
| resources: | ||
| requests: | ||
| memory: 400Mi | ||
| enableAdminAPI: false | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| {{- if .Values.prometheus.enable }} | ||
| {{- if not (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1/ServiceMonitor") }} | ||
| {{- fail "The cluster does not support the required API resource `monitoring.coreos.com/v1/ServiceMonitor`." }} | ||
| {{- end }} | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: ServiceMonitor | ||
| metadata: | ||
| name: {{ include "chart.fullname" . }}-controller-manager-metrics-monitor | ||
| labels: | ||
| app.kubernetes.io/component: metrics | ||
| app.kubernetes.io/created-by: llmaz | ||
| app.kubernetes.io/part-of: llmaz | ||
| control-plane: controller-manager | ||
| {{- include "chart.selectorLabels" . | nindent 4 }} | ||
| spec: | ||
| endpoints: | ||
| - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token | ||
| path: /metrics | ||
| port: https | ||
| scheme: https | ||
| tlsConfig: | ||
| insecureSkipVerify: true | ||
| selector: | ||
| matchLabels: | ||
| control-plane: controller-manager | ||
| {{- include "chart.selectorLabels" . | nindent 4 }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| {{- if .Values.prometheus.enable }} | ||
| {{- if not (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1/ServiceMonitor") }} | ||
| {{- fail "The cluster does not support the required API resource `monitoring.coreos.com/v1/ServiceMonitor`." }} | ||
| {{- end }} | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| name: {{ include "chart.fullname" . }}-prometheus | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: {{ include "chart.fullname" . }}-prometheus | ||
| rules: | ||
| - apiGroups: [""] | ||
| resources: | ||
| - nodes | ||
| - nodes/metrics | ||
| - services | ||
| - endpoints | ||
| - pods | ||
| verbs: ["get", "list", "watch"] | ||
| - apiGroups: [""] | ||
| resources: | ||
| - configmaps | ||
| verbs: ["get"] | ||
| - nonResourceURLs: ["/metrics"] | ||
| verbs: ["get"] | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: {{ include "chart.fullname" . }}-prometheus | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: {{ include "chart.fullname" . }}-prometheus | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ include "chart.fullname" . }}-prometheus | ||
| namespace: llmaz-system | ||
| {{- end }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,7 @@ | ||
| namespace: llmaz-system | ||
| namePrefix: llmaz- | ||
|
|
||
| resources: | ||
| - monitor.yaml | ||
| - prometheus.yaml | ||
| - serviceaccount.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: Prometheus | ||
| metadata: | ||
| name: prometheus | ||
| namespace: system | ||
| spec: | ||
| serviceAccountName: llmaz-prometheus | ||
| # Associated ServiceMonitor selector | ||
| serviceMonitorSelector: | ||
| # Need to match the label in ServiceMonitor | ||
| matchLabels: | ||
| control-plane: controller-manager | ||
| resources: | ||
| requests: | ||
| memory: 400Mi | ||
| enableAdminAPI: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| name: prometheus | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: prometheus | ||
| rules: | ||
| - apiGroups: [""] | ||
| resources: | ||
| - nodes | ||
| - nodes/metrics | ||
| - services | ||
| - endpoints | ||
| - pods | ||
| verbs: ["get", "list", "watch"] | ||
| - apiGroups: [""] | ||
| resources: | ||
| - configmaps | ||
| verbs: ["get"] | ||
| - nonResourceURLs: ["/metrics"] | ||
| verbs: ["get"] | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: prometheus | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: prometheus | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: prometheus | ||
| namespace: llmaz-system |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Install Prometheus Operator Guide | ||
|
|
||
| Currently, llmaz has already integrated metrics. This document provides deployment steps explaining how to install and configure Prometheus Operator in a Kubernetes cluster. | ||
|
|
||
| ### Install the prometheus operator | ||
|
|
||
| Please follow the [documentation](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/getting-started/installation.md) to install | ||
|
|
||
| ```bash | ||
| # Installing the prometheus operator | ||
| root@VM-0-5-ubuntu:/home/ubuntu# kubectl get pods | ||
| NAME READY STATUS RESTARTS AGE | ||
| prometheus-operator-55b5c96cf8-jl2nx 1/1 Running 0 12s | ||
| ``` | ||
| Ensure that the Prometheus Operator Pod is running successfully. | ||
|
|
||
| ### Install the ServiceMonitor CR for llmaz | ||
|
|
||
| To enable monitoring for the llmaz system, you need to install the ServiceMonitor custom resource (CR). | ||
| You can either modify the Helm chart prometheus according to the [documentation](./../../chart/values.global.yaml) or use `make install-prometheus` in Makefile. | ||
|
|
||
| - Using Helm Chart: to modify the values.global.yaml | ||
| ```yaml | ||
| prometheus: | ||
| # -- Whether to enable Prometheus metrics exporting. | ||
| enable: true | ||
| ``` | ||
| - Using Makefile Command: `make install-prometheus ` | ||
| ```bash | ||
| root@VM-0-5-ubuntu:/home/ubuntu/llmaz# make install-prometheus | ||
| kubectl apply --server-side -k config/prometheus | ||
| serviceaccount/llmaz-prometheus serverside-applied | ||
| clusterrole.rbac.authorization.k8s.io/llmaz-prometheus serverside-applied | ||
| clusterrolebinding.rbac.authorization.k8s.io/llmaz-prometheus serverside-applied | ||
| prometheus.monitoring.coreos.com/llmaz-prometheus serverside-applied | ||
| servicemonitor.monitoring.coreos.com/llmaz-controller-manager-metrics-monitor serverside-applied | ||
| ``` | ||
|
|
||
| ### Check Related Resources | ||
|
|
||
| Verify that the necessary resources have been created: | ||
|
|
||
| - ServiceMonitor | ||
| ```bash | ||
| root@VM-0-5-ubuntu:/home/ubuntu/llmaz# kubectl get ServiceMonitor -n llmaz-system | ||
| NAME AGE | ||
| llmaz-controller-manager-metrics-monitor 59s | ||
| ``` | ||
| - Prometheus Pods | ||
| ```bash | ||
| root@VM-0-5-ubuntu:/home/ubuntu/llmaz# kubectl get pods -n llmaz-system | ||
| NAME READY STATUS RESTARTS AGE | ||
| llmaz-controller-manager-7ff8f7d9bd-vztls 2/2 Running 0 28s | ||
| prometheus-llmaz-prometheus-0 2/2 Running 0 27s | ||
| ``` | ||
| - Services | ||
| ```bash | ||
| root@VM-0-5-ubuntu:/home/ubuntu/llmaz# kubectl get svc -n llmaz-system | ||
| NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE | ||
| llmaz-controller-manager-metrics-service ClusterIP 10.96.79.226 <none> 8443/TCP 46s | ||
| llmaz-webhook-service ClusterIP 10.96.249.226 <none> 443/TCP 46s | ||
| prometheus-operated ClusterIP None <none> 9090/TCP 45s | ||
| ``` | ||
|
|
||
| ### View metrics using the prometheus UI | ||
| Use port forwarding to access the Prometheus UI from your local machine: | ||
|
|
||
| ```bash | ||
| root@VM-0-5-ubuntu:/home/ubuntu# kubectl port-forward services/prometheus-operated 9090:9090 --address 0.0.0.0 -n llmaz-system | ||
| Forwarding from 0.0.0.0:9090 -> 9090 | ||
| ``` | ||
|
|
||
| If using kind, we can use port-forward, `kubectl port-forward services/prometheus-operated 39090:9090 --address 0.0.0.0 -n llmaz-system` | ||
| This allows us to access prometheus using a browser: `http://localhost:9090/query` | ||
|
|
||
|  |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.