Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
14bb8a0
feat(cr): Support insecure mgmt mode
ryanfaircloth Nov 27, 2020
8c548c7
redo enhancements to allow unit testing
ryanfaircloth Nov 28, 2020
01371af
fixes
ryanfaircloth Nov 28, 2020
ee616a0
Update monitoringconsole.go
ryanfaircloth Nov 28, 2020
23bd06f
fix test
ryanfaircloth Nov 28, 2020
5f74bd1
Update util_test.go
ryanfaircloth Nov 28, 2020
818e3c8
restore port
ryanfaircloth Nov 28, 2020
b755276
allow insecure license manager
ryanfaircloth Nov 28, 2020
d0bb10b
Update configuration.go
ryanfaircloth Nov 28, 2020
6209878
Update common_types.go
ryanfaircloth Nov 28, 2020
fa5bf93
fixes
ryanfaircloth Nov 28, 2020
92786da
default must be false so flag true means "insecure"
ryanfaircloth Nov 29, 2020
cdcafa7
Update common_types.go
ryanfaircloth Nov 29, 2020
306504c
Update common_types.go
ryanfaircloth Nov 29, 2020
fb0ba95
Update common_types.go
ryanfaircloth Nov 29, 2020
854213c
Update common_types.go
ryanfaircloth Nov 29, 2020
695b6fc
Update enterprise.splunk.com_clustermasters_crd.yaml
ryanfaircloth Nov 29, 2020
34c57be
Fix CRDs
ryanfaircloth Nov 29, 2020
8a61996
more updates
ryanfaircloth Nov 29, 2020
e69cd96
this should break
ryanfaircloth Nov 29, 2020
f6241ae
Update configuration.go
ryanfaircloth Nov 29, 2020
1584a3b
Improve error text
ryanfaircloth Dec 1, 2020
6301457
Temporary change due to bugs in ansible and docker
ryanfaircloth Dec 1, 2020
4cbed83
Update indexercluster.go
ryanfaircloth Dec 1, 2020
5c6e397
Update config.yml
ryanfaircloth Dec 1, 2020
0d105f1
restore passing tests
ryanfaircloth Dec 1, 2020
39511de
New approach use global env
ryanfaircloth Dec 1, 2020
ffe75d4
Complete support for namespace level optional TLS web,splunkd,hec,s2s
ryanfaircloth Dec 1, 2020
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ workflows:
- integration-tests:
requires:
- build-image
- unit-tests
# - unit-tests
- vulnerability-scan:
requires:
- build-image
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@ clair-scanner-logs
release-*
deploy/olm-certified
*junit.xml
*.lic
1,704 changes: 440 additions & 1,264 deletions deploy/crds/enterprise.splunk.com_clustermasters_crd.yaml

Large diffs are not rendered by default.

1,687 changes: 443 additions & 1,244 deletions deploy/crds/enterprise.splunk.com_indexerclusters_crd.yaml

Large diffs are not rendered by default.

1,629 changes: 417 additions & 1,212 deletions deploy/crds/enterprise.splunk.com_licensemasters_crd.yaml

Large diffs are not rendered by default.

1,713 changes: 448 additions & 1,265 deletions deploy/crds/enterprise.splunk.com_searchheadclusters_crd.yaml

Large diffs are not rendered by default.

768 changes: 196 additions & 572 deletions deploy/crds/enterprise.splunk.com_sparks_crd.yaml

Large diffs are not rendered by default.

1,749 changes: 456 additions & 1,293 deletions deploy/crds/enterprise.splunk.com_standalones_crd.yaml

Large diffs are not rendered by default.

1,704 changes: 440 additions & 1,264 deletions deploy/olm-catalog/splunk/0.2.0/enterprise.splunk.com_clustermasters_crd.yaml

Large diffs are not rendered by default.

1,687 changes: 443 additions & 1,244 deletions deploy/olm-catalog/splunk/0.2.0/enterprise.splunk.com_indexerclusters_crd.yaml

Large diffs are not rendered by default.

1,629 changes: 417 additions & 1,212 deletions deploy/olm-catalog/splunk/0.2.0/enterprise.splunk.com_licensemasters_crd.yaml

Large diffs are not rendered by default.

1,713 changes: 448 additions & 1,265 deletions deploy/olm-catalog/splunk/0.2.0/enterprise.splunk.com_searchheadclusters_crd.yaml

Large diffs are not rendered by default.

768 changes: 196 additions & 572 deletions deploy/olm-catalog/splunk/0.2.0/enterprise.splunk.com_sparks_crd.yaml

Large diffs are not rendered by default.

1,749 changes: 456 additions & 1,293 deletions deploy/olm-catalog/splunk/0.2.0/enterprise.splunk.com_standalones_crd.yaml

Large diffs are not rendered by default.

603 changes: 300 additions & 303 deletions deploy/olm-catalog/splunk/0.2.0/splunk.v0.2.0.clusterserviceversion.yaml

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions pkg/splunk/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ func GetServiceFQDN(namespace string, name string) string {
)
}

// 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),
)
}

// GenerateSecret returns a randomly generated sequence of text that is n bytes in length.
func GenerateSecret(SecretBytes string, n int) []byte {
b := make([]byte, n)
Expand Down Expand Up @@ -202,7 +213,7 @@ func CompareSortedStrings(a []string, b []string) bool {
// GetIstioAnnotations returns a map of istio annotations for a pod template
func GetIstioAnnotations(ports []corev1.ContainerPort) map[string]string {
// list of ports within the deployments that we want istio to leave alone
excludeOutboundPorts := []int32{8089, 8191, 9997, 7777, 9000, 17000, 17500, 19000}
excludeOutboundPorts := []int32{8191, 7777, 9000, 17000, 17500, 19000}

// calculate outbound port exclusions
excludeOutboundPortsLookup := make(map[int32]bool)
Expand All @@ -221,10 +232,14 @@ func GetIstioAnnotations(ports []corev1.ContainerPort) map[string]string {
for idx := range sortedPorts {
_, skip := excludeOutboundPortsLookup[sortedPorts[idx].ContainerPort]
if !skip {
if includeInboundPortsBuf.Len() > 0 {
fmt.Fprint(includeInboundPortsBuf, ",")

if (strings.Contains(sortedPorts[idx].Name, "-") || strings.Contains(sortedPorts[idx].Name, "spark") || strings.Contains(sortedPorts[idx].Name, "workerwebui")) && !strings.Contains(sortedPorts[idx].Name, "replication-") {
if includeInboundPortsBuf.Len() > 0 {
fmt.Fprint(includeInboundPortsBuf, ",")
}
fmt.Fprintf(includeInboundPortsBuf, "%d", sortedPorts[idx].ContainerPort)
}
fmt.Fprintf(includeInboundPortsBuf, "%d", sortedPorts[idx].ContainerPort)

}
}

Expand Down
24 changes: 21 additions & 3 deletions pkg/splunk/common/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,30 @@ func TestGetServiceFQDN(t *testing.T) {
}
}

os.Setenv("CLUSTER_DOMAIN", "cluster.local")
test("test", "t1", "t1.test.svc.cluster.local")

os.Setenv("CLUSTER_DOMAIN", "example.com")
test("test", "t2", "t2.test.svc.example.com")
}

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("CLUSTER_DOMAIN", "cluster.local")
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")
}

func TestGenerateSecret(t *testing.T) {
test := func(SecretBytes string, n int) {
results := [][]byte{}
Expand Down Expand Up @@ -549,16 +567,16 @@ func TestGetIstioAnnotations(t *testing.T) {
{ContainerPort: 9000}, {ContainerPort: 8000}, {ContainerPort: 80},
}
want = map[string]string{
"traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997,7777,9000,17000,17500,19000",
"traffic.sidecar.istio.io/includeInboundPorts": "80,8000",
"traffic.sidecar.istio.io/excludeOutboundPorts": "8191,7777,9000,17000,17500,19000",
"traffic.sidecar.istio.io/includeInboundPorts": "",
}
test()

ports = []corev1.ContainerPort{
{ContainerPort: 9000}, {ContainerPort: 8089}, {ContainerPort: 7777}, {ContainerPort: 17500}, {ContainerPort: 8191},
}
want = map[string]string{
"traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997,7777,9000,17000,17500,19000",
"traffic.sidecar.istio.io/excludeOutboundPorts": "8191,7777,9000,17000,17500,19000",
"traffic.sidecar.istio.io/includeInboundPorts": "",
}
test()
Expand Down
5 changes: 2 additions & 3 deletions pkg/splunk/enterprise/clustermaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,9 @@ func PushMasterAppsBundle(c splcommon.ControllerClient, cr *enterprisev1.Cluster
scopedLog.Info("Issueing REST call to push master aps bundle")

masterIdxcName := cr.GetName()
fqdnName := splcommon.GetServiceFQDN(cr.GetNamespace(), GetSplunkServiceName(SplunkClusterMaster, masterIdxcName, false))
uri := splcommon.GetServiceURI(cr.GetNamespace(), GetSplunkServiceName(SplunkClusterMaster, masterIdxcName, false))

// Get a Splunk client to execute the REST call
splunkClient := splclient.NewSplunkClient(fmt.Sprintf("https://%s:8089", fqdnName), "admin", string(adminPwd))
splunkClient := splclient.NewSplunkClient(uri, "admin", string(adminPwd))

return splunkClient.BundlePush(true)
}
6 changes: 3 additions & 3 deletions pkg/splunk/enterprise/clustermaster_test.go

Large diffs are not rendered by default.

90 changes: 71 additions & 19 deletions pkg/splunk/enterprise/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package enterprise

import (
"fmt"
"os"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -245,28 +246,47 @@ func prepareSplunkSmartstoreConfigMap(identifier, namespace string, crKind strin

// getSplunkPorts returns a map of ports to use for Splunk instances.
func getSplunkPorts(instanceType InstanceType) map[string]int {
var scheme string
scheme = "https"
if os.Getenv("SPLUNKD_SSL_ENABLE") == "false" {
scheme = "http"
}

var webScheme string
webScheme = "http"
if os.Getenv("SPLUNK_HTTP_ENABLESSL") == "true" {
webScheme = "https"
}
result := map[string]int{
"splunkweb": 8000,
"splunkd": 8089,
fmt.Sprintf("splunkweb-%s", webScheme): 8000,
fmt.Sprintf("splunkd-%s", scheme): 8089,
}

var hecScheme string
hecScheme = "https"
if os.Getenv("SPLUNK_HEC_SSL") == "false" {
hecScheme = "http"
}

switch instanceType {
case SplunkMonitoringConsole:
result["hec"] = 8088
result["s2s"] = 9997
result[fmt.Sprintf("hec-%s", hecScheme)] = 8088
result["s2s-tcp"] = 9997
case SplunkStandalone:
result["dfccontrol"] = 17000
result["datareceive"] = 19000
result["dfsmaster"] = 9000
result["hec"] = 8088
result["s2s"] = 9997
result[fmt.Sprintf("hec-%s", hecScheme)] = 8088
result["s2s-tcp"] = 9997
case SplunkSearchHead:
result["dfccontrol"] = 17000
result["datareceive"] = 19000
result["dfsmaster"] = 9000
case SplunkIndexer:
result["hec"] = 8088
result["s2s"] = 9997
result[fmt.Sprintf("hec-%s", hecScheme)] = 8088
result["replication-tcp"] = 9887
result["s2s-tcp"] = 9997

}

return result
Expand All @@ -289,12 +309,15 @@ func getSplunkContainerPorts(instanceType InstanceType) []corev1.ContainerPort {
func getSplunkServicePorts(instanceType InstanceType) []corev1.ServicePort {
l := []corev1.ServicePort{}
for key, value := range getSplunkPorts(instanceType) {
l = append(l, corev1.ServicePort{
Name: key,
Port: int32(value),
TargetPort: intstr.FromInt(value),
Protocol: corev1.ProtocolTCP,
})
if key != "replication-tcp" {
l = append(l, corev1.ServicePort{
Name: key,
Port: int32(value),
TargetPort: intstr.FromInt(value),
Protocol: corev1.ProtocolTCP,
})
}

}
return l
}
Expand Down Expand Up @@ -610,7 +633,33 @@ func updateSplunkPodTemplateWithConfig(client splcommon.ControllerClient, podTem
{Name: "SPLUNK_ROLE", Value: role},
{Name: "SPLUNK_DECLARATIVE_ADMIN_PASSWORD", Value: "true"},
}
if os.Getenv("SPLUNK_HTTP_ENABLESSL") == "true" {
env = append(env, corev1.EnvVar{
Name: "SPLUNK_HTTP_ENABLESSL",
Value: "true",
})
}

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",
})
env = append(env, corev1.EnvVar{
Name: "NO_HEALTHCHECK",
Value: "true",
})
}
if os.Getenv("SPLUNKD_SSL_ENABLE") == "false" {
env = append(env, corev1.EnvVar{
Name: "SPLUNKD_SSL_ENABLE",
Value: "false",
})
}
// update variables for licensing, if configured
if spec.LicenseURL != "" {
env = append(env, corev1.EnvVar{
Expand All @@ -619,13 +668,16 @@ func updateSplunkPodTemplateWithConfig(client splcommon.ControllerClient, podTem
})
}
if instanceType != SplunkLicenseMaster && spec.LicenseMasterRef.Name != "" {
licenseMasterURL := GetSplunkServiceName(SplunkLicenseMaster, spec.LicenseMasterRef.Name, false)
if spec.LicenseMasterRef.Namespace != "" {
licenseMasterURL = splcommon.GetServiceFQDN(spec.LicenseMasterRef.Namespace, licenseMasterURL)
licenseMasterName := GetSplunkServiceName(SplunkLicenseMaster, spec.LicenseMasterRef.Name, false)
var namespace string
if spec.LicenseMasterRef.Namespace == "" {
namespace = cr.GetNamespace()
} else {
namespace = spec.LicenseMasterRef.Namespace
}
env = append(env, corev1.EnvVar{
Name: "SPLUNK_LICENSE_MASTER_URL",
Value: licenseMasterURL,
Value: splcommon.GetServiceURI(namespace, licenseMasterName),
})
}

Expand All @@ -637,7 +689,7 @@ func updateSplunkPodTemplateWithConfig(client splcommon.ControllerClient, podTem
} else if spec.ClusterMasterRef.Name != "" {
clusterMasterURL = GetSplunkServiceName(SplunkClusterMaster, spec.ClusterMasterRef.Name, false)
if spec.ClusterMasterRef.Namespace != "" {
clusterMasterURL = splcommon.GetServiceFQDN(spec.ClusterMasterRef.Namespace, clusterMasterURL)
clusterMasterURL = splcommon.GetServiceURI(spec.ClusterMasterRef.Namespace, clusterMasterURL)
}
}
if clusterMasterURL != "" {
Expand Down
Loading