Skip to content

Commit

Permalink
Issue 515: add customized labels support (pravega#514)
Browse files Browse the repository at this point in the history
* add annotation support

Signed-off-by: Aaron Wu <[email protected]>

* add fields to crds

Signed-off-by: Aaron Wu <[email protected]>

* check nil

Signed-off-by: Aaron Wu <[email protected]>

* add values, update doc, fix UT

Signed-off-by: Aaron Wu <[email protected]>

* add deepcopy generated code

Signed-off-by: Aaron Wu <[email protected]>
  • Loading branch information
realAaronWu authored and CraneShiEMC committed Mar 16, 2021
1 parent 24bb31d commit fbc92f8
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ spec:
type: string
description: Annotations to be added to the external service
type: object
controllerPodLabels:
additionalProperties:
type: string
description: Labels to be added to the Controller Pods
type: object
controllerjvmOptions:
description: ControllerJvmOptions is the JVM options for controller.
It will be passed to the JVM for performance tuning. If this
Expand Down Expand Up @@ -729,6 +734,11 @@ spec:
type: string
description: Annotations to be added to the external service
type: object
segmentStorePodLabels:
additionalProperties:
type: string
description: Labels to be added to the SegmentStore Pods
type: object
type: object
tls:
description: 'TLS is the Pravega security configuration that is passed
Expand Down Expand Up @@ -1562,6 +1572,11 @@ spec:
type: string
description: Annotations to be added to the external service
type: object
controllerPodLabels:
additionalProperties:
type: string
description: Labels to be added to the Controller Pods
type: object
controllerjvmOptions:
description: ControllerJvmOptions is the JVM options for controller.
It will be passed to the JVM for performance tuning. If this
Expand Down Expand Up @@ -1657,6 +1672,11 @@ spec:
type: string
description: Annotations to be added to the external service
type: object
segmentStorePodLabels:
additionalProperties:
type: string
description: Labels to be added to the SegmentStore Pods
type: object
tier2:
description: Tier2 is the configuration of Pravega's tier 2 storage.
If no configuration is provided, it will assume that a PersistentVolumeClaim
Expand Down
2 changes: 2 additions & 0 deletions charts/pravega/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The following table lists the configurable parameters of the pravega chart and t
| `controller.resources.limits.memory` | Memory limits for controller | `2Gi` |
| `controller.service.type` | Override the controller service type, if external access is enabled (LoadBalancer/NodePort) | |
| `controller.service.annotations` | Annotations to add to the controller service, if external access is enabled | `{}` |
| `controller.labels` | Labels to add to the controller pods | `{}` |
| `controller.jvmOptions` | JVM Options for controller | `["-Xmx2g", "-XX:MaxDirectMemorySize=2g"]` |
| `segmentStore.replicas` | Number of segmentStore replicas | `1` |
| `segmentStore.secret` | Secret configuration for the segmentStore | `{}` |
Expand All @@ -92,6 +93,7 @@ The following table lists the configurable parameters of the pravega chart and t
| `segmentStore.service.loadBalancerIP` |It is used to provide a LoadBalancerIP for the segmentStore service | |
| `segmentStore.service.externalTrafficPolicy` | It is used to provide ExternalTrafficPolicy for the segmentStore service | |
| `segmentStore.jvmOptions` | JVM Options for segmentStore | `[]` |
| `segmentStore.labels` | Labels to add to the segmentStore pods | `{}` |
| `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` |
| `storage.longtermStorage.ecs` | Configuration to use a Dell EMC ECS system, if long term storage type is ecs | `{}` |
Expand Down
4 changes: 4 additions & 0 deletions charts/pravega/templates/pravega.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ spec:
{{- if .Values.controller.service.annotations }}
controllerSvcAnnotations:
{{ toYaml .Values.controller.service.annotations | indent 6 }}
controllerPodLabels:
{{ toYaml .Values.controller.labels | indent 6 }}
{{- end }}
{{- if .Values.segmentStore.service.type }}
segmentStoreExtServiceType: {{ .Values.segmentStore.service.type }}
{{- end }}
{{- if .Values.segmentStore.service.annotations }}
segmentStoreSvcAnnotations:
{{ toYaml .Values.segmentStore.service.annotations | indent 6 }}
segmentStorePodLabels:
{{ toYaml .Values.segmentStore.labels | indent 6 }}
{{- end }}
{{- end }}
image:
Expand Down
2 changes: 2 additions & 0 deletions charts/pravega/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ controller:
type:
annotations: {}
jvmOptions: []
labels: {}

segmentStore:
replicas: 1
Expand All @@ -82,6 +83,7 @@ segmentStore:
loadBalancerIP:
externalTrafficPolicy: Local
jvmOptions: ["-Xmx2g", "-XX:MaxDirectMemorySize=2g"]
labels: {}

storage:

Expand Down
20 changes: 20 additions & 0 deletions deploy/crds/pravega.pravega.io_pravegaclusters_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ spec:
type: string
description: Annotations to be added to the external service
type: object
controllerPodLabels:
additionalProperties:
type: string
description: Labels to be added to the Controller Pods
type: object
controllerjvmOptions:
description: ControllerJvmOptions is the JVM options for controller.
It will be passed to the JVM for performance tuning. If this
Expand Down Expand Up @@ -717,6 +722,11 @@ spec:
type: string
description: Annotations to be added to the external service
type: object
segmentStorePodLabels:
additionalProperties:
type: string
description: Labels to be added to the SegmentStore Pods
type: object
type: object
tls:
description: 'TLS is the Pravega security configuration that is passed
Expand Down Expand Up @@ -1550,6 +1560,11 @@ spec:
type: string
description: Annotations to be added to the external service
type: object
controllerPodLabels:
additionalProperties:
type: string
description: Labels to be added to the Controller Pods
type: object
controllerjvmOptions:
description: ControllerJvmOptions is the JVM options for controller.
It will be passed to the JVM for performance tuning. If this
Expand Down Expand Up @@ -1645,6 +1660,11 @@ spec:
type: string
description: Annotations to be added to the external service
type: object
segmentStorePodLabels:
additionalProperties:
type: string
description: Labels to be added to the SegmentStore Pods
type: object
tier2:
description: Tier2 is the configuration of Pravega's tier 2 storage.
If no configuration is provided, it will assume that a PersistentVolumeClaim
Expand Down
16 changes: 16 additions & 0 deletions pkg/apis/pravega/v1beta1/pravega.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ type PravegaSpec struct {
// Annotations to be added to the external service
// +optional
ControllerServiceAnnotations map[string]string `json:"controllerSvcAnnotations"`
// Labels to be added to the Controller pods
// +optional
ControllerPodLabels map[string]string `json:"controllerPodLabels"`

// Type specifies the service type to achieve external access.
// Options are "LoadBalancer" and "NodePort".
Expand All @@ -163,6 +166,10 @@ type PravegaSpec struct {
// +optional
SegmentStoreServiceAnnotations map[string]string `json:"segmentStoreSvcAnnotations"`

// Labels to be added to the SegmentStore pods
// +optional
SegmentStorePodLabels map[string]string `json:"segmentStorePodLabels"`

// Specifying this IP would ensure we use same IP address for all the ss services
SegmentStoreLoadBalancerIP string `json:"segmentStoreLoadBalancerIP,omitempty"`

Expand Down Expand Up @@ -260,12 +267,21 @@ func (s *PravegaSpec) withDefaults() (changed bool) {
changed = true
s.ControllerServiceAnnotations = map[string]string{}
}
if s.ControllerPodLabels == nil {
changed = true
s.ControllerPodLabels = map[string]string{}
}

if s.SegmentStoreServiceAnnotations == nil {
changed = true
s.SegmentStoreServiceAnnotations = map[string]string{}
}

if s.SegmentStorePodLabels == nil {
changed = true
s.SegmentStorePodLabels = map[string]string{}
}

return changed
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/pravega/v1beta1/pravegacluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,12 +1158,22 @@ func (p *PravegaCluster) PravegaControllerServiceURL() string {

func (p *PravegaCluster) LabelsForController() map[string]string {
labels := p.LabelsForPravegaCluster()
if p.Spec.Pravega != nil && p.Spec.Pravega.ControllerPodLabels != nil {
for k, v := range p.Spec.Pravega.ControllerPodLabels {
labels[k] = v
}
}
labels["component"] = "pravega-controller"
return labels
}

func (p *PravegaCluster) LabelsForSegmentStore() map[string]string {
labels := p.LabelsForPravegaCluster()
if p.Spec.Pravega != nil && p.Spec.Pravega.SegmentStorePodLabels != nil {
for k, v := range p.Spec.Pravega.SegmentStorePodLabels {
labels[k] = v
}
}
labels["component"] = "pravega-segmentstore"
return labels
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/pravega/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/controller/pravega/pravega_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ var _ = Describe("Controller", func() {
ControllerResources: customReq,
SegmentStoreResources: customReq,
ControllerServiceAnnotations: annotationsMap,
ControllerPodLabels: annotationsMap,
SegmentStoreServiceAnnotations: annotationsMap,
SegmentStorePodLabels: annotationsMap,
Image: &v1beta1.ImageSpec{
Repository: "bar/pravega",
},
Expand Down Expand Up @@ -199,7 +201,9 @@ var _ = Describe("Controller", func() {
SegmentStoreResources: customReq,
ControllerExternalServiceType: corev1.ServiceTypeLoadBalancer,
ControllerServiceAnnotations: annotationsMap,
ControllerPodLabels: annotationsMap,
SegmentStoreServiceAnnotations: annotationsMap,
SegmentStorePodLabels: annotationsMap,
Image: &v1beta1.ImageSpec{
Repository: "bar/pravega",
},
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/pravega/pravega_segmentstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func makeSegmentstorePodSpec(p *api.PravegaCluster) corev1.PodSpec {
}

environment = configureTier2Secrets(environment, p.Spec.Pravega)

podSpec := corev1.PodSpec{
Containers: []corev1.Container{
{
Expand Down
6 changes: 6 additions & 0 deletions pkg/controller/pravega/pravega_segmentstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ var _ = Describe("PravegaSegmentstore", func() {
ControllerResources: customReq,
SegmentStoreResources: customReq,
ControllerServiceAnnotations: annotationsMap,
ControllerPodLabels: annotationsMap,
SegmentStoreServiceAnnotations: annotationsMap,
SegmentStorePodLabels: annotationsMap,
SegmentStoreEnvVars: "SEG_CONFIG_MAP",
SegmentStoreSecret: &v1beta1.SegmentStoreSecret{
Secret: "seg-secret",
Expand Down Expand Up @@ -203,7 +205,9 @@ var _ = Describe("PravegaSegmentstore", func() {
ControllerResources: customReq,
SegmentStoreResources: customReq,
ControllerServiceAnnotations: annotationsMap,
ControllerPodLabels: annotationsMap,
SegmentStoreServiceAnnotations: annotationsMap,
SegmentStorePodLabels: annotationsMap,
SegmentStoreExternalServiceType: corev1.ServiceTypeLoadBalancer,
SegmentStoreSecret: &v1beta1.SegmentStoreSecret{
Secret: "seg-secret",
Expand Down Expand Up @@ -311,7 +315,9 @@ var _ = Describe("PravegaSegmentstore", func() {
ControllerResources: customReq,
SegmentStoreResources: customReq,
ControllerServiceAnnotations: annotationsMap,
ControllerPodLabels: annotationsMap,
SegmentStoreServiceAnnotations: annotationsMap,
SegmentStorePodLabels: annotationsMap,
SegmentStoreExternalServiceType: corev1.ServiceTypeLoadBalancer,
Image: &v1beta1.ImageSpec{
Repository: "bar/pravega",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,9 @@ var _ = Describe("PravegaCluster Controller", func() {
ControllerExternalServiceType: corev1.ServiceTypeLoadBalancer,
SegmentStoreExternalServiceType: corev1.ServiceTypeNodePort,
ControllerServiceAnnotations: annotationsMap,
ControllerPodLabels: annotationsMap,
SegmentStoreServiceAnnotations: annotationsMap,
SegmentStorePodLabels: annotationsMap,
},
}
// equivalent of 1st reconcile
Expand Down
20 changes: 20 additions & 0 deletions test/e2e/resources/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ spec:
type: string
description: Annotations to be added to the external service
type: object
controllerPodLabels:
additionalProperties:
type: string
description: Labels to be added to the Controller Pods
type: object
controllerjvmOptions:
description: ControllerJvmOptions is the JVM options for controller.
It will be passed to the JVM for performance tuning. If this
Expand Down Expand Up @@ -717,6 +722,11 @@ spec:
type: string
description: Annotations to be added to the external service
type: object
segmentStorePodLabels:
additionalProperties:
type: string
description: Labels to be added to the SegmentStore Pods
type: object
type: object
tls:
description: 'TLS is the Pravega security configuration that is passed
Expand Down Expand Up @@ -1550,6 +1560,11 @@ spec:
type: string
description: Annotations to be added to the external service
type: object
controllerPodLabels:
additionalProperties:
type: string
description: Labels to be added to the Controller Pods
type: object
controllerjvmOptions:
description: ControllerJvmOptions is the JVM options for controller.
It will be passed to the JVM for performance tuning. If this
Expand Down Expand Up @@ -1645,6 +1660,11 @@ spec:
type: string
description: Annotations to be added to the external service
type: object
segmentStorePodLabels:
additionalProperties:
type: string
description: Labels to be added to the SegmentStore Pods
type: object
tier2:
description: Tier2 is the configuration of Pravega's tier 2 storage.
If no configuration is provided, it will assume that a PersistentVolumeClaim
Expand Down
Loading

0 comments on commit fbc92f8

Please sign in to comment.