Skip to content

Commit

Permalink
Remove -es-discovery service.
Browse files Browse the repository at this point in the history
It is no longer required for discovery, which is now file based.
  • Loading branch information
nkvoll committed Jun 5, 2019
1 parent 3b4a543 commit 3ca9ede
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 76 deletions.
2 changes: 1 addition & 1 deletion operators/pkg/controller/elasticsearch/driver/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (d *defaultDriver) Reconcile(
d.Scheme,
d.CSRClient,
es,
[]corev1.Service{genericResources.DiscoveryService, genericResources.ExternalService},
[]corev1.Service{genericResources.ExternalService},
d.Parameters.CACertValidity,
d.Parameters.CACertRotateBefore,
d.Parameters.CertValidity,
Expand Down
13 changes: 2 additions & 11 deletions operators/pkg/controller/elasticsearch/driver/generic_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
type GenericResources struct {
// ExternalService is the user-facing service
ExternalService corev1.Service
// DiscoveryService is the service used by ES for discovery purposes
DiscoveryService corev1.Service
}

// reconcileGenericResources reconciles the expected generic resources of a cluster.
Expand All @@ -32,20 +30,13 @@ func reconcileGenericResources(
// TODO: consider removing the "res" bits of the ReconcileService signature?
results := &reconciler.Results{}

discoveryService := services.NewDiscoveryService(es)
_, err := common.ReconcileService(c, scheme, discoveryService, &es)
if err != nil {
return nil, results.WithError(err)
}

externalService := services.NewExternalService(es)
_, err = common.ReconcileService(c, scheme, externalService, &es)
_, err := common.ReconcileService(c, scheme, externalService, &es)
if err != nil {
return nil, results.WithError(err)
}

return &GenericResources{
DiscoveryService: *discoveryService,
ExternalService: *externalService,
ExternalService: *externalService,
}, results
}
5 changes: 0 additions & 5 deletions operators/pkg/controller/elasticsearch/name/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const (
secureSettingsSecretSuffix = "secure-settings"
certsSecretSuffix = "certs"
httpServiceSuffix = "http"
discoveryServiceSuffix = "discovery"
elasticUserSecretSuffix = "elastic-user"
esRolesUsersSecretSuffix = "roles-users"
clusterSecretsSecretSuffix = "secrets"
Expand Down Expand Up @@ -102,10 +101,6 @@ func HTTPService(esName string) string {
return ESNamer.Suffix(esName, httpServiceSuffix)
}

func DiscoveryService(esName string) string {
return ESNamer.Suffix(esName, discoveryServiceSuffix)
}

func ElasticUserSecret(esName string) string {
return ESNamer.Suffix(esName, elasticUserSecretSuffix)
}
Expand Down
2 changes: 0 additions & 2 deletions operators/pkg/controller/elasticsearch/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ type NewPodSpecParams struct {
CustomImageName string
// ClusterName is the name of the Elasticsearch cluster
ClusterName string
// DiscoveryServiceName is the name of the Service that should be used for discovery.
DiscoveryServiceName string
// DiscoveryZenMinimumMasterNodes is the setting for minimum master node in Zen Discovery
DiscoveryZenMinimumMasterNodes int

Expand Down
40 changes: 0 additions & 40 deletions operators/pkg/controller/elasticsearch/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,6 @@ const (
globalServiceSuffix = ".svc.cluster.local"
)

// DiscoveryServiceName returns the name for the discovery service
// associated to this cluster
func DiscoveryServiceName(esName string) string {
return name.DiscoveryService(esName)
}

// NewDiscoveryService returns the discovery service associated to the given cluster
// It is used by nodes to talk to each other.
func NewDiscoveryService(es v1alpha1.Elasticsearch) *corev1.Service {
nsn := k8s.ExtractNamespacedName(&es)
return &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Namespace: es.Namespace,
Name: DiscoveryServiceName(es.Name),
Labels: label.NewLabels(nsn),
},
Spec: corev1.ServiceSpec{
Selector: label.NewLabels(nsn),
Ports: []corev1.ServicePort{
corev1.ServicePort{
Protocol: corev1.ProtocolTCP,
Port: network.TransportPort,
},
},
// We set ClusterIP to None in order to let the ES nodes discover all other node IPs at once.
ClusterIP: "None",
SessionAffinity: corev1.ServiceAffinityNone,
Type: corev1.ServiceTypeClusterIP,
// Nodes need to discover themselves before the pod is considered ready,
// otherwise minimum master nodes would never be reached
PublishNotReadyAddresses: true,
},
}
}

// ExternalServiceName returns the name for the external service
// associated to this cluster
func ExternalServiceName(esName string) string {
Expand All @@ -69,11 +34,6 @@ func ExternalServiceURL(es v1alpha1.Elasticsearch) string {
return stringsutil.Concat("https://", ExternalServiceName(es.Name), ".", es.Namespace, globalServiceSuffix, ":", strconv.Itoa(network.HTTPPort))
}

// ExternalDiscoveryServiceHostname returns the hostname used to reach Elasticsearch's discovery endpoint.
func ExternalDiscoveryServiceHostname(es types.NamespacedName) string {
return stringsutil.Concat(DiscoveryServiceName(es.Name), ".", es.Namespace, globalServiceSuffix, ":", strconv.Itoa(network.TransportPort))
}

// NewExternalService returns the external service associated to the given cluster
// It is used by users to perform requests against one of the cluster nodes.
func NewExternalService(es v1alpha1.Elasticsearch) *corev1.Service {
Expand Down
10 changes: 4 additions & 6 deletions operators/pkg/controller/elasticsearch/version/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/elasticsearch/name"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/elasticsearch/pod"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/elasticsearch/processmanager"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/elasticsearch/services"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/elasticsearch/settings"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/elasticsearch/user"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/elasticsearch/volume"
Expand Down Expand Up @@ -45,11 +44,10 @@ func NewExpectedPodSpecs(
for i := int32(0); i < node.NodeCount; i++ {
params := pod.NewPodSpecParams{
// cluster-wide params
Version: es.Spec.Version,
CustomImageName: es.Spec.Image,
ClusterName: es.Name,
DiscoveryServiceName: services.DiscoveryServiceName(es.Name),
SetVMMaxMapCount: es.Spec.SetVMMaxMapCount,
Version: es.Spec.Version,
CustomImageName: es.Spec.Image,
ClusterName: es.Name,
SetVMMaxMapCount: es.Spec.SetVMMaxMapCount,
// volumes
UsersSecretVolume: paramsTmpl.UsersSecretVolume,
ConfigMapVolume: paramsTmpl.ConfigMapVolume,
Expand Down
9 changes: 0 additions & 9 deletions operators/test/e2e/failure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,6 @@ func TestDeleteServices(t *testing.T) {
WithESMasterDataNodes(1, stack.DefaultResources)
RunFailureTest(t, s, func(k *helpers.K8sHelper) helpers.TestStepList {
return helpers.TestStepList{
{
Name: "Delete discovery service",
Test: func(t *testing.T) {
s, err := k.GetService(s.Elasticsearch.Name + "-es-discovery")
require.NoError(t, err)
err = k.Client.Delete(s)
require.NoError(t, err)
},
},
{
Name: "Delete external service",
Test: func(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions operators/test/e2e/stack/checks_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ func CheckServices(stack Builder, k *helpers.K8sHelper) helpers.TestStep {
Name: "Services should be created",
Test: helpers.Eventually(func() error {
for _, s := range []string{
stack.Elasticsearch.Name + "-es-discovery",
esname.HTTPService(stack.Elasticsearch.Name),
kbname.HTTPService(stack.Kibana.Name),
} {
Expand All @@ -301,7 +300,6 @@ func CheckServicesEndpoints(stack Builder, k *helpers.K8sHelper) helpers.TestSte
Name: "Services should have endpoints",
Test: helpers.Eventually(func() error {
for endpointName, addrCount := range map[string]int{
stack.Elasticsearch.Name + "-es-discovery": int(stack.Elasticsearch.Spec.NodeCount()),
kbname.HTTPService(stack.Kibana.Name): int(stack.Kibana.Spec.NodeCount),
esname.HTTPService(stack.Elasticsearch.Name): int(stack.Elasticsearch.Spec.NodeCount()),
} {
Expand Down

0 comments on commit 3ca9ede

Please sign in to comment.