Skip to content

Commit

Permalink
Add settings to configure reaper HTTP management interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
Miles-Garnsey committed Oct 4, 2023
1 parent d112dda commit 2d9c31e
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 1 deletion.
11 changes: 11 additions & 0 deletions apis/reaper/v1alpha1/reaper_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ type ReaperTemplate struct {
// labels and annotations for Reaper resources
// +optional
ResourceMeta *meta.ResourceMeta `json:"metadata,omitempty"`

// +kubebuilder:default={enabled: "false"}
HttpManagement HttpManagement `json:"httpManagement"`
}

// UseExternalSecrets defines whether the user has specified if credentials and
Expand Down Expand Up @@ -367,6 +370,14 @@ type Reaper struct {
Status ReaperStatus `json:"status,omitempty"`
}

type HttpManagement struct {
// Enable/disable the HTTP management connection between Reaper and Cassandra.
// When enabled, HTTP will be used instead of JMX for management connectivity between Cassandra
// and Reaper. In future, this will be true by default
// +kubebuilder:default=false
Enabled bool `json:"enabled"`
}

// +kubebuilder:object:root=true

// ReaperList contains a list of Reaper
Expand Down
9 changes: 8 additions & 1 deletion pkg/reaper/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
const (
DefaultImageRepository = "thelastpickle"
DefaultImageName = "cassandra-reaper"
DefaultVersion = "3.2.1"
DefaultVersion = "3.2.1" // TODO: ensure that this is updated to reflect the latest version with HTTP management proxy.
// When changing the default version above, please also change the kubebuilder markers in
// apis/reaper/v1alpha1/reaper_types.go accordingly.

Expand Down Expand Up @@ -151,6 +151,13 @@ func NewDeployment(reaper *api.Reaper, dc *cassdcapi.CassandraDatacenter, keysto
})
}

if reaper.Spec.HttpManagement.Enabled {
envVars = append(envVars, corev1.EnvVar{
Name: "REAPER_HTTP_MANAGEMENT_ENABLE",
Value: "true",
})
}

volumeMounts := []corev1.VolumeMount{}
volumes := []corev1.Volume{}
// if client encryption is turned on, we need to mount the keystore and truststore volumes
Expand Down
5 changes: 5 additions & 0 deletions pkg/reaper/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestNewDeployment(t *testing.T) {
reaper.Spec.AutoScheduling = reaperapi.AutoScheduling{Enabled: false}
reaper.Spec.ServiceAccountName = "reaper"
reaper.Spec.DatacenterAvailability = DatacenterAvailabilityAll
reaper.Spec.HttpManagement.Enabled = true
reaper.Spec.ClientEncryptionStores = &encryption.Stores{
KeystoreSecretRef: &encryption.SecretKeySelector{LocalObjectReference: corev1.LocalObjectReference{
Name: "keystore-secret",
Expand Down Expand Up @@ -116,6 +117,10 @@ func TestNewDeployment(t *testing.T) {
Name: "REAPER_CASS_NATIVE_PROTOCOL_SSL_ENCRYPTION_ENABLED",
Value: "true",
},
{
Name: "REAPER_HTTP_MANAGEMENT_ENABLE",
Value: "true",
},
})

assert.Len(t, podSpec.InitContainers, 1)
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ func TestOperator(t *testing.T) {
skipK8ssandraClusterCleanup: true,
doCassandraDatacenterCleanup: true,
}))
t.Run("CreateReaperHttpManagement", e2eTest(ctx, &e2eTestOpts{
testFunc: createReaperAndDatacenter, // same as above, ensure we can trigger repair. Only difference is that we use a fixture which enabled the HTTP management interface.
fixture: framework.NewTestFixture("reaper-http-management", dataPlanes[0]),
skipK8ssandraClusterCleanup: true,
doCassandraDatacenterCleanup: true,
}))
t.Run("ClusterScoped", func(t *testing.T) {
t.Run("MultiDcMultiCluster", e2eTest(ctx, &e2eTestOpts{
testFunc: multiDcMultiCluster,
Expand Down
67 changes: 67 additions & 0 deletions test/testdata/fixtures/reaper-http-management/cassdc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apiVersion: cassandra.datastax.com/v1beta1
kind: CassandraDatacenter
metadata:
name: dc1
spec:
clusterName: test
config:
cassandra-yaml:
auto_snapshot: false
commitlog_segment_size_in_mb: 2
compaction_throughput_mb_per_sec: 0
concurrent_compactors: 1
concurrent_counter_writes: 2
concurrent_reads: 2
concurrent_writes: 2
counter_cache_size_in_mb: 0
key_cache_size_in_mb: 0
memtable_flush_writers: 1
prepared_statements_cache_size_mb: 1
slow_query_log_timeout_in_ms: 0
sstable_preemptive_open_interval_in_mb: 0
thrift_prepared_statements_cache_size_mb: 1
authenticator: PasswordAuthenticator
authorizer: CassandraAuthorizer
role_manager: CassandraRoleManager
jvm-options:
additional-jvm-opts:
- -Dcassandra.system_distributed_replication_dc_names=dc1
- -Dcassandra.system_distributed_replication_per_dc=1
- -Dcassandra.jmx.remote.login.config=CassandraLogin
- -Djava.security.auth.login.config=/etc/cassandra/cassandra-jaas.config
- -Dcassandra.jmx.authorizer=org.apache.cassandra.auth.jmx.AuthorizationProxy
initial_heap_size: 512m
max_heap_size: 512m
users:
- secretName: reaper-cql-secret
superuser: true
serverType: cassandra
serverVersion: 3.11.14
networking:
hostNetwork: false
size: 3
racks:
- name: rack1
nodeAffinityLabels:
"topology.kubernetes.io/zone": region1-zone1
- name: rack2
nodeAffinityLabels:
"topology.kubernetes.io/zone": region1-zone2
- name: rack3
nodeAffinityLabels:
"topology.kubernetes.io/zone": region1-zone3
storageConfig:
cassandraDataVolumeClaimSpec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: standard
podTemplateSpec:
spec:
containers:
- name: cassandra
env:
- name: "LOCAL_JMX"
value: "no"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- cassdc.yaml
- reaper.yaml
- reaper-cql-secret.yaml
- reaper-ui-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: reaper-cql-secret
data:
# username: reaper-cql
username: cmVhcGVyLWNxbA==
# password: R3ap3r
password: UjNhcDNy
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: reaper-ui-secret
data:
# username: reaper-ui
username: cmVhcGVyLWpteA==
# password: R3ap3r
password: UjNhcDNy
25 changes: 25 additions & 0 deletions test/testdata/fixtures/reaper-http-management/reaper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: reaper.k8ssandra.io/v1alpha1
kind: Reaper
metadata:
name: reaper1
spec:
httpManagement:
enabled: true
datacenterRef:
# TODO check multi-namespace when cluster-scope is ready
name: dc1
cassandraUserSecretRef:
name: reaper-cql-secret
uiUserSecretRef:
name: reaper-ui-secret
containerImage:
repository: thelastpickle
name: cassandra-reaper
tag: "3.0.0"
pullPolicy: Always
initContainerImage:
repository: thelastpickle
name: cassandra-reaper
tag: "3.0.0"
pullPolicy: IfNotPresent
heapSize: 256Mi

0 comments on commit 2d9c31e

Please sign in to comment.