Skip to content

Commit b6e4ba1

Browse files
chore: clean-up and improve repository setup (#25)
* chore: make manifests * docs(readme): update sample * chore: remove `ClusterAccess` CRD * fix: remove test * fix(helm): image location * refactor: co-metrics-operator to metrics-operator * refactor: co-dynatrace-credentials to dynatrace-credentials * refactor: main.go * chore: update rbac * chore: cleanup PROJECT file * fix: remove unused file * docs: update example * fix(PROJECT): version of CRD * refactor: remove `co` occurrences * chore: delete files * fix: kustomization * fix: sample secret * fix: sample file * chore: simplify Makefile * Revert "chore: simplify Makefile" This reverts commit b94153d. * chore: simplify Makefile & add comments * refactor(make): target name * chore(makefile): simplify * chore: restructure Makefile * chore: update sample secret * fix: `make run` target * fix: remove folder * delete sample secret * chore: clean up Makefile * fix(Makefile): golang-ci installation * docs(reamde): restructure table of contents * chore: update .gitignore * docs(readme): enrich quickstart * docs(readme): add CRD links to resource type definitions * docs(readme): update table of contents * docs(readme): update install instructions
1 parent c92aefc commit b6e4ba1

File tree

63 files changed

+316
-1031
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+316
-1031
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ examples/sample_secret.yaml
3232
examples/dynatrace_secret.yaml
3333
examples/secret.yaml
3434
/examples/datasink/dynatrace-prod-setup.yaml
35+
36+
# debug file
37+
*debug*

Makefile

Lines changed: 144 additions & 189 deletions
Large diffs are not rendered by default.

PROJECT

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,27 @@ resources:
3131
kind: RemoteClusterAccess
3232
path: github.com/SAP/metrics-operator/api/v1alpha1
3333
version: v1alpha1
34-
- api:
35-
crdVersion: v1
36-
namespaced: true
37-
controller: true
38-
domain: metrics.cloud.sap
39-
kind: CompoundMetric
40-
path: github.com/SAP/metrics-operator/api/v1beta1
41-
version: v1beta1
4234
- api:
4335
crdVersion: v1
4436
namespaced: true
4537
controller: true
4638
domain: metrics.cloud.sap
4739
kind: FederatedMetric
48-
path: github.com/SAP/metrics-operator/api/v1beta1
49-
version: v1beta1
50-
- api:
51-
crdVersion: v1
52-
namespaced: true
53-
controller: true
54-
domain: metrics.cloud.sap
55-
kind: ClusterAccess
56-
path: github.com/SAP/metrics-operator/api/v1beta1
40+
path: github.com/SAP/metrics-operator/api/v1alpha1
5741
version: v1beta1
5842
- api:
5943
crdVersion: v1
6044
namespaced: true
6145
domain: metrics.cloud.sap
6246
kind: FederatedClusterAccess
63-
path: github.com/SAP/metrics-operator/api/v1beta1
47+
path: github.com/SAP/metrics-operator/api/v1alpha1
6448
version: v1beta1
6549
- api:
6650
crdVersion: v1
6751
namespaced: true
6852
controller: true
6953
domain: metrics.cloud.sap
7054
kind: FederatedManagedMetric
71-
path: github.com/SAP/metrics-operator/api/v1beta1
55+
path: github.com/SAP/metrics-operator/api/v1alpha1
7256
version: v1beta1
7357
version: "3"

README.md

Lines changed: 83 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,45 @@ The Metrics Operator is a powerful tool designed to monitor and provide insights
66

77
## Table of Contents
88

9-
- [Key Features](#key-features)
10-
- [Architecture Overview](#architecture-overview)
11-
- [Installation](#installation)
12-
- [Usage](#usage)
13-
- [RBAC Configuration](#rbac-configuration)
14-
- [Remote Cluster Access](#remote-cluster-access)
15-
- [DataSink Configuration](#datasink-configuration)
16-
- [Data Sink Integration](#data-sink-integration)
9+
- [Metrics Operator](#metrics-operator)
10+
- [Table of Contents](#table-of-contents)
11+
- [Key Features](#key-features)
12+
- [Architecture Overview](#architecture-overview)
13+
- [Metric Resource Flow](#metric-resource-flow)
14+
- [ManagedMetric Resource Flow](#managedmetric-resource-flow)
15+
- [FederatedMetric Resource Flow](#federatedmetric-resource-flow)
16+
- [FederatedManagedMetric Resource Flow](#federatedmanagedmetric-resource-flow)
17+
- [Resource Type Descriptions:](#resource-type-descriptions)
18+
- [Installation](#installation)
19+
- [Prerequisites](#prerequisites)
20+
- [Deployment](#deployment)
21+
- [Getting Started](#getting-started)
22+
- [Quickstart](#quickstart)
23+
- [Common Development Tasks](#common-development-tasks)
24+
- [Usage](#usage)
25+
- [Metric](#metric)
26+
- [Managed Metric](#managed-metric)
27+
- [Federated Metric](#federated-metric)
28+
- [Federated Managed Metric](#federated-managed-metric)
29+
- [Remote Cluster Access](#remote-cluster-access)
30+
- [Remote Cluster Access](#remote-cluster-access-1)
31+
- [Federated Cluster Access](#federated-cluster-access)
32+
- [RBAC Configuration](#rbac-configuration)
33+
- [DataSink Configuration](#datasink-configuration)
34+
- [Creating a DataSink](#creating-a-datasink)
35+
- [DataSink Specification](#datasink-specification)
36+
- [Connection](#connection)
37+
- [Authentication](#authentication)
38+
- [Using DataSink in Metrics](#using-datasink-in-metrics)
39+
- [Default Behavior](#default-behavior)
40+
- [Supported Metric Types](#supported-metric-types)
41+
- [Examples and Detailed Documentation](#examples-and-detailed-documentation)
42+
- [Migration from Legacy Configuration](#migration-from-legacy-configuration)
43+
- [Data Sink Integration](#data-sink-integration)
44+
- [Support, Feedback, Contributing](#support-feedback-contributing)
45+
- [Security / Disclosure](#security--disclosure)
46+
- [Code of Conduct](#code-of-conduct)
47+
- [Licensing](#licensing)
1748

1849
## Key Features
1950

@@ -37,12 +68,12 @@ graph LR
3768
M -.->|optional| RCA[RemoteClusterAccess]
3869
RCA -->|accesses remote cluster| K8S
3970
M -->|sends data to| DS[Data Sink<br/>Dynatrace, etc.]
40-
71+
4172
classDef metricType fill:#e1f5fe,stroke:#01579b,stroke-width:2px
4273
classDef accessType fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
4374
classDef targetType fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
4475
classDef dataType fill:#fff3e0,stroke:#e65100,stroke-width:2px
45-
76+
4677
class M metricType
4778
class RCA accessType
4879
class K8S targetType
@@ -57,12 +88,12 @@ graph LR
5788
MM -.->|optional| RCA[RemoteClusterAccess]
5889
RCA -->|accesses remote cluster| MR
5990
MM -->|sends data to| DS[Data Sink<br/>Dynatrace, etc.]
60-
91+
6192
classDef metricType fill:#e1f5fe,stroke:#01579b,stroke-width:2px
6293
classDef accessType fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
6394
classDef targetType fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
6495
classDef dataType fill:#fff3e0,stroke:#e65100,stroke-width:2px
65-
96+
6697
class MM metricType
6798
class RCA accessType
6899
class MR targetType
@@ -78,12 +109,12 @@ graph LR
78109
FCA -->|provides access to| MC[Multiple Clusters]
79110
FM -->|targets across clusters| K8S[Kubernetes Objects<br/>across federated clusters]
80111
FM -->|aggregates & sends to| DS[Data Sink<br/>Dynatrace, etc.]
81-
112+
82113
classDef metricType fill:#e1f5fe,stroke:#01579b,stroke-width:2px
83114
classDef accessType fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
84115
classDef targetType fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
85116
classDef dataType fill:#fff3e0,stroke:#e65100,stroke-width:2px
86-
117+
87118
class FM metricType
88119
class FCA accessType
89120
class CP,MC,K8S targetType
@@ -99,26 +130,27 @@ graph LR
99130
FCA -->|provides access to| MC[Multiple Clusters]
100131
FMM -->|targets managed resources<br/>across clusters| MR[Managed Resources<br/>with 'crossplane' & 'managed' categories]
101132
FMM -->|aggregates & sends to| DS[Data Sink<br/>Dynatrace, etc.]
102-
133+
103134
classDef metricType fill:#e1f5fe,stroke:#01579b,stroke-width:2px
104135
classDef accessType fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
105136
classDef targetType fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px
106137
classDef dataType fill:#fff3e0,stroke:#e65100,stroke-width:2px
107-
138+
108139
class FMM metricType
109140
class FCA accessType
110141
class CP,MC,MR targetType
111142
class DS dataType
112143
```
113144

114-
### Resource Type Descriptions:
145+
## Resource Type Descriptions:
115146

116-
- **Metric**: Monitors specific Kubernetes resources in the local or remote clusters using GroupVersionKind targeting
117-
- **ManagedMetric**: Specialized for monitoring Crossplane managed resources (resources with "crossplane" and "managed" categories)
118-
- **FederatedMetric**: Monitors resources across multiple clusters, aggregating data from federated sources
119-
- **FederatedManagedMetric**: Monitors Crossplane managed resources across multiple clusters
120-
- **RemoteClusterAccess**: Provides access configuration for monitoring resources in remote clusters
121-
- **FederatedClusterAccess**: Discovers and provides access to multiple clusters for federated monitoring
147+
- [**Metric**](config/crd/bases/metrics.cloud.sap_metrics.yaml): Monitors specific Kubernetes resources in the local or remote clusters using GroupVersionKind targeting
148+
- [**ManagedMetric**](config/crd/bases/metrics.cloud.sap_managedmetrics.yaml): Specialized for monitoring Crossplane managed resources (resources with "crossplane" and "managed" categories)
149+
- [**FederatedMetric**](config/crd/bases/metrics.cloud.sap_federatedmetrics.yaml): Monitors resources across multiple clusters, aggregating data from federated sources
150+
- [**FederatedManagedMetric**](config/crd/bases/metrics.cloud.sap_federatedmanagedmetrics.yaml): Monitors Crossplane managed resources across multiple clusters
151+
- [**RemoteClusterAccess**](config/crd/bases/metrics.cloud.sap_remoteclusteraccesses.yaml): Provides access configuration for monitoring resources in remote clusters
152+
- [**FederatedClusterAccess**](config/crd/bases/metrics.cloud.sap_federatedclusteraccesses.yaml): Discovers and provides access to multiple clusters for federated monitoring
153+
- [**DataSink**](config/crd/bases/metrics.cloud.sap_datasinks.yaml): Defines where and how metrics data should be sent, supporting various destinations like Dynatrace
122154

123155
## Installation
124156

@@ -132,7 +164,7 @@ graph LR
132164
Deploy the Metrics Operator using the Helm chart:
133165

134166
```bash
135-
helm upgrade --install metrics-operator ghcr.io/sap/github.com/sap/metrics-operator/charts/metrics-operator \
167+
helm upgrade --install metrics-operator oci://ghcr.io/sap/github.com/sap/metrics-operator/charts/metrics-operator \
136168
--namespace <operator-namespace> \
137169
--create-namespace \
138170
--version=<version>
@@ -142,6 +174,30 @@ Replace `<operator-namespace>` and `<version>` with appropriate values.
142174

143175
After deployment, create your DataSink configuration as described in the [DataSink Configuration](#datasink-configuration) section.
144176

177+
## Getting Started
178+
You’ll need a Kubernetes cluster to run against. You can use [KIND](https://sigs.k8s.io/kind) to get a local cluster for testing, or run against a remote cluster.
179+
**Note:** Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster `kubectl cluster-info` shows).
180+
181+
### Quickstart
182+
183+
1. Clone the repository and install prerequisites (Go, Docker, kind, kubectl).
184+
2. Configure your data sink by copying the configuration in [`examples/datasink/basic-datasink.yaml`](examples/datasink/basic-datasink.yaml) and modifying it to suit your environment.
185+
- For example, if using Dynatrace, create a Kubernetes Secret with your API token and update the DataSink resource accordingly.
186+
- The file should be placed and named like this: `examples/datasink/dynatrace-prod-setup.yaml`. (automatically excluded in [.gitignore](.gitignore))
187+
3. Run `make dev-local-all` to set up a local development environment.
188+
4. Run `make run` to start the Metrics Operator locally.
189+
5. Check your data sink for incoming metrics.
190+
191+
### Common Development Tasks
192+
This project uses a Makefile to streamline development tasks. Common targets include:
193+
194+
- `make dev-local-all` – Set up a local kind cluster with all CRDs, Crossplane, and sample resources.
195+
- `make run` – Run the operator locally for development.
196+
- `make dev-clean` – Delete the local kind cluster.
197+
- `make test` – Run all Go tests.
198+
- `make lint` – Run golangci-lint on the codebase.
199+
- `make manifests generate` – Regenerate CRDs and deepcopy code after API changes.
200+
145201
## Usage
146202

147203
### Metric
@@ -154,9 +210,9 @@ The projections are then translated to dimensions in the metric.
154210
apiVersion: metrics.cloud.sap/v1alpha1
155211
kind: Metric
156212
metadata:
157-
name: comp-pod
213+
name: metric-pod-count
158214
spec:
159-
name: comp-metric-pods
215+
name: metric-pod-count
160216
description: Pods
161217
target:
162218
kind: Pod
@@ -416,7 +472,7 @@ The detailed guide covers:
416472

417473
### Migration from Legacy Configuration
418474

419-
**Important**: The old method of using hardcoded secret names (such as `co-dynatrace-credentials`) has been deprecated and removed. You must now use DataSink resources to configure your metrics destinations.
475+
**Important**: The old method of using hardcoded secret names (such as `dynatrace-credentials`) has been deprecated and removed. You must now use DataSink resources to configure your metrics destinations.
420476

421477
To migrate:
422478
1. Create a DataSink resource pointing to your existing authentication secret
@@ -437,37 +493,6 @@ To make the most of your metrics:
437493
For specific instructions on using your data sink's features, refer to its documentation. For example, if using Dynatrace, consult the Dynatrace documentation for information on creating custom charts, setting up alerts, and performing advanced analytics on your metric data.
438494

439495

440-
## Getting Started
441-
You’ll need a Kubernetes cluster to run against. You can use [KIND](https://sigs.k8s.io/kind) to get a local cluster for testing, or run against a remote cluster.
442-
**Note:** Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster `kubectl cluster-info` shows).
443-
444-
### Running on the cluster
445-
1. Install Instances of Custom Resources:
446-
447-
```sh
448-
make dev-local-all
449-
```
450-
451-
2. Run the controller:
452-
453-
```sh
454-
make dev-run
455-
```
456-
Or run it from your IDE.
457-
458-
### Delete Kind Cluster
459-
Delete Kind cluster
460-
```sh
461-
make dev-clean
462-
```
463-
464-
### Modifying the API definitions
465-
If you are editing the API definitions, generate the manifests such as CRs or CRDs using:
466-
467-
```sh
468-
make manifests generate
469-
```
470-
471496
## Support, Feedback, Contributing
472497

473498
This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/SAP/metrics-operator/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).

charts/metrics-operator/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Default values for co-metrics-operator.
1+
# Default values for metrics-operator.
22
# This is a YAML-formatted file.
33
# Declare variables to be passed into your templates.
44

55
replicaCount: 1
66

77
image:
8-
repository: deploy-releases-hyperspace-docker.common.cdn.repositories.cloud.sap/cloud-orchestration/co-metrics-operator
8+
repository: ghcr.io/sap/github.com/sap/metrics-operator/images/metrics-operator
99
pullPolicy: IfNotPresent
1010
# Overrides the image tag whose default is the chart appVersion.
1111
tag: v0.5.2-dev

charts/metrics-operator/values.yaml.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Default values for co-metrics-operator.
1+
# Default values for metrics-operator.
22
# This is a YAML-formatted file.
33
# Declare variables to be passed into your templates.
44

55
replicaCount: 1
66

77
image:
8-
repository: deploy-releases-hyperspace-docker.common.cdn.repositories.cloud.sap/cloud-orchestration/co-metrics-operator
8+
repository: ghcr.io/sap/github.com/sap/metrics-operator/images/metrics-operator
99
pullPolicy: IfNotPresent
1010
# Overrides the image tag whose default is the chart appVersion.
1111
tag: $OPERATOR_VERSION

0 commit comments

Comments
 (0)