Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate splunk monitoring console app for indexer clustering #135

Merged
merged 5 commits into from
Oct 5, 2020

Conversation

kashok-splunk
Copy link
Contributor

Automate Splunk monitoring console app for indexer clustering

  • Add cluster master URL to MC configMap
  • Add MC as a searchhead on CM to get indexer info
  • Automate the "Apply Changes" button on the monitoring console app when IndexerCluster custom resource is applied
  • For multi-site get cluster-info and append "SPLUNK_SITE" and "SPLUNK_MULTISITE_MASTER" env variables to MC

pkg/splunk/client/enterprise.go Show resolved Hide resolved
pkg/splunk/client/enterprise.go Show resolved Hide resolved
pkg/splunk/client/enterprise.go Show resolved Hide resolved
pkg/splunk/enterprise/finalizers_test.go Show resolved Hide resolved
pkg/splunk/enterprise/indexercluster.go Show resolved Hide resolved
pkg/splunk/enterprise/indexercluster.go Show resolved Hide resolved
pkg/splunk/enterprise/monitoringconsole.go Show resolved Hide resolved
pkg/splunk/enterprise/util.go Show resolved Hide resolved
@kashok-splunk kashok-splunk requested a review from akondur October 3, 2020 02:39
pkg/splunk/client/enterprise.go Outdated Show resolved Hide resolved
pkg/splunk/client/enterprise.go Show resolved Hide resolved
deploy/crds/enterprise.splunk.com_clustermasters_crd.yaml Outdated Show resolved Hide resolved
pkg/splunk/client/enterprise.go Outdated Show resolved Hide resolved
pkg/splunk/client/enterprise.go Show resolved Hide resolved
pkg/splunk/enterprise/monitoringconsole.go Outdated Show resolved Hide resolved
pkg/splunk/enterprise/monitoringconsole.go Outdated Show resolved Hide resolved
Comment on lines 76 to 78
if spec.ClusterMasterRef.Namespace != "" {
clusterMasterURL = splcommon.GetServiceFQDN(spec.ClusterMasterRef.Namespace, clusterMasterURL)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need an additional conditional check here, just to make sure that the current CRs namespace same as the ClusterMasterRef. If there is a mismatch, we should not proceed here... Thoughts?

Also, GetServiceFQDN is not an option here, and it should be the Master URL always?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How will namespace similar to ClusterMasterRef? We can actually use any valid service/URL name or pod name, we just need valid service where we can connect to

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we supporting the case of indexers in one namespace and CM in another namespace? If so, how are we dealing with the two MCs in different namespaces? Are we officially supporting the deployments across the namespaces?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No,I dont think so we are supporting indexers in a different namespace than CM. Check validateIndexerClusterSpec.

func validateIndexerClusterSpec(cr *enterprisev1.IndexerCluster) error {
	// We cannot have 0 replicas in IndexerCluster spec, since this refers to number of indexers in an indexer cluster
	if cr.Spec.Replicas == 0 {
		cr.Spec.Replicas = 1
	}

	// Cannot leave clusterMasterRef field empty or else we cannot connect to CM
	if len(cr.Spec.ClusterMasterRef.Name) == 0 {
		return fmt.Errorf("IndexerCluster spec should refer to ClusterMaster via clusterMasterRef")
	}

	// Multisite / multipart clusters: can't reference a cluster master located in another namespace because of Service and Secret limitations
	if len(cr.Spec.ClusterMasterRef.Namespace) > 0 && cr.Spec.ClusterMasterRef.Namespace != cr.GetNamespace() {
		return fmt.Errorf("Multisite cluster does not support cluster master to be located in a different namespace")
	}
	return validateCommonSplunkSpec(&cr.Spec.CommonSplunkSpec)
}

licenseMasterURL := GetSplunkServiceName(SplunkLicenseMaster, spec.LicenseMasterRef.Name, false)
if spec.LicenseMasterRef.Namespace != "" {
licenseMasterURL = splcommon.GetServiceFQDN(spec.LicenseMasterRef.Namespace, licenseMasterURL)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as the case of Licence Master. I may be missing something here, but please let me know if we don't need FQDN in a certain cases?
Wondering how this is different from a case when we are dealing with the REST calls..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For rest calls we are using fqdn service, For license master, we are not using it anywhere. This is just for MC to add LM as its peer

pkg/splunk/enterprise/util.go Show resolved Hide resolved
Comment on lines 76 to 78
if spec.ClusterMasterRef.Namespace != "" {
clusterMasterURL = splcommon.GetServiceFQDN(spec.ClusterMasterRef.Namespace, clusterMasterURL)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

How will namespace similar to ClusterMasterRef? We can actually use any valid service/URL name or pod name, we just need valid service where we can connect to

pkg/splunk/enterprise/monitoringconsole.go Outdated Show resolved Hide resolved
pkg/splunk/enterprise/monitoringconsole.go Outdated Show resolved Hide resolved
pkg/splunk/enterprise/clustermaster_test.go Show resolved Hide resolved
pkg/splunk/enterprise/clustermaster.go Show resolved Hide resolved
pkg/splunk/client/enterprise.go Show resolved Hide resolved
pkg/splunk/client/enterprise.go Outdated Show resolved Hide resolved
pkg/splunk/client/enterprise.go Show resolved Hide resolved
pkg/splunk/enterprise/util.go Show resolved Hide resolved
pkg/splunk/enterprise/util.go Show resolved Hide resolved
@kashok-splunk kashok-splunk requested a review from sgontla October 5, 2020 00:08
@kashok-splunk kashok-splunk force-pushed the monitoringConsole_IDXC branch from a93ed4a to 4c5ee96 Compare October 5, 2020 16:24
…ger array from string. Adding logging if len(apiresponse.Entry)<1
@kashok-splunk kashok-splunk force-pushed the monitoringConsole_IDXC branch from 4c5ee96 to d7ddda6 Compare October 5, 2020 16:27
@kashok-splunk
Copy link
Contributor Author

Integration tests passing locally
image

@smohan-splunk
Copy link
Contributor

Integration tests passing locally
image

Manual int-test run due to ongoing circleci limitations

pkg/apis/enterprise/v1alpha3/common_types.go Show resolved Hide resolved
pkg/splunk/client/enterprise.go Show resolved Hide resolved
pkg/splunk/enterprise/monitoringconsole.go Show resolved Hide resolved
pkg/splunk/enterprise/monitoringconsole.go Show resolved Hide resolved
pkg/splunk/client/enterprise.go Show resolved Hide resolved
Comment on lines 76 to 78
if spec.ClusterMasterRef.Namespace != "" {
clusterMasterURL = splcommon.GetServiceFQDN(spec.ClusterMasterRef.Namespace, clusterMasterURL)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

No,I dont think so we are supporting indexers in a different namespace than CM. Check validateIndexerClusterSpec.

func validateIndexerClusterSpec(cr *enterprisev1.IndexerCluster) error {
	// We cannot have 0 replicas in IndexerCluster spec, since this refers to number of indexers in an indexer cluster
	if cr.Spec.Replicas == 0 {
		cr.Spec.Replicas = 1
	}

	// Cannot leave clusterMasterRef field empty or else we cannot connect to CM
	if len(cr.Spec.ClusterMasterRef.Name) == 0 {
		return fmt.Errorf("IndexerCluster spec should refer to ClusterMaster via clusterMasterRef")
	}

	// Multisite / multipart clusters: can't reference a cluster master located in another namespace because of Service and Secret limitations
	if len(cr.Spec.ClusterMasterRef.Namespace) > 0 && cr.Spec.ClusterMasterRef.Namespace != cr.GetNamespace() {
		return fmt.Errorf("Multisite cluster does not support cluster master to be located in a different namespace")
	}
	return validateCommonSplunkSpec(&cr.Spec.CommonSplunkSpec)
}

pkg/splunk/enterprise/util.go Outdated Show resolved Hide resolved
@kashok-splunk
Copy link
Contributor Author

Integration tests after the lastest commit
image

@smohan-splunk smohan-splunk merged commit 57dbb22 into develop Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants