From 71bf4284d17a29c63ee6ad5ace67ca436b4949d2 Mon Sep 17 00:00:00 2001 From: Ethan Date: Thu, 29 Jun 2017 09:26:54 -0400 Subject: [PATCH] added optional nodeport variable --- example/example-es-cluster.json | 1 + pkg/k8sutil/k8sutil.go | 7 +++++-- pkg/processor/processor.go | 2 +- pkg/spec/cluster.go | 6 +++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/example/example-es-cluster.json b/example/example-es-cluster.json index 62233d94d..79cf3a087 100644 --- a/example/example-es-cluster.json +++ b/example/example-es-cluster.json @@ -20,6 +20,7 @@ "type": "gp2", "storage-class-provisioner": "kubernetes.io/aws-ebs" }, + "nodePort": 30303, "resources": { "requests": { "memory": "512Mi", diff --git a/pkg/k8sutil/k8sutil.go b/pkg/k8sutil/k8sutil.go index d9dad52c6..eb4eef4c4 100644 --- a/pkg/k8sutil/k8sutil.go +++ b/pkg/k8sutil/k8sutil.go @@ -401,7 +401,7 @@ func (k *K8sutil) CreateDataService(clusterName string) error { } // CreateClientService creates the client service -func (k *K8sutil) CreateClientService(clusterName string) error { +func (k *K8sutil) CreateClientService(clusterName string, nodePort int32) error { fullClientServiceName := clientServiceName + "-" + clusterName component := "elasticsearch" + "-" + clusterName @@ -434,7 +434,10 @@ func (k *K8sutil) CreateClientService(clusterName string) error { }, }, } - + if nodePort > 0 { + clientSvc.Spec.Type = v1.ServiceTypeNodePort + clientSvc.Spec.Ports[0].NodePort = nodePort + } _, err := k.Kclient.Services(namespace).Create(clientSvc) if err != nil { diff --git a/pkg/processor/processor.go b/pkg/processor/processor.go index 5fd5638b4..ca416228f 100644 --- a/pkg/processor/processor.go +++ b/pkg/processor/processor.go @@ -181,7 +181,7 @@ func (p *Processor) processElasticSearchCluster(c *myspec.ElasticsearchCluster) // Create Services p.k8sclient.CreateDiscoveryService(c.Metadata.Name) p.k8sclient.CreateDataService(c.Metadata.Name) - p.k8sclient.CreateClientService(c.Metadata.Name) + p.k8sclient.CreateClientService(c.Metadata.Name, c.Spec.NodePort) p.k8sclient.CreateClientMasterDeployment("client", baseImage, &c.Spec.ClientNodeReplicas, c.Spec.JavaOptions, c.Spec.Resources, c.Spec.ImagePullSecrets, c.Metadata.Name, c.Spec.Instrumentation.StatsdHost) p.k8sclient.CreateClientMasterDeployment("master", baseImage, &c.Spec.MasterNodeReplicas, c.Spec.JavaOptions, c.Spec.Resources, c.Spec.ImagePullSecrets, c.Metadata.Name, c.Spec.Instrumentation.StatsdHost) diff --git a/pkg/spec/cluster.go b/pkg/spec/cluster.go index 5135f7c1f..44e78d962 100644 --- a/pkg/spec/cluster.go +++ b/pkg/spec/cluster.go @@ -1,3 +1,4 @@ + /* Copyright (c) 2017, UPMC Enterprises All rights reserved. @@ -88,7 +89,10 @@ type ClusterSpec struct { // Instrumentation defines metrics for the cluster Instrumentation Instrumentation `json:"instrumentation"` - + + //NodePort + NodePort int32 `json:"nodePort"` + Scheduler *snapshot.Scheduler }