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
11 changes: 11 additions & 0 deletions pkg/splunk/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ func ParseResourceQuantity(str string, useIfEmpty string) (resource.Quantity, er
return result, nil
}

// GetServiceURI returns the fully qualified domain name for a Kubernetes service as URI.
func GetServiceURI(namespace string, name string) string {
var scheme string = "https"
if os.Getenv("SPLUNKD_SSL_ENABLE") == "false" {
scheme = "http"
}
return fmt.Sprintf(
"%s://%s:8089", scheme, GetServiceFQDN(namespace, name),
)
}

// GetServiceFQDN returns the fully qualified domain name for a Kubernetes service.
func GetServiceFQDN(namespace string, name string) string {
clusterDomain := os.Getenv("CLUSTER_DOMAIN")
Expand Down
16 changes: 16 additions & 0 deletions pkg/splunk/common/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1013,3 +1013,19 @@ func TestSortAndCompareSlices(t *testing.T) {
t.Errorf("Expect 2 slices to be equal - (%v, %v)", a, b)
}
}

func TestGetServiceURI(t *testing.T) {
test := func(namespace string, name string, want string) {
got := GetServiceURI(namespace, name)
if got != want {
t.Errorf("GetServiceURI() = %s; want %s", got, want)
}
}

os.Setenv("SPLUNKD_SSL_ENABLE", "true")
test("test", "t1", "https://t1.test.svc.cluster.local:8089")

os.Setenv("CLUSTER_DOMAIN", "cluster.local")
os.Setenv("SPLUNKD_SSL_ENABLE", "false")
test("test", "t2", "http://t2.test.svc.cluster.local:8089")
}
16 changes: 16 additions & 0 deletions pkg/splunk/enterprise/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,22 @@ func updateSplunkPodTemplateWithConfig(ctx context.Context, client splcommon.Con
{Name: livenessProbeDriverPathEnv, Value: GetLivenessDriverFilePath()},
}

if os.Getenv("SPLUNKD_SSL_ENABLE") == "false" {
env = append(env, corev1.EnvVar{
Name: "SPLUNK_CERT_PREFIX",
Value: "http",
})
env = append(env, corev1.EnvVar{
Name: "SPLUNKD_SSL_ENABLE",
Value: "false",
})
}
if os.Getenv("SPLUNK_HEC_SSL") == "false" {
env = append(env, corev1.EnvVar{
Name: "SPLUNK_HEC_SSL",
Value: "false",
})
}
// update variables for licensing, if configured
if spec.LicenseURL != "" {
env = append(env, corev1.EnvVar{
Expand Down
Loading