Skip to content

Conversation

@Baarsgaard
Copy link
Collaborator

@Baarsgaard Baarsgaard commented Nov 4, 2025

Managed to get a PoC up and running.
The code still needs a fair bit of cleanup and some helper functions to simplify things a bit.

In theory, this should allow making the instanceSelector and allowCrossNamespaceImport mutable.

setup.yml
---    
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
  labels:
    dashboards: grafana
  name: grafana1
  namespace: default
spec:
  client:
    preferIngress: true
  config:
    security:
      admin_password: secret
      admin_user: root
  ingress:
    spec:
      ingressClassName: nginx
      rules:
      - host: grafana1.127.0.0.1.nip.io
        http:
          paths:
          - backend:
              service:
                name: grafana1-service
                port:
                  number: 3000
            path: /
            pathType: Prefix
---              
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
  labels:
    dashboards: grafana
  name: grafana2
  namespace: default
spec:
  client:
    preferIngress: true
  config:
    security:
      admin_password: secret
      admin_user: root
  ingress:
    spec:
      ingressClassName: nginx
      rules:
      - host: grafana2.127.0.0.1.nip.io
        http:
          paths:
          - backend:
              service:
                name: grafana2-service
                port:
                  number: 3000
            path: /
            pathType: Prefix
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaContactPoint
metadata:
  name: grafanacontactpoint-sample
  namespace: default
spec:
  instanceSelector:
    matchLabels:
      dashboards: grafana
  receivers:
  - settings:
      addresses: email1@email.com
    type: email
  - settings:
      addresses: email2@email.com
    type: email
  resyncPeriod: 10s
make start-kind
kubectl apply --serverside -f setup.yml

# Start the operator in a separate terminal 
make run

# Wait for both Grafanas to be ready
kubectl get grafanas

# ContactPoint matched both instances 
kubectl get grafanas -o yaml | yq '.items[].status.contactPoints'
# - default/grafanacontactpoint-sample/grafanacontactpoint-sample
# - default/grafanacontactpoint-sample/grafanacontactpoint-sample

kubectl get grafanacontactpoints grafanacontactpoint-sample -o yaml | yq '.metadata.annotations'
# annotations:
#   operator.grafana.com/matched-instances: default/grafana1,default/grafana2

# Remove label from an instance
kubectl label grafana grafana2 dashboards-

# Verify it was removed from Grafana status and ContactPoint annotations
kubectl get grafanas -o yaml | yq '.items[].status.contactPoints'
# - default/grafanacontactpoint-sample/grafanacontactpoint-sample
# []
kubectl get grafanacontactpoints grafanacontactpoint-sample -o yaml | yq '.metadata.annotations'
# annotations:
#   operator.grafana.com/matched-instances: default/grafana1

# Label the instance again and see it's matched again.
kubectl label grafana grafana2 dashboards=grafana

@github-actions github-actions bot added the feature this PR introduces a new feature label Nov 4, 2025
@Baarsgaard Baarsgaard force-pushed the feat_track_prev_matched_grafanas branch 2 times, most recently from ccac653 to 7b286ec Compare November 4, 2025 21:54
@Baarsgaard Baarsgaard force-pushed the feat_track_prev_matched_grafanas branch from 08d29b9 to 5aa0ed2 Compare November 6, 2025 12:17
@github-actions
Copy link

github-actions bot commented Dec 7, 2025

This PR hasn't been updated for a while, marking as stale

@github-actions github-actions bot added the stale label Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature this PR introduces a new feature stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant