From 33788cfd6a58fe7eca3476a1b6bbcf666e3fb180 Mon Sep 17 00:00:00 2001 From: prabhaker24 Date: Tue, 21 Jul 2020 10:32:23 +0530 Subject: [PATCH 01/11] spec changes added Signed-off-by: prabhaker24 --- pkg/apis/pravega/v1beta1/pravega.go | 6 +++++ .../pravega/pravega_segmentstore.go | 23 ++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/pkg/apis/pravega/v1beta1/pravega.go b/pkg/apis/pravega/v1beta1/pravega.go index f34bf637f..b507c7921 100644 --- a/pkg/apis/pravega/v1beta1/pravega.go +++ b/pkg/apis/pravega/v1beta1/pravega.go @@ -147,6 +147,12 @@ type PravegaSpec struct { // Annotations to be added to the external service SegmentStoreServiceAnnotations map[string]string `json:"segmentStoreSvcAnnotations"` + + // Specifying this I/P would insure we use same I/P address for all the ss services + SegmentStoreLoadBalancerIP string `json:"segmentStoreLoadBalancerIP,omitempty"` + + // SegmentStoreExternalTrafficPolicy defines the ExternalTrafficPolicy it can have cluster or local + SegmentStoreExternalTrafficPolicy string`json:"segmentStoreExternalTrafficPolicy,omitempty"` } func (s *PravegaSpec) withDefaults() (changed bool) { diff --git a/pkg/controller/pravega/pravega_segmentstore.go b/pkg/controller/pravega/pravega_segmentstore.go index e465786c4..f49db8517 100644 --- a/pkg/controller/pravega/pravega_segmentstore.go +++ b/pkg/controller/pravega/pravega_segmentstore.go @@ -12,6 +12,7 @@ package pravega import ( "fmt" + "log" "strings" api "github.com/pravega/pravega-operator/pkg/apis/pravega/v1beta1" @@ -450,20 +451,21 @@ func generateDNSAnnotationForSvc(domainName string, podName string) (dnsAnnotati func MakeSegmentStoreExternalServices(p *api.PravegaCluster) []*corev1.Service { var service *corev1.Service - + var temp int32 = 0 serviceType := getSSServiceType(p) services := make([]*corev1.Service, p.Spec.Pravega.SegmentStoreReplicas) - for i := int32(0); i < p.Spec.Pravega.SegmentStoreReplicas; i++ { ssPodName := p.ServiceNameForSegmentStore(i) annotationMap := p.Spec.Pravega.SegmentStoreServiceAnnotations annotationValue := generateDNSAnnotationForSvc(p.Spec.ExternalAccess.DomainName, ssPodName) - if annotationValue != "" { annotationMap = cloneMap(p.Spec.Pravega.SegmentStoreServiceAnnotations) annotationMap[externalDNSAnnotationKey] = annotationValue } - + log.Printf("prabhaker = %v, value = %v", annotationMap, annotationValue) + if p.Spec.Pravega.SegmentStoreLoadBalancerIP != "" { + temp = i + } service = &corev1.Service{ TypeMeta: metav1.TypeMeta{ Kind: "Service", @@ -480,17 +482,26 @@ func MakeSegmentStoreExternalServices(p *api.PravegaCluster) []*corev1.Service { Ports: []corev1.ServicePort{ { Name: "server", - Port: 12345, Protocol: "TCP", + Port: 12345 + temp, TargetPort: intstr.FromInt(12345), }, }, - ExternalTrafficPolicy: corev1.ServiceExternalTrafficPolicyTypeLocal, Selector: map[string]string{ appsv1.StatefulSetPodNameLabel: fmt.Sprintf("%s-%d", p.StatefulSetNameForSegmentstore(), i), }, }, } + if p.Spec.Pravega.SegmentStoreExternalTrafficPolicy == "cluster" { + service.Spec.ExternalTrafficPolicy = corev1.ServiceExternalTrafficPolicyTypeCluster + } else { + service.Spec.ExternalTrafficPolicy = corev1.ServiceExternalTrafficPolicyTypeLocal + } + if p.Spec.Pravega.SegmentStoreLoadBalancerIP != "" { + service.Spec.LoadBalancerIP = p.Spec.Pravega.SegmentStoreLoadBalancerIP + } + log.Printf("prabhu75 = %v, value = %v", p.Spec.Pravega.SegmentStoreExternalTrafficPolicy, service.Spec.ExternalTrafficPolicy) + log.Printf("krishna = %v", service.Spec.Ports) services[i] = service } return services From f0eada824b6b440f75ef8685ba1be25e3f13a271 Mon Sep 17 00:00:00 2001 From: prabhaker24 Date: Tue, 21 Jul 2020 15:48:50 +0530 Subject: [PATCH 02/11] doc added Signed-off-by: prabhaker24 --- README.md | 2 ++ charts/pravega-operator/templates/crd.yaml | 6 +++- deploy/crds/crd.yaml | 4 +++ doc/external-access.md | 28 +++++++++++++++++++ go.mod | 1 + go.sum | 2 ++ .../pravega/pravega_segmentstore.go | 14 +++------- 7 files changed, 46 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0fb731c64..0772cb574 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,8 @@ http://-pravega-controller.:10080/ Check out the [external access documentation](doc/external-access.md) if your clients need to connect to Pravega from outside Kubernetes. +Check out the [exposing segmentStore service on single I/P address ](doc/external-access.md#exposing-segmentstore-service-on-single-ip address-and--different-ports) if your clients need to connect to Pravega Segment store on the same I/P address from outside Kubernetes. + ### Scale a Pravega cluster You can scale Pravega components independently by modifying their corresponding field in the Pravega resource spec. You can either `kubectl edit` the cluster or `kubectl patch` it. If you edit it, update the number of replicas for BookKeeper, Controller, and/or Segment Store and save the updated spec. diff --git a/charts/pravega-operator/templates/crd.yaml b/charts/pravega-operator/templates/crd.yaml index e1f4c3ad0..28cb072e3 100644 --- a/charts/pravega-operator/templates/crd.yaml +++ b/charts/pravega-operator/templates/crd.yaml @@ -38,7 +38,7 @@ spec: conversionReviewVersions: ["v1beta1", "v1alpha1"] strategy: Webhook webhookClientConfig: - caBundle: {{ .Values.webhookCert.crt }} + caBundle: {{ .Values.webhookCert.crt }} service: name: pravega-webhook-svc namespace: {{ .Release.Namespace }} @@ -267,6 +267,10 @@ spec: additionalProperties: type: string type: object + segmentStoreLoadBalancerIP: + type: string + segmentStoreExternalTrafficPolicy: + type: string status: type: object description: PravegaCluster Status defines the observed state of PravegaCluster diff --git a/deploy/crds/crd.yaml b/deploy/crds/crd.yaml index fb92cf6a6..49c081885 100644 --- a/deploy/crds/crd.yaml +++ b/deploy/crds/crd.yaml @@ -264,6 +264,10 @@ spec: additionalProperties: type: string type: object + segmentStoreLoadBalancerIP: + type: string + segmentStoreExternalTrafficPolicy: + type: string status: type: object description: PravegaCluster Status defines the observed state of PravegaCluster diff --git a/doc/external-access.md b/doc/external-access.md index cd357e519..bf8d6b893 100644 --- a/doc/external-access.md +++ b/doc/external-access.md @@ -238,3 +238,31 @@ IP: 10.100.200.183 LoadBalancer Ingress: 10.247.108.104 . . . ``` +5. Exposing Segmentstore Service on single IP address and Different ports + +For Exposing SegmentStoreservices on the same I/P address we will use MetalLB, +MetalLB hooks into Kubernetes cluster, and provides a network load-balancer implementation. In short, it allows to create Kubernetes services of type “LoadBalancer” in clusters that don’t run on a cloud provider and thus cannot simply hook into paid products to provide load-balancers. + +By default, Services do not share an IP address, for providing same IP address to all the services we need to set the following configurations while creating the External Service: + +1) Provide annotation key as metallb.universe.tf/allow-shared-ip for all the services. + +2) All the services which want to share the IP address need to have the same value for the above annotation, for example "shared-ss-ip". + +3) The port for all the services should be different + +4) All the services should use External Traffic Policy as Cluster + +5) Finally, we need to provide the I/P address that we want our service to provide to the segment store pod as spec.loadBalancerIP while creating the service + +To enable this we need to provide segmentStoreSvcAnnotations, segmentStoreLoadBalancerIP, segmentStoreExternalTrafficPolicy in the manifest as shown below + +Example: +``` +pravega: + . . . + segmentStoreLoadBalancerIP: "10.243.39.103" + segmentStoreExternalTrafficPolicy: "cluster" + segmentStoreSvcAnnotations: + metallb.universe.tf/allow-shared-ip: "pravega-ss" +``` diff --git a/go.mod b/go.mod index 17847a10c..9d36b1363 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( 4d63.com/gochecknoinits v0.0.0-20200108094044-eb73b47b9fc4 // indirect github.com/alecthomas/gocyclo v0.0.0-20150208221726-aa8f8b160214 // indirect github.com/alexkohler/nakedret v1.0.0 // indirect + github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf // indirect github.com/hashicorp/go-version v1.1.0 github.com/jgautheron/goconst v0.0.0-20200227150835-cda7ea3bf591 // indirect github.com/mdempsky/unconvert v0.0.0-20200228143138-95ecdbfc0b5f // indirect diff --git a/go.sum b/go.sum index 005f9c54c..60d04c37c 100644 --- a/go.sum +++ b/go.sum @@ -400,6 +400,8 @@ github.com/gophercloud/gophercloud v0.6.0 h1:Xb2lcqZtml1XjgYZxbeayEemq7ASbeTp09m github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf h1:vc7Dmrk4JwS0ZPS6WZvWlwDflgDTA26jItmbSj83nug= +github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= diff --git a/pkg/controller/pravega/pravega_segmentstore.go b/pkg/controller/pravega/pravega_segmentstore.go index f49db8517..86027e7df 100644 --- a/pkg/controller/pravega/pravega_segmentstore.go +++ b/pkg/controller/pravega/pravega_segmentstore.go @@ -12,7 +12,6 @@ package pravega import ( "fmt" - "log" "strings" api "github.com/pravega/pravega-operator/pkg/apis/pravega/v1beta1" @@ -451,7 +450,6 @@ func generateDNSAnnotationForSvc(domainName string, podName string) (dnsAnnotati func MakeSegmentStoreExternalServices(p *api.PravegaCluster) []*corev1.Service { var service *corev1.Service - var temp int32 = 0 serviceType := getSSServiceType(p) services := make([]*corev1.Service, p.Spec.Pravega.SegmentStoreReplicas) for i := int32(0); i < p.Spec.Pravega.SegmentStoreReplicas; i++ { @@ -462,10 +460,6 @@ func MakeSegmentStoreExternalServices(p *api.PravegaCluster) []*corev1.Service { annotationMap = cloneMap(p.Spec.Pravega.SegmentStoreServiceAnnotations) annotationMap[externalDNSAnnotationKey] = annotationValue } - log.Printf("prabhaker = %v, value = %v", annotationMap, annotationValue) - if p.Spec.Pravega.SegmentStoreLoadBalancerIP != "" { - temp = i - } service = &corev1.Service{ TypeMeta: metav1.TypeMeta{ Kind: "Service", @@ -482,26 +476,26 @@ func MakeSegmentStoreExternalServices(p *api.PravegaCluster) []*corev1.Service { Ports: []corev1.ServicePort{ { Name: "server", + Port: 12345, Protocol: "TCP", - Port: 12345 + temp, TargetPort: intstr.FromInt(12345), }, }, + ExternalTrafficPolicy: corev1.ServiceExternalTrafficPolicyTypeLocal, Selector: map[string]string{ appsv1.StatefulSetPodNameLabel: fmt.Sprintf("%s-%d", p.StatefulSetNameForSegmentstore(), i), }, }, } - if p.Spec.Pravega.SegmentStoreExternalTrafficPolicy == "cluster" { + if strings.EqualFold(p.Spec.Pravega.SegmentStoreExternalTrafficPolicy, "cluster") == true { service.Spec.ExternalTrafficPolicy = corev1.ServiceExternalTrafficPolicyTypeCluster } else { service.Spec.ExternalTrafficPolicy = corev1.ServiceExternalTrafficPolicyTypeLocal } if p.Spec.Pravega.SegmentStoreLoadBalancerIP != "" { + service.Spec.Ports[0].Port = 12345 + i service.Spec.LoadBalancerIP = p.Spec.Pravega.SegmentStoreLoadBalancerIP } - log.Printf("prabhu75 = %v, value = %v", p.Spec.Pravega.SegmentStoreExternalTrafficPolicy, service.Spec.ExternalTrafficPolicy) - log.Printf("krishna = %v", service.Spec.Ports) services[i] = service } return services From 4aa88641c3d5a1d5afbb2b9e628846639fd13290 Mon Sep 17 00:00:00 2001 From: prabhaker24 Date: Tue, 21 Jul 2020 15:51:39 +0530 Subject: [PATCH 03/11] doc changed Signed-off-by: prabhaker24 --- doc/external-access.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/external-access.md b/doc/external-access.md index bf8d6b893..481f47165 100644 --- a/doc/external-access.md +++ b/doc/external-access.md @@ -238,7 +238,7 @@ IP: 10.100.200.183 LoadBalancer Ingress: 10.247.108.104 . . . ``` -5. Exposing Segmentstore Service on single IP address and Different ports +# Exposing Segmentstore Service on single IP address and Different ports For Exposing SegmentStoreservices on the same I/P address we will use MetalLB, MetalLB hooks into Kubernetes cluster, and provides a network load-balancer implementation. In short, it allows to create Kubernetes services of type “LoadBalancer” in clusters that don’t run on a cloud provider and thus cannot simply hook into paid products to provide load-balancers. From b108e87672c7b94497f33c85840572c370130a85 Mon Sep 17 00:00:00 2001 From: prabhaker24 Date: Tue, 21 Jul 2020 15:53:44 +0530 Subject: [PATCH 04/11] changed readme Signed-off-by: prabhaker24 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0772cb574..a543695f6 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ http://-pravega-controller.:10080/ Check out the [external access documentation](doc/external-access.md) if your clients need to connect to Pravega from outside Kubernetes. -Check out the [exposing segmentStore service on single I/P address ](doc/external-access.md#exposing-segmentstore-service-on-single-ip address-and--different-ports) if your clients need to connect to Pravega Segment store on the same I/P address from outside Kubernetes. +Check out the [exposing segmentStore service on single I/P address ](https://github.com/pravega/pravega-operator/blob/4aa88641c3d5a1d5afbb2b9e628846639fd13290/doc/external-access.md#exposing-segmentstore-service-on-single-ip-address-and-different-ports) if your clients need to connect to Pravega Segment store on the same I/P address from outside Kubernetes. ### Scale a Pravega cluster From e4ce1f9c95a498fc442ae99691b532726e571288 Mon Sep 17 00:00:00 2001 From: prabhaker24 Date: Tue, 21 Jul 2020 15:56:08 +0530 Subject: [PATCH 05/11] changed doc Signed-off-by: prabhaker24 --- README.md | 2 +- doc/external-access.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a543695f6..e76d5b132 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ http://-pravega-controller.:10080/ Check out the [external access documentation](doc/external-access.md) if your clients need to connect to Pravega from outside Kubernetes. -Check out the [exposing segmentStore service on single I/P address ](https://github.com/pravega/pravega-operator/blob/4aa88641c3d5a1d5afbb2b9e628846639fd13290/doc/external-access.md#exposing-segmentstore-service-on-single-ip-address-and-different-ports) if your clients need to connect to Pravega Segment store on the same I/P address from outside Kubernetes. +Check out the [exposing Segmentstore service on single I/P address ](https://github.com/pravega/pravega-operator/blob/4aa88641c3d5a1d5afbb2b9e628846639fd13290/doc/external-access.md#exposing-segmentstore-service-on-single-ip-address-and-different-ports) if your clients need to connect to Pravega Segment store on the same I/P address from outside Kubernetes. ### Scale a Pravega cluster diff --git a/doc/external-access.md b/doc/external-access.md index 481f47165..e4307fb8d 100644 --- a/doc/external-access.md +++ b/doc/external-access.md @@ -264,5 +264,5 @@ pravega: segmentStoreLoadBalancerIP: "10.243.39.103" segmentStoreExternalTrafficPolicy: "cluster" segmentStoreSvcAnnotations: - metallb.universe.tf/allow-shared-ip: "pravega-ss" + metallb.universe.tf/allow-shared-ip: "shared-ss-ip" ``` From 6be7fba3b73000cedfa73eb852f89cf32f247de7 Mon Sep 17 00:00:00 2001 From: prabhaker24 Date: Thu, 23 Jul 2020 14:37:20 +0530 Subject: [PATCH 06/11] chart changes added Signed-off-by: prabhaker24 --- charts/pravega/README.md | 2 ++ charts/pravega/templates/pravega.yaml | 9 +++++++-- charts/pravega/values.yaml | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/charts/pravega/README.md b/charts/pravega/README.md index 06af19e78..3f80285ce 100644 --- a/charts/pravega/README.md +++ b/charts/pravega/README.md @@ -70,6 +70,8 @@ The following table lists the configurable parameters of the Pravega chart and t | `segmentStore.resources.limits.memory` | Memory limits for segmentStore | `4Gi` | | `segmentStore.service.type` | Override the segmentStore service type, if external access is enabled (LoadBalancer/NodePort) | | | `segmentStore.service.annotations` | Annotations to add to the segmentStore service, if external access is enabled | `{}` | +| `segmentStore.service.segmentStoreLoadBalancerIP` |It is used to provide a Load LoadBalancerIP | | +| `segmentStore.service.segmentStoreExternalTrafficPolicy` | It is used to provide segmentStoreExternalTrafficPolicy | | | `segmentStore.jvmOptions` | JVM Options for segmentStore | `[]` | | `storage.longtermStorage.type` | Type of long term storage backend to be used (filesystem/ecs/hdfs) | `filesystem` | | `storage.longtermStorage.filesystem.pvc` | Name of the pre-created PVC, if long term storage type is filesystem | `pravega-tier2` | diff --git a/charts/pravega/templates/pravega.yaml b/charts/pravega/templates/pravega.yaml index b49076257..dc36b023c 100644 --- a/charts/pravega/templates/pravega.yaml +++ b/charts/pravega/templates/pravega.yaml @@ -6,7 +6,7 @@ metadata: labels: {{ include "pravega.commonLabels" . | indent 4 }} spec: - {{- if .Values.tls }} + {{- if .Values.tls }} tls: static: controllerSecret: {{ .Values.tls.secret.controller }} @@ -33,6 +33,10 @@ spec: {{- if .Values.externalAccess.enabled }} controllerServiceAccountName: {{ .Values.serviceAccount.name }} segmentStoreServiceAccountName: {{ .Values.serviceAccount.name }} + {{- if .Values.segmentStore.service.segmentStoreLoadBalancerIP }} + segmentStoreLoadBalancerIP: {{ .Values.segmentStore.service.segmentStoreLoadBalancerIP }} + {{- end }} + segmentStoreExternalTrafficPolicy: {{ .Values.segmentStore.service.segmentStoreExternalTrafficPolicy }} {{- if .Values.controller.service.type }} controllerExtServiceType: {{ .Values.controller.service.type }} {{- end }} @@ -43,7 +47,8 @@ spec: segmentStoreExtServiceType: {{ .Values.segmentStore.service.type }} {{- end }} {{- if .Values.segmentStore.service.annotations }} - segmentStoreSvcAnnotations: {{ .Values.segmentStore.service.annotations }} + segmentStoreSvcAnnotations: + {{ toYaml .Values.segmentStore.service.annotations | indent 6}} {{- end }} {{- end }} image: diff --git a/charts/pravega/values.yaml b/charts/pravega/values.yaml index e940b640c..dc6a90cd4 100644 --- a/charts/pravega/values.yaml +++ b/charts/pravega/values.yaml @@ -73,6 +73,8 @@ segmentStore: ## used to override the service type for segmentStore type: annotations: {} + segmentStoreLoadBalancerIP: + segmentStoreExternalTrafficPolicy: Local jvmOptions: ["-Xmx2g", "-XX:MaxDirectMemorySize=2g"] storage: From c4bc278637aaa5fc6c21a838848bfc7be217176e Mon Sep 17 00:00:00 2001 From: prabhaker24 Date: Thu, 23 Jul 2020 16:29:39 +0530 Subject: [PATCH 07/11] chart changed Signed-off-by: prabhaker24 --- charts/pravega/templates/pravega.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/pravega/templates/pravega.yaml b/charts/pravega/templates/pravega.yaml index 9b456e3e3..45a409932 100644 --- a/charts/pravega/templates/pravega.yaml +++ b/charts/pravega/templates/pravega.yaml @@ -48,6 +48,7 @@ spec: segmentStoreExtServiceType: {{ .Values.segmentStore.service.type }} {{- end }} {{- if .Values.segmentStore.service.annotations }} + segmentStoreSvcAnnotations: {{ toYaml .Values.segmentStore.service.annotations | indent 6}} {{- end }} {{- end }} From 32628a42c84e635d15229b48ad80689ab82980bf Mon Sep 17 00:00:00 2001 From: prabhaker24 Date: Mon, 27 Jul 2020 19:36:41 +0530 Subject: [PATCH 08/11] fixed formatting Signed-off-by: prabhaker24 --- pkg/apis/pravega/v1beta1/pravega.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apis/pravega/v1beta1/pravega.go b/pkg/apis/pravega/v1beta1/pravega.go index b507c7921..b7734bd7f 100644 --- a/pkg/apis/pravega/v1beta1/pravega.go +++ b/pkg/apis/pravega/v1beta1/pravega.go @@ -152,7 +152,7 @@ type PravegaSpec struct { SegmentStoreLoadBalancerIP string `json:"segmentStoreLoadBalancerIP,omitempty"` // SegmentStoreExternalTrafficPolicy defines the ExternalTrafficPolicy it can have cluster or local - SegmentStoreExternalTrafficPolicy string`json:"segmentStoreExternalTrafficPolicy,omitempty"` + SegmentStoreExternalTrafficPolicy string `json:"segmentStoreExternalTrafficPolicy,omitempty"` } func (s *PravegaSpec) withDefaults() (changed bool) { From 4b43e132f72fae123ff31319e37d1a953fefe2c8 Mon Sep 17 00:00:00 2001 From: prabhaker24 Date: Mon, 27 Jul 2020 22:03:38 +0530 Subject: [PATCH 09/11] ca bundle added Signed-off-by: prabhaker24 --- charts/pravega-operator/templates/crd.yaml | 2 ++ deploy/crds/crd.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/charts/pravega-operator/templates/crd.yaml b/charts/pravega-operator/templates/crd.yaml index 28cb072e3..1e50e21e2 100644 --- a/charts/pravega-operator/templates/crd.yaml +++ b/charts/pravega-operator/templates/crd.yaml @@ -79,6 +79,8 @@ spec: static: type: object properties: + caBundle: + type: string controllerSecret: type: string segmentStoreSecret: diff --git a/deploy/crds/crd.yaml b/deploy/crds/crd.yaml index 49c081885..92e54ae14 100644 --- a/deploy/crds/crd.yaml +++ b/deploy/crds/crd.yaml @@ -76,6 +76,8 @@ spec: static: type: object properties: + caBundle: + type: string controllerSecret: type: string segmentStoreSecret: From faea44c3889243613aa192b09c33a5e5fad1ca5e Mon Sep 17 00:00:00 2001 From: prabhaker24 Date: Tue, 28 Jul 2020 11:56:47 +0530 Subject: [PATCH 10/11] ut added Signed-off-by: prabhaker24 --- .../pravega/pravega_segmentstore_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/controller/pravega/pravega_segmentstore_test.go b/pkg/controller/pravega/pravega_segmentstore_test.go index f08417b6a..89622b4ac 100644 --- a/pkg/controller/pravega/pravega_segmentstore_test.go +++ b/pkg/controller/pravega/pravega_segmentstore_test.go @@ -262,6 +262,7 @@ var _ = Describe("PravegaSegmentstore", func() { It("should set external access service type to LoadBalancer", func() { Ω(p.Spec.ExternalAccess.Type).Should(Equal(corev1.ServiceTypeClusterIP)) }) + }) }) @@ -377,6 +378,24 @@ var _ = Describe("PravegaSegmentstore", func() { Ω(err).Should(BeNil()) }) }) + Context("Create External service with SegmentStoreExternalTrafficPolicy as cluster", func() { + BeforeEach(func() { + p.Spec.Pravega.SegmentStoreExternalTrafficPolicy = "cluster" + }) + It("should create external service with ExternalTrafficPolicy type cluster", func() { + svc := pravega.MakeSegmentStoreExternalServices(p) + Ω(svc[0].Spec.ExternalTrafficPolicy).To(Equal(corev1.ServiceExternalTrafficPolicyTypeCluster)) + }) + }) + Context("Create External service with LoadBalancerIP", func() { + BeforeEach(func() { + p.Spec.Pravega.SegmentStoreLoadBalancerIP = "10.240.12.18" + }) + It("should create external service with LoadBalancerIP", func() { + svc := pravega.MakeSegmentStoreExternalServices(p) + Ω(svc[0].Spec.LoadBalancerIP).To(Equal("10.240.12.18")) + }) + }) Context("Create External service with external service type empty", func() { BeforeEach(func() { m := make(map[string]string) From bf746a01cce1fb34237d638725a4208dae13573c Mon Sep 17 00:00:00 2001 From: prabhaker24 Date: Thu, 30 Jul 2020 02:11:57 +0530 Subject: [PATCH 11/11] addressed comments Signed-off-by: prabhaker24 --- README.md | 2 +- charts/pravega/README.md | 2 +- charts/pravega/templates/pravega.yaml | 4 ++-- doc/external-access.md | 4 ++-- pkg/apis/pravega/v1beta1/pravega.go | 2 +- pkg/controller/pravega/pravega_segmentstore.go | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e76d5b132..6f74555b5 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ http://-pravega-controller.:10080/ Check out the [external access documentation](doc/external-access.md) if your clients need to connect to Pravega from outside Kubernetes. -Check out the [exposing Segmentstore service on single I/P address ](https://github.com/pravega/pravega-operator/blob/4aa88641c3d5a1d5afbb2b9e628846639fd13290/doc/external-access.md#exposing-segmentstore-service-on-single-ip-address-and-different-ports) if your clients need to connect to Pravega Segment store on the same I/P address from outside Kubernetes. +Check out the [exposing Segmentstore service on single IP address ](https://github.com/pravega/pravega-operator/blob/4aa88641c3d5a1d5afbb2b9e628846639fd13290/doc/external-access.md#exposing-segmentstore-service-on-single-ip-address-and-different-ports) if your clients need to connect to Pravega Segment store on the same IP address from outside Kubernetes. ### Scale a Pravega cluster diff --git a/charts/pravega/README.md b/charts/pravega/README.md index 3f80285ce..a2c20d555 100644 --- a/charts/pravega/README.md +++ b/charts/pravega/README.md @@ -70,7 +70,7 @@ The following table lists the configurable parameters of the Pravega chart and t | `segmentStore.resources.limits.memory` | Memory limits for segmentStore | `4Gi` | | `segmentStore.service.type` | Override the segmentStore service type, if external access is enabled (LoadBalancer/NodePort) | | | `segmentStore.service.annotations` | Annotations to add to the segmentStore service, if external access is enabled | `{}` | -| `segmentStore.service.segmentStoreLoadBalancerIP` |It is used to provide a Load LoadBalancerIP | | +| `segmentStore.service.segmentStoreLoadBalancerIP` |It is used to provide a LoadBalancerIP | | | `segmentStore.service.segmentStoreExternalTrafficPolicy` | It is used to provide segmentStoreExternalTrafficPolicy | | | `segmentStore.jvmOptions` | JVM Options for segmentStore | `[]` | | `storage.longtermStorage.type` | Type of long term storage backend to be used (filesystem/ecs/hdfs) | `filesystem` | diff --git a/charts/pravega/templates/pravega.yaml b/charts/pravega/templates/pravega.yaml index 45a409932..ddc80f1a9 100644 --- a/charts/pravega/templates/pravega.yaml +++ b/charts/pravega/templates/pravega.yaml @@ -6,7 +6,7 @@ metadata: labels: {{ include "pravega.commonLabels" . | indent 4 }} spec: - {{- if .Values.tls }} + {{- if .Values.tls }} tls: static: controllerSecret: {{ .Values.tls.secret.controller }} @@ -49,7 +49,7 @@ spec: {{- end }} {{- if .Values.segmentStore.service.annotations }} segmentStoreSvcAnnotations: -{{ toYaml .Values.segmentStore.service.annotations | indent 6}} +{{ toYaml .Values.segmentStore.service.annotations | indent 6 }} {{- end }} {{- end }} image: diff --git a/doc/external-access.md b/doc/external-access.md index e4307fb8d..ee7f8c542 100644 --- a/doc/external-access.md +++ b/doc/external-access.md @@ -240,12 +240,12 @@ LoadBalancer Ingress: 10.247.108.104 ``` # Exposing Segmentstore Service on single IP address and Different ports -For Exposing SegmentStoreservices on the same I/P address we will use MetalLB, +For Exposing SegmentStoreservices on the same I/P address we will use MetalLB. MetalLB hooks into Kubernetes cluster, and provides a network load-balancer implementation. In short, it allows to create Kubernetes services of type “LoadBalancer” in clusters that don’t run on a cloud provider and thus cannot simply hook into paid products to provide load-balancers. By default, Services do not share an IP address, for providing same IP address to all the services we need to set the following configurations while creating the External Service: -1) Provide annotation key as metallb.universe.tf/allow-shared-ip for all the services. +1) Provide annotation key as **metallb.universe.tf/allow-shared-ip** for all the services. 2) All the services which want to share the IP address need to have the same value for the above annotation, for example "shared-ss-ip". diff --git a/pkg/apis/pravega/v1beta1/pravega.go b/pkg/apis/pravega/v1beta1/pravega.go index b7734bd7f..5315242d0 100644 --- a/pkg/apis/pravega/v1beta1/pravega.go +++ b/pkg/apis/pravega/v1beta1/pravega.go @@ -148,7 +148,7 @@ type PravegaSpec struct { // Annotations to be added to the external service SegmentStoreServiceAnnotations map[string]string `json:"segmentStoreSvcAnnotations"` - // Specifying this I/P would insure we use same I/P address for all the ss services + // Specifying this IP would ensure we use same IP address for all the ss services SegmentStoreLoadBalancerIP string `json:"segmentStoreLoadBalancerIP,omitempty"` // SegmentStoreExternalTrafficPolicy defines the ExternalTrafficPolicy it can have cluster or local diff --git a/pkg/controller/pravega/pravega_segmentstore.go b/pkg/controller/pravega/pravega_segmentstore.go index 86027e7df..a9e6a90cc 100644 --- a/pkg/controller/pravega/pravega_segmentstore.go +++ b/pkg/controller/pravega/pravega_segmentstore.go @@ -487,7 +487,7 @@ func MakeSegmentStoreExternalServices(p *api.PravegaCluster) []*corev1.Service { }, }, } - if strings.EqualFold(p.Spec.Pravega.SegmentStoreExternalTrafficPolicy, "cluster") == true { + if strings.EqualFold(p.Spec.Pravega.SegmentStoreExternalTrafficPolicy, "Cluster") == true { service.Spec.ExternalTrafficPolicy = corev1.ServiceExternalTrafficPolicyTypeCluster } else { service.Spec.ExternalTrafficPolicy = corev1.ServiceExternalTrafficPolicyTypeLocal