streamnative / pulsar-resources-operator

Apache License 2.0
34 stars 15 forks source link

support config oauth2 for geo replication #237

Closed freeznet closed 2 months ago

freeznet commented 2 months ago

(If this PR fixes a github issue, please add Fixes #<xyz>.)

Fixes #

(or if this PR is one task of a github issue, please add Master Issue: #<xyz> to link to the master issue.)

Master Issue: #

Motivation

Explain here the context, and why you're making that change. What is the problem you're trying to solve.

Modifications

Describe the modifications you've done.

Verifying this change

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

Documentation

Check the box below.

Need to update docs?

github-actions[bot] commented 2 months ago

@freeznet:Thanks for your contribution. For this PR, do we need to update docs? (The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

freeznet commented 2 months ago

Verified with the below CRs

---
apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarConnection
metadata:
  name: pulsar-connection-rui-1
  namespace: default
spec:
  adminServiceSecureURL: https://cluster1
  brokerServiceSecureURL: pulsar+ssl://cluster1:6651
  clusterName: geo-replica-test-1
  authentication:
    oauth2: 
      issuerEndpoint: https://issuerEndpoint/
      clientID: $clientID
      audience: $audience
      key:
        value: "{\"type\":\"sn_service_account\",\"client_id\":\"xxx\",\"client_secret\":\"xxx\",\"client_email\":\"xxx\",\"issuer_url\":\"https://issuerEndpoint/\"}"
---
apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarConnection
metadata:
  name: pulsar-connection-rui-2
  namespace: default
spec:
    adminServiceSecureURL: https://cluster2
  brokerServiceSecureURL: pulsar+ssl://cluster2:6651
  clusterName: geo-replica-test-2
  authentication:
    oauth2: 
      issuerEndpoint: https://issuerEndpoint/
      clientID: $clientID
      audience: $audience
      key:
        value: "{\"type\":\"sn_service_account\",\"client_id\":\"xxx\",\"client_secret\":\"xxx\",\"client_email\":\"xxx\",\"issuer_url\":\"https://issuerEndpoint/\"}"
---
apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarGeoReplication
metadata:
  name: geo-rep-rui-1
  namespace: default
spec:
  connectionRef:
    name: pulsar-connection-rui-1
  destinationConnectionRef:
    name: pulsar-connection-rui-2
  lifecyclePolicy: CleanUpAfterDeletion
---
apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarGeoReplication
metadata:
  name: geo-rep-rui-2
  namespace: default
spec:
  connectionRef:
    name: pulsar-connection-rui-2
  destinationConnectionRef:
    name: pulsar-connection-rui-1
  lifecyclePolicy: CleanUpAfterDeletion
---
apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarTenant
metadata:
  name: geo-tenant-east
  namespace: default
spec:
  name: geo-tenant
  connectionRef:
    name: pulsar-connection-rui-1
  geoReplicationRefs:
  - name: geo-rep-rui-1
  lifecyclePolicy: CleanUpAfterDeletion
---
apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarTenant
metadata:
  name: geo-tenant-west
  namespace: default
spec:
  name: geo-tenant
  connectionRef:
    name: pulsar-connection-rui-2
  geoReplicationRefs:
  - name: geo-rep-rui-2
  lifecyclePolicy: CleanUpAfterDeletion

And operator controller logs as below

{"severity":"info","timestamp":"2024-08-21T09:29:12Z","logger":"controller.pulsarconnection","message":"Starting Controller","reconciler group":"resource.streamnative.io","reconciler kind":"PulsarConnection"}
{"severity":"info","timestamp":"2024-08-21T09:29:12Z","logger":"controller.pulsarconnection","message":"Starting workers","reconciler group":"resource.streamnative.io","reconciler kind":"PulsarConnection","worker count":1}
{"severity":"info","timestamp":"2024-08-21T09:29:12Z","logger":"controllers.PulsarConnection","message":"Reconciling PulsarConnection","name":"pulsar-connection-rui-1","namespace":"default"}
{"severity":"info","timestamp":"2024-08-21T09:29:12Z","logger":"controllers.PulsarConnection","message":"Start PulsarConnectionReconciler Observe"}
{"severity":"info","timestamp":"2024-08-21T09:29:12Z","logger":"controllers.PulsarConnection.PulsarSource","message":"Observe sources","connectionRef":"default/pulsar-connection-rui-1","Count":0}
{"severity":"info","timestamp":"2024-08-21T09:29:12Z","logger":"controllers.PulsarConnection","message":"Reconciling pulsar resources","name":"pulsar-connection-rui-1","namespace":"default","resources":["PulsarGeoReplication:default/geo-rep-rui-1","PulsarTenant:default/geo-tenant-east"]}
{"severity":"info","timestamp":"2024-08-21T09:29:13Z","logger":"controllers.PulsarConnection.PulsarGeoReplication","message":"Start Reconcile","connectionRef":"default/pulsar-connection-rui-1","name":"geo-rep-rui-1","namespace":"default"}
{"severity":"info","timestamp":"2024-08-21T09:29:15Z","logger":"controllers.PulsarConnection.PulsarGeoReplication","message":"Create cluster success","connectionRef":"default/pulsar-connection-rui-1","name":"geo-rep-rui-1","namespace":"default","ClusterName":"geo-replica-test-2"}
{"severity":"info","timestamp":"2024-08-21T09:29:15Z","logger":"controllers.PulsarConnection.PulsarTenant","message":"Start Reconcile","connectionRef":"default/pulsar-connection-rui-1","name":"geo-tenant-east","namespace":"default"}
{"severity":"info","timestamp":"2024-08-21T09:29:15Z","logger":"controllers.PulsarConnection.PulsarTenant","message":"Geo Replication is enabled. Apply tenant with allowed clusters","connectionRef":"default/pulsar-connection-rui-1","name":"geo-tenant-east","namespace":"default","clusters":["geo-replica-test-2","geo-replica-test-1"]}
{"severity":"info","timestamp":"2024-08-21T09:29:16Z","logger":"controllers.PulsarConnection","message":"Reconciling PulsarConnection","name":"pulsar-connection-rui-2","namespace":"default"}
{"severity":"info","timestamp":"2024-08-21T09:29:16Z","logger":"controllers.PulsarConnection","message":"Start PulsarConnectionReconciler Observe"}
{"severity":"info","timestamp":"2024-08-21T09:29:16Z","logger":"controllers.PulsarConnection.PulsarSource","message":"Observe sources","connectionRef":"default/pulsar-connection-rui-2","Count":0}
{"severity":"info","timestamp":"2024-08-21T09:29:16Z","logger":"controllers.PulsarConnection","message":"Reconciling pulsar resources","name":"pulsar-connection-rui-2","namespace":"default","resources":["PulsarGeoReplication:default/geo-rep-rui-2","PulsarTenant:default/geo-tenant-west"]}
{"severity":"info","timestamp":"2024-08-21T09:29:16Z","logger":"controllers.PulsarConnection.PulsarGeoReplication","message":"Start Reconcile","connectionRef":"default/pulsar-connection-rui-2","name":"geo-rep-rui-2","namespace":"default"}
{"severity":"info","timestamp":"2024-08-21T09:29:19Z","logger":"controllers.PulsarConnection.PulsarGeoReplication","message":"Create cluster success","connectionRef":"default/pulsar-connection-rui-2","name":"geo-rep-rui-2","namespace":"default","ClusterName":"geo-replica-test-1"}
{"severity":"info","timestamp":"2024-08-21T09:29:19Z","logger":"controllers.PulsarConnection.PulsarTenant","message":"Start Reconcile","connectionRef":"default/pulsar-connection-rui-2","name":"geo-tenant-west","namespace":"default"}
{"severity":"info","timestamp":"2024-08-21T09:29:19Z","logger":"controllers.PulsarConnection.PulsarTenant","message":"Geo Replication is enabled. Apply tenant with allowed clusters","connectionRef":"default/pulsar-connection-rui-2","name":"geo-tenant-west","namespace":"default","clusters":["geo-replica-test-1","geo-replica-test-2"]}
{"severity":"info","timestamp":"2024-08-21T09:29:19Z","logger":"controllers.PulsarConnection","message":"Reconciling PulsarConnection","name":"pulsar-connection-rui-1","namespace":"default"}
{"severity":"info","timestamp":"2024-08-21T09:29:19Z","logger":"controllers.PulsarConnection","message":"Start PulsarConnectionReconciler Observe"}
{"severity":"info","timestamp":"2024-08-21T09:29:19Z","logger":"controllers.PulsarConnection.PulsarSource","message":"Observe sources","connectionRef":"default/pulsar-connection-rui-1","Count":0}
{"severity":"info","timestamp":"2024-08-21T09:29:19Z","logger":"controllers.PulsarConnection","message":"Reconciling pulsar resources","name":"pulsar-connection-rui-1","namespace":"default","resources":["PulsarGeoReplication:default/geo-rep-rui-1"]}
{"severity":"info","timestamp":"2024-08-21T09:29:19Z","logger":"controllers.PulsarConnection.PulsarGeoReplication","message":"Start Reconcile","connectionRef":"default/pulsar-connection-rui-1","name":"geo-rep-rui-1","namespace":"default"}
{"severity":"info","timestamp":"2024-08-21T09:29:19Z","logger":"controllers.PulsarConnection.PulsarGeoReplication","message":"Skip reconcile, geo resource is ready","connectionRef":"default/pulsar-connection-rui-1","name":"geo-rep-rui-1","namespace":"default","Name":"geo-rep-rui-1","Namespace":"default"}
{"severity":"info","timestamp":"2024-08-21T09:29:19Z","logger":"controllers.PulsarConnection.PulsarTenant","message":"Start Reconcile","connectionRef":"default/pulsar-connection-rui-1","name":"geo-tenant-east","namespace":"default"}
{"severity":"info","timestamp":"2024-08-21T09:29:19Z","logger":"controllers.PulsarConnection.PulsarTenant","message":"Skip reconcile, tenant resource is ready","connectionRef":"default/pulsar-connection-rui-1","name":"geo-tenant-east","namespace":"default"}