Skip to content

Commit

Permalink
Requirements for Prometheus
Browse files Browse the repository at this point in the history
Add a label to the ServiceMonitor resource that will be common across all
DWS and NNF repos so we easily tell Prometheus which ones it should select.

Copy the namespace value into config/prometheus so that part of config/ can
be deployed on its own.

Add a ClusterRoleBinding that can be used by a metrics reader process to
debug the metrics endpoing of the controller.  The ClusterRole is already
being installed, and the ServiceAccount is already installed.

Update the deploy.sh script to determine whether or not the ServiceMonitor
resource can be applied.

Signed-off-by: Dean Roehrich <[email protected]>
  • Loading branch information
roehrich-hpe committed Nov 6, 2023
1 parent 66e6f08 commit 536c6d3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/prometheus/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Adds namespace to all resources.
namespace: nnf-dm-system

resources:
- monitor.yaml
1 change: 1 addition & 0 deletions config/prometheus/monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ kind: ServiceMonitor
metadata:
labels:
control-plane: controller-manager
prometheus-app: rabbit-nnf
name: controller-manager-metrics-monitor
namespace: system
spec:
Expand Down
12 changes: 12 additions & 0 deletions config/rbac/auth_proxy_client_clusterrole_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: metrics-reader-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: metrics-reader
subjects:
- kind: ServiceAccount
name: controller-manager
namespace: system
1 change: 1 addition & 0 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ resources:
- auth_proxy_role.yaml
- auth_proxy_role_binding.yaml
- auth_proxy_client_clusterrole.yaml
- auth_proxy_client_clusterrole_binding.yaml

configurations:
- kustomizeconfig.yaml
7 changes: 7 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ deploy)
$KUSTOMIZE build $OVERLAY_DIR | kubectl apply -f -
break
done

# Deploy the ServiceMonitor resource if its CRD is found. The CRD would
# have been installed by a metrics service such as Prometheus.
if kubectl get crd servicemonitors.monitoring.coreos.com > /dev/null 2>&1; then
$KUSTOMIZE build config/prometheus | kubectl apply -f-
fi
;;
undeploy)
$KUSTOMIZE build config/prometheus | kubectl delete --ignore-not-found -f-
# When the DataMovementManager CRD gets deleted all related resource are also
# removed, so the delete will always fail. We ignore all errors at our
# own risk.
Expand Down

0 comments on commit 536c6d3

Please sign in to comment.