Skip to content

Commit 1f3c964

Browse files
authored
Merge pull request #18 from bswartz/metrics
Add metrics support
2 parents 5347d79 + cacde4d commit 1f3c964

File tree

205 files changed

+37422
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+37422
-474
lines changed

example/hello-populator/deploy.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ spec:
6666
args:
6767
- --mode=controller
6868
- --image-name=k8s.gcr.io/sig-storage/hello-populator:v0.1.0
69+
- --http-endpoint=:8080
70+
ports:
71+
- containerPort: 8080
72+
name: http-endpoint
73+
protocol: TCP
6974
---
7075
kind: VolumePopulator
7176
apiVersion: populator.storage.k8s.io/v1alpha1

example/hello-populator/main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ import (
2222
"os"
2323
"strings"
2424

25-
populator_machinery "github.com/kubernetes-csi/lib-volume-populator/populator-machinery"
2625
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2726
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2827
"k8s.io/apimachinery/pkg/runtime"
2928
"k8s.io/apimachinery/pkg/runtime/schema"
3029
"k8s.io/klog/v2"
30+
31+
populator_machinery "github.com/kubernetes-csi/lib-volume-populator/populator-machinery"
3132
)
3233

3334
const (
@@ -43,6 +44,8 @@ func main() {
4344
mode string
4445
fileName string
4546
fileContents string
47+
httpEndpoint string
48+
metricsPath string
4649
masterURL string
4750
kubeconfig string
4851
imageName string
@@ -58,6 +61,10 @@ func main() {
5861
flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
5962
flag.StringVar(&masterURL, "master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
6063
flag.StringVar(&imageName, "image-name", "", "Image to use for populating")
64+
// Metrics args
65+
flag.StringVar(&httpEndpoint, "http-endpoint", "", "The TCP network address where the HTTP server for diagnostics, including metrics and leader election health check, will listen (example: `:8080`). The default is empty string, which means the server is disabled.")
66+
flag.StringVar(&metricsPath, "metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`.")
67+
// Other args
6168
flag.BoolVar(&showVersion, "version", false, "display the version string")
6269
flag.StringVar(&namespace, "namespace", "hello", "Namespace to deploy controller")
6370
flag.Parse()
@@ -79,7 +86,7 @@ func main() {
7986
gk = schema.GroupKind{Group: groupName, Kind: kind}
8087
gvr = schema.GroupVersionResource{Group: groupName, Version: apiVersion, Resource: resource}
8188
)
82-
populator_machinery.RunController(masterURL, kubeconfig, imageName,
89+
populator_machinery.RunController(masterURL, kubeconfig, imageName, httpEndpoint, metricsPath,
8390
namespace, prefix, gk, gvr, mountPath, devicePath, getPopulatorPodArgs)
8491
case "populate":
8592
populate(fileName, fileContents)

go.mod

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,50 @@
11
module github.com/kubernetes-csi/lib-volume-populator
22

3-
go 1.16
3+
go 1.17
44

55
require (
6-
k8s.io/api v0.23.4
7-
k8s.io/apimachinery v0.23.4
8-
k8s.io/client-go v0.23.4
6+
github.com/prometheus/client_model v0.2.0
7+
github.com/prometheus/common v0.28.0
8+
k8s.io/api v0.23.5
9+
k8s.io/apimachinery v0.23.5
10+
k8s.io/client-go v0.23.5
11+
k8s.io/component-base v0.23.5
912
k8s.io/klog/v2 v2.30.0
1013
)
14+
15+
require (
16+
github.com/beorn7/perks v1.0.1 // indirect
17+
github.com/blang/semver v3.5.1+incompatible // indirect
18+
github.com/cespare/xxhash/v2 v2.1.1 // indirect
19+
github.com/davecgh/go-spew v1.1.1 // indirect
20+
github.com/go-logr/logr v1.2.0 // indirect
21+
github.com/gogo/protobuf v1.3.2 // indirect
22+
github.com/golang/protobuf v1.5.2 // indirect
23+
github.com/google/go-cmp v0.5.5 // indirect
24+
github.com/google/gofuzz v1.1.0 // indirect
25+
github.com/googleapis/gnostic v0.5.5 // indirect
26+
github.com/imdario/mergo v0.3.5 // indirect
27+
github.com/json-iterator/go v1.1.12 // indirect
28+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
29+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
30+
github.com/modern-go/reflect2 v1.0.2 // indirect
31+
github.com/prometheus/client_golang v1.11.0 // indirect
32+
github.com/prometheus/procfs v0.6.0 // indirect
33+
github.com/spf13/pflag v1.0.5 // indirect
34+
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
35+
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
36+
golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e // indirect
37+
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
38+
golang.org/x/text v0.3.7 // indirect
39+
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
40+
google.golang.org/appengine v1.6.7 // indirect
41+
google.golang.org/protobuf v1.27.1 // indirect
42+
gopkg.in/inf.v0 v0.9.1 // indirect
43+
gopkg.in/yaml.v2 v2.4.0 // indirect
44+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
45+
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
46+
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
47+
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
48+
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
49+
sigs.k8s.io/yaml v1.2.0 // indirect
50+
)

0 commit comments

Comments
 (0)