Skip to content

Commit

Permalink
Self review changes
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Wall <richard.wall@venafi.com>
  • Loading branch information
wallrj committed Jun 28, 2024
1 parent 373564b commit 9a66116
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 10 deletions.
8 changes: 5 additions & 3 deletions cmd/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ type Options struct {
// CMClient is a rest client for interacting with cert-manager resources.
CMClient cmclient.Interface

// The host and port that the metrics endpoint should listen on.
// MetricsBindAddress is the TCP address for exposing HTTP Prometheus metrics
// which will be served on the HTTP path '/metrics'. The value "0" will
// disable exposing metrics.
MetricsBindAddress string
}

Expand Down Expand Up @@ -156,6 +158,6 @@ func (o *Options) addAppFlags(fs *pflag.FlagSet) {
fs.BoolVar(&o.UseTokenRequest, "use-token-request", false,
"Use the empty audience token request for creating CertificateRequests. Requires the token request to be defined on the CSIDriver manifest.")
fs.StringVar(&o.MetricsBindAddress, "metrics-bind-address", "0",
"The host and port that the metrics endpoint should listen on (for example ::9402). "+
"If 0, the metrics server will be disabled. (default).")
"TCP address for exposing HTTP Prometheus metrics which will be served on the HTTP path '/metrics'. "+
`The value "0" will disable exposing metrics.`)
}
2 changes: 1 addition & 1 deletion deploy/charts/csi-driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The TCP port on which the metrics server will listen.
> false
> ```
Create a PodMonitor to add csi-driver to Prometheus.
Create a PodMonitor to add csi-driver to Prometheus if you are using Prometheus Operator. See https://prometheus-operator.dev/docs/operator/api/#monitoring.coreos.com/v1.PodMonitor
#### **metrics.podmonitor.namespace** ~ `string`
The namespace that the pod monitor should live in, defaults to the cert-manager-csi-driver namespace.
Expand Down
2 changes: 1 addition & 1 deletion deploy/charts/csi-driver/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
},
"helm-values.metrics.podmonitor.enabled": {
"default": false,
"description": "Create a PodMonitor to add csi-driver to Prometheus.",
"description": "Create a PodMonitor to add csi-driver to Prometheus if you are using Prometheus Operator. See https://prometheus-operator.dev/docs/operator/api/#monitoring.coreos.com/v1.PodMonitor",
"type": "boolean"
},
"helm-values.metrics.podmonitor.endpointAdditionalProperties": {
Expand Down
3 changes: 2 additions & 1 deletion deploy/charts/csi-driver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ metrics:
# The TCP port on which the metrics server will listen.
port: 9402
podmonitor:
# Create a PodMonitor to add csi-driver to Prometheus.
# Create a PodMonitor to add csi-driver to Prometheus if you are using Prometheus Operator.
# See https://prometheus-operator.dev/docs/operator/api/#monitoring.coreos.com/v1.PodMonitor
enabled: false

# The namespace that the pod monitor should live in, defaults
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/go-logr/logr v1.4.2
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
github.com/prometheus/client_golang v1.18.0
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
Expand Down Expand Up @@ -75,6 +74,7 @@ require (
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.46.0 // indirect
github.com/prometheus/procfs v0.15.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions make/test-e2e.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ e2e-setup-cert-manager: | kind-cluster $(NEEDS_HELM) $(NEEDS_KUBECTL)
--set startupapicheck.image.repository=$(quay.io/jetstack/cert-manager-startupapicheck.REPO) \
--set startupapicheck.image.tag=$(quay.io/jetstack/cert-manager-startupapicheck.TAG) \
--set startupapicheck.image.pullPolicy=Never \
--set prometheus.podmonitor.enabled=true \
cert-manager cert-manager >/dev/null

# The "install" target can be run on its own with any currently active cluster,
Expand All @@ -47,7 +46,6 @@ endif

test-e2e-deps: INSTALL_OPTIONS :=
test-e2e-deps: INSTALL_OPTIONS += --set image.repository=$(oci_manager_image_name_development)
test-e2e-deps: INSTALL_OPTIONS += --set metrics.podmonitor.enabled=true
test-e2e-deps: e2e-setup-cert-manager
test-e2e-deps: install

Expand Down
18 changes: 17 additions & 1 deletion test/e2e/suite/cases/metrics.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2021 The cert-manager 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 cases

import (
Expand All @@ -17,7 +33,7 @@ const (
var _ = framework.CasesDescribe("Metrics", func() {
f := framework.NewDefaultFramework("metrics")

FIt("Should serve Go and process metrics on port 9402", func() {
It("Should serve Go and process metrics on port 9402", func() {
By("Discovering the name of the csi-driver Pod")
pods, err := f.KubeClientSet.CoreV1().Pods(certManagerNamespace).List(context.TODO(), metav1.ListOptions{
LabelSelector: "app.kubernetes.io/instance=csi-driver",
Expand Down

0 comments on commit 9a66116

Please sign in to comment.