Skip to content

Commit dfb0713

Browse files
committed
Inject app runtime supervisor address as env var
Signed-off-by: Rafal Lal <rafall@splunk.com>
1 parent caf298d commit dfb0713

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

pkg/splunk/enterprise/configuration.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,10 @@ func updateSplunkPodTemplateWithConfig(ctx context.Context, client splcommon.Con
951951
{Name: livenessProbeDriverPathEnv, Value: GetLivenessDriverFilePath()},
952952
{Name: "SPLUNK_GENERAL_TERMS", Value: os.Getenv("SPLUNK_GENERAL_TERMS")},
953953
{Name: "SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH", Value: "true"},
954+
{
955+
Name: "SPLUNK_APPRUNTIME_HEADLESS_SERVICE_FQDN",
956+
Value: GetSplunkAppRuntimeServiceFQDN(cr.GetNamespace(), instanceType, cr.GetName()),
957+
},
954958
}
955959

956960
// update variables for licensing, if configured

pkg/splunk/enterprise/names.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,17 @@ func GetSplunkServiceName(instanceType InstanceType, identifier string, isHeadle
253253
return result
254254
}
255255

256+
// GetSplunkAppRuntimeServiceName uses a template to name the headless Kubernetes Service for Splunk App Runtime instances.
257+
func GetSplunkAppRuntimeServiceName(instanceType InstanceType, identifier string) string {
258+
appRuntimeInstanceType := fmt.Sprintf("%s-appruntime", instanceType)
259+
return fmt.Sprintf(serviceTemplateStr, identifier, appRuntimeInstanceType, "headless")
260+
}
261+
262+
// GetSplunkAppRuntimeServiceFQDN returns the fully qualified domain name for the headless Kubernetes service for Splunk App Runtime instances.
263+
func GetSplunkAppRuntimeServiceFQDN(namespace string, instanceType InstanceType, identifier string) string {
264+
return splcommon.GetServiceFQDN(namespace, GetSplunkAppRuntimeServiceName(instanceType, identifier))
265+
}
266+
256267
// GetSplunkDefaultsName uses a template to name a Kubernetes ConfigMap for a SplunkEnterprise resource.
257268
func GetSplunkDefaultsName(identifier string, instanceType InstanceType) string {
258269
return fmt.Sprintf(defaultsTemplateStr, identifier, instanceType.ToKind())

pkg/splunk/enterprise/names_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,27 @@ func TestGetSplunkServiceName(t *testing.T) {
7070
test("splunk-stack1-license-manager-service", SplunkLicenseManager, LicenseManagerRefName, false)
7171
}
7272

73+
func TestGetSplunkAppRuntimeServiceName(t *testing.T) {
74+
test := func(want string, instanceType InstanceType, identifier string) {
75+
got := GetSplunkAppRuntimeServiceName(instanceType, identifier)
76+
if got != want {
77+
t.Errorf("GetSplunkAppRuntimeServiceName(\"%s\",\"%s\") = %s; want %s",
78+
instanceType.ToString(), identifier, got, want)
79+
}
80+
}
81+
82+
test("splunk-t1-standalone-appruntime-headless", SplunkStandalone, "t1")
83+
test("splunk-t2-cluster-manager-appruntime-headless", SplunkClusterManager, "t2")
84+
}
85+
86+
func TestGetSplunkAppRuntimeServiceFQDN(t *testing.T) {
87+
want := "splunk-t1-search-head-appruntime-headless.splunktest.svc.cluster.local"
88+
got := GetSplunkAppRuntimeServiceFQDN("splunktest", SplunkSearchHead, "t1")
89+
if got != want {
90+
t.Errorf("GetSplunkAppRuntimeServiceFQDN() = %s; want %s", got, want)
91+
}
92+
}
93+
7394
func TestGetSplunkDefaultsName(t *testing.T) {
7495
got := GetSplunkDefaultsName("t1", SplunkSearchHead)
7596
want := "splunk-t1-search-head-defaults"

0 commit comments

Comments
 (0)