Skip to content

Commit

Permalink
refactor: rename monitoring-stack-operator to observability-operator
Browse files Browse the repository at this point in the history
This patch addresses Issue #145.

With expansion of the scope of the operator to a more generic
observability operator used of deploying Monitoring, Logging and Tracing
stacks, rename the operator to Observability Operator.

Significant changes other than renaming are
  * create separate directory in deployment for `monitoring` related
    resources like prometheus, alertmanager rules.
  * Move monitoring api to `pkg/apis/monitoring` directory
  * Move monitoring controllers to `pkg/controllers/monitoring` directory
  * Move to quay.io/rhobs/observability-operator image repository

Signed-off-by: Sunil Thaha <sthaha@redhat.com>
  • Loading branch information
sthaha authored Jun 1, 2022
1 parent ab5c7f0 commit 192b610
Show file tree
Hide file tree
Showing 45 changed files with 250 additions and 190 deletions.
14 changes: 7 additions & 7 deletions .github/e2e-tests-olm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ runs:
- name: Build images
shell: bash
run: make operator-image bundle bundle-image IMAGE_BASE="local-registry:30000/monitoring-stack-operator" VERSION=0.0.0-ci
run: make operator-image bundle bundle-image IMAGE_BASE="local-registry:30000/observability-operator" VERSION=0.0.0-ci

- name: Wait for cluster to finish bootstraping
shell: bash
Expand All @@ -61,7 +61,7 @@ runs:
- name: Publish images
shell: bash
run: make operator-push bundle-push IMAGE_BASE="local-registry:30000/monitoring-stack-operator" VERSION=0.0.0-ci
run: make operator-push bundle-push IMAGE_BASE="local-registry:30000/observability-operator" VERSION=0.0.0-ci

- name: Deploy the operator
shell: bash
Expand All @@ -71,12 +71,12 @@ runs:
kubectl wait --for=condition=Established crds --all --timeout=300s
./tmp/bin/operator-sdk run bundle \
local-registry:30000/monitoring-stack-operator-bundle:0.0.0-ci \
local-registry:30000/observability-operator-bundle:0.0.0-ci \
--install-mode AllNamespaces \
--namespace operators \
--skip-tls
kubectl rollout status deployment monitoring-stack-operator -n operators
kubectl rollout status deployment observability-operator -n operators
- name: Expose operator metrics endpoint
shell: bash
Expand Down Expand Up @@ -108,7 +108,7 @@ runs:
echo "Reconcile errors before running tests: $reconcile_errors"
if [[ "$reconcile_errors" -ne 0 ]]; then
kubectl logs -n operators deploy/monitoring-stack-operator
kubectl logs -n operators deploy/observability-operator
echo ================================================================
echo "Expecting 0 reconcile errors but found $reconcile_errors"
exit 1
Expand All @@ -121,7 +121,7 @@ runs:
- name: Print operator logs and reconcile stats
shell: bash
run: |
kubectl logs -n operators deploy/monitoring-stack-operator
kubectl logs -n operators deploy/observability-operator
echo ================================================================
./tmp/bin/promq -t http://localhost:30001/metrics \
Expand All @@ -146,7 +146,7 @@ runs:
shell: bash
run: |
# Output operator logs
kubectl logs -n operators deploy/monitoring-stack-operator
kubectl logs -n operators deploy/observability-operator
# Capture apiserver state
oc adm inspect node --dest-dir cluster-state || true
oc adm inspect -A statefulset --dest-dir cluster-state || true
Expand Down
2 changes: 1 addition & 1 deletion .github/olm-publish/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ runs:

- name: Build Catalog Image
shell: bash
run: make catalog-image
run: make catalog-image FIRST_OLM_RELEASE=true

- name: Publish catalog image
shell: bash
Expand Down
3 changes: 2 additions & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* @rhobs/monitoring-stack-operator-maintainers
* @rhobs/monitoring-stack-operator-maintainers
* @rhobs/observability-operator-maintainers
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include Makefile.tools

# IMAGE_BASE defines the registry/namespace and part of the image name
# This variable is used to construct full image tags for bundle and catalog images.
IMAGE_BASE ?= monitoring-stack-operator
IMAGE_BASE ?= observability-operator

VERSION ?= $(shell cat VERSION)
OPERATOR_IMG = $(IMAGE_BASE):$(VERSION)
Expand Down Expand Up @@ -51,9 +51,9 @@ generate-prometheus-rules: jsonnet-tools check-jq kustomize jsonnet-vendor
echo "Generating prometheusrule file for $$component" ;\
$(JSONNET) -J $(JSONNET_VENDOR) $$dir/main.jsonnet \
| jq .rule \
| $(GOJSONTOYAML) > deploy/operator/monitoring-stack-operator-$$component-rules.yaml ;\
| $(GOJSONTOYAML) > deploy/operator/monitoring/monitoring-$$component-rules.yaml ;\
cd deploy/operator && \
$(KUSTOMIZE) edit add resource "monitoring-stack-operator-$$component-rules.yaml" && cd - ;\
$(KUSTOMIZE) edit add resource "monitoring/monitoring-$$component-rules.yaml" && cd - ;\
done;

.PHONY: docs
Expand All @@ -76,16 +76,16 @@ generate-crds: $(CONTROLLER_GEN) generate-prom-op-crds
$(CONTROLLER_GEN) crd \
paths=./pkg/apis/... \
paths=./pkg/controllers/... \
rbac:roleName=monitoring-stack-operator \
rbac:roleName=observability-operator \
output:dir=. \
output:rbac:dir=./deploy/operator \
output:crd:dir=./deploy/crds/common
mv deploy/operator/role.yaml deploy/operator/monitoring-stack-operator-cluster-role.yaml
mv deploy/operator/role.yaml deploy/operator/observability-operator-cluster-role.yaml

.PHONY: generate-kustomize
generate-kustomize: $(KUSTOMIZE)
cd deploy/operator && \
$(KUSTOMIZE) edit set image monitoring-stack-operator=*:$(VERSION)
$(KUSTOMIZE) edit set image observability-operator=*:$(VERSION)

.PHONY: generate-deepcopy
generate-deepcopy: $(CONTROLLER_GEN)
Expand Down Expand Up @@ -140,14 +140,14 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
.PHONY: bundle
bundle: $(KUSTOMIZE) $(OPERATOR_SDK) generate
cd deploy/olm && \
$(KUSTOMIZE) edit set image monitoring-stack-operator=$(OPERATOR_IMG)
$(KUSTOMIZE) edit set image observability-operator=$(OPERATOR_IMG)

$(KUSTOMIZE) build deploy/olm | tee tmp/pre-bundle.yaml | \
$(OPERATOR_SDK) generate bundle \
--overwrite \
--version $(VERSION) \
--kustomize-dir=deploy/olm \
--package=monitoring-stack-operator \
--package=observability-operator \
$(BUNDLE_METADATA_OPTS)
$(OPERATOR_SDK) bundle validate ./bundle

Expand Down Expand Up @@ -215,12 +215,12 @@ $(STANDARD_VERSION):

.PHONY: initiate-release
initiate-release: $(STANDARD_VERSION)
git fetch git@github.com:rhobs/monitoring-stack-operator.git --tags
git fetch git@github.com:rhobs/observability-operator.git --tags
$(STANDARD_VERSION) -a --skip.tag # The tag will be created in the pipeline

.PHONY: initiate-release-as
initiate-release-as: $(STANDARD_VERSION)
git fetch git@github.com:rhobs/monitoring-stack-operator.git --tags
git fetch git@github.com:rhobs/observability-operator.git --tags
$(STANDARD_VERSION) -a --skip.tag --release-as $(RELEASE_VERSION)

.PHONY: kind-cluster
Expand Down
83 changes: 70 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# monitoring-stack-operator
# observability-operator

The monitoring stack operator is a Kubernetes operator which enables the management of independent and self-contained, Prometheus-based monitoring stacks through Kubernetes CRDs.
The Observability Operator (previously known as Monitoring Stack Operator) is a
Kubernetes operator which enables the management of Monitoring, Logging and
Tracing stacks through Kubernetes CRDs.

The project is based on the [controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) library.

Expand All @@ -9,15 +11,14 @@ The project is based on the [controller-runtime](https://github.com/kubernetes-s
### OLM

The easiest way to try out the operator is to use OLM (that comes shipped with
OpenShift). Assuming you are using OpenShift, add the Monitoring Stack Operator Catalog
OpenShift). Assuming you are using OpenShift, add the Observability Operator Catalog
as shown below.

```
kubectl apply -f hack/olm/catalog-src.yaml
```

This adds a new Catalog to the list of Catalogs. Now, you should be able to use
OLM Web interface to install Monitoring Stack Operator like any other operator.
OLM Web interface to install Observability Operator like any other operator.

### Kubernetes

Expand Down Expand Up @@ -73,13 +74,13 @@ to the controller-gen CLI page in the [kubebuilder documentation](https://book.k
```sh
kind create cluster --config=hack/kind/config.yaml
```
* Apply the CRDs by running
* Apply the CRDs by running

```sh
kubectl create -k deploy/crds/kubernetes
```

* Apply the dependecies; i.e - Prometheus Operator by running
* Apply the dependencies; i.e. - Prometheus Operator by running

```sh
kubectl create ns operators
Expand All @@ -93,7 +94,7 @@ to the controller-gen CLI page in the [kubebuilder documentation](https://book.k
`go run ./cmd/operator/... --kubeconfig <path-to-kubeconfig>`

**TIP**: Using `fd` and `entr` to automatically build and run operator can come handy.
E.g the following re-runs operator when any of the `.go` files change.
E.g. the following re-runs operator when any of the `.go` files change.

```sh
fd .go$ -- cmd pkg |
Expand All @@ -103,18 +104,74 @@ E.g the following re-runs operator when any of the `.go` files change.

The above can be tweaked to automatically run `make generate` when the `pkg/apis/` change.

### Running e2e tests
### Running E2E Tests

E2E tests are run against a deployment, so it requires operator to be running
in cluster or outside it (`go run ./cmd/operator/...`). To run e2e tests locally,

* Follow the section above to run the operator'
* Follow the section above to run the operator

* In a new terminal, run `go test -v ./test/e2e/...`

Note: when running the operator outside of the cluster the post e2e tests are
expected to fail.
expected to fail since it requires operator to be deployed in the cluster.
Refer to the "Running Operator Bundle" section below.

## Running Operator Bundle

OperatorSDK provides `run bundle` command allowing us to run the Operator in
`kind` cluster as if it is installed via OLM. To run the operator follow the
steps below

1. Use `hack/kind/config.yaml` to create your kind cluster
```sh
kind create cluster --config=hack/kind/config.yaml
```
2. Install Prometheus Operator CRDs and Dependencies
```sh
kubectl create -k deploy/crds/kubernetes
kubectl create -k deploy/dependencies
```
3. Ensure local-registry entry is added to `/etc/hosts`. This is needed
to build and push all container images (operator, bundle and catalog) that
is used by `run bundle` command to subscribe and run the operator. E.g.
below is a sample hosts entry that works.
```
❯ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
127.0.0.2 www.example.com
127.0.0.1 local-registry
# ☝️ adds the local-registry
```
4. Build and push operator images to the `local-registry`
```
make operator-image bundle-image \
operator-push bundle-push \
IMAGE_BASE=local-registry:30000/observability-operator \
VERSION=0.0.0-ci \
FIRST_OLM_RELEASE=true
```

5. Run operator-sdk run bundle to subscribe to the operator
```
./tmp/bin/operator-sdk run bundle \
local-registry:30000/observability-operator-bundle:0.0.0-ci \
--install-mode AllNamespaces \
--skip-tls \
--namespace operators \
--verbose | tee tmp/olm.log
```
6. Run `e2e` tests
```
go test -v ./test/e2e/...
```
A good way to monitor if the tests are running correctly is to watch the
pods in the `e2e-tests` namespace. E.g.
```
kubectl get pods -w --output-watch-events -n e2e-tests
```
## Managing releases

This project follows [SemVer 2.0.0](https://semver.org/)
Expand Down Expand Up @@ -169,6 +226,6 @@ ___

## Contact
___
- CoreOS Slack #mso-users and ping @mso-support.
- CoreOS Slack #mso-users and ping @mso-support.
- [Mailing list](mso-users@redhat.com)
- Github Team: @rhobs/monitoring-stack-operator-maintainers
- Github Team: @rhobs/observability-operator-maintainers
2 changes: 1 addition & 1 deletion cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"flag"
"os"

"github.com/rhobs/monitoring-stack-operator/pkg/operator"
"github.com/rhobs/observability-operator/pkg/operator"
"go.uber.org/zap/zapcore"

ctrl "sigs.k8s.io/controller-runtime"
Expand Down
14 changes: 7 additions & 7 deletions deploy/dependencies/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ resources:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: operators
namePrefix: monitoring-stack-operator-
namePrefix: observability-operator-
commonLabels:
app.kubernetes.io/part-of: monitoring-stack-operator
app.kubernetes.io/part-of: observability-operator

patches:
- patch: |-
Expand All @@ -20,21 +20,21 @@ patches:
spec:
selector:
matchLabels:
app.kubernetes.io/part-of: monitoring-stack-operator
app.kubernetes.io/part-of: observability-operator
template:
metadata:
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
labels:
app.kubernetes.io/part-of: monitoring-stack-operator
app.kubernetes.io/part-of: observability-operator
spec:
containers:
- name: prometheus-operator
args:
- --prometheus-config-reloader=quay.io/prometheus-operator/prometheus-config-reloader:v0.55.1
- --prometheus-instance-selector=app.kubernetes.io/managed-by=monitoring-stack-operator
- --alertmanager-instance-selector=app.kubernetes.io/managed-by=monitoring-stack-operator
- --thanos-ruler-instance-selector=app.kubernetes.io/managed-by=monitoring-stack-operator
- --prometheus-instance-selector=app.kubernetes.io/managed-by=observability-operator
- --alertmanager-instance-selector=app.kubernetes.io/managed-by=observability-operator
- --thanos-ruler-instance-selector=app.kubernetes.io/managed-by=observability-operator
resources:
requests:
cpu: 5m
Expand Down

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions deploy/olm/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ resources:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: monitoring-stack-operator
newName: monitoring-stack-operator
newTag: 0.0.5
- name: observability-operator
newName: local-registry:30000/observability-operator
newTag: 0.0.0-ci
22 changes: 11 additions & 11 deletions deploy/operator/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
resources:
- monitoring-stack-operator-deployment.yaml
- monitoring-stack-operator-service-account.yaml
- monitoring-stack-operator-cluster-role.yaml
- monitoring-stack-operator-cluster-role-binding.yaml
- monitoring-stack-operator-service.yaml
- monitoring-stack-operator-service-monitor.yaml
- monitoring-stack-operator-rules.yaml
- monitoring-stack-operator-alertmanager-rules.yaml
- monitoring-stack-operator-prometheus-operator-rules.yaml
- monitoring-stack-operator-prometheus-rules.yaml
- observability-operator-deployment.yaml
- observability-operator-service-account.yaml
- observability-operator-cluster-role.yaml
- observability-operator-cluster-role-binding.yaml
- observability-operator-service.yaml
- observability-operator-service-monitor.yaml
- observability-operator-rules.yaml
- monitoring/monitoring-prometheus-rules.yaml
- monitoring/monitoring-alertmanager-rules.yaml
- monitoring/monitoring-prometheus-operator-rules.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: monitoring-stack-operator
- name: observability-operator
newTag: 0.0.9
namespace: operators
Loading

0 comments on commit 192b610

Please sign in to comment.