Skip to content

Commit

Permalink
Merge pull request #366 from jprzychodzen/nodeipam-metrics
Browse files Browse the repository at this point in the history
Add support for nodeipam metrics
  • Loading branch information
k8s-ci-robot authored Sep 2, 2022
2 parents 427c014 + 3b9cc64 commit fe52cf0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ rules:
- serviceaccounts/token
verbs:
- create
- apiGroups:
- authentication.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- ""
resources:
- namespaces
- configmaps
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
Expand Down
Binary file modified cluster/bin/kubectl
Binary file not shown.
2 changes: 2 additions & 0 deletions cluster/gce/gci/configure-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2278,6 +2278,8 @@ function start-cloud-controller-manager {
params+=" --use-service-account-credentials"
params+=" --cloud-provider=gce"
params+=" --kubeconfig=/etc/srv/kubernetes/cloud-controller-manager/kubeconfig"
params+=" --authorization-kubeconfig=/etc/srv/kubernetes/cloud-controller-manager/kubeconfig"
params+=" --authentication-kubeconfig=/etc/srv/kubernetes/cloud-controller-manager/kubeconfig"
if [[ -n "${INSTANCE_PREFIX:-}" ]]; then
params+=" --cluster-name=${INSTANCE_PREFIX}"
fi
Expand Down
3 changes: 2 additions & 1 deletion cluster/gce/manifests/cloud-controller-manager.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"livenessProbe": {
"httpGet": {
"host": "127.0.0.1",
"port": 10253,
"port": 10258,
"scheme": "HTTPS",
"path": "/healthz"
},
"initialDelaySeconds": 15,
Expand Down
2 changes: 1 addition & 1 deletion cmd/cloud-controller-manager/nodeipamcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func startNodeIpamController(ccmConfig *cloudcontrollerconfig.CompletedConfig, n
if err != nil {
return nil, false, err
}
go nodeIpamController.Run(ctx.Stop)
go nodeIpamController.Run(ctx.Stop, ctx.ControllerManagerMetrics)
return nil, true, nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/controller/nodeipam/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ go_library(
"//vendor/k8s.io/client-go/tools/cache",
"//vendor/k8s.io/client-go/tools/record",
"//vendor/k8s.io/cloud-provider",
"//vendor/k8s.io/component-base/metrics/prometheus/controllers",
"//vendor/k8s.io/component-base/metrics/prometheus/ratelimiter",
"//vendor/k8s.io/klog/v2:klog",
],
Expand Down
5 changes: 4 additions & 1 deletion pkg/controller/nodeipam/node_ipam_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
corelisters "k8s.io/client-go/listers/core/v1"
cloudprovider "k8s.io/cloud-provider"
"k8s.io/cloud-provider-gcp/pkg/controller/nodeipam/ipam"
controllersmetrics "k8s.io/component-base/metrics/prometheus/controllers"
"k8s.io/component-base/metrics/prometheus/ratelimiter"
)

Expand Down Expand Up @@ -148,11 +149,13 @@ func NewNodeIpamController(
}

// Run starts an asynchronous loop that monitors the status of cluster nodes.
func (nc *Controller) Run(stopCh <-chan struct{}) {
func (nc *Controller) Run(stopCh <-chan struct{}, controllerManagerMetrics *controllersmetrics.ControllerManagerMetrics) {
defer utilruntime.HandleCrash()

klog.Infof("Starting ipam controller")
defer klog.Infof("Shutting down ipam controller")
controllerManagerMetrics.ControllerStarted("nodeipam")
defer controllerManagerMetrics.ControllerStopped("nodeipam")

if !cache.WaitForNamedCacheSync("node", stopCh, nc.nodeInformerSynced) {
return
Expand Down

0 comments on commit fe52cf0

Please sign in to comment.