Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8OP-303 Use namespaced service name when registering k8ssandra cluster to Reaper #1477

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG/CHANGELOG-1.21.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ When cutting a new release, update the `unreleased` heading to the tag being gen
* [BUGFIX] [#1460](https://github.com/k8ssandra/k8ssandra-operator/issues/1460) Fix podName calculations in medusa's hostmap.go to account for unbalanced racks also
* [BUGFIX] [#1466](https://github.com/k8ssandra/k8ssandra-operator/issues/1466) Do not overwrite existing status fields or forget to write the changes. Also, add new ContextName for the Datacenter to know where it used to be.
* [ENHANCEMENT] [#1455](https://github.com/k8ssandra/k8ssandra-operator/issues/1455) Expose configuration of Medusa's gRPC server port
* [BUGFIX] [#1471](https://github.com/k8ssandra/k8ssandra-operator/issues/1471) Use namespaced service name when registering k8ssandra cluster to Reaper
3 changes: 2 additions & 1 deletion pkg/reaper/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func (r *restReaperManager) connect(ctx context.Context, reaperSvc, username, pa
}

func (r *restReaperManager) AddClusterToReaper(ctx context.Context, cassdc *cassdcapi.CassandraDatacenter) error {
return r.reaperClient.AddCluster(ctx, cassdcapi.CleanupForKubernetes(cassdc.Spec.ClusterName), cassdc.GetSeedServiceName())
namespacedServiceName := cassdc.GetSeedServiceName() + "." + cassdc.Namespace
return r.reaperClient.AddCluster(ctx, cassdcapi.CleanupForKubernetes(cassdc.Spec.ClusterName), namespacedServiceName)
}

func (r *restReaperManager) VerifyClusterIsConfigured(ctx context.Context, cassdc *cassdcapi.CassandraDatacenter) (bool, error) {
Expand Down
21 changes: 21 additions & 0 deletions test/e2e/cluster_scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func multiDcMultiCluster(t *testing.T, ctx context.Context, klusterNamespace str

dc1Namespace := "test-1"
dc2Namespace := "test-2"
reaperNamespace := "test-0"

t.Log("check that the K8ssandraCluster was created")
k8ssandra := &api.K8ssandraCluster{}
Expand Down Expand Up @@ -84,4 +85,24 @@ func multiDcMultiCluster(t *testing.T, ctx context.Context, klusterNamespace str
t.Log("check nodes in dc2 see nodes in dc1")
pod = DcPrefix(t, f, dc2Key) + "-rack1-sts-0"
checkNodeToolStatus(t, f, f.DataPlaneContexts[1], dc2Namespace, pod, count, 0, "-u", username, "-pw", password)

t.Log("check that cluster was registered in Reaper")
reaperKey := framework.ClusterKey{K8sContext: f.ControlPlaneContext, NamespacedName: types.NamespacedName{Namespace: reaperNamespace, Name: "reaper1"}}
dcKey := framework.ClusterKey{K8sContext: f.DataPlaneContexts[0], NamespacedName: types.NamespacedName{Namespace: dc1Namespace, Name: "dc1"}}
dcPrefix := DcPrefix(t, f, dcKey)
checkReaperReady(t, f, ctx, reaperKey)
createKeyspaceAndTable(t, f, ctx, f.DataPlaneContexts[0], dc1Namespace, k8ssandra.Name, dcPrefix+"-rack1-sts-0", "test_ks", "test_table", 2)

t.Log("deploying Reaper ingress routes in context", f.ControlPlaneContext)
reaperRestHostAndPort := ingressConfigs[f.ControlPlaneContext].ReaperRest
f.DeployReaperIngresses(t, f.ControlPlaneContext, k8ssandra.Namespace, "reaper1-service", reaperRestHostAndPort)
defer f.UndeployAllIngresses(t, f.ControlPlaneContext, k8ssandra.Namespace)
checkReaperApiReachable(t, ctx, reaperRestHostAndPort)

t.Run("TestReaperApi[0]", func(t *testing.T) {
t.Log("test Reaper API in context", f.ControlPlaneContext)
secretKey := framework.ClusterKey{K8sContext: f.ControlPlaneContext, NamespacedName: types.NamespacedName{Namespace: k8ssandra.Namespace, Name: "reaper-ui-secret"}}
username, password := retrieveCredentials(t, f, ctx, secretKey)
testReaperApi(t, ctx, f.ControlPlaneContext, DcClusterName(t, f, dcKey), "test_ks", username, password)
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ spec:
concurrent_writes: 2
concurrent_counter_writes: 2
jvmOptions:
cassandra_ring_delay_ms: 0
heapSize: 512Mi
heapNewGenSize: 256Mi
gc: CMS
Expand Down Expand Up @@ -69,3 +70,9 @@ spec:
nodeAffinityLabels:
"topology.kubernetes.io/zone": region2-zone2
mgmtAPIHeap: 64Mi
reaper:
reaperRef:
name: reaper1
namespace: test-0
uiUserSecretRef:
name: reaper-ui-secret
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- medusa-config.yaml
- reaper.yaml
- k8ssandra.yaml
29 changes: 29 additions & 0 deletions test/testdata/fixtures/multi-dc-cluster-scope/reaper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: v1
kind: Secret
metadata:
name: reaper-ui-secret
data:
# username: reaper-jmx (actually)
username: cmVhcGVyLWpteA==
# password: R3ap3r
password: UjNhcDNy
---
apiVersion: reaper.k8ssandra.io/v1alpha1
kind: Reaper
metadata:
name: reaper1
spec:
storageType: local
storageConfig:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 256Mi
httpManagement:
enabled: true
heapSize: 256Mi
autoScheduling:
enabled: false
uiUserSecretRef:
name: reaper-ui-secret
Loading