From b1a2e768c88b45ef640453662d642f4d44963387 Mon Sep 17 00:00:00 2001 From: Holger Protzek Date: Thu, 27 Jun 2019 11:04:44 +0200 Subject: [PATCH 1/2] added carbon ingester port config to cluster spec Signed-off-by: Holger Protzek --- .gitignore | 1 + assets/default-config.tmpl | 5 +++ assets/default-config.yaml | 3 ++ pkg/apis/m3dboperator/v1alpha1/cluster.go | 4 +++ .../v1alpha1/openapi_generated.go | 7 ++++ pkg/assets/statik.go | 2 +- pkg/k8sops/config_map.go | 6 +++- pkg/k8sops/config_map_test.go | 3 ++ pkg/k8sops/fixtures/testM3DBCluster.yaml | 1 + pkg/k8sops/generators.go | 33 ++++++++++++++----- pkg/k8sops/generators_test.go | 6 ++-- pkg/k8sops/ports.go | 1 + 12 files changed, 58 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index cb74a738..24687f1c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ # Dev artifacts .vscode/ +.idea # Binaries for programs and plugins *.so diff --git a/assets/default-config.tmpl b/assets/default-config.tmpl index ac122784..beb4781b 100644 --- a/assets/default-config.tmpl +++ b/assets/default-config.tmpl @@ -18,6 +18,11 @@ coordinator: extended: none tagOptions: idScheme: quoted +{{- if .CarbonIngester }} + carbon: + ingester: + listenAddress: "0.0.0.0:7204" +{{- end }} db: logging: diff --git a/assets/default-config.yaml b/assets/default-config.yaml index d7cfbb38..840f2d80 100644 --- a/assets/default-config.yaml +++ b/assets/default-config.yaml @@ -18,6 +18,9 @@ coordinator: extended: none tagOptions: idScheme: quoted + carbon: + ingester: + listenAddress: "0.0.0.0:7204" db: logging: diff --git a/pkg/apis/m3dboperator/v1alpha1/cluster.go b/pkg/apis/m3dboperator/v1alpha1/cluster.go index febf390c..42d809f0 100644 --- a/pkg/apis/m3dboperator/v1alpha1/cluster.go +++ b/pkg/apis/m3dboperator/v1alpha1/cluster.go @@ -200,6 +200,10 @@ type ClusterSpec struct { // +optional KeepEtcdDataOnDelete bool `json:"keepEtcdDataOnDelete,omitempty"` + // EnableCarbonIngester enables the listener port for the carbon ingester + // +optional + EnableCarbonIngester bool `json:"enableCarbonIngester,omitempty"` + // ConfigMapName specifies the ConfigMap to use for this cluster. If unset a // default configmap with template variables for etcd endpoints will be used. // See "Configuring M3DB" in the docs for more. diff --git a/pkg/apis/m3dboperator/v1alpha1/openapi_generated.go b/pkg/apis/m3dboperator/v1alpha1/openapi_generated.go index 2eaf3ba1..333be39e 100644 --- a/pkg/apis/m3dboperator/v1alpha1/openapi_generated.go +++ b/pkg/apis/m3dboperator/v1alpha1/openapi_generated.go @@ -407,6 +407,13 @@ func schema_pkg_apis_m3dboperator_v1alpha1_ClusterSpec(ref common.ReferenceCallb Format: "", }, }, + "enableCarbonIngester": { + SchemaProps: spec.SchemaProps{ + Description: "EnableCarbonIngester enables the listener port for the carbon ingester", + Type: []string{"boolean"}, + Format: "", + }, + }, "configMapName": { SchemaProps: spec.SchemaProps{ Description: "ConfigMapName specifies the ConfigMap to use for this cluster. If unset a default configmap with template variables for etcd endpoints will be used. See \"Configuring M3DB\" in the docs for more.", diff --git a/pkg/assets/statik.go b/pkg/assets/statik.go index 2740a95f..59aff0cc 100644 --- a/pkg/assets/statik.go +++ b/pkg/assets/statik.go @@ -26,6 +26,6 @@ import ( ) func init() { - data := "PK\x03\x04\x14\x00\x08\x00\x08\x00\x00\x00!(\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x13\x00 \x00default-config.tmplUT\x05\x00\x01\x80Cm8\xa4T\xdfo\xdbF\x0c~\xd7_Ad\xcf\xb6l7^\xd2{k\x9d\x16\x18\x90u\xc6\xb2>\x1b\xe7;J\xbe\xf5tTy<5N\x90\xff}8I\xfe\x91\x05\xc60\x14~\x91\xc9O\x1f\xbf\x8f\xa4h\x88\xd8\xba\xa0\x85X\x15\x00\xdeE\xc1\xf0\xc1Z\xc6\x18s\x00@\xf6-*\xb82\x14*W_\xf5\xa1N\xfb\x94c\xb3i\xffS7\x8b\xd9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x95\xf3\x1e\xedg\xe2\x151\xa7VV\xbd\x86{\xaa?\xe7^(\xa8\xb4\x8f\xd8o\xc7kq\x95Oq\xf7\xbb~\xfc\xb8\x97\x0c[.\xae\x17\xb7\xb7\xa7\xcc\xa7\x0ey\xaf`>4\xe9{\xc2\x84'SF{\x93|\xaf\xff\xaf\xfe\x8cV\xee\xf1x?\x01\xa2{B\x05\x8b\xd9\xfb\x9b\xf9r\x91K\x1fZ\x98\xc7\x93\xaf\xc3z\xbc\x9be\xa7\xb9\xf4n\xdb\xaf\xfa\xa01\x9f\xfb\xf1\xd2\"w\xce\x9cU\xc5\xd0)\xb8z~\x86\xe9\xa7\xd0\xc1\xcb\xcb\xd51\xf3D\x01\x15`\xb3Ek\xcfu\x8c\x0c\xd0\xd3\x9f\xc4\x9b\x1d\xde9~U\xfe[w*#\xc6\x8e_\xfe\xab\xdd\xbaP$\xeb\xb2-\xb9 Q\x15\xcf\xcf\x13`\x1dj\xcc\x1a\xc7(\xbc\xbc\x9c\x81'\xd9\xc1\x04\xa6\xbd\xfe\xfc\x84\xc1f\xc4?\x01\x00\x00\xff\xffPK\x07\x08\x91\x19\xad^\x1b\x03\x00\x00\x12\x07\x00\x00PK\x03\x04\x14\x00\x08\x00\x08\x00\x00\x00!(\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x13\x00 \x00default-config.yamlUT\x05\x00\x01\x80Cm8\xa4TMo\xe36\x10\xbd\xebW\x10{O,+q\x93\xf0\xb6\x9b\xf4P \xdd\x1aM{\x0eh\xf2Ib\x97\xe2h\xc9\xa1\x13\xe7\xd7\x17\x94dYi`\xb4\xc5\xc2\x07K3O\xef\xbd\xf9 5Q0\xd6+\xa6 \x0b!\x9c\x8d\x0c\xff\xd9\x98\x80\x18s@\x08>\xf4\x90\xe2\x93&_\xdb\xe6\xd3\x10\xda+\x97r\xac\xbc\x1c~\xf2\xa6*\xd79\xe3H+7~\xe5U\x87\xd8+\x8d\x89\xe5\xe2\x14\x91\x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d5\x0b\x05\x9f\xbam \x8d\x18)\xc4-\xc2\xfd\xf6\xcf<\xedu\xb5\x19\xfa\x7f\x14\x1a?\xa8]\x8a\xed\xaf\xea\xf5\xcb\x81\x11\xa5\xd8T\xd7\xd5\xed\xed)\xf3\xf3\x1e\xe1 \xc5z\xb4\xf1=!\xe1$\xa4\x95\xd3\xc9\x0dM\xf8c\xb8\xa8j\xfb:\xdfPBD\xfb\x06)\xaa\xf2\xeef\xbd\xa9\xb2\xf4\xd1dn@>\x7f\xdb\xe9fZ\xedUX9\xbb\x1b\x96i\xf4\x98/\xd4\xe9.C\xd8[\xbdP\x85\xdf\xcf\xd7\xe43\xfc~N\xbc\x91\x87\x14\xe8v0fic\"\x10\x03\xfb\xc9\xbbn\xf1`\xc3;\xf5o'2\xb06\xd3\xd1z7\xbc3\"\xd9\x96\xe9\xc9z^\xa03>\x1fQ\xb9\xcaG\xc5\\\x94\x97\xf9OVW7wg1\xeb\xff\x80\xa9\x16\x98\xbf\x03\x00\x00\xff\xffPK\x07\x08\xd5\x85\xf3L\xc2\x02\x00\x00\xa5\x06\x00\x00PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00\x00\x00!(\x91\x19\xad^\x1b\x03\x00\x00\x12\x07\x00\x00\x13\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00default-config.tmplUT\x05\x00\x01\x80Cm8PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00\x00\x00!(\xd5\x85\xf3L\xc2\x02\x00\x00\xa5\x06\x00\x00\x13\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81e\x03\x00\x00default-config.yamlUT\x05\x00\x01\x80Cm8PK\x05\x06\x00\x00\x00\x00\x02\x00\x02\x00\x94\x00\x00\x00q\x06\x00\x00\x00\x00" + data := "PK\x03\x04\x14\x00\x08\x00\x08\x00\x00\x00!(\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x13\x00 \x00default-config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Lps\xb7\xb9\xfd\xe1\x03\xee\xb3\xd2_\xa9\xae\x1fS\x98F\xa5\xeab\x8e\xb4#\xe2\xc8A\xf5cr\xf3\xb1G\x98\xa7/o\x8a\\\xc9x\x88\x8cna\xd4\xd4u\x96\x1d5\x0b[\x0f\x84\xb88'o\xf3\x84*g\xdf`^\x98zr\xd4\x8cU\xaa\x17\x11|\xea\xb6\x814b\xa4\x10\xb7\x08\x0f\xdb\xdfs\xb7\xd7\xd5f\xa8\xff1\xd0x\xa1v)\xb6?\xab\xd7\xcf\x07F\x94bS\xddTww'\xcf\x8f{\x84\x83\x14\xebQ\xc6\xb7\x84\x84S \xad\x9cNn(\xc2o\xc3\x92\xab\xed\xeb\xbc\xdd\x84\x88\xf6\x0dRT\xe5\xfd\xedzS\xe5\xd0G\x91\xb9\x00\xf9\xfdm\xa7\xad\xb6\xda\xab\xb0rv7\x0c\xd3\xa81/\xe3i\x0f\"\xec\xad^D\x85\xdf\xcf+\xf6\x05~?;\xde\xc8C\nt;\x18\xb3\x941\x11\x88\x81\xfd\xa4]\xb7x\xb4\xe1]\xf4\xaf'2\xb06\xd3\xd3z\xd7\xbc3A\xb2,\xd3\x93\xf5\xbc@g|~\xa2r\x95\x9f\x8a\xb9,\xaf\xf2\x9f\xac\xaeo\xef\xcfb\xd6\xff\x02S-0\x7f\x06\x00\x00\xff\xffPK\x07\x08\x8bu'\x00\xd6\x02\x00\x00\xe1\x06\x00\x00PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00\x00\x00!( \xca]^A\x03\x00\x00t\x07\x00\x00\x13\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00default-config.tmplUT\x05\x00\x01\x80Cm8PK\x01\x02\x14\x03\x14\x00\x08\x00\x08\x00\x00\x00!(\x8bu'\x00\xd6\x02\x00\x00\xe1\x06\x00\x00\x13\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x8b\x03\x00\x00default-config.yamlUT\x05\x00\x01\x80Cm8PK\x05\x06\x00\x00\x00\x00\x02\x00\x02\x00\x94\x00\x00\x00\xab\x06\x00\x00\x00\x00" fs.Register(data) } diff --git a/pkg/k8sops/config_map.go b/pkg/k8sops/config_map.go index 1ef7de3d..a7486459 100644 --- a/pkg/k8sops/config_map.go +++ b/pkg/k8sops/config_map.go @@ -46,6 +46,7 @@ var ( type configData struct { Env string Endpoints []string + CarbonIngester bool } // GenerateDefaultConfigMap creates a ConfigMap for the clusters with the @@ -77,10 +78,13 @@ func GenerateDefaultConfigMap(cluster *myspec.M3DBCluster) (*corev1.ConfigMap, e config := &configData{ Env: DefaultM3ClusterEnvironmentName(cluster), Endpoints: cluster.Spec.EtcdEndpoints, + CarbonIngester: cluster.Spec.EnableCarbonIngester, } buf := &bytes.Buffer{} - tmpl.Execute(buf, &config) + if err:= tmpl.Execute(buf, &config); err != nil { + return nil, err + } ownerRef := GenerateOwnerRef(cluster) diff --git a/pkg/k8sops/config_map_test.go b/pkg/k8sops/config_map_test.go index 2f1b9d94..b0fe5af3 100644 --- a/pkg/k8sops/config_map_test.go +++ b/pkg/k8sops/config_map_test.go @@ -75,6 +75,9 @@ func TestGenerateDefaultConfigMap(t *testing.T) { assert.Contains(t, data, `env: "foo/m3db-cluster"`) assert.Contains(t, data, `- "ep0"`) assert.Contains(t, data, `- "ep1"`) + assert.Contains(t, data, `carbon:`) + assert.Contains(t, data, `ingester:`) + assert.Contains(t, data, `listenAddress: "0.0.0.0:7204"`) } func TestGenerateDefaultConfigMap_Err(t *testing.T) { diff --git a/pkg/k8sops/fixtures/testM3DBCluster.yaml b/pkg/k8sops/fixtures/testM3DBCluster.yaml index dcc68c45..16fd7b6b 100644 --- a/pkg/k8sops/fixtures/testM3DBCluster.yaml +++ b/pkg/k8sops/fixtures/testM3DBCluster.yaml @@ -8,6 +8,7 @@ spec: image: fake.fake/fake/m3dbnode:latest replicationFactor: 3 numberOfShards: 8 + enableCarbonIngester: true isolationGroups: - name: us-fake1-a numInstances: 1 diff --git a/pkg/k8sops/generators.go b/pkg/k8sops/generators.go index edebd862..3c2f6b56 100644 --- a/pkg/k8sops/generators.go +++ b/pkg/k8sops/generators.go @@ -82,6 +82,8 @@ var baseCoordinatorPorts = [...]m3dbPort{ {"coord-metrics", PortM3CoordinatorMetrics, v1.ProtocolTCP}, } +var carbonListenerPort = m3dbPort{"coord-carbon", PortM3CoordinatorCarbon, v1.ProtocolTCP} + // GenerateCRD generates the crd object needed for the M3DBCluster func GenerateCRD(enableValidation bool) *apiextensionsv1beta1.CustomResourceDefinition { crd := &apiextensionsv1beta1.CustomResourceDefinition{ @@ -149,7 +151,7 @@ func GenerateStatefulSet( statefulSet := NewBaseStatefulSet(ssName, isolationGroupName, cluster, instanceAmount) m3dbContainer := &statefulSet.Spec.Template.Spec.Containers[0] m3dbContainer.Resources = clusterSpec.ContainerResources - m3dbContainer.Ports = generateContainerPorts() + m3dbContainer.Ports = generateContainerPorts(cluster) statefulSet.Spec.Template.Spec.Affinity = affinity statefulSet.Spec.Template.Spec.Tolerations = cluster.Spec.Tolerations @@ -205,7 +207,7 @@ func GenerateM3DBService(cluster *myspec.M3DBCluster) (*v1.Service, error) { }, Spec: v1.ServiceSpec{ Selector: svcLabels, - Ports: generateM3DBServicePorts(), + Ports: generateM3DBServicePorts(cluster), ClusterIP: v1.ClusterIPNone, Type: v1.ServiceTypeClusterIP, }, @@ -232,10 +234,11 @@ func GenerateCoordinatorService(cluster *myspec.M3DBCluster) (*v1.Service, error }, Spec: v1.ServiceSpec{ Selector: selectorLabels, - Ports: generateCoordinatorServicePorts(), + Ports: generateCoordinatorServicePorts(cluster), Type: v1.ServiceTypeClusterIP, }, }, nil + } func buildServicePorts(ports []m3dbPort) []v1.ServicePort { @@ -251,18 +254,30 @@ func buildServicePorts(ports []m3dbPort) []v1.ServicePort { return svcPorts } -func generateM3DBServicePorts() []v1.ServicePort { - return buildServicePorts(baseM3DBPorts[:]) +func generateM3DBServicePorts(cluster *myspec.M3DBCluster) []v1.ServicePort { + ports := baseM3DBPorts[:] + if cluster.Spec.EnableCarbonIngester { + ports = append(ports, carbonListenerPort) + } + return buildServicePorts(ports) } -func generateCoordinatorServicePorts() []v1.ServicePort { - return buildServicePorts(baseCoordinatorPorts[:]) +func generateCoordinatorServicePorts(cluster *myspec.M3DBCluster) []v1.ServicePort { + ports := baseCoordinatorPorts[:] + if cluster.Spec.EnableCarbonIngester { + ports = append(ports, carbonListenerPort) + } + return buildServicePorts(ports) } // generateContainerPorts will produce default container ports. -func generateContainerPorts() []v1.ContainerPort { +func generateContainerPorts(cluster *myspec.M3DBCluster) []v1.ContainerPort { cntPorts := []v1.ContainerPort{} - for _, v := range baseM3DBPorts { + basePorts := baseM3DBPorts[:] + if cluster.Spec.EnableCarbonIngester { + basePorts = append(basePorts, carbonListenerPort) + } + for _, v := range basePorts { newPortMapping := v1.ContainerPort{ Name: v.name, ContainerPort: int32(v.port), diff --git a/pkg/k8sops/generators_test.go b/pkg/k8sops/generators_test.go index f3b06b00..42b110b8 100644 --- a/pkg/k8sops/generators_test.go +++ b/pkg/k8sops/generators_test.go @@ -190,7 +190,7 @@ func TestGenerateStatefulSet(t *testing.T) { }, }, }, - Ports: generateContainerPorts(), + Ports: generateContainerPorts(fixture), VolumeMounts: []v1.VolumeMount{ { Name: _dataVolumeName, @@ -380,7 +380,7 @@ func TestGenerateM3DBService(t *testing.T) { }, Spec: v1.ServiceSpec{ Selector: baseLabels, - Ports: generateM3DBServicePorts(), + Ports: generateM3DBServicePorts(cluster), ClusterIP: v1.ClusterIPNone, Type: v1.ServiceTypeClusterIP, }, @@ -419,7 +419,7 @@ func TestGenerateCoordinatorService(t *testing.T) { }, Spec: v1.ServiceSpec{ Selector: selectLabels, - Ports: generateCoordinatorServicePorts(), + Ports: generateCoordinatorServicePorts(cluster), Type: v1.ServiceTypeClusterIP, }, } diff --git a/pkg/k8sops/ports.go b/pkg/k8sops/ports.go index b320e45e..f95b844c 100644 --- a/pkg/k8sops/ports.go +++ b/pkg/k8sops/ports.go @@ -33,4 +33,5 @@ const ( PortM3Coordinator = 7201 PortM3CoordinatorMetrics = 7203 + PortM3CoordinatorCarbon = 7204 ) From 22c0b38ae289fad8522e02b0aa742fd9055ecda1 Mon Sep 17 00:00:00 2001 From: Matt Schallert Date: Tue, 2 Jul 2019 00:02:50 -0400 Subject: [PATCH 2/2] gen docs --- docs/api.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/api.md b/docs/api.md index b6be2e2c..99fc6e6a 100644 --- a/docs/api.md +++ b/docs/api.md @@ -46,6 +46,7 @@ ClusterSpec defines the desired state for a M3 cluster to be converge to. | namespaces | Namespaces specifies the namespaces this cluster will hold. | [][Namespace](#namespace) | false | | etcdEndpoints | EtcdEndpoints defines the etcd endpoints to use for service discovery. Must be set if no custom configmap is defined. If set, etcd endpoints will be templated in to the default configmap template. | []string | false | | keepEtcdDataOnDelete | KeepEtcdDataOnDelete determines whether the operator will remove cluster metadata (placement + namespaces) in etcd when the cluster is deleted. Unless true, etcd data will be cleared when the cluster is deleted. | bool | false | +| enableCarbonIngester | EnableCarbonIngester enables the listener port for the carbon ingester | bool | false | | configMapName | ConfigMapName specifies the ConfigMap to use for this cluster. If unset a default configmap with template variables for etcd endpoints will be used. See \"Configuring M3DB\" in the docs for more. | *string | false | | podIdentityConfig | PodIdentityConfig sets the configuration for pod identity. If unset only pod name and UID will be used. | *PodIdentityConfig | false | | containerResources | Resources defines memory / cpu constraints for each container in the cluster. | [corev1.ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#resourcerequirements-v1-core) | false |