Skip to content

Commit

Permalink
Remove deployment of elasticsearch-exporter (#1)
Browse files Browse the repository at this point in the history
* Remove elasticsearch exporter

* update test

* more test changes
  • Loading branch information
bobdonat authored Jun 22, 2020
1 parent 8ec2a81 commit f9c60df
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 51 deletions.
13 changes: 1 addition & 12 deletions pkg/config/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 2 additions & 4 deletions pkg/resources/deployments/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}

Expand Down Expand Up @@ -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) {
Expand Down
23 changes: 0 additions & 23 deletions pkg/resources/deployments/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions pkg/resources/deployments/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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) {
Expand All @@ -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")
Expand Down
6 changes: 0 additions & 6 deletions pkg/resources/services/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
7 changes: 4 additions & 3 deletions pkg/resources/services/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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")
}

0 comments on commit f9c60df

Please sign in to comment.