Skip to content

Commit

Permalink
Requirements for Prometheus (#236)
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 can 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 endpoint 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 authored Nov 6, 2023
1 parent 621786e commit ff88eaf
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-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 @@ -56,9 +56,16 @@ if [[ $CMD == 'deploy' ]]; then
kubectl get crds nnfportmanagers.nnf.cray.hpe.com && break
done
$KUSTOMIZE build config/ports| kubectl apply --server-side=true --force-conflicts -f -

# 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
fi

if [[ $CMD == 'undeploy' ]]; then
$KUSTOMIZE build config/prometheus | kubectl delete --ignore-not-found -f-
$KUSTOMIZE build config/ports | kubectl delete --ignore-not-found -f -
$KUSTOMIZE build $OVERLAY_EXAMPLES_DIR | kubectl delete --ignore-not-found -f -
$KUSTOMIZE build $OVERLAY_DIR | kubectl delete --ignore-not-found -f -
Expand Down

0 comments on commit ff88eaf

Please sign in to comment.