Skip to main content
This lesson demonstrates how to run two independent Kubernetes operators in the same namespace without mixing ownership of their custom resources. You will install or verify two controllers, create the custom resources each operator manages, and confirm that each operator reconciles only its own resources.
  • cert-manager: manages certificate lifecycle (Issuer, Certificate) and produces TLS Secrets.
  • Prometheus Operator: manages monitoring lifecycle (ServiceMonitor, Prometheus) and generates the Prometheus workload.
These cert-manager components work together: the controller reconciles Certificate resources, the webhook validates cert-manager API requests, and cainjector injects CA trust data into Kubernetes resources.
Operators claim ownership only of the custom resources defined by their CRDs. Co-locating resources in the same Kubernetes namespace is useful for visibility, but it does not imply shared ownership or control.

Prerequisites and overview

  1. Confirm cert-manager and Prometheus Operator deployments are running.
  2. Create a single namespace combined to host the application-facing custom resources (the operators themselves run in their own namespaces).
  3. Apply cert-manager resources (Issuer + Certificate) and verify a TLS Secret is produced.
  4. Apply Prometheus resources (Deployment, Service, ServiceMonitor, Prometheus) and verify the operator generates the Prometheus StatefulSet.
  5. Validate that each operator only reconciles its own resources and verify the label selector match between Prometheus and the ServiceMonitor.

Verify controllers and create namespace

Confirm both operator deployments are available, then create the combined namespace:
Example output:
Both sets of application-facing custom resources will live in the combined namespace while their controllers continue to run in separate operator namespaces.

cert-manager resources (Issuer + Certificate)

Inspect the cert-manager resources: an Issuer (who signs) and a Certificate (what certificate is requested and which Secret should receive it). The Certificate in this lesson targets the Secret web-tls in namespace combined.
The image shows a Visual Studio Code interface with an open folder containing files like "cert-resources.yaml" and "prometheus-resources.yaml." The main area displays the VS Code welcome logo with shortcut tips.
cert-resources.yaml:
Apply the resources and wait for the Certificate to become Ready. The Ready condition means cert-manager has issued the certificate and populated the Secret.
Example output:
Verify the Secret type is kubernetes.io/tls, the standard type used by applications for TLS secrets:
Example output:

Prometheus resources (Deployment, Service, ServiceMonitor, Prometheus)

Next, create the monitoring resources that the Prometheus Operator will reconcile. This example includes:
  • a small example Deployment that exports metrics,
  • a Service exposing the metrics port,
  • a ServiceMonitor that discovers the Service,
  • a Prometheus custom resource that selects ServiceMonitors via labels.
prometheus-resources.yaml:
Apply the Prometheus resources:
Example apply output:
The Prometheus Operator reconciles the Prometheus CR and will create the actual Prometheus StatefulSet. The generated StatefulSet name may vary by operator version; this example expects prometheus-combined.
If the operator generated a differently named StatefulSet, find it with:

Quick reference: resources created in combined namespace

Validate operator ownership and selector match

List and inspect resources in the combined namespace to confirm both workflows coexist without ownership overlap:
  • cert-manager produced web-tls Secret from the Certificate request.
  • Prometheus Operator generated the Prometheus StatefulSet and included the ServiceMonitor in its scrape targets.
Finally, verify the label selector match between the Prometheus resource and the ServiceMonitor. Both values should be combined so the ServiceMonitor is included in Prometheus’ configuration:
Expected output:
When these match, the Prometheus Operator includes the ServiceMonitor target in Prometheus’ generated scrape configuration.

Summary

You now have two operators performing different responsibilities within the same namespace:
  • cert-manager issued a certificate and wrote a kubernetes.io/tls Secret for application consumption.
  • Prometheus Operator generated the Prometheus StatefulSet and configured scraping via the ServiceMonitor you created.
Running multiple operators side-by-side is a common pattern; namespaces are convenient observation boundaries but do not change CR ownership. For more details see the operator projects:

Watch Video