Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSSM-3374 Add servicemesh_members metric #1119

Open
wants to merge 18 commits into
base: maistra-2.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build/generate-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if [[ ${COMMUNITY} == "true" ]]; then
OLM_FEATURES="[]"
ARCHITECTURE_LABELS=$(generateArchitectureLabels amd64)
OLM_SUBSCRIPTION_ANNOTATION=""
OLM_CLUSTER_MONITORING=""
else
BUILD_TYPE="servicemesh"
JAEGER_STORAGE="Memory"
Expand All @@ -37,6 +38,7 @@ else
OLM_FEATURES="[\"Disconnected\",\"fips\"]"
ARCHITECTURE_LABELS=$(generateArchitectureLabels amd64 s390x ppc64le arm64)
OLM_SUBSCRIPTION_ANNOTATION="operators.openshift.io/valid-subscription: '[\"OpenShift Container Platform\", \"OpenShift Platform Plus\"]'"
OLM_CLUSTER_MONITORING="operatorframework.io/cluster-monitoring: \"true\""
fi
: "${DEPLOYMENT_FILE:=deploy/${BUILD_TYPE}-operator.yaml}"
: "${MANIFESTS_DIR:=manifests-${BUILD_TYPE}}"
Expand Down Expand Up @@ -115,6 +117,7 @@ $RELATED_IMAGES"
sed -i -e 's+__BUG_URL__+'"$BUG_URL"'+' "${csv_path}"
sed -i -e 's+__OLM_FEATURES__+'"$OLM_FEATURES"'+' "${csv_path}"
sed -i -e 's+__OLM_SUBSCRIPTION_ANNOTATION__+'"$OLM_SUBSCRIPTION_ANNOTATION"'+' "${csv_path}"
sed -i -e 's+__OLM_CLUSTER_MONITORING__+'"$OLM_CLUSTER_MONITORING"'+' "${csv_path}"
sed -i -e 's/__JAEGER_STORAGE__/'${JAEGER_STORAGE}'/' "${csv_path}"
sed -i -e 's/__DATE__/'"$(date +%Y-%m-%dT%H:%M:%S%Z)"'/g' "${csv_path}"
sed -i -e 's+__IMAGE_SRC__+'"${IMAGE_SRC}"'+g' "${csv_path}"
Expand Down
1 change: 1 addition & 0 deletions build/manifest-templates/clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ metadata:
createdAt: __DATE__
support: Red Hat, Inc.
olm.skipRange: ">=1.0.2 <__SEMANTIC_VERSION__"
__OLM_CLUSTER_MONITORING__
operators.openshift.io/infrastructure-features: '__OLM_FEATURES__'
__OLM_SUBSCRIPTION_ANNOTATION__
alm-examples: |-
Expand Down
4 changes: 4 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
maistrav2 "github.com/maistra/istio-operator/pkg/apis/maistra/v2"
"github.com/maistra/istio-operator/pkg/controller"
"github.com/maistra/istio-operator/pkg/controller/common"
"github.com/maistra/istio-operator/pkg/internalmetrics"
"github.com/maistra/istio-operator/pkg/version"
)

Expand Down Expand Up @@ -246,6 +247,9 @@ func addMetrics(ctx context.Context, cfg *rest.Config) {
log.Info("Install prometheus-operator in your cluster to create ServiceMonitor objects", "error", err.Error())
}
}

// Prepare our custom metrics so Prometheus can scrape them
internalmetrics.RegisterMetrics()
}

func intOrStringFromInt32(val int32) intstr.IntOrString {
Expand Down
40 changes: 40 additions & 0 deletions deploy/maistra-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10642,6 +10642,7 @@ rules:
- monitoring.coreos.com
resources:
- servicemonitors
- prometheusrules
verbs:
- get
- create
Expand Down Expand Up @@ -10893,6 +10894,45 @@ roleRef:
name: istio-operator
apiGroup: rbac.authorization.k8s.io

# required for sending metrics to telemetry
---

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: prometheus
rules:
- apiGroups:
- ""
resources:
- pods
- services
- endpoints
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: prometheus
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: prometheus
subjects:
- kind: ServiceAccount
name: prometheus-k8s
namespace: openshift-monitoring
---

apiVersion: v1
Expand Down
40 changes: 40 additions & 0 deletions deploy/servicemesh-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10642,6 +10642,7 @@ rules:
- monitoring.coreos.com
resources:
- servicemonitors
- prometheusrules
verbs:
- get
- create
Expand Down Expand Up @@ -10893,6 +10894,45 @@ roleRef:
name: istio-operator
apiGroup: rbac.authorization.k8s.io

# required for sending metrics to telemetry
---

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: prometheus
rules:
- apiGroups:
- ""
resources:
- pods
- services
- endpoints
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: prometheus
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: prometheus
subjects:
- kind: ServiceAccount
name: prometheus-k8s
namespace: openshift-monitoring
---

apiVersion: v1
Expand Down
41 changes: 41 additions & 0 deletions deploy/src/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ rules:
- monitoring.coreos.com
resources:
- servicemonitors
- prometheusrules
verbs:
- get
- create
Expand Down Expand Up @@ -283,3 +284,43 @@ roleRef:
kind: ClusterRole
name: istio-operator
apiGroup: rbac.authorization.k8s.io

# required for sending metrics to telemetry
---

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: prometheus
rules:
- apiGroups:
- ""
resources:
- pods
- services
- endpoints
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: prometheus
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: prometheus
subjects:
- kind: ServiceAccount
name: prometheus-k8s
namespace: openshift-monitoring
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ require (
github.com/Masterminds/semver v1.5.0
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/containerd/typeurl v0.0.0-20190228175220-2a93cfde8c20 // indirect
github.com/coreos/prometheus-operator v0.38.1-0.20200424145508-7e176fda06cc
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect
github.com/emicklei/go-restful v2.11.1+incompatible // indirect
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/go-logr/logr v0.2.1
github.com/goccy/go-yaml v1.8.8
github.com/google/go-cmp v0.5.2
github.com/google/go-cmp v0.5.8
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.1.0
github.com/magiconair/properties v1.8.1
Expand All @@ -23,6 +24,7 @@ require (
github.com/openshift/library-go v0.0.0-20200214084717-e77ad9dd8ebd
github.com/operator-framework/operator-sdk v0.18.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.10.0
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.0
Expand Down
Loading