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

added x-metrics pod monitor #8

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e79781a
added x-metrics pod monitor
humoflife Oct 31, 2023
97c6a6e
feat(podmonitors): change pod monitors to operators namespace and add…
haarchri Nov 1, 2023
ab39fc9
Merge pull request #9 from upbound/feature/streamline-podmonitors
humoflife Nov 1, 2023
e75584e
xmetrics dashboard checkpoint checkin
humoflife Nov 2, 2023
80c294a
variable setup for top level dashboard
humoflife Nov 3, 2023
798f785
dashboard updates
humoflife Nov 3, 2023
91b73ff
added dashboard panels
humoflife Nov 4, 2023
96db29f
added new line to yaml
humoflife Nov 4, 2023
ec5c873
moved patch for deterministic dashboard creation
humoflife Nov 6, 2023
9c1e7ed
Merge pull request #11 from upbound/fix/dashboard-creation
humoflife Nov 6, 2023
7be5310
moved patch for deterministic dashboard creation
humoflife Nov 6, 2023
aca5877
dashboard update
humoflife Nov 6, 2023
09c9e68
Merge pull request #10 from upbound/feature/x-metrics-dashboard
haarchri Nov 6, 2023
884713b
added x-metrics pod monitor
humoflife Oct 31, 2023
aa7502e
Merge branch 'x-metrics' of github.com:upbound/configuration-observab…
humoflife Nov 7, 2023
dab3b01
added usage
humoflife Nov 7, 2023
86ed1a4
x-metrics port name is metrics
humoflife Nov 7, 2023
f16fb4e
added x-metrics install
humoflife Nov 7, 2023
b68c396
updated Makefile
humoflife Nov 8, 2023
7d199f6
updated README.md and moved dashboards
humoflife Nov 8, 2023
ac0453e
updated README.md
humoflife Nov 8, 2023
9ba87a6
updated Makefile
Nov 14, 2023
10b18ff
added usage
humoflife Nov 7, 2023
e980050
x-metrics port name is metrics
humoflife Nov 7, 2023
8be1e6a
added x-metrics install
humoflife Nov 7, 2023
d235260
updated Makefile
humoflife Nov 8, 2023
1a9e312
updated README.md and moved dashboards
humoflife Nov 8, 2023
554b2c6
updated README.md
humoflife Nov 8, 2023
b692476
updated Makefile
Nov 14, 2023
8fb5789
Merge branch 'x-metrics' of github.com:upbound/configuration-observab…
Nov 14, 2023
658dde8
replaced generic metrics example with smaller scoped ones
Nov 15, 2023
7cb4f68
added make cluster option and updated README disclaimers
Nov 15, 2023
a4dc317
updated README.md
Nov 15, 2023
f5b61c3
replace disclaimer with note
Nov 15, 2023
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
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ PLATFORMS ?= linux_amd64
UP_VERSION = v0.21.0
UP_CHANNEL = stable
UPTEST_VERSION = v0.6.1
UXP_INSTALL_OPTS = "--unstable"
UXP_VERSION = 1.14.0-up.1.rc.2"

-include build/makelib/k8s_tools.mk
# ====================================================================================
Expand All @@ -34,6 +36,7 @@ XPKGS = $(PROJECT_NAME)

CROSSPLANE_NAMESPACE = upbound-system
CROSSPLANE_ARGS = "--enable-usages"
KIND_CLUSTER_NAME = "crossplane-local-dev"
-include build/makelib/local.xpkg.mk
-include build/makelib/controlplane.mk

Expand Down Expand Up @@ -69,11 +72,13 @@ build.init: $(UP)
# You can check the basic implementation here: https://github.com/upbound/uptest/blob/main/internal/templates/01-delete.yaml.tmpl.
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
@$(INFO) running automated tests
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e examples/folder-grafana.yaml,examples/dashboard-grafana-crossplane-health.yaml,examples/dashboard-grafana-crossplane-mr.yaml,examples/dashboard-grafana-crossplane-resources-ttr.yaml,examples/dashboard-grafana-crossplane-sli-metrics.yaml,examples/oss.yaml --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL)
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e examples/dashboards/folder-grafana.yaml,examples/dashboards/dashboard-grafana-crossplane-health.yaml,examples/dashboards/dashboard-grafana-crossplane-mr.yaml,examples/dashboards/dashboard-grafana-crossplane-resources-ttr.yaml,examples/dashboards/dashboard-grafana-crossplane-sli-metrics.yaml,examples/dashboards/dashboard-grafana-crossplane-top-level.yaml,examples/dashboards/dashboard-grafana-crossplane-xmetrics.yaml,examples/oss.yaml --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL)
@$(OK) running automated tests

# This target requires the following environment variables to be set:
# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat ~/.aws/credentials)
e2e: build controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME) uptest

cluster: build controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME)

.PHONY: uptest e2e
78 changes: 51 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,67 @@ with open source software integrations such as Prometheus and Grafana.
Observability is a measure of how well platform performance can be inferred
from knowledge of its metrics, logs and traces outputs.

## Note: Happily Operational Management Cluster
This configuration provides useful insights into the
health of Crossplane and its providers. To do so,
it installs 3rd party open source software as part of
its package. This software includes Prometheus and Grafana.
Both are tunable to accomodate the arbitrary scale that
may be needed based on the amount of resources for which
metrics are collected and visualized. Take a look
at the [Prometheus configuration options](https://prometheus.io/docs/prometheus/latest/configuration/configuration/)
prior to applying this Crossplane observability
configuration on mission critical clusters. Tune as appropriate
for your use case to help keep your control planes happy
and operational.

## Note: Using Metrics With Confidence
We are blessed with Crossplane and provider metrics endpoints
that help us gain insight about their performance.
Similar to early Kubernetes metrics APIs,
Crossplane does not yet distinguish between alpha, beta and v1
metrics endpoints. Metrics API evolution is expected over time.

## Purpose
The goal for configuration-observability-oss is to complement
other configurations such as configuration-caas. See the

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is configuration-caas?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configuration-caas is a plug and play configuration for cluster as a service.

[Upbound Marketplace](https://marketplace.upbound.io/) for
additional configurations.

## Usage
Run `make e2e` directly to exercise end to end tests
for the observability integrations. After running the
tests, the kind cluster will remain but the tests will
clean up the operator namespace and delete the pods in it
at the conclusion of the tests by default.
Run `make cluster` to spin up a cluster with a
Crossplane control plane.

Apply the resource claim as follows to re-create
the namespace, Prometheus, Grafana and dependencies for further
exploration.
Apply the resource claim as follows to create
the namespace, Prometheus, Grafana and dependencies for
exploration. Note that the xmetrics configuration examples
rely on the CRDs to be installed through the oss composition
first.
```
kubectl apply -f examples/oss.yaml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this claim installing x-metrics? If so, change the name. OSS is very generic, I would avoid using it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you recommend to not use oss.yaml for the claim name, even though x-metrics, prometheus and grafana are open source?

If so, which name would resonate with you?

```
Wait until xmetrics CRDs have been installed, then apply
the xmetrics configuration to see metrics flowing.
```
kubectl apply -f examples/xmetrics.yaml
```

To load dashboards that are part of this configuration repository,
please apply the following dashboard resource claims.
The following command will apply all the dashboard
resource claims located in the `dashboards` folder.
Each claim installs a respective Grafana dashboard.
```
kubectl apply -f examples/dashboards/folder-grafana.yaml
kubectl apply -f examples/dashboards/dashboard-grafana-crossplane-health.yaml
kubectl apply -f examples/dashboards/dashboard-grafana-crossplane-mr.yaml
kubectl apply -f examples/dashboards/dashboard-grafana-crossplane-resources-ttr.yaml
kubectl apply -f examples/dashboards/dashboard-grafana-crossplane-sli-metrics.yaml
kubectl apply -f examples/dashboards
```

Use the following to forward localhost:9090 to the Prometheus pod.
To access the Prometheus dashboard, port-forward
to the the Prometheus services on port 9090.
```
PROMETHEUS_POD_NAME=$(k -n operators get pods|\
awk '{print $1}'|\
tail +2|\
grep prometheus-0)
kubectl -n operators port-forward ${PROMETHEUS_POD_NAME} 9090
kubectl -n operators port-forward svc/oss-kube-prometheus-stack-prometheus 9090:9090
```

Use the following to forward localhost:3000 to the Grafana pod.
To access the Grafana dashboard, port-forward to the Grafana service on port 80.
```
GRAFANA_POD_NAME=$(k -n operators get pods|\
awk '{print $1}'|\
tail +2|\
grep grafana)
kubectl -n operators port-forward ${GRAFANA_POD_NAME} 3000
kubectl -n operators port-forward svc/oss-grafana 3000:80
```

Log in to Grafana at http://localhost:3000 with the credentials
Expand All @@ -59,6 +74,15 @@ obtained from running the following.
scripts/grafana-get-creds.sh
```

#### Uptest
Run `make e2e` to exercise end to end tests
for the observability integrations. `make e2e`
has no prerequisites, that is it does not require
a previously created cluster. After running the
tests, the kind cluster will remain but the tests will
clean up the operator namespace and delete the pods in it
at the conclusion of the tests by default.

See example dashboards below.

#### Crossplane MR Dashboard
Expand Down
103 changes: 91 additions & 12 deletions apis/oss/composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
metadata:
labels:
labels:
type: podMonitorCrossplaneRbacManager
spec:
forProvider:
Expand All @@ -31,10 +31,14 @@ spec:
kind: PodMonitor
metadata:
name: crossplane-rbac-manager
namespace: upbound-system
namespace: operators
labels:
app: crossplane-rbac-manager
spec:
namespaceSelector:
matchNames:
- crossplane-system
- upbound-system
selector:
matchLabels:
app: crossplane-rbac-manager
Expand All @@ -49,7 +53,7 @@ spec:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
metadata:
labels:
labels:
type: podMonitorCrossplane
spec:
forProvider:
Expand All @@ -58,10 +62,14 @@ spec:
kind: PodMonitor
metadata:
name: crossplane
namespace: upbound-system
namespace: operators
labels:
app: crossplane
spec:
namespaceSelector:
matchNames:
- crossplane-system
- upbound-system
selector:
matchLabels:
app: crossplane
Expand All @@ -76,7 +84,7 @@ spec:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
metadata:
labels:
labels:
type: podMonitorCrossplaneProviders
spec:
forProvider:
Expand All @@ -85,10 +93,14 @@ spec:
kind: PodMonitor
metadata:
name: crossplane-providers
namespace: upbound-system
namespace: operators
labels:
app: crossplane-providers
spec:
namespaceSelector:
matchNames:
- crossplane-system
- upbound-system
selector:
matchLabels:
app: crossplane-providers
Expand All @@ -98,6 +110,39 @@ spec:
- type: PatchSet
patchSetName: common

- name: podMonitorXmetrics
base:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
metadata:
labels:
type: podMonitorXmetrics
Comment on lines +113 to +119

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

X-metrics installs with a service, when a service exists, it is better to use a service monitor for Prometheus. The helm chart already supports service monitor, use helm values to enable it.

spec:
forProvider:
manifest:
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: x-metrics
namespace: operators
labels:
app: x-metrics
spec:
namespaceSelector:
matchNames:
- crossplane-system
- upbound-system
- x-metrics
selector:
matchLabels:
app: x-metrics
podMetricsEndpoints:
- port: metrics
path: "/x-metrics"
patches:
- type: PatchSet
patchSetName: common

- name: releasePrometheus
base:
apiVersion: helm.crossplane.io/v1beta1
Expand All @@ -122,6 +167,12 @@ spec:
patchSetName: common
- fromFieldPath: spec.parameters.id
toFieldPath: metadata.name
- fromFieldPath: metadata.labels
toFieldPath: metadata.labels
- fromFieldPath: metadata.annotations
toFieldPath: metadata.annotations
- fromFieldPath: spec.parameters.operators.prometheus.version
toFieldPath: spec.forProvider.chart.version
- fromFieldPath: spec.parameters.id
toFieldPath: metadata.annotations[crossplane.io/external-name]
transforms:
Expand All @@ -131,12 +182,24 @@ spec:
- type: regexp
regexp: '.*'
result: oss
- fromFieldPath: metadata.labels
toFieldPath: metadata.labels
- fromFieldPath: metadata.annotations
toFieldPath: metadata.annotations
- fromFieldPath: spec.parameters.operators.prometheus.version
toFieldPath: spec.forProvider.chart.version

- name: usagePrometheusByPodMonitorXmetrics
base:
apiVersion: apiextensions.crossplane.io/v1alpha1
kind: Usage
spec:
of:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
resourceSelector:
matchControllerRef: true
by:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
resourceSelector:
matchControllerRef: true
matchLabels:
type: podMonitorXmetrics

- name: usagePrometheusByPodMonitorCrossplaneRbacManager
base:
Expand Down Expand Up @@ -191,3 +254,19 @@ spec:
matchControllerRef: true
matchLabels:
type: podMonitorCrossplaneProviders

- name: releaseXMetrics
base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
spec:
rollbackLimit: 3
forProvider:
namespace: x-metrics
chart:
name: x-metrics
repository: https://crossplane-contrib.github.io/x-metrics
version: "0.1.3"
patches:
- type: PatchSet
patchSetName: common
Loading