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

Commit 6473858

Browse files
authored
make cluster domain configurable (#318)
1 parent 48947b8 commit 6473858

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

controllers/flinkcluster_util.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"k8s.io/apimachinery/pkg/api/meta"
3030
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3131
"k8s.io/apimachinery/pkg/runtime"
32+
"os"
3233
"strconv"
3334
"strings"
3435
"time"
@@ -67,10 +68,16 @@ type objectMetaForPatch struct {
6768
}
6869

6970
func getFlinkAPIBaseURL(cluster *v1beta1.FlinkCluster) string {
71+
clusterDomain := os.Getenv("CLUSTER_DOMAIN")
72+
if clusterDomain == "" {
73+
clusterDomain = "cluster.local"
74+
}
75+
7076
return fmt.Sprintf(
71-
"http://%s.%s.svc.cluster.local:%d",
77+
"http://%s.%s.svc.%s:%d",
7278
getJobManagerServiceName(cluster.ObjectMeta.Name),
7379
cluster.ObjectMeta.Namespace,
80+
clusterDomain,
7481
*cluster.Spec.JobManager.Ports.UI)
7582
}
7683

controllers/flinkcluster_util_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"k8s.io/apimachinery/pkg/api/resource"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"k8s.io/apimachinery/pkg/runtime"
28+
"os"
2829
"testing"
2930
"time"
3031

@@ -528,3 +529,27 @@ func TestHasTimeElapsed(t *testing.T) {
528529
elapsed = hasTimeElapsed(timeToCheckStr, timeToCompare, 30)
529530
assert.Equal(t, elapsed, false)
530531
}
532+
533+
func TestGetFlinkAPIBaseURL(t *testing.T) {
534+
var uiPort int32 = 8004
535+
var cluster = v1beta1.FlinkCluster{
536+
ObjectMeta: metav1.ObjectMeta{
537+
Name: "mycluster",
538+
Namespace: "default",
539+
},
540+
Spec: v1beta1.FlinkClusterSpec{
541+
JobManager: v1beta1.JobManagerSpec{
542+
Ports: v1beta1.JobManagerPorts{
543+
UI: &uiPort,
544+
},
545+
},
546+
},
547+
}
548+
549+
var apiBaseURL = getFlinkAPIBaseURL(&cluster)
550+
assert.Equal(t, apiBaseURL, "http://mycluster-jobmanager.default.svc.cluster.local:8004")
551+
552+
os.Setenv("CLUSTER_DOMAIN", "my.domain")
553+
apiBaseURL = getFlinkAPIBaseURL(&cluster)
554+
assert.Equal(t, apiBaseURL, "http://mycluster-jobmanager.default.svc.my.domain:8004")
555+
}

docs/user_guide.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ following 2 ways:
7777
Follow the [Helm Chart Installation Guide](../helm-chart/flink-operator/README.md) to
7878
install the operator through Helm Chart.
7979

80+
Note, for kubernetes cluster with private cluster domain, you should add a CLUSTER\_DOMAIN environment to the operator deployment.
81+
8082
## Verify the deployment
8183

8284
After deploying the operator, you can verify CRD `flinkclusters.flinkoperator.k8s.io`

0 commit comments

Comments
 (0)