-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Francesco Cheinasso <cheinasso.francesco@gmail.com>
- Loading branch information
1 parent
1a9ff8e
commit 4efc2ed
Showing
13 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
22 changes: 22 additions & 0 deletions
22
deployments/liqo/templates/liqo-virtualkubelet-podmonitor.yaml
This file contains 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 @@ | ||
{{- $kubeletMetricsConfig := (merge (dict "name" "virtual-kubelet" "module" "virtual-kubelet") .) -}} | ||
{{- if .Values.virtualKubelet.metrics.podMonitor.enabled }} | ||
|
||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PodMonitor | ||
metadata: | ||
name: {{ include "liqo.prefixedName" $kubeletMetricsConfig }} | ||
labels: | ||
{{- include "liqo.labels" $kubeletMetricsConfig | nindent 4 }} | ||
spec: | ||
namespaceSelector: | ||
any: true | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: "virtual-kubelet" | ||
app.kubernetes.io/component: "virtual-kubelet" | ||
podMetricsEndpoints: | ||
- port: metrics | ||
interval: {{ .Values.virtualKubelet.metrics.podMonitor.interval }} | ||
scrapeTimeout: {{ .Values.virtualKubelet.metrics.podMonitor.scrapeTimeout }} | ||
{{- end }} | ||
|
This file contains 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 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 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 @@ | ||
// Copyright 2019-2023 The Liqo Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package metrics provides a set of metrics for Virtual Kubelet component. | ||
package metrics |
This file contains 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,84 @@ | ||
// Copyright 2019-2023 The Liqo Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package metrics | ||
|
||
import ( | ||
"net/http" | ||
"os" | ||
"time" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promhttp" | ||
"k8s.io/klog/v2" | ||
) | ||
|
||
const ( | ||
// MetricsPort is the metrics port constant. | ||
MetricsPort = ":9090" | ||
) | ||
|
||
var ( | ||
// ErrorsCounter is the counter of the errors occurred during the reflection. | ||
ErrorsCounter *prometheus.CounterVec | ||
// ItemsCounter is the counter of the reflected resources. | ||
// A fast increase of this metric can indicate a race condition between local and remote operators. | ||
ItemsCounter *prometheus.CounterVec | ||
) | ||
|
||
// Init initializes the metrics. If no error occurs or no item is processed, the corresponding metric is not exported. | ||
func init() { | ||
var MetricsLabels = []string{"namespace", "reflector_resource"} | ||
|
||
ErrorsCounter = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "liqo_virtual_kubelet_reflection_error_counter", | ||
Help: "The counter of the transient errors.", | ||
}, | ||
MetricsLabels, | ||
) | ||
|
||
ItemsCounter = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "liqo_virtual_kubelet_reflection_item_counter", | ||
Help: "The counter of the reflected resources. A fast increase of this metric can indicate a race condition between local and remote operators.", | ||
}, | ||
MetricsLabels, | ||
) | ||
} | ||
|
||
// SetupMetricHandler sets up the metric handler. | ||
func SetupMetricHandler() { | ||
// Register the metrics to the prometheus registry. | ||
prometheus.MustRegister(ErrorsCounter) | ||
// Register the metrics to the prometheus registry. | ||
prometheus.MustRegister(ItemsCounter) | ||
|
||
http.Handle("/metrics", promhttp.Handler()) | ||
|
||
go func() { | ||
klog.Infof("Starting the virtual kubelet Metric Handler listening on %q", MetricsPort) | ||
|
||
server := &http.Server{ | ||
Addr: ":1234", | ||
ReadHeaderTimeout: 10 * time.Second, | ||
} | ||
|
||
// Key and certificate paths are not specified, since already configured as part of the TLSConfig. | ||
if err := server.ListenAndServe(); err != nil { | ||
klog.Errorf("Failed to start the Metric Handler: %v", err) | ||
os.Exit(1) | ||
} | ||
}() | ||
} |
This file contains 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 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 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