Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit cf9dd72

Browse files
authored
Add Headless AccessScope to jobmanager service spec (#280)
This allows you to have the operator create a headless service (https://kubernetes.io/docs/concepts/services-networking/service/#headless-services) for the jobmanager. This is useful when e.g. your pod network is directly routable and you'd like to use SRV or A record round-robin to discover the underlying pods.
1 parent 230d621 commit cf9dd72

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

api/v1beta1/flinkcluster_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const (
5858
AccessScopeVPC = "VPC"
5959
AccessScopeExternal = "External"
6060
AccessScopeNodePort = "NodePort"
61+
AccessScopeHeadless = "Headless"
6162
)
6263

6364
// JobRestartPolicy defines the restart policy when a job fails.

api/v1beta1/flinkcluster_validate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ func (v *Validator) validateJobManager(jmSpec *JobManagerSpec) error {
296296
case AccessScopeVPC:
297297
case AccessScopeExternal:
298298
case AccessScopeNodePort:
299+
case AccessScopeHeadless:
299300
default:
300301
return fmt.Errorf("invalid JobManager access scope: %v", jmSpec.AccessScope)
301302
}

controllers/flinkcluster_converter.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ func getDesiredJobManagerService(
280280
jobManagerService.Spec.Type = corev1.ServiceTypeLoadBalancer
281281
case v1beta1.AccessScopeNodePort:
282282
jobManagerService.Spec.Type = corev1.ServiceTypeNodePort
283+
case v1beta1.AccessScopeHeadless:
284+
// Headless services do not allocate any sort of VIP or LoadBalancer, and merely
285+
// collect a set of Pod IPs that are assumed to be independently routable:
286+
jobManagerService.Spec.Type = corev1.ServiceTypeClusterIP
287+
jobManagerService.Spec.ClusterIP = "None"
283288
default:
284289
panic(fmt.Sprintf(
285290
"Unknown service access cope: %v", jobManagerSpec.AccessScope))

docs/crd.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ FlinkCluster
144144
* **batchSchedulerName** (optional): BatchSchedulerName specifies the batch scheduler name for JobManager, TaskManager.
145145
If empty, no batch scheduling is enabled.
146146
* **jobManager** (required): JobManager spec.
147-
* **accessScope** (optional): Access scope of the JobManager service. `enum("Cluster", "VPC", "External",
148-
"NodePort")`.`Cluster`: accessible from within the same cluster; `VPC`: accessible from within the same VPC;
149-
`External`:accessible from the internet. `NodePort`: accessible through node port.
147+
* **accessScope** (optional): Access scope of the JobManager service. `enum("Cluster", "VPC", "External",
148+
"NodePort", "Headless")`. `Cluster`: accessible from within the same cluster; `VPC`: accessible from within the same VPC;
149+
`External`: accessible from the internet. `NodePort`: accessible through node port; `Headless`: pod IPs assumed to
150+
be routable and advertised directly with `clusterIP: None`.
150151
Currently `VPC` and `External` are only available for GKE.
151152
* **ports** (optional): Ports that JobManager listening on.
152153
* **rpc** (optional): RPC port, default: 6123.

0 commit comments

Comments
 (0)