From f9c60df6f3d89c861642d582cc636b88e912e5b3 Mon Sep 17 00:00:00 2001 From: Robert Donat Date: Mon, 22 Jun 2020 12:52:22 -0400 Subject: [PATCH] Remove deployment of elasticsearch-exporter (#1) * Remove elasticsearch exporter * update test * more test changes --- pkg/config/components.go | 13 +---------- pkg/resources/deployments/deployment_test.go | 6 ++--- pkg/resources/deployments/elasticsearch.go | 23 ------------------- .../deployments/elasticsearch_test.go | 6 ++--- pkg/resources/services/elasticsearch.go | 6 ----- pkg/resources/services/elasticsearch_test.go | 7 +++--- 6 files changed, 10 insertions(+), 51 deletions(-) diff --git a/pkg/config/components.go b/pkg/config/components.go index ef158605..90a30b49 100644 --- a/pkg/config/components.go +++ b/pkg/config/components.go @@ -27,7 +27,7 @@ type ComponentDetails struct { } // Array of all ComponentDetails -var AllComponentDetails = []*ComponentDetails{&Grafana, &Prometheus, &PrometheusInit, &PrometheusGW, &AlertManager, &AlertManagerCluster, &ESWait, &Kibana, &ElasticsearchIngest, &ElasticsearchMaster, &ElasticsearchData, &ElasticsearchInit, &Api, &ElasticsearchExporter, &ConfigReloader, &NodeExporter} +var AllComponentDetails = []*ComponentDetails{&Grafana, &Prometheus, &PrometheusInit, &PrometheusGW, &AlertManager, &AlertManagerCluster, &ESWait, &Kibana, &ElasticsearchIngest, &ElasticsearchMaster, &ElasticsearchData, &ElasticsearchInit, &Api, &ConfigReloader, &NodeExporter} // Storage operation-related stuff var StorageEnableComponents = []*ComponentDetails{&Grafana, &Prometheus, &ElasticsearchData} @@ -168,17 +168,6 @@ var Api = ComponentDetails{ Privileged: false, } -// Default ElasticsearchExporter configuration -var ElasticsearchExporter = ComponentDetails{ - Name: "es-exporter", - EnvName: "ELASTICSEARCH_EXPORTER_IMAGE", - ImagePullPolicy: constants.DefaultImagePullPolicy, - Port: 9114, - LivenessHTTPPath: "/", - ReadinessHTTPPath: "/", - Privileged: true, -} - // Default config-reloader configuration var ConfigReloader = ComponentDetails{ Name: "config-reloader", diff --git a/pkg/resources/deployments/deployment_test.go b/pkg/resources/deployments/deployment_test.go index 261869f6..e46668c9 100644 --- a/pkg/resources/deployments/deployment_test.go +++ b/pkg/resources/deployments/deployment_test.go @@ -8,10 +8,10 @@ import ( "github.com/verrazzano/verrazzano-monitoring-operator/pkg/config" + "github.com/stretchr/testify/assert" vmcontrollerv1 "github.com/verrazzano/verrazzano-monitoring-operator/pkg/apis/vmcontroller/v1" "github.com/verrazzano/verrazzano-monitoring-operator/pkg/constants" "github.com/verrazzano/verrazzano-monitoring-operator/pkg/resources" - "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -56,7 +56,7 @@ func TestSauronFullDeploymentSize(t *testing.T) { if err != nil { t.Error(err) } - assert.Equal(t, 8, len(deployments), "Length of generated deployments") + assert.Equal(t, 7, len(deployments), "Length of generated deployments") assert.Equal(t, constants.SauronKind, deployments[0].ObjectMeta.OwnerReferences[0].Kind, "OwnerReferences is not set by default") } @@ -192,8 +192,6 @@ func TestSauronWithResourceConstraints(t *testing.T) { // No resources specified on this endpoint } else if deployment.Name == resources.GetMetaName(sauron.Name, config.ElasticsearchData.Name) { // No resources specified on this endpoint - } else if deployment.Name == resources.GetMetaName(sauron.Name, config.ElasticsearchExporter.Name) { - // No resources specified on this endpoint } else if deployment.Name == resources.GetMetaName(sauron.Name, config.Api.Name) { // No resources specified on API endpoint } else if deployment.Name == resources.GetMetaName(sauron.Name, config.PrometheusGW.Name) { diff --git a/pkg/resources/deployments/elasticsearch.go b/pkg/resources/deployments/elasticsearch.go index 96816250..3e3d1d31 100644 --- a/pkg/resources/deployments/elasticsearch.go +++ b/pkg/resources/deployments/elasticsearch.go @@ -191,33 +191,10 @@ func (es ElasticsearchBasic) createElasticsearchDataDeploymentElements(sauron *v return deployList } -// Creates all Elasticsearch Exporter deployment elements -func (es ElasticsearchBasic) createElasticsearchExporterDeploymentElements(sauron *vmcontrollerv1.VerrazzanoMonitoringInstance) []*appsv1.Deployment { - elasticsearchExporterDeployment := createDeploymentElement(sauron, nil, nil, config.ElasticsearchExporter) - - elasticsearchExporterDeployment.Spec.Template.Spec.Containers[0].Command = []string{ - "/bin/elasticsearch_exporter", - "--es.uri=" + fmt.Sprintf("http://%s:%d", resources.GetMetaName(sauron.Name, config.ElasticsearchIngest.Name), config.ElasticsearchIngest.Port), - "--es.all", - "--es.timeout=20s", - } - - elasticsearchExporterDeployment.Spec.Template.Spec.Containers[0].Ports[0].Name = "http" - elasticsearchExporterDeployment.Spec.Template.Spec.Containers[0].LivenessProbe.FailureThreshold = 3 - elasticsearchExporterDeployment.Spec.Template.Spec.Containers[0].LivenessProbe.TimeoutSeconds = 5 - elasticsearchExporterDeployment.Spec.Template.Spec.Containers[0].LivenessProbe.PeriodSeconds = 10 - - elasticsearchExporterDeployment.Spec.Template.Spec.Containers[0].ReadinessProbe.FailureThreshold = 3 - elasticsearchExporterDeployment.Spec.Template.Spec.Containers[0].ReadinessProbe.TimeoutSeconds = 5 - elasticsearchExporterDeployment.Spec.Template.Spec.Containers[0].ReadinessProbe.PeriodSeconds = 10 - return []*appsv1.Deployment{elasticsearchExporterDeployment} -} - // Creates *all* Elasticsearch deployment elements func (es ElasticsearchBasic) createElasticsearchDeploymentElements(sauron *vmcontrollerv1.VerrazzanoMonitoringInstance, pvcToAdMap map[string]string) []*appsv1.Deployment { var deployList []*appsv1.Deployment deployList = append(deployList, es.createElasticsearchIngestDeploymentElements(sauron)...) deployList = append(deployList, es.createElasticsearchDataDeploymentElements(sauron, pvcToAdMap)...) - deployList = append(deployList, es.createElasticsearchExporterDeploymentElements(sauron)...) return deployList } diff --git a/pkg/resources/deployments/elasticsearch_test.go b/pkg/resources/deployments/elasticsearch_test.go index 1146906d..5ffdf375 100644 --- a/pkg/resources/deployments/elasticsearch_test.go +++ b/pkg/resources/deployments/elasticsearch_test.go @@ -7,10 +7,10 @@ import ( "strconv" "testing" + "github.com/stretchr/testify/assert" vmcontrollerv1 "github.com/verrazzano/verrazzano-monitoring-operator/pkg/apis/vmcontroller/v1" "github.com/verrazzano/verrazzano-monitoring-operator/pkg/config" "github.com/verrazzano/verrazzano-monitoring-operator/pkg/resources" - "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -35,7 +35,7 @@ func TestElasticsearchDefaultDeployments1(t *testing.T) { } var es Elasticsearch = ElasticsearchBasic{} deployments := es.createElasticsearchDeploymentElements(sauron, map[string]string{}) - assert.Equal(t, 3, len(deployments), "Length of generated deployments") + assert.Equal(t, 2, len(deployments), "Length of generated deployments") } func TestElasticsearchDefaultDeployments2(t *testing.T) { @@ -58,7 +58,7 @@ func TestElasticsearchDefaultDeployments2(t *testing.T) { } var es Elasticsearch = ElasticsearchBasic{} deployments := es.createElasticsearchDeploymentElements(sauron, map[string]string{}) - assert.Equal(t, 5, len(deployments), "Length of generated deployments") + assert.Equal(t, 4, len(deployments), "Length of generated deployments") clientDeployment, _ := getDeploymentByName(resources.GetMetaName(sauron.Name, config.ElasticsearchIngest.Name), deployments) assert.NotNil(t, clientDeployment, "Client deployment") diff --git a/pkg/resources/services/elasticsearch.go b/pkg/resources/services/elasticsearch.go index 79f4bfe0..20c564cf 100644 --- a/pkg/resources/services/elasticsearch.go +++ b/pkg/resources/services/elasticsearch.go @@ -33,17 +33,11 @@ func createElasticsearchDataServiceElements(sauron *vmcontrollerv1.VerrazzanoMon return elasticsearchDataService } -// Creates Elasticsearch Exporter service element -func createElasticsearchExporterServiceElements(sauron *vmcontrollerv1.VerrazzanoMonitoringInstance) *corev1.Service { - return createServiceElement(sauron, config.ElasticsearchExporter) -} - // Creates *all* Elasticsearch service elements func createElasticsearchServiceElements(sauron *vmcontrollerv1.VerrazzanoMonitoringInstance) []*corev1.Service { var services []*corev1.Service services = append(services, createElasticsearchIngestServiceElements(sauron)) services = append(services, createElasticsearchMasterServiceElements(sauron)) services = append(services, createElasticsearchDataServiceElements(sauron)) - services = append(services, createElasticsearchExporterServiceElements(sauron)) return services } diff --git a/pkg/resources/services/elasticsearch_test.go b/pkg/resources/services/elasticsearch_test.go index 44b8fab2..13f9fc7d 100644 --- a/pkg/resources/services/elasticsearch_test.go +++ b/pkg/resources/services/elasticsearch_test.go @@ -3,10 +3,11 @@ package services import ( - vmcontrollerv1 "github.com/verrazzano/verrazzano-monitoring-operator/pkg/apis/vmcontroller/v1" + "testing" + "github.com/stretchr/testify/assert" + vmcontrollerv1 "github.com/verrazzano/verrazzano-monitoring-operator/pkg/apis/vmcontroller/v1" "k8s.io/apimachinery/pkg/apis/meta/v1" - "testing" ) func TestElasticsearchDefaultServices1(t *testing.T) { @@ -24,5 +25,5 @@ func TestElasticsearchDefaultServices1(t *testing.T) { }, } services := createElasticsearchServiceElements(sauron) - assert.Equal(t, 4, len(services), "Length of generated services") + assert.Equal(t, 3, len(services), "Length of generated services") }