Skip to content
Open
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
4 changes: 2 additions & 2 deletions pkg/splunk/enterprise/clustermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ func ApplyClusterManager(ctx context.Context, client splcommon.ControllerClient,
}

// create or update KVService CR with owner reference
err = ApplyKVServiceCR(ctx, client, cr)
err = createKVServiceCR(ctx, client, cr)
if err != nil {
eventPublisher.Warning(ctx, "ApplyKVServiceCR", fmt.Sprintf("apply KVService CR failed %s", err.Error()))
eventPublisher.Warning(ctx, "createKVServiceCR", fmt.Sprintf("apply KVService CR failed %s", err.Error()))
return result, err
}

Expand Down
24 changes: 24 additions & 0 deletions pkg/splunk/enterprise/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,15 @@ func updateSplunkPodTemplateWithConfig(ctx context.Context, client splcommon.Con
})
}

// append KVService connection string, if KVService is ready
kvConnStr := getKVServiceConnectionString(ctx, client, cr.GetNamespace())
if kvConnStr != "" {
env = append(env, corev1.EnvVar{
Name: "KVSERVICE_CONNECTION_STRING",
Value: kvConnStr,
})
}

// append URL for cluster manager, if configured
var clusterManagerURL string
if isCMDeployed(instanceType) {
Expand Down Expand Up @@ -2114,3 +2123,18 @@ func validateSplunkGeneralTerms() error {
}
return fmt.Errorf("license not accepted, please adjust SPLUNK_GENERAL_TERMS to indicate you have accepted the current/latest version of the license. See README file for additional information")
}

// getKVServiceConnectionString returns the connection string for KVService
func getKVServiceConnectionString(ctx context.Context, client splcommon.ControllerClient, namespace string) string {
// TODO:
// wait until the KVService is ready
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, for now, we can return nil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its fine to have some dummy value returned since we are not merging it to main branch and its easier for our testings


// Derive connection string from fixed KVService name
// Format: splunk-kvservice.{namespace}.svc.cluster.local:{port}
kvServiceName := splcommon.KVServiceCrName
url := splcommon.GetServiceFQDN(namespace, kvServiceName)
// TODO: Define KVService port constant? configurable?
// 443 placeholder for https

return fmt.Sprintf("%s:%d", url, 443)
}
16 changes: 16 additions & 0 deletions pkg/splunk/enterprise/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1816,3 +1816,19 @@ func TestValidateLivenessProbe(t *testing.T) {
t.Errorf("Unexpected error when less than deault values passed for livenessProbe InitialDelaySeconds %d, TimeoutSeconds %d, PeriodSeconds %d. Error %s", livenessProbe.InitialDelaySeconds, livenessProbe.TimeoutSeconds, livenessProbe.PeriodSeconds, err)
}
}

func TestGetKVServiceConnectionString(t *testing.T) {
ctx := context.TODO()
client := spltest.NewMockClient()
namespace := "test-namespace"

// Test that the connection string is correctly formatted
result := getKVServiceConnectionString(ctx, client, namespace)

// Expected format: splunk-kvservice.test-namespace.svc.cluster.local:443
expected := fmt.Sprintf("%s.%s.svc.cluster.local:%d", splcommon.KVServiceCrName, namespace, 443)

if result != expected {
t.Errorf("getKVServiceConnectionString() = %s; want %s", result, expected)
}
}
4 changes: 2 additions & 2 deletions pkg/splunk/enterprise/indexercluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ func ApplyIndexerClusterManager(ctx context.Context, client splcommon.Controller
}

// create or update KVService CR with owner reference
err = ApplyKVServiceCR(ctx, client, cr)
err = createKVServiceCR(ctx, client, cr)
if err != nil {
eventPublisher.Warning(ctx, "ApplyKVServiceCR", fmt.Sprintf("apply KVService CR failed %s", err.Error()))
eventPublisher.Warning(ctx, "createKVServiceCR", fmt.Sprintf("apply KVService CR failed %s", err.Error()))
return result, err
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/splunk/enterprise/licensemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ func ApplyLicenseManager(ctx context.Context, client splcommon.ControllerClient,
}

// create or update KVService CR with owner reference
err = ApplyKVServiceCR(ctx, client, cr)
err = createKVServiceCR(ctx, client, cr)
if err != nil {
eventPublisher.Warning(ctx, "ApplyKVServiceCR", fmt.Sprintf("apply KVService CR failed %s", err.Error()))
eventPublisher.Warning(ctx, "createKVServiceCR", fmt.Sprintf("apply KVService CR failed %s", err.Error()))
return result, err
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/splunk/enterprise/monitoringconsole.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ func ApplyMonitoringConsole(ctx context.Context, client splcommon.ControllerClie
}

// create or update KVService CR with owner reference
err = ApplyKVServiceCR(ctx, client, cr)
err = createKVServiceCR(ctx, client, cr)
if err != nil {
eventPublisher.Warning(ctx, "ApplyKVServiceCR", fmt.Sprintf("apply KVService CR failed %s", err.Error()))
eventPublisher.Warning(ctx, "createKVServiceCR", fmt.Sprintf("apply KVService CR failed %s", err.Error()))
return result, err
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/splunk/enterprise/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,8 @@ func GetLivenessDriverFileDir() string {
func GetStartupScriptName() string {
return startupScriptName
}

// GetKVServiceName returns the fixed KVService CR name
func GetKVServiceName() string {
return splcommon.KVServiceCrName
}
4 changes: 2 additions & 2 deletions pkg/splunk/enterprise/searchheadcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ func ApplySearchHeadCluster(ctx context.Context, client splcommon.ControllerClie
}

// create or update KVService CR with owner reference
err = ApplyKVServiceCR(ctx, client, cr)
err = createKVServiceCR(ctx, client, cr)
if err != nil {
eventPublisher.Warning(ctx, "ApplyKVServiceCR", fmt.Sprintf("apply KVService CR failed %s", err.Error()))
eventPublisher.Warning(ctx, "createKVServiceCR", fmt.Sprintf("apply KVService CR failed %s", err.Error()))
return result, err
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/splunk/enterprise/standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ func ApplyStandalone(ctx context.Context, client splcommon.ControllerClient, cr
}

// create or update KVService CR with owner reference
err = ApplyKVServiceCR(ctx, client, cr)
err = createKVServiceCR(ctx, client, cr)
if err != nil {
eventPublisher.Warning(ctx, "ApplyKVServiceCR", fmt.Sprintf("apply KVService CR failed %s", err.Error()))
eventPublisher.Warning(ctx, "createKVServiceCR", fmt.Sprintf("apply KVService CR failed %s", err.Error()))
return result, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
{
"name": "SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH",
"value": "true"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
{
"name": "SPLUNK_LICENSE_MASTER_URL",
"value": "splunk-stack1-license-manager-service.test.svc.cluster.local"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down Expand Up @@ -302,4 +306,4 @@
"replicas": 0,
"availableReplicas": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
{
"name": "SPLUNK_LICENSE_URI",
"value": "/mnt/splunk.lic"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down Expand Up @@ -302,4 +306,4 @@
"replicas": 0,
"availableReplicas": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
{
"name": "SPLUNK_LICENSE_URI",
"value": "/mnt/splunk.lic"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down Expand Up @@ -302,4 +306,4 @@
"replicas": 0,
"availableReplicas": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
{
"name": "SPLUNK_LICENSE_URI",
"value": "/mnt/splunk.lic"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down Expand Up @@ -303,4 +307,4 @@
"replicas": 0,
"availableReplicas": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@
{
"name": "SPLUNK_LICENSE_URI",
"value": "/mnt/splunk.lic"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down Expand Up @@ -307,4 +311,4 @@
"replicas": 0,
"availableReplicas": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@
{
"name": "SPLUNK_LICENSE_URI",
"value": "/mnt/splunk.lic"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down Expand Up @@ -311,4 +315,4 @@
"replicas": 0,
"availableReplicas": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
{
"name": "SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH",
"value": "true"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
{
"name": "SPLUNK_LICENSE_MASTER_URL",
"value": "splunk-stack1-license-manager-service.test.svc.cluster.local"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down Expand Up @@ -302,4 +306,4 @@
"replicas": 0,
"availableReplicas": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
{
"name": "SPLUNK_LICENSE_URI",
"value": "/mnt/splunk.lic"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down Expand Up @@ -302,4 +306,4 @@
"replicas": 0,
"availableReplicas": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
{
"name": "SPLUNK_LICENSE_URI",
"value": "/mnt/splunk.lic"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down Expand Up @@ -302,4 +306,4 @@
"replicas": 0,
"availableReplicas": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
{
"name": "SPLUNK_LICENSE_URI",
"value": "/mnt/splunk.lic"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down Expand Up @@ -303,4 +307,4 @@
"replicas": 0,
"availableReplicas": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@
{
"name": "SPLUNK_LICENSE_URI",
"value": "/mnt/splunk.lic"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down Expand Up @@ -307,4 +311,4 @@
"replicas": 0,
"availableReplicas": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@
{
"name": "SPLUNK_LICENSE_URI",
"value": "/mnt/splunk.lic"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down Expand Up @@ -311,4 +315,4 @@
"replicas": 0,
"availableReplicas": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
{
"name": "SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH",
"value": "true"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
{
"name": "SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH",
"value": "true"
},
{
"name": "KVSERVICE_CONNECTION_STRING",
"value": "splunk-kvservice.test.svc.cluster.local:443"
}
],
"resources": {
Expand Down
Loading
Loading