Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 572: Enable external option to client service #576

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/v1beta1/zookeepercluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,8 @@ type ClientServicePolicy struct {
// Annotations specifies the annotations to attach to client service the operator
// creates.
Annotations map[string]string `json:"annotations,omitempty"`

External bool `json:"external,omitempty"`
}

type HeadlessServicePolicy struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ spec:
description: Annotations specifies the annotations to attach to
client service the operator creates.
type: object
external:
type: boolean
type: object
config:
description: Conf is the zookeeper configuration, which will be used
Expand Down
1 change: 1 addition & 0 deletions charts/zookeeper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ The following table lists the configurable parameters of the zookeeper chart and
| `pod.imagePullSecrets` | ImagePullSecrets is a list of references to secrets in the same namespace to use for pulling any images. | `[]` |
| `clientService` | Defines the policy to create client Service for the zookeeper cluster. | {} |
| `clientService.annotations` | Specifies the annotations to attach to client Service the operator creates. | {} |
| `clientService.external` | Specifies if LoadBalancer should be created for the Client. True means LoadBalancer will be created, false - only ClusterIP will be used. | false |
| `headlessService` | Defines the policy to create headless Service for the zookeeper cluster. | {} |
| `headlessService.annotations` | Specifies the annotations to attach to headless Service the operator creates. | {} |
| `adminServerService` | Defines the policy to create AdminServer Service for the zookeeper cluster. | {} |
Expand Down
3 changes: 3 additions & 0 deletions charts/zookeeper/templates/zookeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ spec:
annotations:
{{ toYaml .Values.clientService.annotations | indent 6 }}
{{- end }}
{{- if .Values.clientService.external }}
external: {{ .Values.clientService.external }}
{{- end }}
{{- end }}
{{- if .Values.headlessService }}
headlessService:
Expand Down
1 change: 1 addition & 0 deletions charts/zookeeper/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ adminServerService: {}

clientService: {}
# annotations: {}
# external: false

headlessService: {}
# annotations: {}
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ spec:
description: Annotations specifies the annotations to attach to
client service the operator creates.
type: object
external:
type: boolean
type: object
config:
description: Conf is the zookeeper configuration, which will be used
Expand Down
4 changes: 3 additions & 1 deletion pkg/zk/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ func MakeClientService(z *v1beta1.ZookeeperCluster) *v1.Service {
svcPorts := []v1.ServicePort{
{Name: "tcp-client", Port: ports.Client},
}
return makeService(z.GetClientServiceName(), svcPorts, true, false, z.Spec.ClientService.Annotations, z)
external := z.Spec.ClientService.External
annotations := z.Spec.ClientService.Annotations
return makeService(z.GetClientServiceName(), svcPorts, true, external, annotations, z)
}

// MakeAdminServerService returns a service which provides an interface
Expand Down
28 changes: 28 additions & 0 deletions pkg/zk/generators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,34 @@ var _ = Describe("Generators Spec", func() {
"exampleAnnotation",
"exampleValue"))
})

It("should have no LoadBalancer attached by default", func() {
Ω(s.Spec.Type).NotTo(Equal(v1.ServiceTypeLoadBalancer))
})
})

Context("#MakeClientService external with LoadBalancer", func() {
var s *v1.Service

BeforeEach(func() {
z := &v1beta1.ZookeeperCluster{
ObjectMeta: metav1.ObjectMeta{
Name: "example",
Namespace: "default",
},
Spec: v1beta1.ZookeeperClusterSpec{
ClientService: v1beta1.ClientServicePolicy{
External: true,
},
},
}
z.WithDefaults()
s = zk.MakeClientService(z)
})

It("should have LoadBalancer attached", func() {
Ω(s.Spec.Type).To(Equal(v1.ServiceTypeLoadBalancer))
})
})

Context("#MakeHeadlessService", func() {
Expand Down
Loading